import /vendor/etc/init/hw/init.zuma.storage.rc
import /vendor/etc/init/hw/init.zuma.usb.rc
import android.hardware.drm@1.2-service.widevine.rc
import init.exynos.sensorhub.rc

on early-init
    write /proc/sys/kernel/sched_pelt_multiplier 1
    write /sys/kernel/mm/lru_gen/enabled n

on init
    # CPU0 cannot be offline
    chmod 0444 /sys/devices/system/cpu/cpu0/online

    # Set teo as cpu idle governor
    write /sys/devices/system/cpu/cpuidle/current_governor teo
    # Disable util-awareness for mids and bigs
    write /proc/vendor_sched/teo_util_threshold "2 1024 1024"

    chown system system /sys/devices/system/cpu/cpufreq/policy0/sched_pixel/lcpi_threshold
    chown system system /sys/devices/system/cpu/cpufreq/policy0/sched_pixel/spc_threshold
    chown system system /sys/devices/system/cpu/cpufreq/policy0/sched_pixel/limit_frequency
    chown system system /sys/devices/system/cpu/cpufreq/policy0/sched_pixel/pmu_limit_enable
    chown system system /sys/devices/system/cpu/cpufreq/policy4/sched_pixel/lcpi_threshold
    chown system system /sys/devices/system/cpu/cpufreq/policy4/sched_pixel/spc_threshold
    chown system system /sys/devices/system/cpu/cpufreq/policy4/sched_pixel/limit_frequency
    chown system system /sys/devices/system/cpu/cpufreq/policy4/sched_pixel/pmu_limit_enable
    chown system system /sys/devices/system/cpu/cpufreq/policy8/sched_pixel/lcpi_threshold
    chown system system /sys/devices/system/cpu/cpufreq/policy8/sched_pixel/spc_threshold
    chown system system /sys/devices/system/cpu/cpufreq/policy8/sched_pixel/limit_frequency
    chown system system /sys/devices/system/cpu/cpufreq/policy8/sched_pixel/pmu_limit_enable

    chown system system /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu0_memlat@17000010/memlat_cpuidle_state_aware
    chown system system /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu1_memlat@17000010/memlat_cpuidle_state_aware
    chown system system /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu2_memlat@17000010/memlat_cpuidle_state_aware
    chown system system /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu3_memlat@17000010/memlat_cpuidle_state_aware
    chown system system /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu4_memlat@17000010/memlat_cpuidle_state_aware
    chown system system /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu5_memlat@17000010/memlat_cpuidle_state_aware
    chown system system /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu6_memlat@17000010/memlat_cpuidle_state_aware
    chown system system /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu7_memlat@17000010/memlat_cpuidle_state_aware
    chown system system /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu8_memlat@17000010/memlat_cpuidle_state_aware

    start vendor.keymaster-4-0

    # ZRAM setup
    write /proc/sys/vm/page-cluster 0

    # Some user code relies on ro.boot.hardware.revision
    setprop ro.boot.hardware.revision ${ro.revision}

    # Allow PAI targeting per hardware SKU
    setprop ro.oem.key1 ${ro.boot.hardware.sku}

    # Property used by vintf for sku specific manifests
    # Property used by NFC for sku specific configurations
    setprop ro.boot.product.hardware.sku ${ro.boot.hardware.sku}

    # Support legacy paths
    symlink /data/app /factory

    # Apply network parameters for high data performance.
    write /proc/sys/net/core/rmem_default 1310720
    write /proc/sys/net/core/rmem_max 8388608
    write /proc/sys/net/core/wmem_default 327680
    write /proc/sys/net/core/wmem_max 8388608
    write /proc/sys/net/core/optmem_max 20480
    write /proc/sys/net/core/netdev_max_backlog 10000
    write /proc/sys/net/ipv4/tcp_rmem "2097152 4194304 8388608"
    write /proc/sys/net/ipv4/tcp_wmem "262144 524288 8388608"
    write /proc/sys/net/ipv4/tcp_mem "44259 59012 88518"
    write /proc/sys/net/ipv4/udp_mem "88518 118025 177036"

    write /sys/class/net/rmnet0/queues/rx-0/rps_cpus fe
    write /sys/class/net/rmnet1/queues/rx-0/rps_cpus fe
    write /sys/class/net/rmnet2/queues/rx-0/rps_cpus fe
    write /sys/class/net/rmnet3/queues/rx-0/rps_cpus fe
    write /sys/class/net/rmnet4/queues/rx-0/rps_cpus fe
    write /sys/class/net/rmnet5/queues/rx-0/rps_cpus fe
    write /sys/class/net/rmnet6/queues/rx-0/rps_cpus fe
    write /sys/class/net/rmnet7/queues/rx-0/rps_cpus fe

    # Boot time 183626384
    write /proc/vendor_sched/groups/ta/uclamp_min 221
    write /proc/vendor_sched/groups/ta/prefer_idle 1
    write /proc/vendor_sched/groups/fg/uclamp_min 221
    write /proc/vendor_sched/groups/fg/prefer_idle 1
    write /proc/vendor_sched/groups/sys/uclamp_min 221
    write /proc/vendor_sched/groups/sys/prefer_idle 1


    # memlat cpuidle awareness setting
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu0_memlat@17000010/memlat_cpuidle_state_aware 2
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu1_memlat@17000010/memlat_cpuidle_state_aware 2
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu2_memlat@17000010/memlat_cpuidle_state_aware 2
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu3_memlat@17000010/memlat_cpuidle_state_aware 2
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu4_memlat@17000010/memlat_cpuidle_state_aware 2
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu5_memlat@17000010/memlat_cpuidle_state_aware 2
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu6_memlat@17000010/memlat_cpuidle_state_aware 2
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu7_memlat@17000010/memlat_cpuidle_state_aware 2
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu8_memlat@17000010/memlat_cpuidle_state_aware 2

    mkdir /dev/cpuset/camera-daemon-high-group
    write /dev/cpuset/camera-daemon-high-group/cpus 0-8
    write /dev/cpuset/camera-daemon-high-group/mems 0
    chown system system /dev/cpuset/camera-daemon-high-group/tasks
    chmod 0664 /dev/cpuset/camera-daemon-high-group/tasks

    mkdir /dev/cpuset/camera-daemon-mid-group
    write /dev/cpuset/camera-daemon-mid-group/cpus 0-8
    write /dev/cpuset/camera-daemon-mid-group/mems 0
    chown system system /dev/cpuset/camera-daemon-mid-group/tasks
    chmod 0664 /dev/cpuset/camera-daemon-mid-group/tasks

    mkdir /dev/cpuset/camera-daemon-mid-high-group
    write /dev/cpuset/camera-daemon-mid-high-group/cpus 0-8
    write /dev/cpuset/camera-daemon-mid-high-group/mems 0
    chown system system /dev/cpuset/camera-daemon-mid-high-group/tasks
    chmod 0664 /dev/cpuset/camera-daemon-mid-high-group/tasks

    # nanohub sensor
    chmod 0664 /dev/nanohub
    chmod 0664 /dev/nanohub_comms
    chown system system /dev/nanohub
    chown system system /dev/nanohub_comms

    # Dump maxfg
    chown system system /sys/class/power_supply/maxfg/m5_model_state
    chown system system /sys/class/power_supply/maxfg_base/m5_model_state

    # Dump eeprom
    chown system system /sys/devices/platform/10c90000.hsi2c/i2c-9/9-0050/eeprom
    chown system system /dev/battery_history
    chmod 0644 /dev/battery_history

    # Loading common kernel modules in background
    start init_display

    # Charge stats (write 0)
    chown system system /sys/class/power_supply/battery/charge_stats

    # Pca Charge stats (write 0)
    chown system system /sys/class/power_supply/dc-mains/device/chg_stats

    # Wireless Charge stats (write 0)
    chown system system /sys/class/power_supply/wireless/device/charge_stats

    # Thermal Charge stats (write 0)
    chown system system /sys/devices/platform/google,charger/thermal_stats

    # Google Charger stats (write 0)
    chown system system /sys/devices/platform/google,charger/charge_stats

    # Permission for wireless charging
    chown system system /sys/class/power_supply/wireless/capacity
    chown system system /sys/class/power_supply/wireless/device/rtx
    chown system system /sys/class/power_supply/wireless/device/rxdata
    chown system system /sys/class/power_supply/wireless/device/txdata
    chown system system /sys/class/power_supply/wireless/device/rxlen
    chown system system /sys/class/power_supply/wireless/device/txlen
    chown system system /sys/class/power_supply/wireless/device/ccreset
    chown system system /sys/class/power_supply/wireless/device/status
    chown system system /sys/class/power_supply/wireless/device/version
    chown system system /sys/class/power_supply/wireless/device/features
    chown system system /sys/class/power_supply/wireless/device/authtype
    chown system system /sys/class/power_supply/wireless/device/authstart

    # Adaptive charge
    chown system system /sys/class/power_supply/battery/charge_deadline

    # Charging policy
    chown system system /sys/class/power_supply/battery/charging_policy

    # BatteryHealthData
    chown system system /sys/class/power_supply/battery/first_usage_date
    chown system system /sys/class/power_supply/battery/swelling_data

    # Battery Defender
    chown system system /sys/devices/platform/google,battery/power_supply/battery/bd_trickle_cnt
    chown system system /sys/devices/platform/google,battery/power_supply/battery/bd_trickle_dry_run
    chown system system /sys/devices/platform/google,battery/power_supply/battery/bd_trickle_enable
    chown system system /sys/devices/platform/google,battery/power_supply/battery/bd_trickle_recharge_soc
    chown system system /sys/devices/platform/google,battery/power_supply/battery/bd_trickle_reset_sec
    chown system system /sys/devices/platform/google,battery/power_supply/battery/bd_clear
    chown system system /sys/devices/platform/google,battery/power_supply/battery/health_safety_margin
    chown system system /sys/devices/platform/google,charger/bd_drainto_soc
    chown system system /sys/devices/platform/google,charger/bd_recharge_soc
    chown system system /sys/devices/platform/google,charger/bd_recharge_voltage
    chown system system /sys/devices/platform/google,charger/bd_resume_abs_temp
    chown system system /sys/devices/platform/google,charger/bd_resume_soc
    chown system system /sys/devices/platform/google,charger/bd_resume_temp
    chown system system /sys/devices/platform/google,charger/bd_resume_time
    chown system system /sys/devices/platform/google,charger/bd_temp_dry_run
    chown system system /sys/devices/platform/google,charger/bd_temp_enable
    chown system system /sys/devices/platform/google,charger/bd_trigger_temp
    chown system system /sys/devices/platform/google,charger/bd_trigger_time
    chown system system /sys/devices/platform/google,charger/bd_trigger_voltage
    chown system system /sys/devices/platform/google,charger/bd_clear
    chown system system /sys/devices/platform/google,charger/bd_state
    chown system system /sys/devices/platform/google,charger/charge_start_level
    chown system system /sys/devices/platform/google,charger/charge_stop_level
    chown system system /sys/devices/platform/google,cpm/dc_ctl

    # Power Stats HAL
    chown system system /dev/bbd_pwrstat

    # Add memlat governor settings
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu0_memlat@17000010/polling_interval 10
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu1_memlat@17000010/polling_interval 10
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu2_memlat@17000010/polling_interval 10
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu3_memlat@17000010/polling_interval 10
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu4_memlat@17000010/polling_interval 10
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu5_memlat@17000010/polling_interval 10
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu6_memlat@17000010/polling_interval 10
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu7_memlat@17000010/polling_interval 10
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu8_memlat@17000010/polling_interval 10
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu0_memlat@17000010/mem_latency/ratio_ceil 1800
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu1_memlat@17000010/mem_latency/ratio_ceil 1800
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu2_memlat@17000010/mem_latency/ratio_ceil 1800
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu3_memlat@17000010/mem_latency/ratio_ceil 1800
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu4_memlat@17000010/mem_latency/ratio_ceil 3700
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu5_memlat@17000010/mem_latency/ratio_ceil 3700
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu6_memlat@17000010/mem_latency/ratio_ceil 3700
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu7_memlat@17000010/mem_latency/ratio_ceil 3700
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu8_memlat@17000010/mem_latency/ratio_ceil 3400
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu0_memlat@17000010/mem_latency/stall_floor 3000
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu1_memlat@17000010/mem_latency/stall_floor 3000
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu2_memlat@17000010/mem_latency/stall_floor 3000
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu3_memlat@17000010/mem_latency/stall_floor 3000
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu4_memlat@17000010/mem_latency/stall_floor 2400
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu5_memlat@17000010/mem_latency/stall_floor 2400
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu6_memlat@17000010/mem_latency/stall_floor 2400
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu7_memlat@17000010/mem_latency/stall_floor 2400
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu8_memlat@17000010/mem_latency/stall_floor 500

    # Set boost_adpf_prio, -1 by default
    write /proc/vendor_sched/boost_adpf_prio ${persist.device_config.vendor_system_native_boot.boost_adpf_prio:--1}

    # Add dsulat governor settings
    write /sys/class/devfreq/gs_dsulat_devfreq:devfreq_dsu_lat@17000090/dsu_latency/ratio_ceil_cl0 700
    write /sys/class/devfreq/gs_dsulat_devfreq:devfreq_dsu_lat@17000090/dsu_latency/ratio_ceil_cl1 1000
    write /sys/class/devfreq/gs_dsulat_devfreq:devfreq_dsu_lat@17000090/dsu_latency/ratio_ceil_cl2 3000

    write /sys/class/devfreq/gs_dsulat_devfreq:devfreq_dsu_lat@17000090/dsu_latency/mem_stall_floor_cl0 1750
    write /sys/class/devfreq/gs_dsulat_devfreq:devfreq_dsu_lat@17000090/dsu_latency/mem_stall_floor_cl1 1750
    write /sys/class/devfreq/gs_dsulat_devfreq:devfreq_dsu_lat@17000090/dsu_latency/mem_stall_floor_cl2 1750

    write /sys/class/devfreq/gs_dsulat_devfreq:devfreq_dsu_lat@17000090/dsu_latency/dsulat_cpuidle_state_aware_cl0 2
    write /sys/class/devfreq/gs_dsulat_devfreq:devfreq_dsu_lat@17000090/dsu_latency/dsulat_cpuidle_state_aware_cl1 2
    write /sys/class/devfreq/gs_dsulat_devfreq:devfreq_dsu_lat@17000090/dsu_latency/dsulat_cpuidle_state_aware_cl2 2

    # Give pixelstats group access to PCIe link statistics counters
    chown system system /sys/devices/platform/12100000.pcie/link_stats/complete_timeout_irqs
    chown system system /sys/devices/platform/12100000.pcie/link_stats/link_down_irqs
    chown system system /sys/devices/platform/12100000.pcie/link_stats/link_recovery_failures
    chown system system /sys/devices/platform/12100000.pcie/link_stats/link_up_failures
    chown system system /sys/devices/platform/13120000.pcie/link_stats/complete_timeout_irqs
    chown system system /sys/devices/platform/13120000.pcie/link_stats/link_down_irqs
    chown system system /sys/devices/platform/13120000.pcie/link_stats/link_recovery_failures
    chown system system /sys/devices/platform/13120000.pcie/link_stats/link_up_failures

    # Change GSA log group for dumpstate
    chown root system /sys/devices/platform/16490000.gsa-ns/log_main
    chown root system /sys/devices/platform/16490000.gsa-ns/log_intermediate

    # Enable CPU Idle histograms
    write /sys/kernel/metrics/cpuidle_histogram/enable 1

