# Comet specific init.rc
import /vendor/etc/init/hw/init.${ro.board.platform}.board.rc

on init && property:ro.vendor.factory=1
    import /vendor/etc/init/hw/init.factory.rc

on init
    # eSE streset tool name
    setprop persist.vendor.se.streset libstreset24
# No se_chip_en for P1.0
on late-init && property:ro.boot.hardware.revision=PROTO1.0
    setprop persist.vendor.se.reset.chip_en false

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

service insmod_sh_comet /vendor/bin/insmod.sh /vendor_dlkm/etc/init.insmod.${ro.hardware}.cfg
    class main
    user root
    group root system
    disabled
    oneshot

on property:vendor.mfgapi.touchpanel.permission=1
    chmod 0600 /sys/devices/virtual/sec/tsp/cmd
    chown system system /sys/devices/virtual/sec/tsp/cmd

# WiFi
on post-fs-data
    setprop wifi.direct.interface p2p-dev-wlan0
    setprop wifi.aware.interface aware_nmi0

    # Speaker amp permission
    chmod 644 /mnt/vendor/persist/audio/speaker.cal

# Bluetooth
on post-fs-data
    chown bluetooth system /proc/bluetooth/timesync

# Hall sensor
on init && property:ro.bootmode=normal
    write /sys/devices/platform/hall_sensor/enable 0

on init && property:ro.bootmode=unknown
    write /sys/devices/platform/hall_sensor/enable 0

on init && property:ro.bootmode=factory
    write /sys/devices/platform/hall_sensor/enable 0

# Thermal
service init_thermal_config /vendor/bin/init_thermal_config
    class main
    user root
    group root system
    disabled
    oneshot

on late-init
    start init_thermal_config

on property:vendor.thermal.config=thermal_info_config_charge
    start init_thermal_config

on property:vendor.thermal.link_ready=1
    chown system system /dev/thermal/tz-by-name/charger_therm/trip_point_0_temp
    chown system system /dev/thermal/tz-by-name/charger_therm/trip_point_0_hyst
    chown system system /dev/thermal/tz-by-name/batoilo2/trip_point_0_temp
    chown system system /dev/thermal/tz-by-name/batoilo2/trip_point_0_hyst
    chown system system /dev/thermal/tz-by-name/gnss_tcxo_therm/trip_point_0_temp
    chown system system /dev/thermal/tz-by-name/gnss_tcxo_therm/trip_point_0_hyst
    chown system system /dev/thermal/tz-by-name/modem_therm/trip_point_0_temp
    chown system system /dev/thermal/tz-by-name/modem_therm/trip_point_0_hyst
    chown system system /dev/thermal/tz-by-name/rffe_therm/trip_point_0_temp
    chown system system /dev/thermal/tz-by-name/rffe_therm/trip_point_0_hyst

# ODPM
on early-boot && property:ro.boot.hardware.sku=GC15S
    write /sys/bus/iio/devices/iio:device0/enabled_rails "CH11=BUCK12S"
    write /sys/bus/iio/devices/iio:device1/enabled_rails "CH11=BUCK12S"

# SFPS Fingerprint
on post-fs-data
    chown system system /sys/devices/platform/odm/odm:fp_fpc1020/clk_enable
    chown system system /sys/devices/platform/odm/odm:fp_fpc1020/hw_reset
    chown system system /sys/devices/platform/odm/odm:fp_fpc1020/irq
    chown system system /sys/devices/platform/odm/odm:fp_fpc1020/wakeup_enable

on fs
    exec_background - system shell -- /vendor/bin/trusty_apploader /vendor/firmware/1540.app

# Permissions for hwcomposer
    chown system system /sys/class/backlight/panel1-backlight/als_table
    chown system system /sys/class/backlight/panel1-backlight/brightness
    chown system system /sys/class/backlight/panel1-backlight/dimming_on
    chown system system /sys/class/backlight/panel1-backlight/hbm_mode
    chown system system /sys/class/backlight/panel1-backlight/local_hbm_mode
    chown system system /sys/class/backlight/panel1-backlight/allow_wakeup_by_state_change
    chown system system /sys/devices/platform/exynos-drm/secondary-panel/gamma
    chown system system /sys/devices/platform/exynos-drm/secondary-panel/min_vrefresh
    chown system system /sys/devices/platform/exynos-drm/secondary-panel/idle_delay_ms
    chown system system /sys/devices/platform/exynos-drm/secondary-panel/panel_idle
    chown system system /sys/devices/platform/exynos-drm/secondary-panel/panel_need_handle_idle_exit
    chown system system /sys/devices/platform/exynos-drm/secondary-panel/op_hz
    chown system system /sys/devices/platform/exynos-drm/secondary-panel/power_state
    chown system system /sys/class/dqe1/atc/ambient_light
    chown system system /sys/class/dqe1/atc/st
    chown system system /sys/class/dqe1/atc/en
    chown system system /sys/class/dqe1/atc/lt
    chown system system /sys/class/dqe1/atc/ns
    chown system system /sys/class/dqe1/atc/dither
    chown system system /sys/class/dqe1/atc/pl_w1
    chown system system /sys/class/dqe1/atc/pl_w2
    chown system system /sys/class/dqe1/atc/ctmode
    chown system system /sys/class/dqe1/atc/pp_en
    chown system system /sys/class/dqe1/atc/upgrade_on
    chown system system /sys/class/dqe1/atc/tdr_max
    chown system system /sys/class/dqe1/atc/tdr_min
    chown system system /sys/class/dqe1/atc/back_light
    chown system system /sys/class/dqe1/atc/dstep
    chown system system /sys/class/dqe1/atc/scale_mode
    chown system system /sys/class/dqe1/atc/threshold_1
    chown system system /sys/class/dqe1/atc/threshold_2
    chown system system /sys/class/dqe1/atc/threshold_3
    chown system system /sys/class/dqe1/atc/gain_limit
    chown system system /sys/class/dqe1/atc/lt_calc_ab_shift
    chown system system /sys/devices/platform/19471000.drmdecon/early_wakeup
    chmod 0660 /sys/devices/platform/19471000.drmdecon/early_wakeup

# Load FPC's internal lib
on init
    setprop ro.hardware.fingerprint "fpc"

# Toggle high_sensitivity according to touch_sensitivity_mode
on property:persist.vendor.touch_sensitivity_mode=0 && property:sys.boot_completed=1
    write /sys/devices/virtual/goog_touch_interface/gti.1/screen_protector_mode_enabled 0

on property:persist.vendor.touch_sensitivity_mode=1 && property:sys.boot_completed=1
    write /sys/devices/virtual/goog_touch_interface/gti.1/screen_protector_mode_enabled 1

# Start the twoshay touch service
on property:sys.boot_completed=1
    chown system input /dev/touch_offload
    chown system input /dev/touch_offload_outer
    chmod 660 /dev/touch_offload
    chmod 660 /dev/touch_offload_outer
    start twoshay

# For Japan sku, always enforce camera shutter sound
# Since this property is read by the audio server in system service,
# it should be written by the system init.
on property:ro.boot.hardware.sku=GC15S
    setprop audio.camerasound.force true

# Enable bootstrap for US devices
on boot && property:ro.boot.warranty.sku=UVZ
    setprop setupwizard.feature.provisioning_profile_mode true
on boot && property:ro.boot.warranty.sku=UTM
    setprop setupwizard.feature.provisioning_profile_mode true

