on charger
    write /sys/devices/system/cpu/cpu2/online 0
    write /sys/devices/system/cpu/cpu3/online 0
    write /sys/module/lpm_levels/parameters/sleep_disabled 0
    wait /dev/block/platform/soc/624000.ufshc
    # Enable UFS powersaving
    write /sys/devices/soc/624000.ufshc/clkgate_enable 1
    write /sys/devices/soc/624000.ufshc/624000.ufshc:ufs_variant/pm_qos_enable 1
    write /sys/module/lpm_levels/parameters/sleep_disabled N

service vendor.charger /charger
    class charger
    seclabel u:r:charger:s0

on early-init
    mount debugfs debugfs /sys/kernel/debug
    chmod 0755 /sys/kernel/debug

on init
    # Disable UFS powersaving
    write /sys/devices/soc/624000.ufshc/clkgate_enable 0
    write /sys/devices/soc/624000.ufshc/624000.ufshc:ufs_variant/pm_qos_enable 0
    write /sys/module/lpm_levels/parameters/sleep_disabled Y

    # QSEE rpmb listener need symlink for bootdevice
    wait /dev/block/platform/soc/${ro.boot.bootdevice}
    symlink /dev/block/platform/soc/${ro.boot.bootdevice} /dev/block/bootdevice

    # We have vendor/ as early mount so we can start qseecomd earlier
    # early mount partions e.g. vendor/ will be mounted in init first stage
    # see b/27805372
    start vendor.qseecomd

    # Support legacy paths
    symlink /sdcard /mnt/sdcard
    symlink /sdcard /storage/sdcard0

    # Setup cpusets used by the VR services.
    mkdir /dev/cpuset/kernel 0750 root system
    write /dev/cpuset/kernel/cpus 0
    write /dev/cpuset/kernel/mems 0
    chown system system /dev/cpuset/kernel/tasks
    chmod 0660 /dev/cpuset/kernel/tasks

    mkdir /dev/cpuset/system 0750 root system
    write /dev/cpuset/system/cpus 0
    write /dev/cpuset/system/mems 0
    chown system system /dev/cpuset/system/tasks
    chmod 0660 /dev/cpuset/system/tasks

    mkdir /dev/cpuset/system/performance 0750 root system
    write /dev/cpuset/system/performance/cpus 0
    write /dev/cpuset/system/performance/mems 0
    chown system system /dev/cpuset/system/performance/tasks
    chmod 0660 /dev/cpuset/system/performance/tasks

    mkdir /dev/cpuset/system/background 0750 root system
    write /dev/cpuset/system/background/cpus 0
    write /dev/cpuset/system/background/mems 0
    chown system system /dev/cpuset/system/background/tasks
    chmod 0660 /dev/cpuset/system/background/tasks

    mkdir /dev/cpuset/application 0750 root system
    write /dev/cpuset/application/cpus 0
    write /dev/cpuset/application/mems 0
    chown system system /dev/cpuset/application/tasks
    chmod 0660 /dev/cpuset/application/tasks

    mkdir /dev/cpuset/application/performance 0750 root system
    write /dev/cpuset/application/performance/cpus 0
    write /dev/cpuset/application/performance/mems 0
    chown system system /dev/cpuset/application/performance/tasks
    chmod 0660 /dev/cpuset/application/performance/tasks

    mkdir /dev/cpuset/application/background 0750 root system
    write /dev/cpuset/application/background/cpus 0
    write /dev/cpuset/application/background/mems 0
    chown system system /dev/cpuset/application/background/tasks
    chmod 0660 /dev/cpuset/application/background/tasks

    # set default schedTune value for foreground/top-app (only affects EAS)
    write /dev/stune/foreground/schedtune.prefer_idle 1
    write /dev/stune/top-app/schedtune.boost 10
    write /dev/stune/top-app/schedtune.prefer_idle 1
    write /dev/stune/rt/schedtune.boost 30
    write /dev/stune/rt/schedtune.prefer_idle 1

    # Create UDS structure for base VR services.
    mkdir /dev/socket/pdx 0775 system system
    mkdir /dev/socket/pdx/system 0775 system system
    mkdir /dev/socket/pdx/system/buffer_hub 0775 system system
    mkdir /dev/socket/pdx/system/performance 0775 system system
    mkdir /dev/socket/pdx/system/vr 0775 system system
    mkdir /dev/socket/pdx/system/vr/display 0775 system system
    mkdir /dev/socket/pdx/system/vr/pose 0775 system system
    mkdir /dev/socket/pdx/system/vr/sensors 0775 system system

    # ZRAM setup
    write /sys/block/zram0/comp_algorithm lz4
    write /proc/sys/vm/page-cluster 0

