summaryrefslogtreecommitdiff
path: root/conf/init.gs101.rc
blob: 9b0e133864037c76f7b7f8fd882a5e918dfc544b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
import /vendor/etc/init/hw/init.gs101.usb.rc
import android.hardware.drm@1.2-service.widevine.rc
import init.exynos.sensorhub.rc
import /vendor/etc/init/hw/init.aoc.rc

on early-init
    mount_all /vendor/etc/fstab.persist --early

on init
    # CPU0 cannot be offline
    chmod 0444 /sys/devices/system/cpu/cpu0/online

    # Set teo as cpu idle governor
    write /sys/devices/system/cpu/cpuidle/current_governor teo
    # Disable util-awareness
    write /proc/vendor_sched/teo_util_threshold "1024 1024 1024"

    # Boot time fs tuning
    write /sys/block/sda/queue/iostats 0
    write /sys/block/sda/queue/scheduler bfq
    write /sys/block/sda/queue/iosched/slice_idle 0
    write /sys/block/sda/queue/nr_requests 256
    write /dev/sys/fs/by-name/userdata/data_io_flag 56
    write /dev/sys/fs/by-name/userdata/node_io_flag 56

    chown system system /proc/vendor_sched/set_task_group_bg
    chown system system /proc/vendor_sched/set_task_group_cam
    chown system system /proc/vendor_sched/set_task_group_fg
    chown system system /proc/vendor_sched/set_task_group_nnapi
    chown system system /proc/vendor_sched/set_task_group_sys
    chown system system /proc/vendor_sched/set_task_group_sysbg
    chown system system /proc/vendor_sched/set_task_group_ta
    chown system system /proc/vendor_sched/set_task_group_rt
    chown system system /proc/vendor_sched/set_task_group_sf
    chown system system /proc/vendor_sched/set_task_group_dex2oat
    chown system system /proc/vendor_sched/set_task_group_cam_power
    chown system system /proc/vendor_sched/set_task_group_ota
    chown system system /proc/vendor_sched/set_proc_group_bg
    chown system system /proc/vendor_sched/set_proc_group_cam
    chown system system /proc/vendor_sched/set_proc_group_fg
    chown system system /proc/vendor_sched/set_proc_group_nnapi
    chown system system /proc/vendor_sched/set_proc_group_sys
    chown system system /proc/vendor_sched/set_proc_group_sysbg
    chown system system /proc/vendor_sched/set_proc_group_ta
    chown system system /proc/vendor_sched/set_proc_group_rt
    chown system system /proc/vendor_sched/set_proc_group_sf
    chown system system /proc/vendor_sched/set_proc_group_dex2oat
    chown system system /proc/vendor_sched/set_proc_group_cam_power
    chown system system /proc/vendor_sched/set_proc_group_ota
    chown system system /proc/vendor_sched/prefer_idle_set
    chown system system /proc/vendor_sched/prefer_idle_clear
    chown system system /proc/vendor_sched/pmu_poll_enable
    chown system system /proc/vendor_sched/pmu_poll_time
    chown system system /sys/devices/system/cpu/cpufreq/policy0/sched_pixel/lcpi_threshold
    chown system system /sys/devices/system/cpu/cpufreq/policy0/sched_pixel/spc_threshold
    chown system system /sys/devices/system/cpu/cpufreq/policy0/sched_pixel/limit_frequency
    chown system system /sys/devices/system/cpu/cpufreq/policy0/sched_pixel/pmu_limit_enable
    chown system system /sys/devices/system/cpu/cpufreq/policy4/sched_pixel/lcpi_threshold
    chown system system /sys/devices/system/cpu/cpufreq/policy4/sched_pixel/spc_threshold
    chown system system /sys/devices/system/cpu/cpufreq/policy4/sched_pixel/limit_frequency
    chown system system /sys/devices/system/cpu/cpufreq/policy4/sched_pixel/pmu_limit_enable
    chown system system /sys/devices/system/cpu/cpufreq/policy6/sched_pixel/lcpi_threshold
    chown system system /sys/devices/system/cpu/cpufreq/policy6/sched_pixel/spc_threshold
    chown system system /sys/devices/system/cpu/cpufreq/policy6/sched_pixel/limit_frequency
    chown system system /sys/devices/system/cpu/cpufreq/policy6/sched_pixel/pmu_limit_enable
    chown system system /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu0_memlat@17000010/memlat_cpuidle_state_aware
    chown system system /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu1_memlat@17000010/memlat_cpuidle_state_aware
    chown system system /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu2_memlat@17000010/memlat_cpuidle_state_aware
    chown system system /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu3_memlat@17000010/memlat_cpuidle_state_aware
    chown system system /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu4_memlat@17000010/memlat_cpuidle_state_aware
    chown system system /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu5_memlat@17000010/memlat_cpuidle_state_aware
    chown system system /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu6_memlat@17000010/memlat_cpuidle_state_aware
    chown system system /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu7_memlat@17000010/memlat_cpuidle_state_aware

    chmod 0220 /proc/vendor_sched/set_task_group_bg
    chmod 0220 /proc/vendor_sched/set_task_group_cam
    chmod 0220 /proc/vendor_sched/set_task_group_fg
    chmod 0220 /proc/vendor_sched/set_task_group_nnapi
    chmod 0220 /proc/vendor_sched/set_task_group_sys
    chmod 0220 /proc/vendor_sched/set_task_group_sysbg
    chmod 0220 /proc/vendor_sched/set_task_group_ta
    chmod 0220 /proc/vendor_sched/set_task_group_rt
    chmod 0220 /proc/vendor_sched/set_task_group_sf
    chmod 0220 /proc/vendor_sched/set_task_group_dex2oat
    chmod 0220 /proc/vendor_sched/set_task_group_cam_power
    chmod 0220 /proc/vendor_sched/set_task_group_ota
    chmod 0220 /proc/vendor_sched/set_proc_group_bg
    chmod 0220 /proc/vendor_sched/set_proc_group_cam
    chmod 0220 /proc/vendor_sched/set_proc_group_fg
    chmod 0220 /proc/vendor_sched/set_proc_group_nnapi
    chmod 0220 /proc/vendor_sched/set_proc_group_sys
    chmod 0220 /proc/vendor_sched/set_proc_group_sysbg
    chmod 0220 /proc/vendor_sched/set_proc_group_ta
    chmod 0220 /proc/vendor_sched/set_proc_group_rt
    chmod 0220 /proc/vendor_sched/set_proc_group_sf
    chmod 0220 /proc/vendor_sched/set_proc_group_dex2oat
    chmod 0220 /proc/vendor_sched/set_proc_group_cam_power
    chmod 0220 /proc/vendor_sched/set_proc_group_ota
    chmod 0220 /proc/vendor_sched/prefer_idle_set
    chmod 0220 /proc/vendor_sched/prefer_idle_clear
    chmod 0220 /proc/vendor_sched/pmu_poll_enable
    chmod 0220 /proc/vendor_sched/pmu_poll_time

    wait /dev/block/platform/${ro.boot.boot_devices}
    symlink /dev/block/platform/${ro.boot.boot_devices} /dev/block/bootdevice

    # to access UFS/eMMC sysfs directly
    symlink /sys/devices/platform/${ro.boot.boot_devices} /dev/sys/block/bootdevice

    # Disable UFS powersaving
    write /dev/sys/block/bootdevice/clkgate_enable 0

    start vendor.keymaster-3-0

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

    # Some user code relies on ro.boot.hardware.revision
    setprop ro.boot.hardware.revision ${ro.revision}

    # Allow PAI targeting per hardware SKU
    setprop ro.oem.key1 ${ro.boot.hardware.sku}

    # Property used by vintf for sku specific manifests
    # Property used by NFC for sku specific configurations
    setprop ro.boot.product.hardware.sku ${ro.boot.hardware.sku}

    # Support legacy paths
    symlink /data/app /factory

    # Apply network parameters for high data performance.
    write /proc/sys/net/core/rmem_default 327680
    write /proc/sys/net/core/rmem_max 8388608
    write /proc/sys/net/core/wmem_default 327680
    write /proc/sys/net/core/wmem_max 8388608
    write /proc/sys/net/core/optmem_max 20480
    write /proc/sys/net/core/netdev_max_backlog 10000
    write /proc/sys/net/ipv4/tcp_rmem "2097152 4194304 8388608"
    write /proc/sys/net/ipv4/tcp_wmem "262144 524288 8388608"
    write /proc/sys/net/ipv4/tcp_mem "44259 59012 88518"
    write /proc/sys/net/ipv4/udp_mem "88518 118025 177036"

    write /sys/class/net/rmnet0/queues/rx-0/rps_cpus fe
    write /sys/class/net/rmnet1/queues/rx-0/rps_cpus fe
    write /sys/class/net/rmnet2/queues/rx-0/rps_cpus fe
    write /sys/class/net/rmnet3/queues/rx-0/rps_cpus fe
    write /sys/class/net/rmnet4/queues/rx-0/rps_cpus fe
    write /sys/class/net/rmnet5/queues/rx-0/rps_cpus fe
    write /sys/class/net/rmnet6/queues/rx-0/rps_cpus fe
    write /sys/class/net/rmnet7/queues/rx-0/rps_cpus fe

    # 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

    # Boot time 183626384
    write /proc/vendor_sched/ta_uclamp_min 161
    write /proc/vendor_sched/ta_prefer_idle 1
    write /proc/vendor_sched/fg_uclamp_min 161
    write /proc/vendor_sched/fg_prefer_idle 1
    write /proc/vendor_sched/sys_uclamp_min 161
    write /proc/vendor_sched/sys_prefer_idle 1

    # governor setting
    write /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor sched_pixel
    write /sys/devices/system/cpu/cpu0/cpufreq/sched_pixel/up_rate_limit_us 500
    write /sys/devices/system/cpu/cpu0/cpufreq/sched_pixel/down_rate_limit_us 5000
    write /sys/devices/system/cpu/cpu0/cpufreq/sched_pixel/down_rate_limit_scale_pow 2
    write /sys/devices/system/cpu/cpu4/cpufreq/scaling_governor sched_pixel
    write /sys/devices/system/cpu/cpu4/cpufreq/sched_pixel/up_rate_limit_us 500
    write /sys/devices/system/cpu/cpu4/cpufreq/sched_pixel/down_rate_limit_us 20000
    write /sys/devices/system/cpu/cpu6/cpufreq/scaling_governor sched_pixel
    write /sys/devices/system/cpu/cpu6/cpufreq/sched_pixel/up_rate_limit_us 500
    write /sys/devices/system/cpu/cpu6/cpufreq/sched_pixel/down_rate_limit_us 20000

    # memlat cpuidle awareness setting
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu0_memlat@17000010/memlat_cpuidle_state_aware 2
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu1_memlat@17000010/memlat_cpuidle_state_aware 2
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu2_memlat@17000010/memlat_cpuidle_state_aware 2
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu3_memlat@17000010/memlat_cpuidle_state_aware 2
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu4_memlat@17000010/memlat_cpuidle_state_aware 2
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu5_memlat@17000010/memlat_cpuidle_state_aware 2
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu6_memlat@17000010/memlat_cpuidle_state_aware 2
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu7_memlat@17000010/memlat_cpuidle_state_aware 2

    # RT uclamp setting
    write /proc/sys/kernel/sched_util_clamp_min_rt_default 0

    # change permissions and default values for camera-daemon cpu controller
    chown system system /dev/cpuctl/camera-daemon/cpu.uclamp.min
    chown system system /dev/cpuctl/camera-daemon/cpu.uclamp.max
    chown root root /dev/cpuctl/camera-daemon/cpu.uclamp.latency_sensitive
    chown system system /dev/cpuctl/camera-daemon/cgroup.procs

    mkdir /dev/cpuset/camera-daemon-high-group
    write /dev/cpuset/camera-daemon-high-group/cpus 0-7
    write /dev/cpuset/camera-daemon-high-group/mems 0
    chown system system /dev/cpuset/camera-daemon-high-group/tasks
    chmod 0664 /dev/cpuset/camera-daemon-high-group/tasks

    mkdir /dev/cpuset/camera-daemon-mid-group
    write /dev/cpuset/camera-daemon-mid-group/cpus 0-7
    write /dev/cpuset/camera-daemon-mid-group/mems 0
    chown system system /dev/cpuset/camera-daemon-mid-group/tasks
    chmod 0664 /dev/cpuset/camera-daemon-mid-group/tasks

    mkdir /dev/cpuset/camera-daemon-mid-high-group
    write /dev/cpuset/camera-daemon-mid-high-group/cpus 0-7
    write /dev/cpuset/camera-daemon-mid-high-group/mems 0
    chown system system /dev/cpuset/camera-daemon-mid-high-group/tasks
    chmod 0664 /dev/cpuset/camera-daemon-mid-high-group/tasks

    write /proc/vendor_sched/cam_prefer_idle 1
    write /proc/vendor_sched/cam_uclamp_min 1

    chown system system /dev/cpuset/cgroup.procs

    # nanohub sensor
    chmod 0664 /dev/nanohub
    chmod 0664 /dev/nanohub_comms
    chown system system /dev/nanohub
    chown system system /dev/nanohub_comms

    # logbuffer
    chown system system /dev/logbuffer_maxfg
    chown system system /dev/logbuffer_maxfg_base
    chown system system /dev/logbuffer_maxfg_flip
    chown system system /dev/logbuffer_maxfg_monitor
    chown system system /dev/logbuffer_maxfg_base_monitor
    chown system system /dev/logbuffer_maxfg_flip_monitor
    chown system system /dev/logbuffer_maxq
    chown system system /dev/logbuffer_google,cpm
    chown system system /dev/logbuffer_rtx
    chown system system /dev/logbuffer_ssoc
    chown system system /dev/logbuffer_ttf
    chown system system /dev/logbuffer_tcpm
    chown system system /dev/logbuffer_usbpd
    chown system system /dev/logbuffer_pogo_transport
    chown system system /dev/logbuffer_wireless
    chown system system /dev/logbuffer_pca9468
    chown system system /dev/logbuffer_cpm
    chown system system /dev/logbuffer_bd

    # Dump maxfg
    chown system system /sys/class/power_supply/maxfg/m5_model_state
    chown system system /sys/class/power_supply/maxfg_base/m5_model_state

    # Dump eeprom
    chown system system /sys/devices/platform/10970000.hsi2c/i2c-8/8-0050/eeprom
    chown system system /sys/devices/platform/10970000.hsi2c/i2c-7/7-0050/eeprom
    chown system system /sys/devices/platform/10970000.hsi2c/i2c-6/6-0050/eeprom
    chown system system /sys/devices/platform/10970000.hsi2c/i2c-5/5-0050/eeprom
    chown system system /sys/devices/platform/10970000.hsi2c/i2c-4/4-0050/eeprom
    chown system system /dev/battery_history

    # Modem temperature driver
    chown radio system /sys/devices/platform/cp-tm1/cp_temp

    # insert display module
    start init_display

    # Charge stats (write 0)
    chown system system /sys/class/power_supply/battery/charge_stats

    # Pca Charge stats (write 0)
    chown system system /sys/class/power_supply/pca9468-mains/device/chg_stats

    # Wireless Charge stats (write 0)
    chown system system /sys/class/power_supply/wireless/device/charge_stats

    # Thermal Charge stats (write 0)
    chown system system /sys/devices/platform/google,charger/thermal_stats

    # Google Charger stats (write 0)
    chown system system /sys/devices/platform/google,charger/charge_stats

    # Permission for wireless charging fan
    chown system system /sys/devices/platform/google,charger/thermal_dc_fan_alarm
    chown system system /sys/devices/platform/google,cpm/thermal_mdis_fan_alarm

    # Permission for wireless charging
    chown system system /sys/class/power_supply/wireless/capacity
    chown system system /sys/class/power_supply/wireless/device/rtx
    chown system system /sys/class/power_supply/wireless/device/rxdata
    chown system system /sys/class/power_supply/wireless/device/txdata
    chown system system /sys/class/power_supply/wireless/device/rxlen
    chown system system /sys/class/power_supply/wireless/device/txlen
    chown system system /sys/class/power_supply/wireless/device/ccreset
    chown system system /sys/class/power_supply/wireless/device/status
    chown system system /sys/class/power_supply/wireless/device/version
    chown system system /sys/class/power_supply/wireless/device/features
    chown system system /sys/class/power_supply/wireless/device/authtype

    # Adaptive charge
    chown system system /sys/class/power_supply/battery/charge_deadline

    # Charging policy
    chown system system /sys/class/power_supply/battery/charging_policy

    # BatteryHealthData
    chown system system /sys/class/power_supply/battery/first_usage_date

    # Battery Defender
    chown system system /sys/devices/platform/google,battery/power_supply/battery/bd_trickle_cnt
    chown system system /sys/devices/platform/google,battery/power_supply/battery/bd_trickle_dry_run
    chown system system /sys/devices/platform/google,battery/power_supply/battery/bd_trickle_enable
    chown system system /sys/devices/platform/google,battery/power_supply/battery/bd_trickle_recharge_soc
    chown system system /sys/devices/platform/google,battery/power_supply/battery/bd_trickle_reset_sec
    chown system system /sys/devices/platform/google,battery/power_supply/battery/bd_clear
    chown system system /sys/devices/platform/google,battery/power_supply/battery/health_safety_margin
    chown system system /sys/devices/platform/google,battery/power_supply/battery/aacr_state
    chown system system /sys/devices/platform/google,battery/power_supply/battery/aacr_cycle_max
    chown system system /sys/devices/platform/google,battery/power_supply/battery/aacr_cycle_grace
    chown system system /sys/devices/platform/google,charger/bd_drainto_soc
    chown system system /sys/devices/platform/google,charger/bd_recharge_soc
    chown system system /sys/devices/platform/google,charger/bd_recharge_voltage
    chown system system /sys/devices/platform/google,charger/bd_resume_abs_temp
    chown system system /sys/devices/platform/google,charger/bd_resume_soc
    chown system system /sys/devices/platform/google,charger/bd_resume_temp
    chown system system /sys/devices/platform/google,charger/bd_resume_time
    chown system system /sys/devices/platform/google,charger/bd_temp_dry_run
    chown system system /sys/devices/platform/google,charger/bd_temp_enable
    chown system system /sys/devices/platform/google,charger/bd_trigger_temp
    chown system system /sys/devices/platform/google,charger/bd_trigger_time
    chown system system /sys/devices/platform/google,charger/bd_trigger_voltage
    chown system system /sys/devices/platform/google,charger/bd_clear
    chown system system /sys/devices/platform/google,charger/charge_start_level
    chown system system /sys/devices/platform/google,charger/charge_stop_level
    chown system system /sys/devices/platform/google,cpm/dc_ctl
    # Important to include dd_state as it's used in battery defender in charger mode
    chown system system /sys/devices/platform/google,charger/dd_state
    chown system system /sys/devices/platform/google,charger/dd_settings

    # Power Stats HAL
    chown system system /dev/bbd_pwrstat

    # Add a boost for NNAPI HAL
    write /proc/vendor_sched/nnapi_prefer_idle 0
    write /proc/vendor_sched/nnapi_uclamp_min 512

    # Add memlat governor settings
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu0_memlat@17000010/polling_interval 10
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu1_memlat@17000010/polling_interval 10
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu2_memlat@17000010/polling_interval 10
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu3_memlat@17000010/polling_interval 10
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu4_memlat@17000010/polling_interval 10
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu5_memlat@17000010/polling_interval 10
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu6_memlat@17000010/polling_interval 10
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu7_memlat@17000010/polling_interval 10
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu0_memlat@17000010/mem_latency/ratio_ceil 400
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu1_memlat@17000010/mem_latency/ratio_ceil 400
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu2_memlat@17000010/mem_latency/ratio_ceil 400
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu3_memlat@17000010/mem_latency/ratio_ceil 400
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu4_memlat@17000010/mem_latency/ratio_ceil 2700
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu5_memlat@17000010/mem_latency/ratio_ceil 2700
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu6_memlat@17000010/mem_latency/ratio_ceil 3200
    write /sys/class/devfreq/gs_memlat_devfreq:devfreq_mif_cpu7_memlat@17000010/mem_latency/ratio_ceil 3200

    # Set boost_adpf_prio, -1 by default
    write /proc/vendor_sched/boost_adpf_prio ${persist.device_config.vendor_system_native_boot.boost_adpf_prio:--1}