on init && property:ro.boot.hardware.cpu.pagesize=4096
    write /sys/block/zram0/comp_algorithm lz77eh

on init && property:ro.boot.hardware.cpu.pagesize=16384
    write /sys/block/zram0/comp_algorithm lzo-rle

on post-fs
    # Ensure device is ready and start storageproxyd
    wait /dev/sg1
    start storageproxyd

on late-fs
    # Start bootanimation class before mount
    start bootanim
    class_start animation

    # Mount RW partitions which need run fsck
    mount_all --late

on late-init
    write /sys/devices/system/cpu/cpu0/cpufreq/sched_pixel/down_rate_limit_us 5000
    write /sys/devices/system/cpu/cpu4/cpufreq/sched_pixel/down_rate_limit_us 20000
    write /sys/devices/system/cpu/cpu8/cpufreq/sched_pixel/down_rate_limit_us 20000

on post-fs-data
    # Modem temperature driver
    chown radio system /sys/devices/platform/cp-tm1/cp_temp

    # Log data folder
    mkdir /data/vendor 0771 radio system
    mkdir /data/vendor/log 0771 radio system
    mkdir /data/vendor/log/cbd 0771 radio system
    mkdir /data/vendor/log/rfsd 0771 radio system

    mkdir /data/exynos/log 0771 radio system
    mkdir /data/vendor/rild 0771 radio system
    mkdir /data/vendor/dump 0771 radio system
    mkdir /data/vendor/slog 0771 system system

    # PixelLogger log paths.
    mkdir /data/vendor/radio 773 system radio
    mkdir /data/vendor/radio/logs 773 system radio
    mkdir /data/vendor/radio/logs/always-on 777 system radio

    # Modem extended log folder
    mkdir /data/vendor/radio/extended_logs 0771 radio system

    # Log Mask Library Mask storage paths
    mkdir /data/vendor/radio/log_masks 777 system system

    # Modem MDS log folder
    mkdir /data/vendor/radio/mds 0771 radio system

    # Modem SIM log folder
    mkdir /data/vendor/radio/sim 0771 radio system

    # Modem OTA UECap folder
    mkdir /data/vendor/radio/ota_uecap 0773 radio system

    # Unzipped modem images folder
    mkdir /data/vendor/radio/image 0771 radio system

    # Modem stat folder
    mkdir /data/vendor/modem_stat 0771 radio system
    write /data/vendor/modem_stat/debug.txt ""
    chown radio system /data/vendor/modem_stat/debug.txt
    chmod 0664 /data/vendor/modem_stat/debug.txt

    # Modem replay folder
    mkdir /mnt/vendor/modem_userdata/replay 0775 radio system

    # Write display MIPI frequency from Modem
    chown system system /sys/devices/platform/19440000.drmdsim/hs_clock
    chown system system /sys/devices/platform/19450000.drmdsim/hs_clock
    chmod 0664 /sys/devices/platform/19440000.drmdsim/hs_clock
    chmod 0664 /sys/devices/platform/19450000.drmdsim/hs_clock

    # IPSEC PIDDIR for VoWiFi
    mkdir /data/vendor/misc 0771 root system
    mkdir /data/vendor/misc/vpn 0771 root system

    # Permissions Camera
    mkdir /data/vendor/camera 0770 system camera
    mkdir /data/vendor/camera/catpipe 0770 system camera

    # ranging sensor
    chown system system /dev/ispolin_ranging
    chmod 0660 /dev/ispolin_ranging

    # Audio dump and debug
    mkdir /data/vendor/audio 0770 system audio

    # Create the directories for Darwinn HAL.
    mkdir /data/vendor/hal_neuralnetworks_darwinn 0770 system system
    mkdir /data/vendor/hal_neuralnetworks_darwinn/checksum_cache 0770 system system
    mkdir /data/vendor/edgetpu 0770 system system
    mkdir /data/vendor/edgetpu/cache 0770 system system

    # Compatibility path for TPU
    symlink /dev/edgetpu-soc /dev/edgetpu