on fs
    mount_all /vendor/etc/fstab.${ro.hardware} --early

    # Keeping following partitions outside fstab file. As user may not have
    # these partition flashed on the device. Failure to mount any partition in fstab file
    # results in failure to launch late-start class.

    wait /dev/block/platform/soc/624000.ufshc/sda18
    mount ext4 /dev/block/platform/soc/624000.ufshc/by-name/cache /cache nosuid nodev noatime barrier=1

    restorecon_recursive /persist
    mkdir /persist/data 0700 system system

    # for android.hardware.health@2.0-service.marlin cycle count backup
    mkdir /persist/battery 0700 system system

on post-fs
    symlink /dev/block/platform/soc.0/f9824900.sdhci /dev/block/bootdevice
    # Wait qseecomd started
    wait_for_prop sys.listeners.registered true

on late-fs
    # Start devices by sysfs trigger
    start vendor.devstart_sh

    # Start services for bootanim
    start surfaceflinger
    start bootanim
    start vendor.hwcomposer-2-1
    start vendor.configstore-hal
    start vendor.gralloc-2-0

    # Wait for hwservicemanager ready since fsck might be triggered in mount_all --late
    # In such case, init won't responce the property_set from hwservicemanager and then
    # cause services for bootanim not running.
    wait_for_prop hwservicemanager.ready true
    # Mount RW partitions which need run fsck
    mount_all /vendor/etc/fstab.${ro.hardware} --late

    # boot time fs tune
    write /sys/block/sda/queue/iostats 0
    write /sys/block/sda/queue/scheduler cfq
    write /sys/block/sda/queue/iosched/slice_idle 0
    write /sys/block/sda/queue/read_ahead_kb 2048
    write /sys/block/sda/queue/nr_requests 256
    write /sys/block/dm-0/queue/read_ahead_kb 2048
    write /sys/block/dm-1/queue/read_ahead_kb 2048

    # Start time daemon early so that the system time can be set early
    start vendor.time_daemon

on post-fs-data
    # We can start netd here before in is launched in common init.rc on zygote-start
    start netd
    # Set sku property
    start vendor.mid_sh
    # Wait until the system time is set
    wait_for_prop sys.time.set true

    # b/36601397 Setup debug folders for camera
    mkdir /data/vendor/camera 0770 camera camera