on init && property:ro.boot.hw.soc.rev=0
    setprop vendor.powerhal.config powerhint_a0.json

on init && property:ro.boot.hw.soc.rev=1
    setprop vendor.powerhal.config powerhint_a1.json

on init && property:ro.boot.hw.soc.rev=0
    # STOPSHIP b/177967147 disable SICD
    write /sys/devices/platform/cpupm/cpupm/sicd 0

on init && property:ro.boot.hw.soc.rev=1
    # STOPSHIP b/177967147 disable SICD
    write /sys/devices/platform/cpupm/cpupm/sicd 0

on late-fs
    # Start bootanimation class before mount
    start bootanim
    class_start animation

    # Mount RW partitions which need run fsck
    mount_all --late

on post-fs-data
    # Log data folder
    mkdir /data/vendor 0771 radio system
    mkdir /data/vendor/log 0771 radio system
    mkdir /data/vendor/log/cbd 0771 radio system
    mkdir /data/vendor/log/rfsd 0771 radio system

    mkdir /data/exynos/log 0771 radio system
    mkdir /data/vendor/rild 0771 radio system
    mkdir /data/vendor/dump 0771 radio system
    mkdir /data/vendor/slog 0771 system system

    # PixelLogger log paths.
    mkdir /data/vendor/radio 773 system radio
    mkdir /data/vendor/radio/logs 773 system radio
    mkdir /data/vendor/radio/logs/always-on 777 system radio

    # Modem extended log folder
    mkdir /data/vendor/radio/extended_logs 0770 radio system

    # Modem MDS log folder
    mkdir /data/vendor/radio/mds 0771 radio system

    # Unzipped modem images folder
    mkdir /data/vendor/radio/image 0771 radio system

    # Modem stat folder
    mkdir /data/vendor/modem_stat 0771 radio system
    write /data/vendor/modem_stat/debug.txt ""
    chown radio system /data/vendor/modem_stat/debug.txt
    chmod 0664 /data/vendor/modem_stat/debug.txt

    # Modem replay folder
    mkdir /mnt/vendor/modem_userdata/replay 0775 radio system

    # Write display MIPI frequency from Modem
    chown system system /sys/devices/platform/1c2c0000.drmdsim/hs_clock
    chown system system /sys/devices/platform/1c2d0000.drmdsim/hs_clock
    chmod 0664 /sys/devices/platform/1c2c0000.drmdsim/hs_clock
    chmod 0664 /sys/devices/platform/1c2d0000.drmdsim/hs_clock

    setprop wifi.direct.interface p2p-dev-wlan0
    setprop wifi.aware.interface aware_nmi0