on zygote-start
    # For PixelLogger configuration file.
    chmod 0771 /data/vendor/wifi
    write /proc/vendor_sched/groups/ta/uclamp_min 1
    write /proc/vendor_sched/groups/fg/uclamp_min 0
    write /proc/vendor_sched/groups/sys/uclamp_min 0
    write /proc/vendor_sched/groups/ta/preferred_idle_mask_low 0x03f
    write /proc/vendor_sched/groups/ta/preferred_idle_mask_mid 0x1f0
    write /proc/vendor_sched/groups/ta/preferred_idle_mask_high 0x1f0
    write /proc/vendor_sched/groups/ta/prefer_idle 1
    write /proc/vendor_sched/groups/fg/preferred_idle_mask_low 0x03f
    write /proc/vendor_sched/groups/fg/preferred_idle_mask_mid 0x1f0
    write /proc/vendor_sched/groups/fg/preferred_idle_mask_high 0x1f0
    write /proc/vendor_sched/groups/fg/prefer_idle 1
    write /proc/vendor_sched/groups/sys/preferred_idle_mask_low 0x03f
    write /proc/vendor_sched/groups/sys/preferred_idle_mask_mid 0x1f0
    write /proc/vendor_sched/groups/sys/preferred_idle_mask_high 0x1f0
    write /proc/vendor_sched/groups/sys/prefer_idle 1

    write /proc/vendor_sched/groups/bg/ug 0
    write /proc/vendor_sched/groups/sys_bg/ug 0
    write /proc/vendor_sched/groups/ota/ug 0
    write /proc/vendor_sched/groups/dex2oat/ug 1
    write /proc/vendor_sched/groups/ta/ug 2
    write /proc/vendor_sched/groups/fg/ug 2
    write /proc/vendor_sched/groups/nnapi/ug 2
    write /proc/vendor_sched/groups/rt/ug 2
    write /proc/vendor_sched/groups/sf/ug 2
    write /proc/vendor_sched/groups/sys/ug 2