# zygote need to be started after otapreopt which will be done on post-fs-data
on zygote-start
    # zygote is started in common init.rc
    # and now we can continue initialize /data/
    mkdir /data/tombstones 0771 system system
    mkdir /tombstones/modem 0771 system system
    mkdir /tombstones/lpass 0771 system system
    mkdir /tombstones/wcnss 0771 system system
    mkdir /tombstones/dsps 0771 system system
    mkdir /persist/data/sfs 0700 system system
    mkdir /persist/data/tz 0700 system system
    mkdir /data/misc/dts 0770 media audio
    mkdir /data/misc/tloc/ 0700 system drmrpc
    mkdir /data/misc/qvop 0660 system system
    mkdir /data/misc/audio_pp 0771 media audio
    mkdir /data/preloads 0775 system system
    mkdir /data/preloads/media 0775 system system
    mkdir /data/preloads/demo 0775 system system
    mkdir /data/misc/netmgr 0770 system radio

    # Disable verbosity for sensorhub
    write /d/sps/debug_level_option 4
    write /d/sps/log_level_sel 4
    # Write to the base address of BAM pipe
    write /d/sps/bam_addr 122961920

    # Create directory for TZ Apps
    mkdir /data/misc/qsee 0770 system system

    mkdir /data/media 0770 media_rw media_rw
    chown media_rw media_rw /data/media

    mkdir /data/misc/ipa 0700 net_admin net_admin

    # Create the directories used by the Wireless subsystem
    mkdir /data/misc/wifi 0770 wifi wifi
    mkdir /data/misc/wifi/wpa_supplicant 0770 wifi wifi
    mkdir /data/vendor/wifi 0771 wifi wifi
    mkdir /data/vendor/wifi/wpa 0770 wifi wifi
    mkdir /data/vendor/wifi/wpa/sockets 0770 wifi wifi
    mkdir /data/misc/dhcp 0770 dhcp dhcp
    chown dhcp dhcp /data/misc/dhcp

    # Create port-bridge log dir
    mkdir /data/misc/port_bridge 0770 radio radio
    chmod 0770 /data/misc/port_bridge

    # Create the directories used by CnE subsystem
    mkdir /data/connectivity 0771 system system
    chown system system /data/connectivity

    # Create the directories used by DPM subsystem
    mkdir /data/dpm 0771 system system
    chown system system /data/dpm

    mkdir /data/dpm/nsrm 0771 system system
    chown system system /data/dpm/nsrm

    # Create directory used by audio subsystem
    mkdir /data/vendor/audio 0770 audio audio

    # Create directory for audio delta files
    mkdir /data/vendor/audio/acdbdata 0770 media audio
    mkdir /data/vendor/audio/acdbdata/delta 0770 media audio

    # Create directory used by the DASH client
    mkdir /data/misc/dash 0770 media audio

    # Create directory used by display clients
    mkdir /data/misc/display 0770 system graphics
    mkdir /persist/display 0770 system graphics

    # Mounting of persist is moved to 'on emmc-fs' and 'on fs' sections
    # We chown/chmod /persist again so because mount is run as root + defaults
    chown system system /persist
    chmod 0771 /persist
    chmod 0664 /sys/devices/platform/msm_sdcc.1/polling
    chmod 0664 /sys/devices/platform/msm_sdcc.2/polling
    chmod 0664 /sys/devices/platform/msm_sdcc.3/polling
    chmod 0664 /sys/devices/platform/msm_sdcc.4/polling

    # Chown polling nodes as needed from UI running on system server
    chown system system /sys/devices/platform/msm_sdcc.1/polling
    chown system system /sys/devices/platform/msm_sdcc.2/polling
    chown system system /sys/devices/platform/msm_sdcc.3/polling
    chown system system /sys/devices/platform/msm_sdcc.4/polling

    # Create the symlink to qcn wpa_supplicant folder for ar6000 wpa_supplicant
    mkdir /data/system 0775 system system

    # Create directories for Location services
    mkdir /data/misc/location 0770 gps gps
    mkdir /data/misc/location/mq 0770 gps gps
    mkdir /data/misc/location/xtwifi 0770 gps gps
    mkdir /data/misc/location/gpsone_d 0770 system gps
    mkdir /data/misc/location/quipc 0770 gps system
    mkdir /data/misc/location/gsiff 0770 gps gps

    # migrating the GNSS hal to vendor requires this to be relabeled; the
    # directory itself is created by /vendor/bin/xtra-daemon
    chown gps gps /data/misc/location/xtra
    chmod 0750 /data/misc/location/xtra
    chown gps gps /data/misc/location/xtra/socket_hal_xtra
    chmod 0660 /data/misc/location/xtra/socket_hal_xtra
    chown gps gps /data/misc/location/xtra/xtra.sqlite

    # Create directory from IMS services
    mkdir /data/shared 0755
    chown system system /data/shared

    # Create directory for FOTA
    mkdir /data/fota 0771
    chown system system /data/fota

    # Create /data/time folder for time-services
    mkdir /data/time/ 0700 system system

    mkdir /data/audio/ 0770 media audio

    # Create a folder for audio delta files
    mkdir /data/audio/acdbdata 0770 media audio
    mkdir /data/audio/acdbdata/delta 0770 media audio

    setprop vold.post_fs_data_done 1

    # Create FM dir for patchdownloader
    mkdir /data/misc/fm 0770 system system
    chmod 0770 /data/misc/fm

    # RIDL data
    mkdir /data/misc/SelfHost/ 0710 system shell
    mkdir /data/misc/SelfHost/QCLogs/ 2750 system shell
    mkdir /data/misc/SelfHost/QCLogs/temp/ 0700 system shell
    mkdir /data/misc/SelfHost/storage/ 0700 system shell
    mkdir /data/misc/SelfHost/Running/ 2750 system shell
    mkdir /data/misc/SelfHost/socket/ 2770 system system

    # Create PERFD deamon related dirs
    setprop ro.min_freq_0 384000
    mkdir /data/misc/perfd 0755 root system
    chmod 2755 /data/misc/perfd
    mkdir /data/system/perfd 0770 root system
    rm /data/system/perfd/default_values
    chmod 2770 /data/system/perfd

    # NFC local data and nfcee xml storage
    mkdir /data/vendor/nfc 0770 nfc nfc

    # Create IOP deamon related dirs
    mkdir /data/misc/iop 0770 root system

    # Mark the copy complete flag to not completed
    write /data/misc/radio/copy_complete 0
    chown radio radio /data/misc/radio/copy_complete
    chmod 0660 /data/misc/radio/copy_complete

    # File flags for prebuilt ril db file
    write /data/misc/radio/prebuilt_db_support 1
    chown radio radio /data/misc/radio/prebuilt_db_support
    chmod 0400 /data/misc/radio/prebuilt_db_support
    write /data/misc/radio/db_check_done 0
    chown radio radio /data/misc/radio/db_check_done
    chmod 0660 /data/misc/radio/db_check_done

    chown system system /sys/class/kgsl/kgsl-3d0/devfreq/max_freq
    chmod 0660 /sys/class/kgsl/kgsl-3d0/devfreq/max_freq
    chown system system /sys/class/kgsl/kgsl-3d0/devfreq/min_freq
    chmod 0660 /sys/class/kgsl/kgsl-3d0/devfreq/min_freq
    chown system system /sys/class/devfreq/soc:qcom,gpubw/min_freq
    chmod 0660 /sys/class/devfreq/soc:qcom,gpubw/min_freq