# IPSEC PIDDIR for VoWiFi
    mkdir /data/vendor/misc 0771 root system
    mkdir /data/vendor/misc/vpn 0771 root system

# Permissions Camera
    mkdir /data/vendor/camera 0770 system camera
    mkdir /data/vendor/camera/catpipe 0770 system camera
    chmod 0755 /sys/kernel/debug/tracing
    restorecon /sys/kernel/debug/tracing/trace_marker

    # ranging sensor
    chown system system /dev/stmvl53l1_ranging
    chmod 0660 /dev/stmvl53l1_ranging

    # Factory calibration files
    chmod 0771 /mnt/vendor/persist/camera
    chmod 0771 /mnt/vendor/persist/camera/OTP_calibration
    chmod 0771 /mnt/vendor/persist/camera/pdaf_calibration_data
    chmod 0771 /mnt/vendor/persist/camera/rear

# Audio dump and debug
    mkdir /data/vendor/audio 0770 audio audio

# Create the directories for Darwinn HAL.
    mkdir /data/vendor/hal_neuralnetworks_darwinn 0770 system system
    mkdir /data/vendor/hal_neuralnetworks_darwinn/checksum_cache 0770 system system
    mkdir /data/vendor/edgetpu 0770 system system
    mkdir /data/vendor/edgetpu/cache 0770 system system