on post-fs-data
    # Create the directories used by the Wireless subsystem
    mkdir /data/vendor/wifi 0771 wifi wifi
    mkdir /data/vendor/wifi/wpa 0770 wifi wifi
    mkdir /data/vendor/wifi/wpa/sockets 0770 wifi wifi

# Gatekeeper data
    mkdir /data/vendor/gk 0771 system system

# HWC data
    mkdir /data/vendor/log/hwc 0771 system graphics

# Video data
    mkdir /data/vendor/media 0700 mediacodec mediacodec

on post-fs-data
    # GPS
    mkdir /data/vendor/gps 0771 system system
    chown system system /data/vendor/gps
    rm /data/vendor/gps/gps_started
    rm /data/vendor/gps/glonass_started
    rm /data/vendor/gps/beidou_started
    rm /data/vendor/gps/smd_started
    rm /data/vendor/gps/sv_cno.info

    chown gps system /sys/devices/platform/111e0000.spi/spi_master/spi21/spi21.0/nstandby
    chmod 0664 /dev/ttyBCM
    chown gps system /dev/ttyBCM
    chmod 0664 /dev/bbd_control
    chown gps system /dev/bbd_control
    chmod 0664 /dev/bbd_patch
    chown gps system /dev/bbd_patch
    chmod 0664 /dev/bbd_sensor
    chown gps system /dev/bbd_sensor

on early-boot
    # Wait for insmod_sh to finish all common modules
    wait_for_prop vendor.common.modules.ready 1

    # logbuffer
    chown system system /dev/logbuffer_maxfg
    chown system system /dev/logbuffer_maxfg_monitor
    chown system system /dev/logbuffer_maxq
    chown system system /dev/logbuffer_rtx
    chown system system /dev/logbuffer_ssoc
    chown system system /dev/logbuffer_ttf
    chown system system /dev/logbuffer_tcpm
    chown system system /dev/logbuffer_usbpd
    chown system system /dev/logbuffer_wireless
    chown system system /dev/logbuffer_pca9468
    chown system system /dev/logbuffer_dc_mains
    chown system system /dev/logbuffer_cpm
    chown system system /dev/logbuffer_wc68
    chown system system /dev/logbuffer_pcie0
    chown system system /dev/logbuffer_pcie1
    chown system system /dev/logbuffer_bd
    chown system system /dev/logbuffer_cpif

on boot

    # Allow to access debugfs for system:system
    chmod 0755 /sys/kernel/debug
    chown system system /sys/kernel/debug

    #setprop ro.radio.noril no

    # default country code
    setprop ro.boot.wificountrycode 00

    # Set up kernel tracing, but disable it by default
    chmod 0222 /sys/kernel/debug/tracing/trace_marker
    write /sys/kernel/debug/tracing/tracing_on 0

    # Trigger TMU to ACPM pi table update
    write /sys/module/gs_thermal/parameters/update_acpm_pi_table 1

    # Change permission for A-Box firmware logs file & GPR dump
    chown audioserver system /sys/devices/platform/17c50000.abox/reset
    chown audioserver system /sys/devices/platform/17c50000.abox/service
    chown audioserver system /sys/devices/platform/17c50000.abox/0.abox_debug/gpr
    chown audioserver system /sys/devices/platform/17c50000.abox/0.abox_debug/calliope_sram
    chown audioserver system /sys/devices/platform/17c50000.abox/0.abox_debug/calliope_dram
    chown audioserver system /sys/devices/platform/17c50000.abox/0.abox_debug/calliope_iva
    chown audioserver system /sys/kernel/debug/abox/log-00

    # Change sched lib affinity
    write /proc/vendor_sched/sched_lib_name libunity.so
    write /proc/vendor_sched/sched_lib_mask_out 0x1f0

# Permission for USB SELECT
    chown system system /sys/class/android_usb/android0/enable
    chmod 0660 /sys/class/android_usb/android0/enable
    chown system system /sys/class/android_usb/android0/idVendor
    chmod 0660 /sys/class/android_usb/android0/idVendor
    chown system system /sys/class/android_usb/android0/idProduct
    chmod 0660 /sys/class/android_usb/android0/idProduct
    chown system system /sys/class/android_usb/android0/f_diag/clients
    chmod 0660 /sys/class/android_usb/android0/f_diag/clients
    chown system system /sys/class/android_usb/android0/functions
    chmod 0660 /sys/class/android_usb/android0/functions
    chown system system /sys/class/android_usb/android0/bDeviceClass
    chmod 0660 /sys/class/android_usb/android0/bDeviceClass

# Permission for UART SWITCH
    chmod 0660 /sys/class/sec/switch/uart_sel
    chown system system /sys/class/sec/switch/uart_sel

# VTS sysfs file permission
    chown audioserver system /sys/devices/platform/13810000.vts/vts_svoice_model
    chown audioserver system /sys/devices/platform/13810000.vts/vts_google_model
    chmod 0660 /sys/devices/platform/13810000.vts/vts_svoice_model
    chmod 0660 /sys/devices/platform/13810000.vts/vts_google_model

on property:persist.vendor.radio.no_modem_board=1
    setprop ro.radio.noril yes

on fs
    mount_all --early

    # Mount modem partition
    mount_all /vendor/etc/fstab.modem --early
    restorecon_recursive /mnt/vendor/modem_img

# Permissions for ION
    chmod 0660 /sys/class/ion_cma/ion_video_ext/isolated
    chown system system /sys/class/ion_cma/ion_video_ext/isolated