on early-boot
    # set RLIMIT_MEMLOCK to 64MB
    setrlimit 8 67108864 67108864
    # Allow subsystem (modem etc) debugging
    write /sys/module/subsystem_restart/parameters/enable_debug ${persist.sys.ssr.enable_debug}
    write /sys/module/pil_msa/parameters/pbl_mba_boot_timeout_ms ${persist.sys.mba_boot_timeout}
    write /sys/module/pil_msa/parameters/modem_auth_timeout_ms ${persist.sys.modem_auth_timeout}
    write /sys/module/peripheral_loader/parameters/proxy_timeout_ms ${persist.sys.pil_proxy_timeout}
    # Update dm-verity state and set partition.*.verified properties
    verity_update_state

    # access permission for secure touch
    chmod 0660 /sys/devices/soc/75ba000.i2c/i2c-12/12-004a/secure_touch_enable
    chmod 0440 /sys/devices/soc/75ba000.i2c/i2c-12/12-004a/secure_touch

    chmod 0664 /sys/devices/virtual/graphics/fb0/msm_cmd_autorefresh_en
    chown system graphics /sys/devices/virtual/graphics/fb0/msm_cmd_autorefresh_en

    chown system drmrpc /sys/devices/soc/75ba000.i2c/i2c-12/12-004a/secure_touch_enable
    chown system drmrpc /sys/devices/soc/75ba000.i2c/i2c-12/12-004a/secure_touch

    # Permission for laser sensor driver
    chown camera camera /sys/class/htc_laser/laser/enable_ps_sensor

    # Permission for LED driver
    chown system system /sys/class/leds/red/on_off_ms
    chown system system /sys/class/leds/green/on_off_ms
    chown system system /sys/class/leds/blue/on_off_ms
    chown system system /sys/class/leds/red/rgb_start
    chown system system /sys/class/leds/green/rgb_start
    chown system system /sys/class/leds/blue/rgb_start
    chown system system /sys/class/leds/lcd-backlight/low_persistence

    # Permission for vibrator amplitude
    chown system system /sys/class/timed_output/vibrator/voltage_level

    # wait for devices
    wait_for_prop sys.qcom.devup 1

    # vendor.health-hal needs to be able to RW
    chown system system /sys/devices/soc/qpnp-fg-17/cycle_counts_bins
    # HardwareInfo needs to be able to read CC bins
    chmod 644 /sys/devices/soc/qpnp-fg-17/cycle_counts_bins

    # dumpstate needs to read, vendor.health-hal needs to be able to RW
    chown system system /sys/devices/soc/qpnp-fg-17/power_supply/bms/charge_full
    # HardwareInfo needs to be able to read charge_full
    chmod 644 /sys/devices/soc/qpnp-fg-17/power_supply/bms/charge_full