# Compatibility path for TPU
    symlink /dev/abrolhos /dev/edgetpu

on zygote-start
    # For PixelLogger configuration file.
    chmod 0771 /data/vendor/wifi
    write /proc/vendor_sched/sys_uclamp_min 0

on post-fs-data
    # Create the directories used by the Wireless subsystem
    mkdir /data/vendor/wifi 0771 wifi wifi
    mkdir /data/vendor/wifi/wpa 0770 wifi wifi
    mkdir /data/vendor/wifi/wpa/sockets 0770 wifi wifi

# Gatekeeper data
    mkdir /data/vendor/gk 0771 system system

# HWC data
    mkdir /data/vendor/log/hwc 0771 system graphics

# Video data
    mkdir /data/vendor/media 0700 mediacodec mediacodec

on post-fs-data
    # GPS
    mkdir /data/vendor/gps 0771 system system
    chown system system /data/vendor/gps
    rm /data/vendor/gps/gps_started
    rm /data/vendor/gps/glonass_started
    rm /data/vendor/gps/beidou_started
    rm /data/vendor/gps/smd_started
    rm /data/vendor/gps/sv_cno.info

    chown gps system /sys/devices/platform/10940000.spi/spi_master/spi5/spi5.0/nstandby
    chmod 0664 /dev/ttyBCM
    chown gps system /dev/ttyBCM
    chmod 0664 /dev/bbd_control
    chown gps system /dev/bbd_control
    chmod 0664 /dev/bbd_patch
    chown gps system /dev/bbd_patch
    chmod 0664 /dev/bbd_sensor
    chown gps system /dev/bbd_sensor

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

    # Permission for Health Storage HAL
    chown system system /dev/sys/block/bootdevice/manual_gc

    # Permission for Pixelstats
    chown system system /dev/sys/block/bootdevice/slowio_read_cnt
    chown system system /dev/sys/block/bootdevice/slowio_write_cnt
    chown system system /dev/sys/block/bootdevice/slowio_unmap_cnt
    chown system system /dev/sys/block/bootdevice/slowio_sync_cnt

on boot

    # Allow to access debugfs for system:system
    chmod 0755 /sys/kernel/debug
    chown system system /sys/kernel/debug

    #setprop ro.radio.noril no

    # default country code
    setprop ro.boot.wificountrycode 00

    # Set up kernel tracing, but disable it by default
    chmod 0222 /sys/kernel/debug/tracing/trace_marker
    write /sys/kernel/debug/tracing/tracing_on 0

    # Change permission for A-Box firmware logs file & GPR dump
    chown audioserver system /sys/devices/platform/17c50000.abox/reset
    chown audioserver system /sys/devices/platform/17c50000.abox/service
    chown audioserver system /sys/devices/platform/17c50000.abox/0.abox_debug/gpr
    chown audioserver system /sys/devices/platform/17c50000.abox/0.abox_debug/calliope_sram
    chown audioserver system /sys/devices/platform/17c50000.abox/0.abox_debug/calliope_dram
    chown audioserver system /sys/devices/platform/17c50000.abox/0.abox_debug/calliope_iva
    chown audioserver system /sys/kernel/debug/abox/log-00

# Permission for USB SELECT
    chown system system /sys/class/android_usb/android0/enable
    chmod 0660 /sys/class/android_usb/android0/enable
    chown system system /sys/class/android_usb/android0/idVendor
    chmod 0660 /sys/class/android_usb/android0/idVendor
    chown system system /sys/class/android_usb/android0/idProduct
    chmod 0660 /sys/class/android_usb/android0/idProduct
    chown system system /sys/class/android_usb/android0/f_diag/clients
    chmod 0660 /sys/class/android_usb/android0/f_diag/clients
    chown system system /sys/class/android_usb/android0/functions
    chmod 0660 /sys/class/android_usb/android0/functions
    chown system system /sys/class/android_usb/android0/bDeviceClass
    chmod 0660 /sys/class/android_usb/android0/bDeviceClass

# Permission for UART SWITCH
    chmod 0660 /sys/class/sec/switch/uart_sel
    chown system system /sys/class/sec/switch/uart_sel

# VTS sysfs file permission
    chown audioserver system /sys/devices/platform/13810000.vts/vts_svoice_model
    chown audioserver system /sys/devices/platform/13810000.vts/vts_google_model
    chmod 0660 /sys/devices/platform/13810000.vts/vts_svoice_model
    chmod 0660 /sys/devices/platform/13810000.vts/vts_google_model

# WLAN firmware/driver path
    chown wifi wifi /sys/module/bcmdhd/parameters/nvram_path
    chown wifi wifi /sys/module/bcmdhd/parameters/firmware_path

on property:persist.vendor.radio.no_modem_board=1
    setprop ro.radio.noril yes