# Permissions for hwcomposer
    chown system system /sys/class/backlight/panel0-backlight/als_table
    chown system system /sys/class/backlight/panel0-backlight/brightness
    chown system system /sys/class/backlight/panel0-backlight/dimming_on
    chown system system /sys/class/backlight/panel0-backlight/hbm_mode
    chown system system /sys/class/backlight/panel0-backlight/local_hbm_mode
    chown system system /sys/class/backlight/panel0-backlight/allow_wakeup_by_state_change
    chown system system /sys/devices/platform/exynos-drm/primary-panel/gamma
    chown system system /sys/devices/platform/exynos-drm/primary-panel/min_vrefresh
    chown system system /sys/devices/platform/exynos-drm/primary-panel/idle_delay_ms
    chown system system /sys/devices/platform/exynos-drm/primary-panel/panel_idle
    chown system system /sys/devices/platform/exynos-drm/primary-panel/panel_need_handle_idle_exit
    chown system system /sys/devices/platform/exynos-drm/primary-panel/op_hz
    chown system system /sys/devices/platform/exynos-drm/primary-panel/refresh_ctrl
    chown system system /sys/devices/platform/exynos-drm/primary-panel/power_state
    chown system system /sys/devices/platform/exynos-drm/displayport/drm-displayport/hdcp_negotiation
    chown system system /sys/module/drm/parameters/vblankoffdelay
    chown system system /sys/module/drm/parameters/debug
    chown system system /sys/class/dqe0/atc/ambient_light
    chown system system /sys/class/dqe0/atc/st
    chown system system /sys/class/dqe0/atc/en
    chown system system /sys/class/dqe0/atc/lt
    chown system system /sys/class/dqe0/atc/ns
    chown system system /sys/class/dqe0/atc/dither
    chown system system /sys/class/dqe0/atc/pl_w1
    chown system system /sys/class/dqe0/atc/pl_w2
    chown system system /sys/class/dqe0/atc/ctmode
    chown system system /sys/class/dqe0/atc/pp_en
    chown system system /sys/class/dqe0/atc/upgrade_on
    chown system system /sys/class/dqe0/atc/tdr_max
    chown system system /sys/class/dqe0/atc/tdr_min
    chown system system /sys/class/dqe0/atc/back_light
    chown system system /sys/class/dqe0/atc/dstep
    chown system system /sys/class/dqe0/atc/scale_mode
    chown system system /sys/class/dqe0/atc/threshold_1
    chown system system /sys/class/dqe0/atc/threshold_2
    chown system system /sys/class/dqe0/atc/threshold_3
    chown system system /sys/class/dqe0/atc/gain_limit
    chown system system /sys/class/dqe0/atc/lt_calc_ab_shift

    chown system system /sys/devices/platform/19470000.drmdecon/early_wakeup
    chmod 0660 /sys/devices/platform/19470000.drmdecon/early_wakeup

    chown system system /sys/devices/platform/19470000.drmdecon/hibernation
    chmod 0644 /sys/devices/platform/19470000.drmdecon/hibernation

# Copy DRM Key
#    copy /system/app/wv.keys /factory/wv.keys

# Permission for DRM Key
#    chmod 0644 /factory/wv.keys

# Permission for flashlight control for HAL3.3
# The Istor espresso board does not have the flash led h/w, So the below permission line are blocked.
# If you want to test the flashlight in board which have the flash led h/w, Enable the below blocked lines.
    chmod 0660 /sys/class/camera/flash/rear_torch_flash
    chown system camera /sys/class/camera/flash/rear_torch_flash
#load ecd firmware
    write /proc/ecd/load_firmware 1

service abox /vendor/bin/main_abox 17c50000.abox
    class late_start
    user audioserver
    group audioserver
    seclabel u:r:abox:s0

# on eng builds, enable kgdb on the serial console
on property:ro.build.type=eng
    write /sys/module/kgdboc/parameters/kgdboc ttyFIQ1
    write /sys/module/fiq_debugger/parameters/kgdb_enable 1

# Touch
on property:vendor.device.modules.ready=1
    chown system system /sys/class/spi_master/spi20/spi20.0/stm_fts_cmd
    chown system system /sys/class/spi_master/spi20/spi20.0/glove_mode
    chown system system /sys/devices/virtual/sec/tsp/fw_version
    chown system system /sys/devices/virtual/sec/tsp/cmd
    chown system system /sys/devices/virtual/sec/tsp/cmd_result
    chown system system /sys/devices/virtual/sec/tsp/status
    chown system system /sys/devices/virtual/goog_touch_interface/gti.0/force_active
    chown system system /sys/devices/virtual/goog_touch_interface/gti.0/fw_ver
    chown system system /sys/devices/virtual/goog_touch_interface/gti.0/ms_base
    chown system system /sys/devices/virtual/goog_touch_interface/gti.0/ms_diff
    chown system system /sys/devices/virtual/goog_touch_interface/gti.0/ms_raw
    chown system system /sys/devices/virtual/goog_touch_interface/gti.0/self_test
    chown system system /sys/devices/virtual/goog_touch_interface/gti.0/ss_base
    chown system system /sys/devices/virtual/goog_touch_interface/gti.0/ss_diff
    chown system system /sys/devices/virtual/goog_touch_interface/gti.0/ss_raw
    # Allow access to touch
    chown system input /dev/touch_offload
    chmod 660 /dev/touch_offload

# Route touch_sensitivity_mode to persist
on property:debug.touch_sensitivity_mode=0
    setprop persist.vendor.touch_sensitivity_mode 0

on property:debug.touch_sensitivity_mode=1
    setprop persist.vendor.touch_sensitivity_mode 1

on property:init.svc.vendor.charger=running
    stop keymaster-4-0

    setprop sys.usb.configfs 1
    setprop vendor.setup.power 1

    # keep one little and one big
    write /sys/devices/system/cpu/cpu1/online 0
    write /sys/devices/system/cpu/cpu2/online 0
    write /sys/devices/system/cpu/cpu3/online 0
    write /sys/devices/system/cpu/cpu4/online 0
    write /sys/devices/system/cpu/cpu5/online 0
    write /sys/devices/system/cpu/cpu7/online 0