on boot
    # from init.power.sh
    # disable thermal hotplug to switch governor
    write /sys/module/msm_thermal/core_control/enabled 0

    # bring back main cores CPU 0,2
    write /sys/devices/system/cpu/cpu0/online 1
    write /sys/devices/system/cpu/cpu2/online 1

    write /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq 300000

    # EAS: Capping the max frequency of silver core to 1.6GHz
    write /sys/devices/system/cpu/cpu0/cpufreq/scaling_max_freq 1593600

    write /sys/devices/system/cpu/cpu2/cpufreq/scaling_min_freq 300000

    # if EAS is present, switch to sched governor (no effect if not EAS)
    write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor "sched"
    write /sys/devices/system/cpu/cpu2/cpufreq/scaling_governor "sched"

    # re-enable thermal hotplug
    write /sys/module/msm_thermal/core_control/enabled 1

    # Setting b.L scheduler parameters
    write /proc/sys/kernel/sched_migration_fixup 1
    write /proc/sys/kernel/sched_upmigrate 95
    write /proc/sys/kernel/sched_downmigrate 90
    write /proc/sys/kernel/sched_freq_inc_notify 400000
    write /proc/sys/kernel/sched_freq_dec_notify 400000
    write /proc/sys/kernel/sched_spill_nr_run 3
    write /proc/sys/kernel/sched_init_task_load 100

    # Exec init.foreground.sh in background
    start vendor.foreground_sh
    # add a cpuset for the camera daemon
    # we want all cores for camera
    mkdir /dev/cpuset/camera-daemon
    write /dev/cpuset/camera-daemon/cpus 0-3
    write /dev/cpuset/camera-daemon/mems 0
    chown system system /dev/cpuset/camera-daemon
    chown system system /dev/cpuset/camera-daemon/tasks
    chmod 0664 /dev/cpuset/camera-daemon/tasks

    # Update DVR cpusets to boot-time values.
    write /dev/cpuset/kernel/cpus 0-3
    write /dev/cpuset/system/cpus 0-3
    write /dev/cpuset/system/performance/cpus 0-3
    write /dev/cpuset/system/background/cpus 0-3
    write /dev/cpuset/system/cpus 0-3
    write /dev/cpuset/application/cpus 0-3
    write /dev/cpuset/application/performance/cpus 0-3
    write /dev/cpuset/application/background/cpus 0-3
    write /dev/cpuset/application/cpus 0-3

    # Bluetooth
    chown bluetooth bluetooth /sys/module/bluetooth_power/parameters/power
    chown bluetooth net_bt /sys/class/rfkill/rfkill0/type
    chown bluetooth net_bt /sys/class/rfkill/rfkill0/state
    chown bluetooth bluetooth /proc/bluetooth/sleep/proto
    chown bluetooth bluetooth /sys/module/hci_uart/parameters/ath_lpm
    chown bluetooth bluetooth /sys/module/hci_uart/parameters/ath_btwrite
    chown system system /sys/module/sco/parameters/disable_esco
    chown bluetooth bluetooth /sys/module/hci_smd/parameters/hcismd_set
    chown system system /sys/module/radio_iris_transport/parameters/fmsmd_set
    chmod 0660 /sys/module/bluetooth_power/parameters/power
    chmod 0660 /sys/module/hci_smd/parameters/hcismd_set
    chmod 0660 /sys/module/radio_iris_transport/parameters/fmsmd_set
    chmod 0660 /sys/class/rfkill/rfkill0/state
    chmod 0660 /proc/bluetooth/sleep/proto
    chown bluetooth net_bt /dev/ttyHS0
    chmod 0660 /sys/module/hci_uart/parameters/ath_lpm
    chmod 0660 /sys/module/hci_uart/parameters/ath_btwrite
    chmod 0660 /dev/ttyHS0
    chown bluetooth bluetooth /sys/devices/platform/msm_serial_hs.0/clock
    chmod 0660 /sys/devices/platform/msm_serial_hs.0/clock

    chmod 0660 /dev/ttyHS2
    chown bluetooth bluetooth /dev/ttyHS2

    chown bluetooth net_bt /sys/class/rfkill/rfkill0/device/extldo
    chmod 0660 /sys/class/rfkill/rfkill0/device/extldo

    # Create QMUX deamon socket area
    mkdir /dev/socket/qmux_radio 0770 radio radio
    chmod 2770 /dev/socket/qmux_radio
    mkdir /dev/socket/qmux_audio 0770 media audio
    chmod 2770 /dev/socket/qmux_audio
    mkdir /dev/socket/qmux_bluetooth 0770 bluetooth bluetooth
    chmod 2770 /dev/socket/qmux_bluetooth
    mkdir /dev/socket/qmux_gps 0770 gps gps
    chmod 2770 /dev/socket/qmux_gps

    mkdir /persist/drm 0770 system system

    # Create NETMGR daemon socket area
    mkdir /dev/socket/netmgr 0750 radio radio

    setprop wifi.interface wlan0

    setprop ro.telephony.call_ring.multiple false

    # Remove SUID bit for iproute2 ip tool
    chmod 0755 /system/bin/ip

    chmod 0444 /sys/devices/platform/msm_hsusb/gadget/usb_state

    # For bridgemgr daemon to inform the USB driver of the correct transport
    chown radio radio /sys/class/android_usb/f_rmnet_smd_sdio/transport

    # For port-bridge daemon
    chown radio radio /dev/at_mdm0
    chown radio radio /dev/at_usb0

    setprop net.tcp.2g_init_rwnd 10

    # Assign TCP buffer thresholds to be ceiling value of technology maximums
    # Increased technology maximums should be reflected here.
    write /proc/sys/net/core/rmem_max  8388608
    write /proc/sys/net/core/wmem_max  8388608

    # To prevent out of order acknowledgements from making
    # connection tracking to treat them as not belonging to
    # the connection they belong to.
    # Otherwise, a weird issue happens in which some long
    # connections on high-throughput links get dropped when
    # an ack packet comes out of order
    write /proc/sys/net/netfilter/nf_conntrack_tcp_be_liberal 1

    # Allow access for CCID command/response timeout configuration
    chown system system /sys/module/ccid_bridge/parameters/bulk_msg_timeout

    # bond0 used by FST Manager
    chown wifi wifi /sys/class/net/bond0/bonding/queue_id

    write /proc/sys/net/ipv6/conf/default/accept_ra_defrtr 1

    # bluetooth init
    setprop ro.qualcomm.bluetooth.opp true
    setprop ro.qualcomm.bluetooth.hfp true
    setprop ro.qualcomm.bluetooth.hsp true
    setprop ro.qualcomm.bluetooth.pbap true
    setprop ro.qualcomm.bluetooth.ftp true
    setprop ro.qualcomm.bluetooth.nap true
    setprop ro.bluetooth.sap true
    setprop ro.bluetooth.dun true
    setprop ro.qualcomm.bluetooth.map true
    setprop ro.bluetooth.hfp.ver 1.6

    # Wifi firmware reload path
    chown wifi wifi /sys/module/wlan/parameters/fwpath

    # QCOM FG SRAM dump for dumpstate
    chown system system /d/fg_memif/data
    chown system system /d/fg_memif/count
    chown system system /d/fg_memif/address