on fs
    mount_all --early
    restorecon_recursive /mnt/vendor/efs
    chown radio system /mnt/vendor/efs
    restorecon_recursive /mnt/vendor/efs_backup
    chown radio system /mnt/vendor/efs_backup
    restorecon_recursive /mnt/vendor/modem_userdata
    chown radio system /mnt/vendor/modem_userdata

    # for cycle count backup
    mkdir /mnt/vendor/persist/battery 0700 system system

    restorecon_recursive /mnt/vendor/persist
    restorecon_recursive /mnt/vendor/persist/aoc
    restorecon_recursive /mnt/vendor/persist/audio
    restorecon_recursive /mnt/vendor/persist/sensors
    restorecon_recursive /mnt/vendor/persist/battery
    restorecon_recursive /mnt/vendor/persist/modem
    # Set up display-related directories and permissions
    # Add restorecon_recursive command to make sure the restorecon label is persist_display_file.
    restorecon_recursive /mnt/vendor/persist/display
    mkdir /mnt/vendor/persist/data/sfs 0700 system system
    mkdir /mnt/vendor/persist/data/tz 0700 system system
    mkdir /mnt/vendor/persist/touch 0770 system system
    mkdir /mnt/vendor/persist/audio 0770 system system
    chown media audio /mnt/vendor/persist/audio

# Permissions for ION
    chmod 0660 /sys/class/ion_cma/ion_video_ext/isolated
    chown system system /sys/class/ion_cma/ion_video_ext/isolated

# Permissions for hwcomposer
    chown system system /sys/class/backlight/panel0-backlight/als_table
    chown system system /sys/class/backlight/panel0-backlight/brightness
    chown system system /sys/class/backlight/panel0-backlight/dimming_on
    chown system system /sys/class/backlight/panel0-backlight/hbm_mode
    chown system system /sys/class/backlight/panel0-backlight/local_hbm_mode
    chown system system /sys/devices/platform/exynos-drm/primary-panel/gamma
    chown system system /sys/devices/platform/exynos-drm/primary-panel/min_vrefresh
    chown system system /sys/devices/platform/exynos-drm/primary-panel/idle_delay_ms
    chown system system /sys/devices/platform/exynos-drm/primary-panel/panel_need_handle_idle_exit
    chown system system /sys/module/drm/parameters/vblankoffdelay
    chown system system /sys/class/dqe0/atc/ambient_light
    chown system system /sys/class/dqe0/atc/st
    chown system system /sys/class/dqe0/atc/en
    chown system system /sys/class/dqe0/atc/lt
    chown system system /sys/class/dqe0/atc/ns
    chown system system /sys/class/dqe0/atc/dither
    chown system system /sys/class/dqe0/atc/pl_w1
    chown system system /sys/class/dqe0/atc/pl_w2
    chown system system /sys/class/dqe0/atc/ctmode
    chown system system /sys/class/dqe0/atc/pp_en
    chown system system /sys/class/dqe0/atc/upgrade_on
    chown system system /sys/class/dqe0/atc/tdr_max
    chown system system /sys/class/dqe0/atc/tdr_min
    chown system system /sys/class/dqe0/atc/back_light
    chown system system /sys/class/dqe0/atc/dstep
    chown system system /sys/class/dqe0/atc/scale_mode
    chown system system /sys/class/dqe0/atc/threshold_1
    chown system system /sys/class/dqe0/atc/threshold_2
    chown system system /sys/class/dqe0/atc/threshold_3
    chown system system /sys/class/dqe0/atc/gain_limit
    chown system system /sys/class/dqe0/atc/lt_calc_ab_shift
    chown system system /sys/devices/platform/1c300000.drmdecon/early_wakeup
    chmod 0660 /sys/devices/platform/1c300000.drmdecon/early_wakeup
    chown system system /sys/devices/platform/1c302000.drmdecon/early_wakeup
    chmod 0660 /sys/devices/platform/1c302000.drmdecon/early_wakeup

# Copy DRM Key
#    copy /system/app/wv.keys /factory/wv.keys

# Permission for DRM Key
#    chmod 0644 /factory/wv.keys

# Permission for flashlight control for HAL3.3
# The Istor espresso board does not have the flash led h/w, So the below permission line are blocked.
# If you want to test the flashlight in board which have the flash led h/w, Enable the below blocked lines.
    chmod 0660 /sys/class/camera/flash/rear_torch_flash
    chown system camera /sys/class/camera/flash/rear_torch_flash
#load ecd firmware
    write /proc/ecd/load_firmware 1

service abox /vendor/bin/main_abox 17c50000.abox
    class late_start
    user audioserver
    group audioserver
    seclabel u:r:abox:s0

# on userdebug and eng builds, enable kgdb on the serial console
on property:ro.debuggable=1
    write /sys/module/kgdboc/parameters/kgdboc ttyFIQ1
    write /sys/module/fiq_debugger/parameters/kgdb_enable 1

# Touch
on property:vendor.device.modules.ready=1
    chown system system /sys/class/spi_master/spi11/spi11.0/stm_fts_cmd
    chown system system /sys/class/spi_master/spi11/spi11.0/glove_mode
    chown system system /sys/class/spi_master/spi6/spi6.0/stm_fts_cmd
    chown system system /sys/class/spi_master/spi6/spi6.0/glove_mode
    chown system system /sys/devices/virtual/sec/tsp/fw_version
    chown system system /sys/devices/virtual/sec/tsp/cmd
    chown system system /sys/devices/virtual/sec/tsp/cmd_result
    chown system system /sys/devices/virtual/sec/tsp/status
    chown system system /sys/class/spi_master/spi11/spi11.0/input/nvt_touch/force_touch_active
    chown system system /sys/class/spi_master/spi11/spi11.0/input/nvt_touch/nvt_dttw_mode
    # Allow access to touch
    chown system input /dev/touch_offload
    chmod 660 /dev/touch_offload

# Route touch_sensitivity_mode to persist
on property:debug.touch_sensitivity_mode=0
    setprop persist.vendor.touch_sensitivity_mode 0

on property:debug.touch_sensitivity_mode=1
    setprop persist.vendor.touch_sensitivity_mode 1

on property:init.svc.vendor.charger=running
    stop keymaster-4-0

    setprop sys.usb.configfs 1
    setprop vendor.setup.power 1

    # keep one little and one big
    write /sys/devices/system/cpu/cpu1/online 0
    write /sys/devices/system/cpu/cpu2/online 0
    write /sys/devices/system/cpu/cpu3/online 0
    write /sys/devices/system/cpu/cpu5/online 0
    write /sys/devices/system/cpu/cpu6/online 0
    write /sys/devices/system/cpu/cpu7/online 0

