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

service 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
    # 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 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

    # 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
    wait /dev/block/platform/soc/${ro.boot.bootdevice}
    symlink /dev/block/platform/soc/${ro.boot.bootdevice} /dev/block/bootdevice

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

    # 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

    wait /dev/block/platform/soc/624000.ufshc/sda8
    mount ext4 /dev/block/platform/soc/624000.ufshc/by-name/persist /persist nosuid nodev noatime barrier=1
    restorecon_recursive /persist
    mkdir /persist/data 0700 system system

    # Start HW service manager early
    start hwservicemanager

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 devstart_sh

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

    # 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 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 mid_sh
    # Restart qseecomd once we have /data/
    restart qseecomd
    # 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/sockets 0770 wifi wifi
    mkdir /data/misc/wifi/wpa_supplicant 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/misc/audio 0770 audio audio

    # Create directory for audio delta files
    mkdir /data/misc/audio/acdbdata 0770 media audio
    mkdir /data/misc/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/nfc 0770 nfc nfc
    mkdir /data/vendor/nfc 0770 nfc nfc
    mkdir /data/nfc/param 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

on boot
    # Exec init.mid.sh and init.foreground.sh in background
    start power_sh
    start 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

    # Define TCP buffer sizes for various networks
    # ReadMin, ReadInitial, ReadMax, WriteMin, WriteInitial, WriteMax,
    setprop net.tcp.buffersize.wifi 524288,2097152,4194304,262144,524288,1048576

    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

    # Define TCP buffer sizes for various networks
    # ReadMin, ReadInitial, ReadMax, WriteMin, WriteInitial, WriteMax,
    setprop net.tcp.buffersize.default 4096,87380,524288,4096,16384,110208
    setprop net.tcp.buffersize.lte     2097152,4194304,8388608,262144,524288,1048576
    setprop net.tcp.buffersize.umts    4094,87380,110208,4096,16384,110208
    setprop net.tcp.buffersize.hspa    4094,87380,1220608,4096,16384,1220608
    setprop net.tcp.buffersize.hsupa   4094,87380,1220608,4096,16384,1220608
    setprop net.tcp.buffersize.hsdpa   4094,87380,1220608,4096,16384,1220608
    setprop net.tcp.buffersize.hspap   4094,87380,1220608,4096,16384,1220608
    setprop net.tcp.buffersize.edge    4093,26280,35040,4096,16384,35040
    setprop net.tcp.buffersize.gprs    4092,8760,11680,4096,8760,11680
    setprop net.tcp.buffersize.evdo    4094,87380,524288,4096,16384,262144

    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

on property:wc_transport.start_hci=true
    start start_hci_filter

on property:wc_transport.start_hci=false
    stop start_hci_filter

service start_hci_filter /vendor/bin/wcnss_filter
    class late_start
    user bluetooth
    group bluetooth diag
    disabled

on property:wc_transport.start_root=true
    start hci_filter_root

on property:wc_transport.start_root=false
    stop hci_filter_root

service hci_filter_root /vendor/bin/wcnss_filter
    class late_start
    user bluetooth
    group bluetooth diag system
    disabled

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

service 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.per_mgr=running
    start per_proxy

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

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

service thermal-engine /vendor/bin/thermal-engine -c ${sys.qcom.thermalcfg:-/vendor/etc/thermal-engine.conf}
   class main
   user root
   group root system
   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 time_daemon /vendor/bin/time_daemon
   class core
   user root
   group root

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

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

service 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 imsdatadaemon

service 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

service imscmservice /vendor/bin/imscmservice
   class main
   user system
   group radio diag diag log
   disabled

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

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

service 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
    start 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 cnd /vendor/bin/cnd
    user root
    group root inet wakelock
    class late_start
    socket cnd stream 660 root inet

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

service rmt_storage /vendor/bin/rmt_storage
    class core
    user root
    group root system wakelock
    ioprio rt 1

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

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

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

service wpa_supplicant /vendor/bin/hw/wpa_supplicant \
    -ip2p0 -Dnl80211 -c/data/misc/wifi/p2p_supplicant.conf \
    -I/vendor/etc/wifi/p2p_supplicant_overlay.conf -N \
    -iwlan0 -Dnl80211 -c/data/misc/wifi/wpa_supplicant.conf \
    -I/vendor/etc/wifi/wpa_supplicant_overlay.conf \
    -O/data/misc/wifi/sockets -puse_p2p_group_interface=1 \
    -e/data/misc/wifi/entropy.bin -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
    class main
    socket wpa_wlan0 dgram 660 wifi wifi
    disabled
    oneshot

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

service 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 init-radio-sh /vendor/bin/init.radio.sh
    class late_start
    user radio
    group root radio
    oneshot

service 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 atfwd /vendor/bin/ATFWD-daemon
    class late_start
    user system
    group system radio
    disabled

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

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

service 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 perfd /vendor/bin/perfd
   class main
   user root
   group root system
   writepid /dev/cpuset/system-background/tasks

# 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.boot_completed=1
    # 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/boost/cpus 0-2
    write /dev/cpuset/foreground/cpus 0-2
    write /dev/cpuset/background/cpus 0
    write /dev/cpuset/system-background/cpus 0-2

    # 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 512
    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

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

# battery driver settings for the retail demo environment where
# the device will be perpertually plugged in to a power source
on property:sys.retaildemo.enabled=1
    write /sys/class/power_supply/battery/full_level_dis_batt_chg 35

on property:sys.retaildemo.enabled=0
    write /sys/class/power_supply/battery/full_level_dis_batt_chg 100

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

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

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

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