service thermal-engine /vendor/bin/thermal-engine
    class main
    user root
    group root
    socket thermal-send-client stream 0660 system oem_2907
    socket thermal-recv-client stream 0660 system oem_2907
    socket thermal-recv-passive-client stream 0660 system oem_2907
    socket thermal-send-rule stream 0660 system oem_2907
    disabled

service vendor.nfc_hal_service /vendor/bin/hw/android.hardware.nfc@1.2-service
    override
    class hal
    user nfc
    group nfc
    disabled

on boot && property:ro.product.vendor.device=*
    mount none /vendor/etc/thermal-engine-map-${ro.product.vendor.device}.conf /vendor/etc/thermal-engine-map.conf bind
    start thermal-engine

on init && property:ro.boot.hwname=curtana
    mount none /vendor/lib/libcpion_curtana.so /vendor/lib/libcpion.so bind
    mount none /vendor/lib/liboemcrypto_curtana.so /vendor/lib/liboemcrypto.so bind
    mount none /vendor/lib64/libcpion_curtana.so /vendor/lib64/libcpion.so bind
    mount none /vendor/lib64/liboemcrypto_curtana.so /vendor/lib64/liboemcrypto.so bind

on init && property:ro.boot.hwname=joyeuse
    setprop ro.boot.product.hardware.sku joyeuse
    start vendor.nfc_hal_service

# perf tuning
on property:persist.sys.device_provisioned=1
    setprop dalvik.vm.dex2oat-cpu-set 0,1,2,3,4,5,7
    setprop dalvik.vm.dex2oat-threads 6

on early-init
    # Disable UFS clock scaling
    write /sys/bus/platform/devices/1d84000.ufshc/clkscale_enable 0

    # Boot time fs tuning
    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/sde/queue/iostats 0
    write /sys/block/sde/queue/scheduler cfq
    write /sys/block/sde/queue/iosched/slice_idle 0
    write /sys/block/sde/queue/read_ahead_kb 2048
    write /sys/block/sde/queue/nr_requests 256
    write /sys/block/sdf/queue/iostats 0
    write /sys/block/sdf/queue/scheduler cfq
    write /sys/block/sdf/queue/iosched/slice_idle 0
    write /sys/block/sdf/queue/read_ahead_kb 2048
    write /sys/block/sdf/queue/nr_requests 256
    write /sys/block/dm-0/queue/read_ahead_kb 2048
    write /sys/block/dm-1/queue/read_ahead_kb 2048
    write /sys/block/dm-2/queue/read_ahead_kb 2048
    write /sys/block/dm-3/queue/read_ahead_kb 2048

on late-init
    # Start services for bootanim
    start surfaceflinger
    start bootanim
    start vendor.hwcomposer-2-3
    start vendor.configstore-hal
    start vendor.qti.hardware.display.allocator

on property:sys.boot_completed=1
    # Enable UFS clock scaling back
    write /sys/bus/platform/devices/1d84000.ufshc/clkscale_enable 1

    # Runtime fs tuning
    write /sys/block/sda/queue/nr_requests 128
    write /sys/block/sde/queue/nr_requests 128
    write /sys/block/sdf/queue/nr_requests 128

    # Block layer tuning: discard chunk size up to 128MB
    # Otherwise, contiguous discards can be merged
    write /sys/block/sda/queue/discard_max_bytes 134217728

on property:vendor.post_boot.parsed=1
    # Setup runtime cpusets
    write /dev/cpuset/top-app/cpus 0-7
    write /dev/cpuset/foreground/cpus 0-5,7
    write /dev/cpuset/background/cpus 4-5
    write /dev/cpuset/system-background/cpus 2-5
    write /dev/cpuset/restricted/cpus 2-5

    # Setup default schedTune value for foreground/top-app
    write /dev/stune/foreground/schedtune.prefer_idle 1
    write /dev/stune/top-app/schedtune.boost 5
    write /dev/stune/top-app/schedtune.prefer_idle 1

    # Setup dynamic stune boost
    write /sys/module/cpu_boost/parameters/dynamic_stune_boost 15
    write /sys/module/cpu_boost/parameters/dynamic_stune_boost_ms 1000
    write /dev/stune/top-app/schedtune.sched_boost 15

    # Setup CPU frequencies
    write /sys/devices/system/cpu/cpu0/cpufreq/scaling_min_freq 768000
    write /sys/devices/system/cpu/cpu6/cpufreq/scaling_min_freq 825600

    # Setup schedutil ratelimits
    write /sys/devices/system/cpu/cpu0/cpufreq/schedutil/up_rate_limit_us 500
    write /sys/devices/system/cpu/cpu0/cpufreq/schedutil/down_rate_limit_us 20000
    write /sys/devices/system/cpu/cpu6/cpufreq/schedutil/up_rate_limit_us 500
    write /sys/devices/system/cpu/cpu6/cpufreq/schedutil/down_rate_limit_us 20000

    # Enable schedutil predicted-load boosting
    write /sys/devices/system/cpu/cpu0/cpufreq/schedutil/pl 1
    write /sys/devices/system/cpu/cpu6/cpufreq/schedutil/pl 1

    # Reinit lmkd to reconfigure lmkd properties
    setprop lmkd.reinit 1

    # EAS
    write /proc/sys/kernel/sched_upmigrate 95
    write /proc/sys/kernel/sched_downmigrate 85

    # Configure CPU input boost
    write /sys/module/cpu_boost/parameters/input_boost_freq "0:1324800 6:1324800"
    write /sys/module/cpu_boost/parameters/input_boost_ms 100

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

    # Override readahead to 128KiB
    write /sys/block/dm-0/queue/read_ahead_kb 128
    write /sys/block/dm-1/queue/read_ahead_kb 128
    write /sys/block/dm-2/queue/read_ahead_kb 128
    write /sys/block/dm-3/queue/read_ahead_kb 128
    write /sys/block/mmcblk0/queue/read_ahead_kb 128
    write /sys/block/sda/queue/read_ahead_kb 128
    write /sys/block/sdb/queue/read_ahead_kb 128
    write /sys/block/sdc/queue/read_ahead_kb 128
    write /sys/block/sdd/queue/read_ahead_kb 128
    write /sys/block/sde/queue/read_ahead_kb 128
    write /sys/block/sdf/queue/read_ahead_kb 128