on property:sys.boot_completed=1

    # Runtime fs tuning
    write /sys/block/sda/queue/nr_requests 64
    write /sys/block/sda/queue/iostats 1
    write /dev/sys/fs/by-name/userdata/data_io_flag 8
    write /dev/sys/fs/by-name/userdata/node_io_flag 8

    # Permission for Pixelstats
    chown system system /dev/sys/fs/by-name/userdata/compr_written_block
    chown system system /dev/sys/fs/by-name/userdata/compr_saved_block
    chown system system /dev/sys/fs/by-name/userdata/compr_new_inode
    chown system system /dev/sys/fs/by-name/userdata/gc_segment_mode
    chown system system /dev/sys/fs/by-name/userdata/gc_reclaimed_segments

    # Enable ZRAM on boot_complete
    swapon_all /vendor/etc/fstab.${ro.board.platform}
    write /proc/sys/vm/swappiness 60

    # Force empty CMA
    write /sys/kernel/vendor_mm/cma/farawimg/force_empty 1

    # Back to default VM settings
    write /proc/sys/vm/dirty_expire_centisecs 3000
    write /proc/sys/vm/dirty_background_ratio 10

    # Enable UFS powersaving
    write /dev/sys/block/bootdevice/clkgate_enable 1

    # Reset DDR frequency
    write /sys/devices/platform/17000010.devfreq_mif/devfreq/17000010.devfreq_mif/exynos_data/cancel_boot_freq 1
    write /sys/devices/platform/17000020.devfreq_int/devfreq/17000020.devfreq_int/exynos_data/cancel_boot_freq 1

    # Setup final cpuset
    write /dev/cpuset/top-app/cpus ${persist.device_config.vendor_system_native.top-app_cpuset:-0-7}
    write /dev/cpuset/foreground/cpus ${persist.device_config.vendor_system_native.foreground_cpuset:-0-3,4-5}
    write /dev/cpuset/background/cpus ${persist.device_config.vendor_system_native.background_cpuset:-0-3}
    write /dev/cpuset/system-background/cpus ${persist.device_config.vendor_system_native.system-background_cpuset:-0-3}
    write /dev/cpuset/restricted/cpus ${persist.device_config.vendor_system_native.restricted_cpuset:-0-3}
    write /dev/cpuset/camera-daemon/cpus ${persist.device_config.vendor_system_native.camera-daemon_cpuset:-0-7}
    setprop vendor.powerhal.init 1

    # Setup final cpu.uclamp
    write /proc/vendor_sched/ta_uclamp_min 1
    write /proc/vendor_sched/fg_uclamp_min 0
    write /proc/vendor_sched/sys_prefer_idle 0

    # Set ug group
    write /proc/vendor_sched/bg_ug 0
    write /proc/vendor_sched/sysbg_ug 0
    write /proc/vendor_sched/ota_ug 0
    write /proc/vendor_sched/dex2oat_ug 1
    write /proc/vendor_sched/ta_ug 1

    # Set bg group throttle
    write /proc/vendor_sched/ug_bg_group_throttle ${persist.device_config.vendor_system_native.ug_bg_group_throttle:-308}

    # Set uclamp.max for some groups, which could indicate cpu importance used in scheduling
    write /proc/vendor_sched/bg_uclamp_max 512
    write /proc/vendor_sched/sysbg_uclamp_max 512
    write /proc/vendor_sched/ota_uclamp_max 512
    write /proc/vendor_sched/dex2oat_uclamp_max 615

    # Set PMU freq limit parameters
    write /sys/devices/system/cpu/cpufreq/policy0/sched_pixel/lcpi_threshold 2
    write /sys/devices/system/cpu/cpufreq/policy0/sched_pixel/spc_threshold 59
    write /sys/devices/system/cpu/cpufreq/policy0/sched_pixel/limit_frequency 1401000
    write /sys/devices/system/cpu/cpufreq/policy4/sched_pixel/lcpi_threshold 6
    write /sys/devices/system/cpu/cpufreq/policy4/sched_pixel/spc_threshold 64
    write /sys/devices/system/cpu/cpufreq/policy4/sched_pixel/limit_frequency 1826000
    write /sys/devices/system/cpu/cpufreq/policy6/sched_pixel/lcpi_threshold 5
    write /sys/devices/system/cpu/cpufreq/policy6/sched_pixel/spc_threshold 69
    write /sys/devices/system/cpu/cpufreq/policy6/sched_pixel/limit_frequency 2507000
    write /proc/vendor_sched/pmu_poll_time 10

    # Disable PMU freq limit
    write /sys/devices/system/cpu/cpufreq/policy0/sched_pixel/pmu_limit_enable 1
    write /sys/devices/system/cpu/cpufreq/policy4/sched_pixel/pmu_limit_enable 1
    write /sys/devices/system/cpu/cpufreq/policy6/sched_pixel/pmu_limit_enable 1
    write /proc/vendor_sched/pmu_poll_enable 0

    # Setup cpu.shares to throttle background groups (bg ~ 5% sysbg ~ 5% dex2oat ~2.5%)
    write /dev/cpuctl/background/cpu.shares 1024
    write /dev/cpuctl/system-background/cpu.shares 1024
    write /dev/cpuctl/dex2oat/cpu.shares 512
    write /dev/cpuctl/system/cpu.shares 20480
    # We only have system and background groups holding tasks and the groups below are empty
    write /dev/cpuctl/camera-daemon/cpu.shares 20480
    write /dev/cpuctl/foreground/cpu.shares 20480
    write /dev/cpuctl/nnapi-hal/cpu.shares 20480
    write /dev/cpuctl/rt/cpu.shares 20480
    write /dev/cpuctl/top-app/cpu.shares 20480

    # gvotables for dumpstate
    chown system system /sys/kernel/debug/gvotables

    # AOC reset permission
    chown root system /sys/devices/platform/19000000.aoc/reset
    chmod 0220 /sys/devices/platform/19000000.aoc/reset

    # write serialno to battery path for pairing
    write /sys/class/power_supply/battery/dev_sn ${ro.boot.serialno}

# Test Harness Mode default battery profile.
on  property:persist.sys.test_harness=1 && property:persist.vendor.testing_battery_profile=0
    setprop persist.vendor.charge.stop.level 70
    setprop persist.vendor.charge.start.level 35
    setprop vendor.battery.defender.disable 1

# Extremely restricted battery profile.
on  property:persist.sys.test_harness=1 && property:persist.vendor.testing_battery_profile=1
    setprop persist.vendor.charge.stop.level 50
    setprop persist.vendor.charge.start.level 35
    setprop vendor.battery.defender.disable 1

# Normal behavior (as if the device was a regular device)
on  property:persist.sys.test_harness=1 && property:persist.vendor.testing_battery_profile=2
    setprop persist.vendor.charge.stop.level 100
    setprop persist.vendor.charge.start.level 0

# Unrestricted, allows charging to 100%
on  property:persist.sys.test_harness=1 && property:persist.vendor.testing_battery_profile=3
    setprop persist.vendor.charge.stop.level 100
    setprop persist.vendor.charge.start.level 0
    setprop vendor.battery.defender.disable 1

# ACA (Adaptice Charge Always On) persist properties
on property:persist.vendor.adaptive.charge.soc=*
    write /sys/class/power_supply/battery/charge_limit ${persist.vendor.adaptive.charge.soc}

service init_display /vendor/bin/init.display.sh
    class main
    user root
    group root system
    disabled
    oneshot

# bugreport is triggered by holding down volume down, volume up and power
service bugreport /system/bin/dumpstate -d -p -z
    class main
    disabled
    oneshot
    keycodes 114 115 116

# Proxy for Secure Storage
on post-fs-data
    mkdir /data/vendor/rebootescrow 0770 hsm hsm
    start vendor.rebootescrow-citadel
    mkdir /data/vendor/ss 0770 root system
    mkdir /mnt/vendor/persist/ss 0770 root system
    restorecon_recursive /mnt/vendor/persist/ss
    symlink /mnt/vendor/persist/ss /data/vendor/ss/persist
    chown root system /data/vendor/ss/persist
    chmod 0770 /data/vendor/ss/persist
    chown system system /data/vendor/ss/persist/nsp

    restart storageproxyd