on property:sys.boot_completed=1
    # Enable ZRAM on boot_complete
    swapon_all /vendor/etc/fstab.${ro.board.platform}
    write /proc/sys/vm/swappiness 60

    # Set kswapd affinity
    write /sys/kernel/vendor_mm/kswapd_cpu_affinity ff

    # Set kcompactd affinity
    write /sys/kernel/vendor_mm/kcompactd_cpu_affinity ff

    # Adjust watermark level
    write /proc/sys/vm/watermark_scale_factor 200

    # Back to default VM settings
    write /proc/sys/vm/dirty_expire_centisecs 3000
    write /proc/sys/vm/dirty_background_ratio 10

    # Cancel boot devfreq
    write /sys/devices/platform/17000010.devfreq_mif/devfreq/17000010.devfreq_mif/exynos_data/cancel_boot_freq 1

    # Restore prefer idle
    write /proc/vendor_sched/groups/ta/preferred_idle_mask_low 0xff
    write /proc/vendor_sched/groups/ta/preferred_idle_mask_mid 0xff
    write /proc/vendor_sched/groups/ta/preferred_idle_mask_high 0xff
    write /proc/vendor_sched/groups/fg/preferred_idle_mask_low 0x1ff
    write /proc/vendor_sched/groups/fg/preferred_idle_mask_mid 0x1ff
    write /proc/vendor_sched/groups/fg/preferred_idle_mask_high 0x1ff
    write /proc/vendor_sched/groups/sys/preferred_idle_mask_low 0x1ff
    write /proc/vendor_sched/groups/sys/preferred_idle_mask_mid 0x1ff
    write /proc/vendor_sched/groups/sys/preferred_idle_mask_high 0x1ff

    # Setup final cpuset
    write /dev/cpuset/top-app/cpus 0-8
    write /dev/cpuset/foreground/cpus 0-7
    write /dev/cpuset/foreground_window/cpus 0-7
    write /dev/cpuset/background/cpus 0-3
    write /dev/cpuset/system-background/cpus 0-3
    write /dev/cpuset/restricted/cpus 0-3
    write /dev/cpuset/camera-daemon/cpus 0-8
    setprop vendor.powerhal.init 1

    # Set uclamp.max for some groups, which could indicate cpu importance used in scheduling
    write /proc/vendor_sched/auto_uclamp_max "130 130 130 130 512 512 512 512 670"
    write /proc/vendor_sched/groups/bg/uclamp_max 130
    write /proc/vendor_sched/groups/sys_bg/uclamp_max 512
    write /proc/vendor_sched/groups/ota/uclamp_max 512
    write /proc/vendor_sched/groups/dex2oat/uclamp_max -2

    write /proc/vendor_sched/uclamp_max_filter_divider 4
    write /proc/vendor_sched/uclamp_max_filter_rt 16
    write /proc/vendor_sched/uclamp_max_filter_enable 1

    # Set PMU freq limit parameters
    write /sys/devices/system/cpu/cpufreq/policy0/sched_pixel/lcpi_threshold 0
    write /sys/devices/system/cpu/cpufreq/policy0/sched_pixel/spc_threshold 76
    write /sys/devices/system/cpu/cpufreq/policy0/sched_pixel/limit_frequency 1328000
    write /sys/devices/system/cpu/cpufreq/policy4/sched_pixel/lcpi_threshold 0
    write /sys/devices/system/cpu/cpufreq/policy4/sched_pixel/spc_threshold 73
    write /sys/devices/system/cpu/cpufreq/policy4/sched_pixel/limit_frequency 1836000
    write /sys/devices/system/cpu/cpufreq/policy8/sched_pixel/lcpi_threshold 0
    write /sys/devices/system/cpu/cpufreq/policy8/sched_pixel/spc_threshold 68
    write /sys/devices/system/cpu/cpufreq/policy8/sched_pixel/limit_frequency 2363000
    write /proc/vendor_sched/pmu_poll_time 10

    # Make devices on the critical path for suspend/resume asynchronous
    write /sys/devices/platform/fixedregulator@0/regulator/regulator.2/power/async "enabled"
    write /sys/devices/platform/fixedregulator@0/power/async "enabled"
    write /sys/devices/platform/26040000.clock-controller/power/async "enabled"
    write /sys/devices/platform/10840000.pinctrl/power/async "enabled"
    write /sys/devices/platform/13060000.pinctrl/power/async "enabled"

    # gvotables for dumpstate
    chown system system /sys/kernel/debug/gvotables

    # Permission for wireless charging
    chown system system /sys/class/power_supply/wireless/capacity
    chown system system /sys/class/power_supply/wireless/device/rtx
    chown system system /sys/class/power_supply/wireless/device/rxdata
    chown system system /sys/class/power_supply/wireless/device/txdata
    chown system system /sys/class/power_supply/wireless/device/rxlen
    chown system system /sys/class/power_supply/wireless/device/txlen
    chown system system /sys/class/power_supply/wireless/device/ccreset
    chown system system /sys/class/power_supply/wireless/device/status
    chown system system /sys/class/power_supply/wireless/device/version

    # AOC reset permission
    chown root system /sys/devices/platform/17000000.aoc/reset
    chmod 0220 /sys/devices/platform/17000000.aoc/reset

    # write serialno to battery path for pairing
    write /sys/class/power_supply/battery/dev_sn ${ro.boot.serialno}

    # Disable GPU firmware logging
    write /sys/devices/platform/1f000000.mali/firmware_config/Log\ verbosity/cur 0

    # Enable SICD
    write /sys/devices/system/cpu/cpupm/cpupm/sicd 1

on property:sys.boot_completed=1 && property:persist.sys.device_provisioned=1
    write /sys/class/power_supply/battery/first_usage_date 0

# IMS WiFi Calling
    service charonservice /system/vendor/bin/charon
    class main
    user root
    disabled
    seclabel u:r:charonservice:s0

on property:vendor.charon.exec=1
    rm /data/vendor/misc/vpn/charon.pid
    chmod 0666 /dev/tun
    start charonservice

on property:vendor.charon.exec=0
    stop charonservice
    rm /data/vendor/misc/vpn/charon.pid

# charger driver exposes now finer grain control, map demo mode to those properties
# NOTE: demo mode can only be exit wiping data (which reset the persist properties)
on property:sys.retaildemo.enabled=1
    setprop persist.vendor.charge.stop.level 35
    setprop persist.vendor.charge.start.level 30

# Test Harness Mode default battery profile.
on  property:persist.sys.test_harness=1 && property:persist.vendor.testing_battery_profile=0
    setprop persist.vendor.charge.stop.level 70
    setprop persist.vendor.charge.start.level 35
    setprop vendor.battery.defender.disable 1

# Extremely restricted battery profile.
on  property:persist.sys.test_harness=1 && property:persist.vendor.testing_battery_profile=1
    setprop persist.vendor.charge.stop.level 50
    setprop persist.vendor.charge.start.level 35
    setprop vendor.battery.defender.disable 1

# Normal behavior (as if the device was a regular device)
on  property:persist.sys.test_harness=1 && property:persist.vendor.testing_battery_profile=2
    setprop persist.vendor.charge.stop.level 100
    setprop persist.vendor.charge.start.level 0

# Unrestricted, allows charging to 100%
on  property:persist.sys.test_harness=1 && property:persist.vendor.testing_battery_profile=3
    setprop persist.vendor.charge.stop.level 100
    setprop persist.vendor.charge.start.level 0
    setprop vendor.battery.defender.disable 1