on property:wc_transport.start_hci=true
    start vendor.start_hci_filter

on property:wc_transport.start_hci=false
    stop vendor.start_hci_filter

on property:wc_transport.start_root=true
    start vendor.hci_filter_root

on property:wc_transport.start_root=false
    stop vendor.hci_filter_root

service vendor.per_mgr /vendor/bin/pm-service
    class core
    user system
    group system
    ioprio rt 4

service vendor.per_proxy /vendor/bin/pm-proxy
    class core
    user system
    group system
    disabled

on property:ro.build.type=userdebug
   write /sys/class/uio/uio1/device/rtel/rtel 1

on property:init.svc.vendor.per_mgr=running
    start vendor.per_proxy

on property:sys.uidcpupower=*
   write /proc/uid_cpupower/enable 1

on property:sys.uidcpupower=0
   write /proc/uid_cpupower/enable 0

on property:sys.shutdown.requested=*
    stop vendor.per_proxy
    # Disable subsystem restart
    write /sys/module/subsystem_restart/parameters/disable_restart_work 0x9889deed

service vendor.qseecomd /vendor/bin/qseecomd
   class core
   user root
   group root

service vendor.thermal-engine /vendor/bin/thermal-engine -c ${sys.qcom.thermalcfg:-/vendor/etc/thermal-engine.conf}
   class hal
   user root
   group root system diag
   socket thermal-send-client stream 0666 system system
   socket thermal-recv-client stream 0660 system system
   socket thermal-recv-passive-client stream 0666 system system

service vendor.time_daemon /vendor/bin/time_daemon
   class core
   user root
   group root

service vendor.adsprpcd /vendor/bin/adsprpcd
   class main
   user media
   group media

service vendor.imsqmidaemon /vendor/bin/imsqmidaemon
    class main
    user system
    socket ims_qmid stream 0660 system radio
    group radio log diag

service vendor.imsdatadaemon /vendor/bin/imsdatadaemon
    class main
    user system
    socket ims_datad stream 0660 system radio
    group system wifi radio inet log diag
    disabled

on property:sys.ims.QMI_DAEMON_STATUS=1
    start vendor.imsdatadaemon

service vendor.ims_rtp_daemon /vendor/bin/ims_rtp_daemon
   class main
   user system
   socket ims_rtpd stream 0660 system radio
   group radio diag inet log
   disabled


on property:sys.ims.DATA_DAEMON_STATUS=1
   start vendor.ims_rtp_daemon

service vendor.ssr_setup /vendor/bin/ssr_setup
    class main
    user root
    group root system
    oneshot

service vendor.ss_ramdump /vendor/bin/subsystem_ramdump
    class main
    user root
    group root system
    disabled