service storageproxyd /vendor/bin/storageproxyd -d /dev/trusty-ipc-dev0 \
        -r /dev/sg1 -p /data/vendor/ss -t ufs
    class early_hal
    user system
    group system

# Write build info to kdebuginfo
on property:ro.build.fingerprint=*
    write /sys/module/debug_kinfo/parameters/build_info ${ro.build.fingerprint}

# Bluetooth
on post-fs-data
    chown bluetooth system /sys/devices/platform/175b0000.serial/serial0/serial0-0/bluetooth/hci0/rfkill0/state
    chown bluetooth system /sys/devices/platform/odm/odm:btbcm/rfkill/rfkill0/state
    chown bluetooth system /sys/devices/platform/odm/odm:btbcm/rfkill/rfkill2/state
    chown bluetooth system /proc/bluetooth/sleep/btwake
    chown bluetooth system /proc/bluetooth/sleep/lpm
    chown bluetooth system /proc/bluetooth/sleep/btwrite
    mkdir /data/vendor/bluetooth 0770 bluetooth system

# ODPM
on fs
    chown system system /sys/devices/platform/acpm_mfd_bus@17500000/i2c-0/i2c-s2mpg10mfd/s2mpg10-meter/s2mpg10-odpm/iio:device1/enabled_rails
    chown system system /sys/devices/platform/acpm_mfd_bus@17500000/i2c-0/0-001f/s2mpg10-meter/s2mpg10-odpm/iio:device1/enabled_rails
    chown system system /sys/devices/platform/acpm_mfd_bus@17510000/i2c-1/i2c-s2mpg11mfd/s2mpg11-meter/s2mpg11-odpm/iio:device0/enabled_rails
    chown system system /sys/devices/platform/acpm_mfd_bus@17510000/i2c-1/1-002f/s2mpg11-meter/s2mpg11-odpm/iio:device0/enabled_rails

    chown system system /sys/devices/platform/acpm_mfd_bus@17500000/i2c-6/i2c-s2mpg10mfd/s2mpg10-meter/s2mpg10-odpm/iio:device0/enabled_rails
    chown system system /sys/devices/platform/acpm_mfd_bus@17500000/i2c-6/6-001f/s2mpg10-meter/s2mpg10-odpm/iio:device0/enabled_rails
    chown system system /sys/devices/platform/acpm_mfd_bus@17510000/i2c-7/i2c-s2mpg11mfd/s2mpg11-meter/s2mpg11-odpm/iio:device1/enabled_rails
    chown system system /sys/devices/platform/acpm_mfd_bus@17510000/i2c-7/7-002f/s2mpg11-meter/s2mpg11-odpm/iio:device1/enabled_rails

    chown system system /sys/devices/platform/acpm_mfd_bus@17500000/i2c-7/i2c-s2mpg10mfd/s2mpg10-meter/s2mpg10-odpm/iio:device0/enabled_rails
    chown system system /sys/devices/platform/acpm_mfd_bus@17500000/i2c-7/7-001f/s2mpg10-meter/s2mpg10-odpm/iio:device0/enabled_rails
    chown system system /sys/devices/platform/acpm_mfd_bus@17510000/i2c-8/i2c-s2mpg11mfd/s2mpg11-meter/s2mpg11-odpm/iio:device1/enabled_rails
    chown system system /sys/devices/platform/acpm_mfd_bus@17510000/i2c-8/8-002f/s2mpg11-meter/s2mpg11-odpm/iio:device1/enabled_rails

on post-fs-data
    mkdir /data/vendor/powerstats 0771 system system
    chown system system /data/vendor/powerstats
    # Thermal Residency Stats (write 1 to reset)
    chown system system /sys/kernel/metrics/thermal/tr_by_group/tmu/stats_reset
    chown system system /sys/kernel/metrics/thermal/tr_by_group/spmic/stats_reset