# bugreport is triggered by holding down volume down, volume up and power
service bugreport /system/bin/dumpstate -d -p -z
    class main
    disabled
    oneshot
    keycodes 114 115 116


service storageproxyd /vendor/bin/storageproxyd -d /dev/trusty-ipc-dev0 \
        -r /dev/sg1 -p /data/vendor/ss -t ufs
    class early_hal
    user system
    group system
    task_profiles MaxPerformance

# Write build info to kdebuginfo
on property:ro.build.fingerprint=*
    write /sys/module/debug_kinfo/parameters/build_info ${ro.build.fingerprint}

# Bluetooth
on early-boot
    chown bluetooth system /sys/devices/platform/175b0000.serial/serial0/serial0-0/bluetooth/hci0/rfkill0/state
    chown bluetooth system /sys/devices/platform/odm/odm:btbcm/rfkill/rfkill0/state
    chown bluetooth system /sys/devices/platform/odm/odm:btbcm/rfkill/rfkill2/state

on post-fs-data
    chown bluetooth system /proc/bluetooth/sleep/btwake
    chown bluetooth system /proc/bluetooth/sleep/lpm
    chown bluetooth system /proc/bluetooth/sleep/btwrite
    chown bluetooth system /sys/devices/platform/155d0000.serial/uart_dbg
    mkdir /data/vendor/bluetooth 0770 bluetooth system

# ODPM
on early-boot && property:ro.boot.hardware.sku=GC3VE
    write /sys/bus/iio/devices/iio:device0/enabled_rails "CH11=BUCK12S"
on early-boot && property:ro.boot.hardware.sku=GZPF0
    write /sys/bus/iio/devices/iio:device0/enabled_rails "CH11=BUCK12S"
on early-boot && property:ro.boot.hardware.sku=GPJ41
    write /sys/bus/iio/devices/iio:device0/enabled_rails "CH11=BUCK12S"
on early-boot && property:ro.boot.hardware.sku=G9BQD
    write /sys/bus/iio/devices/iio:device0/enabled_rails "CH11=BUCK12S"
on early-boot && property:ro.boot.hardware.sku=GKV4X
    write /sys/bus/iio/devices/iio:device0/enabled_rails "CH11=BUCK12S"
on early-boot && property:ro.boot.hardware.sku=G6GPR
    write /sys/bus/iio/devices/iio:device0/enabled_rails "CH11=BUCK12S"
on early-boot && property:ro.boot.hardware.sku=G576D
    write /sys/bus/iio/devices/iio:device0/enabled_rails "CH11=BUCK12S"
on early-boot && property:ro.boot.hardware.sku=GGH2X
    write /sys/bus/iio/devices/iio:device0/enabled_rails "CH11=BUCK12S"

on post-fs-data
    mkdir /data/vendor/powerstats 0771 system system
    chown system system /data/vendor/powerstats
    # Thermal Residency Stats (write 1 to reset)
    chown system system /sys/kernel/metrics/thermal/tr_by_group/tmu/stats_reset
    chown system system /sys/kernel/metrics/thermal/tr_by_group/spmic/stats_reset

on property:vendor.thermal.link_ready=1
    # BCL
    write /sys/devices/platform/cpupm/cpupm/cpd_cl1 0 #Disable power down
    write /sys/devices/platform/cpupm/cpupm/cpd_cl2 0 #Disable power down
    write /sys/devices/virtual/pmic/mitigation/clock_ratio/tpu_light_clk_ratio 0x80041c3 #OCP
    write /sys/devices/virtual/pmic/mitigation/clock_ratio/cpu1_heavy_clk_ratio 0xfff041c0 #DFS
    write /sys/devices/virtual/pmic/mitigation/clock_ratio/cpu2_heavy_clk_ratio 0xfff041c0 #DFS
    write /sys/devices/virtual/pmic/mitigation/clock_ratio/gpu_light_clk_ratio 0x80041c3 #OCP
    write /sys/devices/virtual/pmic/mitigation/clock_ratio/cpu2_light_clk_ratio 0xfff041c3 #OCP
    write /sys/devices/virtual/pmic/mitigation/clock_ratio/gpu_heavy_clk_ratio 0xfff04381 #DFS
    write /sys/devices/virtual/pmic/mitigation/clock_ratio/tpu_heavy_clk_ratio 0xfff041c1 #DFS
    write /sys/devices/virtual/pmic/mitigation/triggered_lvl/smpl_lvl 3100
    write /sys/devices/virtual/pmic/mitigation/triggered_lvl/soft_ocp_cpu2_lvl 12000
    write /sys/devices/virtual/pmic/mitigation/triggered_lvl/soft_ocp_gpu_lvl 9000
    write /sys/devices/virtual/pmic/mitigation/triggered_lvl/soft_ocp_tpu_lvl 8500
    write /sys/devices/virtual/pmic/mitigation/triggered_lvl/ocp_cpu2_lvl 12000
    write /sys/devices/virtual/pmic/mitigation/triggered_lvl/ocp_gpu_lvl 9000
    write /sys/devices/virtual/pmic/mitigation/triggered_lvl/ocp_tpu_lvl 12000
    write /sys/devices/virtual/pmic/mitigation/clock_div/tpu_clk_div 0x1
    write /sys/devices/virtual/pmic/mitigation/clock_div/gpu_clk_div 0x1
    write /sys/devices/virtual/pmic/mitigation/clock_div/cpu2_clk_div 0x1
    write /sys/devices/platform/cpupm/cpupm/cpd_cl1 1 #Enable power down
    write /sys/devices/platform/cpupm/cpupm/cpd_cl2 1 #Enable power down
    # Thermal
    chown system system /dev/thermal/tz-by-name/soc_therm/trip_point_0_temp
    chown system system /dev/thermal/tz-by-name/soc_therm/trip_point_0_hyst
    chown system system /dev/thermal/tz-by-name/usb_conn_therm/trip_point_0_temp
    chown system system /dev/thermal/tz-by-name/usb_conn_therm/trip_point_0_hyst
    chown system system /dev/thermal/tz-by-name/disp_therm/trip_point_0_temp
    chown system system /dev/thermal/tz-by-name/disp_therm/trip_point_0_hyst
    chown system system /dev/thermal/tz-by-name/north_therm/trip_point_0_temp
    chown system system /dev/thermal/tz-by-name/north_therm/trip_point_0_hyst
    chown system system /dev/thermal/tz-by-name/cam_therm/trip_point_0_temp
    chown system system /dev/thermal/tz-by-name/cam_therm/trip_point_0_hyst
    chown system system /dev/thermal/tz-by-name/charge_therm/trip_point_0_temp
    chown system system /dev/thermal/tz-by-name/charge_therm/trip_point_0_hyst
    chown system system /dev/thermal/tz-by-name/soc_therm/trip_point_0_temp
    chown system system /dev/thermal/tz-by-name/soc_therm/trip_point_0_hyst
    chown system system /dev/thermal/tz-by-name/neutral_therm/trip_point_0_temp
    chown system system /dev/thermal/tz-by-name/neutral_therm/trip_point_0_hyst
    chown system system /dev/thermal/tz-by-name/usb_pwr_therm/trip_point_0_temp
    chown system system /dev/thermal/tz-by-name/usb_pwr_therm/trip_point_0_hyst
    chown system system /dev/thermal/tz-by-name/quiet_therm/trip_point_0_temp
    chown system system /dev/thermal/tz-by-name/quiet_therm/trip_point_0_hyst

    chmod 664 /dev/thermal/cdev-by-name/thermal-cpufreq-0/user_vote
    chown system system /dev/thermal/cdev-by-name/thermal-cpufreq-0/user_vote
    chmod 664 /dev/thermal/cdev-by-name/thermal-cpufreq-1/user_vote
    chown system system /dev/thermal/cdev-by-name/thermal-cpufreq-1/user_vote
    chmod 664 /dev/thermal/cdev-by-name/thermal-cpufreq-2/user_vote
    chown system system /dev/thermal/cdev-by-name/thermal-cpufreq-2/user_vote
    chmod 664 /dev/thermal/cdev-by-name/thermal-gpufreq-0/user_vote
    chown system system /dev/thermal/cdev-by-name/thermal-gpufreq-0/user_vote
    chmod 664 /dev/thermal/cdev-by-name/gxp-cooling/user_vote
    chown system system /dev/thermal/cdev-by-name/gxp-cooling/user_vote
    chmod 664 /dev/thermal/cdev-by-name/tpu_cooling/user_vote
    chown system system /dev/thermal/cdev-by-name/tpu_cooling/user_vote
    chmod 664 /dev/thermal/cdev-by-name/fcc/cur_state
    chown system system /dev/thermal/cdev-by-name/fcc/cur_state
    chmod 664 /dev/thermal/cdev-by-name/dc_icl/cur_state
    chown system system /dev/thermal/cdev-by-name/dc_icl/cur_state
    chmod 664 /dev/thermal/cdev-by-name/chg_mdis/cur_state
    chown system system /dev/thermal/cdev-by-name/chg_mdis/cur_state
    chmod 664 /dev/thermal/cdev-by-name/usbc-port/cur_state
    chown system system /dev/thermal/cdev-by-name/usbc-port/cur_state

