# Bluejay specific init.rc
import /vendor/etc/init/hw/init.gs101.rc
import /vendor/etc/init/hw/init.blueport.rc

# Start the twoshay touch service
on property:vendor.device.modules.ready=1
    start twoshay

# Toggle glove_mode according to touch_sensitivity_mode
on property:persist.vendor.touch_sensitivity_mode=0 && property:sys.boot_completed=1
    write /sys/class/spi_master/spi11/spi11.0/glove_mode 00

on property:persist.vendor.touch_sensitivity_mode=1 && property:sys.boot_completed=1
    write /sys/class/spi_master/spi11/spi11.0/glove_mode 01

on post-fs-data
    # Speaker amp permission
    chmod 644 /mnt/vendor/persist/audio/speaker.cal

# Ensure Camera sound is enforced audible for JP SKU
on property:ro.boot.hardware.sku=GB17L
    setprop audio.camerasound.force true

# 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

# Haptics
on property:vendor.all.modules.ready=1
    mkdir /mnt/vendor/persist/haptics 0770 system system
    chmod 770 /mnt/vendor/persist/haptics
    chmod 440 /mnt/vendor/persist/haptics/cs40l26.cal
    chown system system /mnt/vendor/persist/haptics
    chown system system /mnt/vendor/persist/haptics/cs40l26.cal

    chown system system /sys/bus/i2c/devices/8-0043/calibration/f0_stored
    chown system system /sys/bus/i2c/devices/8-0043/calibration/q_stored
    chown system system /sys/bus/i2c/devices/8-0043/calibration/redc_stored
    chown system system /sys/bus/i2c/devices/8-0043/default/vibe_state
    chown system system /sys/bus/i2c/devices/8-0043/default/num_waves
    chown system system /sys/bus/i2c/devices/8-0043/default/braking_time_bank
    chown system system /sys/bus/i2c/devices/8-0043/default/braking_time_index
    chown system system /sys/bus/i2c/devices/8-0043/default/braking_time_ms
    chown system system /sys/bus/i2c/devices/8-0043/default/f0_offset
    chown system system /sys/bus/i2c/devices/8-0043/default/owt_free_space
    chown system system /sys/bus/i2c/devices/8-0043/default/f0_comp_enable
    chown system system /sys/bus/i2c/devices/8-0043/default/redc_comp_enable
    chown system system /sys/bus/i2c/devices/8-0043/default/delay_before_stop_playback_us

    enable vendor.vibrator.cs40l26