on property:vendor.thermal.link_ready=1
    # BCL
    write /sys/devices/virtual/pmic/mitigation/clock_ratio/tpu_light_clk_ratio 0xfff041c5
    write /sys/devices/virtual/pmic/mitigation/clock_ratio/cpu2_light_clk_ratio 0xfff041c5
    write /sys/devices/virtual/pmic/mitigation/clock_ratio/gpu_heavy_clk_ratio 0xfff04385
    write /sys/devices/virtual/pmic/mitigation/clock_ratio/tpu_heavy_clk_ratio 0xfff041c3
    write /sys/devices/virtual/pmic/mitigation/clock_ratio/cpu2_heavy_clk_ratio 0xfff041c3
    write /dev/thermal/tz-by-name/smpl_gm/policy user_space
    write /dev/thermal/tz-by-name/vdroop1/policy user_space
    write /dev/thermal/tz-by-name/vdroop2/policy user_space
    write /dev/thermal/tz-by-name/ocp_cpu1/policy user_space
    write /dev/thermal/tz-by-name/ocp_cpu2/policy user_space
    write /dev/thermal/tz-by-name/ocp_tpu/policy user_space
    write /dev/thermal/tz-by-name/ocp_gpu/policy user_space
    write /dev/thermal/tz-by-name/soft_ocp_cpu1/policy user_space
    write /dev/thermal/tz-by-name/soft_ocp_cpu2/policy user_space
    write /dev/thermal/tz-by-name/soft_ocp_tpu/policy user_space
    write /dev/thermal/tz-by-name/soft_ocp_gpu/policy user_space
    write /dev/thermal/tz-by-name/soc/policy user_space
    write /dev/thermal/tz-by-name/batoilo/policy user_space
    write /sys/devices/virtual/pmic/mitigation/triggered_lvl/smpl_lvl 3100
    write /sys/devices/virtual/pmic/mitigation/clock_div/tpu_clk_div 0x1
    write /sys/devices/virtual/pmic/mitigation/clock_div/gpu_clk_div 0x1
    write /sys/devices/virtual/pmic/mitigation/clock_div/cpu2_clk_div 0x1
    chown system system /dev/thermal/tz-by-name/soc/mode
    chown system system /dev/thermal/tz-by-name/batoilo/trip_point_0_temp
    chown system system /dev/thermal/tz-by-name/batoilo/trip_point_0_hyst
    chown system system /dev/thermal/tz-by-name/vdroop2/trip_point_0_temp
    chown system system /dev/thermal/tz-by-name/vdroop2/trip_point_0_hyst
    chown system system /dev/thermal/tz-by-name/vdroop1/trip_point_0_temp
    chown system system /dev/thermal/tz-by-name/vdroop1/trip_point_0_hyst
    chown system system /dev/thermal/tz-by-name/smpl_gm/trip_point_0_temp
    chown system system /dev/thermal/tz-by-name/smpl_gm/trip_point_0_hyst
    chown system system /dev/thermal/tz-by-name/ocp_cpu1/trip_point_0_temp
    chown system system /dev/thermal/tz-by-name/ocp_cpu1/trip_point_0_hyst
    chown system system /dev/thermal/tz-by-name/ocp_cpu2/trip_point_0_temp
    chown system system /dev/thermal/tz-by-name/ocp_cpu2/trip_point_0_hyst
    chown system system /dev/thermal/tz-by-name/ocp_tpu/trip_point_0_temp
    chown system system /dev/thermal/tz-by-name/ocp_tpu/trip_point_0_hyst
    chown system system /dev/thermal/tz-by-name/ocp_gpu/trip_point_0_temp
    chown system system /dev/thermal/tz-by-name/ocp_gpu/trip_point_0_hyst
    chown system system /dev/thermal/tz-by-name/soft_ocp_cpu1/trip_point_0_temp
    chown system system /dev/thermal/tz-by-name/soft_ocp_cpu1/trip_point_0_hyst
    chown system system /dev/thermal/tz-by-name/soft_ocp_cpu2/trip_point_0_temp
    chown system system /dev/thermal/tz-by-name/soft_ocp_cpu2/trip_point_0_hyst
    chown system system /dev/thermal/tz-by-name/soft_ocp_tpu/trip_point_0_temp
    chown system system /dev/thermal/tz-by-name/soft_ocp_tpu/trip_point_0_hyst
    chown system system /dev/thermal/tz-by-name/soft_ocp_gpu/trip_point_0_temp
    chown system system /dev/thermal/tz-by-name/soft_ocp_gpu/trip_point_0_hyst
    chown system system /dev/thermal/tz-by-name/soc/trip_point_0_temp
    chown system system /dev/thermal/tz-by-name/soc/trip_point_0_hyst
    # Thermal
    chown system system /dev/thermal/tz-by-name/quiet_therm/trip_point_0_temp
    chown system system /dev/thermal/tz-by-name/quiet_therm/trip_point_0_hyst
    chown system system /dev/thermal/tz-by-name/neutral_therm/trip_point_0_temp
    chown system system /dev/thermal/tz-by-name/neutral_therm/trip_point_0_hyst
    chown system system /dev/thermal/tz-by-name/usb_pwr_therm2/trip_point_0_temp
    chown system system /dev/thermal/tz-by-name/usb_pwr_therm2/trip_point_0_hyst
    chown system system /dev/thermal/tz-by-name/usb_pwr_therm2/emul_temp
    chmod 664 /dev/thermal/cdev-by-name/thermal-cpufreq-0/user_vote
    chown system system /dev/thermal/cdev-by-name/thermal-cpufreq-0/user_vote
    chmod 664 /dev/thermal/cdev-by-name/thermal-cpufreq-1/user_vote
    chown system system /dev/thermal/cdev-by-name/thermal-cpufreq-1/user_vote
    chmod 664 /dev/thermal/cdev-by-name/thermal-cpufreq-2/user_vote
    chown system system /dev/thermal/cdev-by-name/thermal-cpufreq-2/user_vote
    chmod 664 /dev/thermal/cdev-by-name/thermal-gpufreq-0/user_vote
    chown system system /dev/thermal/cdev-by-name/thermal-gpufreq-0/user_vote
    chmod 664 /dev/thermal/cdev-by-name/tpu_cooling/user_vote
    chown system system /dev/thermal/cdev-by-name/tpu_cooling/user_vote
    chmod 664 /dev/thermal/cdev-by-name/fcc/cur_state
    chown system system /dev/thermal/cdev-by-name/fcc/cur_state
    chmod 664 /dev/thermal/cdev-by-name/dc_icl/cur_state
    chown system system /dev/thermal/cdev-by-name/dc_icl/cur_state
    chmod 664 /dev/thermal/cdev-by-name/wlc_fcc/cur_state
    chown system system /dev/thermal/cdev-by-name/wlc_fcc/cur_state
    chmod 664 /dev/thermal/cdev-by-name/usbc-port/cur_state
    chown system system /dev/thermal/cdev-by-name/usbc-port/cur_state

on charger
    write /proc/vendor_sched/sys_uclamp_min 0
    write /proc/vendor_sched/sys_prefer_idle 0

    # Use charger thermal config
    setprop vendor.thermal.config "thermal_info_config_charge.json"

    # Wait for insmod_sh to finish all common modules
    wait_for_prop vendor.common.modules.ready 1

    # Create thermal symlink in off charging mode
    mkdir /dev/thermal 0750 system system
    mkdir /dev/thermal/tz-by-name 0750 system system
    mkdir /dev/thermal/cdev-by-name 0750 system system
    start vendor.thermal.symlinks

    # Runtime fs tuning
    write /sys/block/sda/queue/nr_requests 64
    write /sys/block/sda/queue/iostats 1
    write /sys/block/sda/queue/iosched/slice_idle 0
    write /dev/sys/fs/by-name/userdata/data_io_flag 8
    write /dev/sys/fs/by-name/userdata/node_io_flag 8

    # Enable UFS powersaving
    write /dev/sys/block/bootdevice/clkgate_enable 1

    # Cancel boot devfreq and uclamp
    write /sys/devices/platform/17000010.devfreq_mif/devfreq/17000010.devfreq_mif/exynos_data/cancel_boot_freq 1
    write /sys/devices/platform/17000020.devfreq_int/devfreq/17000020.devfreq_int/exynos_data/cancel_boot_freq 1
    write /proc/vendor_sched/ta_uclamp_min 0
    write /proc/vendor_sched/ta_prefer_idle 0
    write /proc/vendor_sched/fg_uclamp_min 0
    write /proc/vendor_sched/fg_prefer_idle 0
    write /proc/vendor_sched/sys_uclamp_min 0
    write /proc/vendor_sched/sys_prefer_idle 0

    # Enable SICD
    write /sys/devices/system/cpu/cpupm/cpupm/sicd 1

on property:vendor.disable.bcl.control=1
    write /sys/devices/virtual/pmic/mitigation/instruction/enable_mitigation 0

on property:vendor.disable.bcl.control=0
    write /sys/devices/virtual/pmic/mitigation/instruction/enable_mitigation 1

# UFS
on property:ro.boot.mode=charger && property:init.svc.vendor.charger=running
    # Enable UFS powersaving in Off Mode Charger
    write /dev/sys/block/bootdevice/clkgate_enable 1
    # Disable dock-defend in Off Mode Charger
    write /sys/devices/platform/google,charger/dd_state -1

# Cpuset experiment
on property:persist.device_config.vendor_system_native.top-app_cpuset=*
    write /dev/cpuset/top-app/cpus ${persist.device_config.vendor_system_native.top-app_cpuset:-0-7}
on property:persist.device_config.vendor_system_native.foreground_cpuset=*
    write /dev/cpuset/foreground/cpus ${persist.device_config.vendor_system_native.foreground_cpuset:-0-3,4-5}
on property:persist.device_config.vendor_system_native.background_cpuset=*
    write /dev/cpuset/background/cpus ${persist.device_config.vendor_system_native.background_cpuset:-0-3}
on property:persist.device_config.vendor_system_native.system-background_cpuset=*
    write /dev/cpuset/system-background/cpus ${persist.device_config.vendor_system_native.system-background_cpuset:-0-3}
on property:persist.device_config.vendor_system_native.restricted_cpuset=*
    write /dev/cpuset/restricted/cpus ${persist.device_config.vendor_system_native.restricted_cpuset:-0-3}
on property:persist.device_config.vendor_system_native.camera-daemon_cpuset=*
    write /dev/cpuset/camera-daemon/cpus ${persist.device_config.vendor_system_native.camera-daemon_cpuset:-0-7}

# Set esim property for LPA
on property:persist.vendor.modem.esim_profiles_exist=*
    setprop persist.modem.esim_profiles_exist ${persist.vendor.modem.esim_profiles_exist}