on charger
    # Use charger thermal config
    setprop vendor.thermal.config "thermal_info_config_charge.json"

    # Wait for insmod_sh to finish all common modules
    wait_for_prop vendor.common.modules.ready 1

    # Create thermal symlink in off charging mode
    mkdir /dev/thermal 0750 system system
    mkdir /dev/thermal/tz-by-name 0750 system system
    mkdir /dev/thermal/cdev-by-name 0750 system system
    start vendor.thermal.symlinks

    # Cancel boot devfreq and uclamp
    write /sys/devices/platform/17000010.devfreq_mif/devfreq/17000010.devfreq_mif/exynos_data/cancel_boot_freq 1
    write /proc/vendor_sched/groups/ta/uclamp_min 0
    write /proc/vendor_sched/groups/ta/prefer_idle 0
    write /proc/vendor_sched/groups/fg/uclamp_min 0
    write /proc/vendor_sched/groups/fg/prefer_idle 0
    write /proc/vendor_sched/groups/sys/uclamp_min 0
    write /proc/vendor_sched/groups/sys/prefer_idle 0

on property:vendor.disable.bcl.control=1
    write /sys/devices/virtual/pmic/mitigation/instruction/enable_mitigation 0

on property:vendor.disable.bcl.control=0
    write /sys/devices/virtual/pmic/mitigation/instruction/enable_mitigation 1

# UDFPS
on post-fs-data && property:ro.vendor.factory=1
    # HBM mode for UDFPS factory apk
    chmod 666 /d/dri/0/DSI-1/panel/reg/payload
    chmod 666 /d/dri/0/DSI-1/panel/reg/count
    chmod 666 /d/dri/0/DSI-1/panel/reg/address
    chmod 666 /d/dri/0/DSI-1/panel/hbm_mode
    chmod 666 /sys/class/backlight/panel0-backlight/local_hbm_max_timeout
    chmod 666 /sys/class/backlight/panel0-backlight/local_hbm_mode
    chmod 666 /sys/class/backlight/panel0-backlight/hbm_mode

# MTE
on property:persist.device_config.runtime_native_boot.mode_override=sync
    # Per-core mode overrides.
    # Little Cores: sync
    write /sys/devices/system/cpu/cpu0/mte_tcf_preferred sync
    write /sys/devices/system/cpu/cpu1/mte_tcf_preferred sync
    write /sys/devices/system/cpu/cpu2/mte_tcf_preferred sync
    write /sys/devices/system/cpu/cpu3/mte_tcf_preferred sync
    # Mid Cores: sync
    write /sys/devices/system/cpu/cpu4/mte_tcf_preferred sync
    write /sys/devices/system/cpu/cpu5/mte_tcf_preferred sync
    write /sys/devices/system/cpu/cpu6/mte_tcf_preferred sync
    write /sys/devices/system/cpu/cpu7/mte_tcf_preferred sync
    # Big Core: sync mode performance is prohibitively bad
    write /sys/devices/system/cpu/cpu8/mte_tcf_preferred asymm

on property:persist.device_config.runtime_native_boot.mode_override=asymm
    # Per-core mode overrides.
    write /sys/devices/system/cpu/cpu0/mte_tcf_preferred asymm
    write /sys/devices/system/cpu/cpu1/mte_tcf_preferred asymm
    write /sys/devices/system/cpu/cpu2/mte_tcf_preferred asymm
    write /sys/devices/system/cpu/cpu3/mte_tcf_preferred asymm
    write /sys/devices/system/cpu/cpu4/mte_tcf_preferred asymm
    write /sys/devices/system/cpu/cpu5/mte_tcf_preferred asymm
    write /sys/devices/system/cpu/cpu6/mte_tcf_preferred asymm
    write /sys/devices/system/cpu/cpu7/mte_tcf_preferred asymm
    write /sys/devices/system/cpu/cpu8/mte_tcf_preferred asymm

# Battery health
on property:persist.vendor.pulsar.opt_out=1
    write /sys/class/power_supply/battery/aacp_opt_out 1

on property:persist.vendor.pulsar.opt_out=0
    write /sys/class/power_supply/battery/aacp_opt_out 0

# NFC
on post-fs-data
    mkdir /data/vendor/nfc 0770 nfc nfc