on property:persist.sys.ssr.enable_ramdumps=1
    write /sys/module/subsystem_restart/parameters/enable_ramdumps 1
    mkdir /data/vendor/ramdump 761 root system
    mkdir /data/vendor/ssrdump 771 root system
    start vendor.ss_ramdump

on property:persist.sys.ssr.enable_ramdumps=0
    write /sys/module/subsystem_restart/parameters/enable_ramdumps 0

service iop /system/bin/iop
    class main
    user root
    group root
    disabled

service vendor.cnd /vendor/bin/cnd
    user root
    group root inet wakelock
    class late_start
    socket cnd stream 660 root inet

service vendor.irsc_util /vendor/bin/irsc_util "/vendor/etc/sec_config"
    class core
    user root
    oneshot

service vendor.rmt_storage /vendor/bin/rmt_storage
    class core
    user root
    group root system wakelock
    ioprio rt 0
    shutdown critical

service vendor.port-bridge /vendor/bin/port-bridge
    class main
    user radio
    group radio system inet
    oneshot

service vendor.qmiproxy /vendor/bin/qmiproxy
    class main
    user radio
    group radio diag
    disabled

service vendor.netmgrd /vendor/bin/netmgrd
    class main
    user root
    group root wifi wakelock radio inet

service wpa_supplicant /vendor/bin/hw/wpa_supplicant \
    -O/data/vendor/wifi/wpa/sockets -puse_p2p_group_interface=1 \
    -g@android:wpa_wlan0
#   we will start as root and wpa_supplicant will switch to user wifi
#   after setting up the capabilities required for WEXT
#   user wifi
#   group wifi inet keystore
    interface android.hardware.wifi.supplicant@1.0::ISupplicant default
    interface android.hardware.wifi.supplicant@1.1::ISupplicant default
    class main
    socket wpa_wlan0 dgram 660 wifi wifi
    disabled
    oneshot

service vendor.cnss-daemon /vendor/bin/cnss-daemon -n -l
    class late_start
    user system
    group system inet wifi

service vendor.loc_launcher /vendor/bin/loc_launcher
    #loc_launcher will start as root and set its uid to gps
    class late_start
    group gps inet diag wifi

service vendor.init-radio-sh /vendor/bin/init.radio.sh
    class late_start
    user radio
    group root radio
    oneshot

service vendor.msm_irqbalance /vendor/bin/msm_irqbalance -f /vendor/etc/msm_irqbalance.conf
    socket msm_irqbalance seqpacket 660 root system
    class core
    user root
    group root
    writepid /dev/cpuset/system-background/tasks

service vendor.atfwd /vendor/bin/ATFWD-daemon
    class late_start
    user system
    group system radio
    disabled

service vendor.ssr_diag /vendor/bin/ssr_diag
    class late_start
    user system
    group system
    disabled

service vendor.diag_mdlog_start /vendor/bin/diag_mdlog
    class late_start
    user shell
    group system diag sdcard_rw sdcard_r media_rw
    disabled
    oneshot

service vendor.diag_mdlog_stop /vendor/bin/diag_mdlog -k
    class late_start
    user shell
    group system diag sdcard_rw sdcard_r media_rw
    disabled
    oneshot

service vendor.perfd /vendor/bin/perfd
   class main
   user root
   group root system
   writepid /dev/cpuset/system-background/tasks
   disabled

# bugreport is triggered by holding down volume down, volume up and power
service bugreport /system/bin/dumpstate -d -p -B -z \
        -o /data/user_de/0/com.android.shell/files/bugreports/bugreport
    class main
    disabled
    oneshot
    keycodes 114 115 116

on property:sys.post_boot.parsed=1
    start vendor.perfd

on property:sys.boot_completed=1
    start vendor.power_sh

    # Enable UFS powersaving
    write /sys/devices/soc/624000.ufshc/clkgate_enable 1
    write /sys/devices/soc/624000.ufshc/624000.ufshc:ufs_variant/pm_qos_enable 1
    write /sys/module/lpm_levels/parameters/sleep_disabled N

    # update cpusets now that boot is complete and we want better load balancing
    write /dev/cpuset/top-app/cpus 0-3
    write /dev/cpuset/foreground/cpus 0-2
    write /dev/cpuset/background/cpus 0
    write /dev/cpuset/system-background/cpus 0-2
    write /dev/cpuset/restricted/cpus 0-1

    # Update DVR cpusets to runtime values.
    write /dev/cpuset/kernel/cpus 0,1
    write /dev/cpuset/system/performance/cpus 2
    write /dev/cpuset/system/background/cpus 0
    write /dev/cpuset/system/cpus 0,2
    write /dev/cpuset/application/performance/cpus 3
    write /dev/cpuset/application/background/cpus 1
    write /dev/cpuset/application/cpus 1,3

    # end boot time fs tune
    write /sys/block/sda/queue/read_ahead_kb 128
    write /sys/block/sda/queue/nr_requests 128
    write /sys/block/dm-0/queue/read_ahead_kb 128
    write /sys/block/dm-1/queue/read_ahead_kb 128
    write /sys/block/sda/queue/iostats 1

    # UFS health
    chmod 755 /sys/kernel/debug/ufshcd0
    chmod 644 /sys/kernel/debug/ufshcd0/err_state
    chmod 644 /sys/kernel/debug/ufshcd0/power_mode
    chmod 644 /sys/kernel/debug/ufshcd0/host_regs
    chmod 644 /sys/kernel/debug/ufshcd0/show_hba
    chmod 644 /sys/kernel/debug/ufshcd0/dump_device_desc
    chmod 755 /sys/kernel/debug/ufshcd0/stats
    chmod 644 /sys/kernel/debug/ufshcd0/stats/req_stats
    chmod 644 /sys/kernel/debug/ufshcd0/stats/query_stats
    chmod 644 /sys/kernel/debug/ufshcd0/stats/err_stats

    # Used immediately below
    trigger sys-boot-completed-set

# We want one opportunity per boot to enable zram, so we
# use a trigger we fire from the above stanza. If
# persist.sys.zram_enabled becomes true after boot,
# we don't want to run swapon_all at that time.
on sys-boot-completed-set && property:persist.sys.zram_enabled=1
    swapon_all /vendor/etc/fstab.${ro.hardware}

on property:sys.boot_completed=1 && property:ro.build.type=user
    write /proc/sys/kernel/modules_disabled 1

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

on property:persist.vendor.charge.stop.level=*
    write /sys/module/htc_battery/parameters/charge_stop_level ${persist.vendor.charge.stop.level}

on property:persist.vendor.charge.start.level=*
    write /sys/module/htc_battery/parameters/charge_start_level ${persist.vendor.charge.start.level}

service vendor.devstart_sh /vendor/bin/init.qcom.devstart.sh
    class main
    user root
    group root system
    disabled
    oneshot

service vendor.foreground_sh /vendor/bin/init.foreground.sh
    class main
    user root
    group root system readproc
    disabled
    oneshot

service vendor.power_sh /vendor/bin/init.power.sh
    class main
    user root
    group root system
    disabled
    oneshot

service vendor.mid_sh /vendor/bin/init.mid.sh
    class main
    user root
    group root system
    disabled
    oneshot

# reset thermal-engine when framework dies in VR mode
on property:init.svc.zygote=restarting && property:sys.qcom.thermalcfg=/vendor/etc/thermal-engine-vr.conf
   setprop sys.qcom.thermalcfg "/vendor/etc/thermal-engine.conf"
   restart vendor.thermal-engine

# b/70518189 vDSO experiments
on property:sys.vdso=*
   write /sys/module/vdso/parameters/enable_32 1
   write /sys/module/vdso/parameters/enable_64 1

on property:sys.vdso=false
   write /sys/module/vdso/parameters/enable_32 0
   write /sys/module/vdso/parameters/enable_64 0

on property:sys.vdso=64
   write /sys/module/vdso/parameters/enable_32 0

on property:sys.vdso=32
   write /sys/module/vdso/parameters/enable_64 0

# Write the dark theme magic (`theme-dark`, or 0x7468656d652d6461726b in hex string) to /misc
# partition. Offset 10814 in vendor space is effectively offset 12862 in /misc partition.
service vendor.darkboot /vendor/bin/misc_writer --vendor-space-offset 10814 --hex-string 0x7468656d652d6461726b
    disabled
    oneshot

# Clear the 10-byte dark theme magic in /misc partition. Offset 10814 in vendor space is effectively
# offset 12862 in /misc partition.
service vendor.darkboot_clear /vendor/bin/misc_writer --vendor-space-offset 10814 --hex-string 0x00000000000000000000
    disabled
    oneshot

# Set the dark boot flag on dark mode (UiModeManager.MODE_NIGHT_YES == 2).
on property:persist.sys.theme=2
    start vendor.darkboot

# Clear the dark theme flag on light mode (UiModeManager.MODE_NIGHT_NO == 1) or auto mode
# (UiModeManager.MODE_NIGHT_AUTO == 0).
on property:persist.sys.theme=1
    start vendor.darkboot_clear

on property:persist.sys.theme=0
    start vendor.darkboot_clear