-
Notifications
You must be signed in to change notification settings - Fork 0
/
lazy
865 lines (790 loc) · 28.1 KB
/
lazy
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
#!/system/bin/sh
#=======================================#
#VARIABLES===============================#
LOG=/sdcard/Android/lazy.log
LPM="/sys/module/lpm_levels/parameters"
LMK="/sys/module/lowmemorykiller/parameters"
ST_TOP="/dev/stune/top-app"
ST_FORE="/dev/stune/foreground"
ST_BACK="/dev/stune/background"
ST_RT="/dev/stune/rt"
ST_GLOBAL="/dev/stune/"
CSET="/dev/cpuset"
VM="/proc/sys/vm"
FS="/proc/sys/fs"
KERNEL="/proc/sys/kernel"
DBG="/sys/kernel/debug"
#=======================================#
#=======================================#
#spectrum
setprop persist.spectrum.kernel "Lazy"
setprop spectrum.support 1
###############################
rm $LOG
# Log in white and continue (unnecessary)
kmsg() {
echo -e "[-] $@" >> $LOG
echo -e "[-] $@"
}
ctl() {
# Bail out if file does not exist
[[ ! -f "$1" ]] && return 1
# Fetch the current key value
local curval=`cat "$1" 2> /dev/null`
# Bail out if value is already set
[[ "$curval" == "$2" ]] && return 1
# Make file writable in case it is not already
chmod +w "$1" 2> /dev/null
# Write the new value and bail if there's an error
if ! echo "$2" > "$1" 2> /dev/null
then
kmsg "Failed: $1 -> $2"
return 1
fi
# Log the success
kmsg "$1 $curval -> $2"
}
vibrate_cmode() {
if [ -e /sys/class/leds/vibrator/duration ] && [ -e /sys/class/leds/vibrator/activate ];then
echo 400 > /sys/class/leds/vibrator/duration && echo 1 > /sys/class/leds/vibrator/activate
fi
}
# Check for root permissions and bail if not granted
if [[ "$(id -u)" -ne 0 ]]
then
kmsg "No root permissions. Exiting."
exit 1
fi
kmsg "=======================================================================
LAZY VERSION: IGRIS
============================================================================="
# Log the date and time for records sake
kmsg "BRANCH: STABLE"
kmsg "TIME OF EXECUTION: $(date)"
kmsg "KERNEL: `uname -a` "
kmsg "=======================================================================
STARTING KERNEL TWEAKS
============================================================================="
# Sync to data in the rare case a device crashes
sync
# Kernel
if [ -d $KERNEL ]; then
ctl $KERNEL/perf_cpu_time_max_percent 5
ctl $KERNEL/printk_devkmsg off
ctl $KERNEL/printk_ratelimit 900
ctl $KERNEL/printk_ratelimit_burst 5
ctl $KERNEL/sched_tunable_scaling 0
ctl $KERNEL/sched_schedstats 0
ctl $KERNEL/sched_min_task_util_for_boost_colocation 0
ctl $KERNEL/sched_nr_migrate 2
ctl $KERNEL/sched_rr_timeslice_ms 9
fi
kmsg "=======================================================================
KERNEL OPTIMIZATIONS APPLIED
============================================================================="
if [ -d $CSET ]; then
# Balanced CPUSET for efficiency
ctl $CSET/foreground/cpus "0-7"
ctl $CSET/background/cpus "0-3"
ctl $CSET/system-background/cpus "0-3"
ctl $CSET/restricted/cpus "0-3"
kmsg "=======================================================================
CPUSET OPTIMIZED
============================================================================="
fi
RAM=$(free -m | awk '/Mem:/{print $2}')
# VM
ctl $VM/dirtytime_expire_seconds 44000
ctl $VM/oom_kill_allocating_task 0
ctl $VM/block_dump 0
ctl $VM/panic_on_oom 0
ctl $VM/overcommit_memory 1
ctl $VM/reap_mem_on_sigkill 1
ctl $VM/oom_dump_tasks 0
ctl $VM/extfrag_threshold 750
ctl $VM/swappiness 60
ctl $VM/stat_interval 750
ctl $FS/lease-break-time 10
ctl $FS/dir-notify-enable 0
ctl $FS/leases-enable 1
ctl $VM/compact_memory 1
ctl $VM/page-cluster 0
ctl $VM/drop_caches 3
ctl $VM/laptop_mode 5
# If you set this to lower than 1024KB, your system will
# become subtly broken, and prone to deadlock under high loads, we don't allow it below 3072kb
mfk=$((RAM * 19 / 5))
if [ "$mfk" -le "3072" ]; then
mfk=3072
fi
# Extra free kbytes calculated based on min_free_kbytes
efk=$((mfk * 11 / 5))
if [ "$efk" -le 18432 ]; then
efk=18432
fi
# Background app limit per ram size
if [ "$RAM" -le "1024" ]; then
backgroundAppLimit="25"
elif [ "$RAM" -le "2048" ]; then
backgroundAppLimit="30"
elif [ "$RAM" -le "3072" ]; then
backgroundAppLimit="36"
elif [ "$RAM" -le "4096" ]; then
backgroundAppLimit="42"
else
backgroundAppLimit="44"
fi
resetprop ro.sys.fw.bg_apps_limit $backgroundAppLimit
resetprop ro.vendor.qti.sys.fw.bg_apps_limit $backgroundAppLimit
setprop ro.sys.fw.bg_apps_limit $backgroundAppLimit
setprop ro.vendor.qti.sys.fw.bg_apps_limit $backgroundAppLimit
parameter_adj=$LMK/adj
if [ -e $parameter_adj ]; then
ctl $parameter_adj "0,112,224,408,824,1000"
fi
parameter_oom_reaper=$LMK/oom_reaper
if [ -e $parameter_oom_reaper ]; then
ctl $parameter_oom_reaper 1
fi
parameter_lmk_fast_run=$LMK/lmk_fast_run
if [ -e $parameter_lmk_fast_run ]; then
ctl $parameter_lmk_fast_run 0
fi
parameter_adaptive_lmk=$LMK/enable_adaptive_lmk
if [ -e $parameter_adaptive_lmk ]; then
ctl $parameter_adaptive_lmk 0
setprop lmk.autocalc false
fi
parameter_min_free_kbytes=$VM/min_free_kbytes
if [ -e $parameter_min_free_kbytes ]; then
ctl $parameter_min_free_kbytes "$mfk"
fi
parameter_extra_free_kbytes=$VM/extra_free_kbytes
if [ -e $parameter_extra_free_kbytes ]; then
ctl $parameter_extra_free_kbytes "$efk"
fi
kmsg "=======================================================================
MEMORY OPTIMIZATIONS APPLIED
============================================================================="
# Tweak and decrease tx_queue_len default stock value(s) for less amount of generated bufferbloat and for gaining slightly faster network speed and performance;
for i in $(find /sys/class/net -type l); do
ctl $i/tx_queue_len 128
done;
kmsg "=======================================================================
REDUCING BUFFERBLOAT
============================================================================="
for queue in /sys/block/*/queue/
do
# Choose the first governor available
avail_scheds=`cat "${queue}scheduler"`
for sched in anxiety cfq noop none mq-deadline kyber bfq
do
if [[ "$avail_scheds" == *"$sched"* ]]
then
ctl "${queue}scheduler" "$sched"
break
fi
done
ctl "${queue}iostats" 0
ctl "${queue}add_random" 0
ctl "${queue}nr_requests" 64
done
for queue in /sys/block/mmc*/queue/
do
ctl "${queue}rq_affinity" 2
ctl "${queue}rotational" 0
ctl "${queue}nomerges" 1
ctl "${queue}read_ahead_kb" 64
done
for queue in /sys/block/dm*/queue/
do
ctl "${queue}rq_affinity" 2
ctl "${queue}rotational" 0
ctl "${queue}nomerges" 1
ctl "${queue}read_ahead_kb" 64
done
for queue in /sys/block/sd*/queue/
do
ctl "${queue}rq_affinity" 2
ctl "${queue}rotational" 0
ctl "${queue}nomerges" 1
ctl "${queue}read_ahead_kb" 64
done
for queue in /sys/block/ram*/queue/
do
ctl "${queue}rq_affinity" 0
ctl "${queue}rotational" 1
ctl "${queue}nomerges" 0
ctl "${queue}read_ahead_kb" 0
done
for queue in /sys/block/zram*/queue/
do
ctl "${queue}rq_affinity" 0
ctl "${queue}rotational" 0
ctl "${queue}nomerges" 0
ctl "${queue}read_ahead_kb" 0
done
for i in 0 1 2 3 4 5 6 7 8
do
ctl /sys/block/loop$i/queue/rq_affinity 2
ctl /sys/block/loop$i/queue/rotational 1
ctl /sys/block/loop$i/queue/nomerges 1
ctl /sys/block/loop$i/queue/read_ahead_kb 64
done
for i in 9 10 11 12 13 14 15
do
ctl /sys/block/loop$i/queue/rq_affinity 2
ctl /sys/block/loop$i/queue/rotational 1
ctl /sys/block/loop$i/queue/nomerges 3
ctl /sys/block/loop$i/queue/read_ahead_kb 0
done
for i in /sys/block/*/queue/iosched
do
ctl "$i/back_seek_max" 12582912
ctl "$i/back_seek_penalty" 1
ctl "$i/fifo_expire_async" 335
ctl "$i/fifo_expire_sync" 85
ctl "$i/group_idle" 0
ctl "$i/low_latency" 1
ctl "$i/slice_idle" 0
ctl "$i/slice_sync" 250
ctl "$i/slice_async" 93
ctl "$i/slice_async_rq" 1
ctl "$i/quantum" 16
done
kmsg "=======================================================================
I/O OPTIMIZATIONS APPLIED
============================================================================="
# SCHEDTUNE SETTINGS
#FOREGROUND
ctl $ST_FORE/schedtune.prefer_idle 1
#GLOBAL
ctl $ST_GLOBAL/schedtune.prefer_idle 1
# Reserve 90% IO bandwith for foreground tasks
ctl /dev/blkio/blkio.weight 1000
ctl /dev/blkio/blkio.leaf_weight 1000
ctl /dev/blkio/background/blkio.weight 100
ctl /dev/blkio/background/blkio.leaf_weight 100
ctl $LPM/lpm_prediction Y
ctl $LPM/sleep_disabled N
ctl $LPM/bias_hyst 25
kmsg "=======================================================================
SCHEDTUNE OPTIMIZED
============================================================================="
if [ -e "/sys/module/adreno_idler" ]; then
kmsg "=======================================================================
GPU TWEAKS APPLIED
============================================================================="
ctl /sys/module/adreno_idler/parameters/adreno_idler_active "N"
ctl /sys/module/adreno_idler/parameters/adreno_idler_idleworkload "1000"
ctl /sys/module/adreno_idler/parameters/adreno_idler_downdifferential '15'
ctl /sys/module/adreno_idler/parameters/adreno_idler_idlewait '15'
ctl /sys/class/kgsl/kgsl-3d0/snapshot/snapshot_crashdumper 0
fi
kmsg "=======================================================================
DISABLING MISC LOGGING
============================================================================="
#ctl "/sys/module/wakelock/parameters/debug_mask" 0
#ctl "/sys/module/userwakelock/parameters/debug_mask" 0
ctl "/sys/module/earlysuspend/parameters/debug_mask" 0
ctl "/sys/module/alarm/parameters/debug_mask" 0
ctl "/sys/module/alarm_dev/parameters/debug_mask" 0
ctl "/sys/module/binder/parameters/debug_mask" 0
ctl "/sys/devices/system/edac/cpu/log_ce" 0
ctl "/sys/devices/system/edac/cpu/log_ue" 0
ctl "/sys/module/binder/parameters/debug_mask" 0
ctl "/sys/module/bluetooth/parameters/disable_ertm" "Y"
ctl "/sys/module/bluetooth/parameters/disable_esco" "Y"
ctl "/sys/module/debug/parameters/enable_event_log" 0
ctl "/sys/module/dwc3/parameters/ep_addr_rxdbg_mask" 0
ctl "/sys/module/dwc3/parameters/ep_addr_txdbg_mask" 0
ctl "/sys/module/edac_core/parameters/edac_mc_log_ce" 0
ctl "/sys/module/edac_core/parameters/edac_mc_log_ue" 0
ctl "/sys/module/glink/parameters/debug_mask" 0
ctl "/sys/module/hid_apple/parameters/fnmode" 0
ctl "/sys/module/hid_magicmouse/parameters/emulate_3button" "N"
ctl "/sys/module/hid_magicmouse/parameters/emulate_scroll_wheel" "N"
ctl "/sys/module/ip6_tunnel/parameters/log_ecn_error" "N"
ctl "/sys/module/lowmemorykiller/parameters/debug_level" 0
ctl "/sys/module/mdss_fb/parameters/backlight_dimmer" "N"
ctl "/sys/module/msm_show_resume_irq/parameters/debug_mask" 0
ctl "/sys/module/msm_smd/parameters/debug_mask" 0
ctl "/sys/module/msm_smem/parameters/debug_mask" 0
ctl "/sys/module/otg_wakelock/parameters/enabled" "N"
ctl "/sys/module/service_locator/parameters/enable" 0
ctl "/sys/module/sit/parameters/log_ecn_error" "N"
ctl "/sys/module/smem_log/parameters/log_enable" 0
ctl "/sys/module/smp2p/parameters/debug_mask" 0
ctl "/sys/module/touch_core_base/parameters/debug_mask" 0
ctl "/sys/module/usb_bam/parameters/enable_event_log" 0
ctl "/sys/module/printk/parameters/console_suspend" "Y"
ctl "/proc/sys/debug/exception-trace" 0
ctl "/proc/sys/kernel/printk" "0 0 0 0"
ctl "/proc/sys/kernel/compat-log" "0"
sysctl -e -w kernel.panic_on_oops=0
sysctl -e -w kernel.panic=0
if [ -e /sys/module/logger/parameters/log_mode ]; then
ctl /sys/module/logger/parameters/log_mode 2
fi;
if [ -e /sys/module/printk/parameters/console_suspend ]; then
ctl /sys/module/printk/parameters/console_suspend 'Y'
fi;
for i in $(find /sys/ -name debug_mask); do
ctl $i 0;
done
for i in $(find /sys/ -name debug_level); do
ctl $i 0;
done
for i in $(find /sys/ -name edac_mc_log_ce); do
ctl $i 0;
done
for i in $(find /sys/ -name edac_mc_log_ue); do
ctl $i 0;
done
for i in $(find /sys/ -name enable_event_log); do
ctl $i 0;
done
for i in $(find /sys/ -name log_ecn_error); do
ctl $i 0;
done
for i in $(find /sys/ -name snapshot_crashdumper); do
ctl $i 0;
done
# =========
# FIX DEEPSLEEP
# =========
for i in $(ls /sys/class/scsi_disk/); do
lock_val 'temporary none' '/sys/class/scsi_disk/$i/cache_type';
done;
# =========
# Blocking Wakelocks
# =========
WK=0
if [ -e "/sys/module/bcmdhd/parameters/wlrx_divide" ]; then
ctl /sys/module/bcmdhd/parameters/wlrx_divide "8"
WK=$(( ${WK} + 1 ))
fi
if [ -e "/sys/module/bcmdhd/parameters/wlctrl_divide" ]; then
ctl /sys/module/bcmdhd/parameters/wlctrl_divide "8"
WK=$(( ${WK} + 1 ))
fi
if [ -e "/sys/module/wakeup/parameters/enable_bluetooth_timer" ]; then
ctl /sys/module/wakeup/parameters/enable_bluetooth_timer "Y"
WK=$(( ${WK} + 1 ))
fi
if [ -e "/sys/module/wakeup/parameters/enable_wlan_ipa_ws" ]; then
ctl /sys/module/wakeup/parameters/enable_wlan_ipa_ws "N"
WK=$(( ${WK} + 1 ))
fi
if [ -e "/sys/module/wakeup/parameters/enable_wlan_pno_wl_ws" ]; then
ctl /sys/module/wakeup/parameters/enable_wlan_pno_wl_ws "N"
WK=$(( ${WK} + 1 ))
fi
if [ -e "/sys/module/wakeup/parameters/enable_wcnss_filter_lock_ws" ]; then
ctl /sys/module/wakeup/parameters/enable_wcnss_filter_lock_ws "N"
WK=$(( ${WK} + 1 ))
fi
if [ -e "/sys/module/wakeup/parameters/wlan_wake" ]; then
ctl /sys/module/wakeup/parameters/wlan_wake "N"
WK=$(( ${WK} + 1 ))
fi
if [ -e "/sys/module/wakeup/parameters/wlan_ctrl_wake" ]; then
ctl /sys/module/wakeup/parameters/wlan_ctrl_wake "N"
WK=$(( ${WK} + 1 ))
fi
if [ -e "/sys/module/wakeup/parameters/wlan_rx_wake" ]; then
ctl /sys/module/wakeup/parameters/wlan_rx_wake "N"
WK=$(( ${WK} + 1 ))
fi
if [ -e "/sys/module/wakeup/parameters/enable_msm_hsic_ws" ]; then
ctl /sys/module/wakeup/parameters/enable_msm_hsic_ws "N"
WK=$(( ${WK} + 1 ))
fi
if [ -e "/sys/module/wakeup/parameters/enable_si_ws" ]; then
ctl /sys/module/wakeup/parameters/enable_si_ws "N"
WK=$(( ${WK} + 1 ))
fi
if [ -e "/sys/module/wakeup/parameters/enable_si_ws" ]; then
ctl /sys/module/wakeup/parameters/enable_si_ws "N"
WK=$(( ${WK} + 1 ))
fi
if [ -e "/sys/module/wakeup/parameters/enable_bluedroid_timer_ws" ]; then
ctl /sys/module/wakeup/parameters/enable_bluedroid_timer_ws "N"
WK=$(( ${WK} + 1 ))
fi
if [ -e "/sys/module/wakeup/parameters/enable_ipa_ws" ]; then
ctl /sys/module/wakeup/parameters/enable_ipa_ws "N"
WK=$(( ${WK} + 1 ))
fi
if [ -e "/sys/module/wakeup/parameters/enable_netlink_ws" ]; then
ctl /sys/module/wakeup/parameters/enable_netlink_ws "N"
WK=$(( ${WK} + 1 ))
fi
if [ -e "/sys/module/wakeup/parameters/enable_netmgr_wl_ws" ]; then
ctl /sys/module/wakeup/parameters/enable_netmgr_wl_ws "N"
WK=$(( ${WK} + 1 ))
fi
if [ -e "/sys/module/wakeup/parameters/enable_qcom_rx_wakelock_ws" ]; then
ctl /sys/module/wakeup/parameters/enable_qcom_rx_wakelock_ws "N"
WK=$(( ${WK} + 1 ))
fi
if [ -e "/sys/module/wakeup/parameters/enable_timerfd_ws" ]; then
ctl /sys/module/wakeup/parameters/enable_timerfd_ws "N"
WK=$(( ${WK} + 1 ))
fi
if [ -e "/sys/module/wakeup/parameters/enable_wlan_extscan_wl_ws" ]; then
ctl /sys/module/wakeup/parameters/enable_wlan_extscan_wl_ws "N"
WK=$(( ${WK} + 1 ))
fi
if [ -e "/sys/module/wakeup/parameters/enable_wlan_rx_wake_ws" ]; then
ctl /sys/module/wakeup/parameters/enable_wlan_rx_wake_ws "N"
WK=$(( ${WK} + 1 ))
fi
if [ -e "/sys/module/wakeup/parameters/enable_wlan_wake_ws" ]; then
ctl /sys/module/wakeup/parameters/enable_wlan_wake_ws "N"
WK=$(( ${WK} + 1 ))
fi
if [ -e "/sys/module/wakeup/parameters/enable_wlan_wow_wl_ws" ]; then
ctl /sys/module/wakeup/parameters/enable_wlan_wow_wl_ws "N"
WK=$(( ${WK} + 1 ))
fi
if [ -e "/sys/module/wakeup/parameters/enable_wlan_ws" ]; then
ctl /sys/module/wakeup/parameters/enable_wlan_ws "N"
WK=$(( ${WK} + 1 ))
fi
if [ -e "/sys/module/wakeup/parameters/enable_wlan_ctrl_wake_ws" ]; then
ctl /sys/module/wakeup/parameters/enable_wlan_ctrl_wake_ws "N"
WK=$(( ${WK} + 1 ))
fi
if [ -e "/sys/module/smb135x_charger/parameters/use_wlock" ]; then
ctl /sys/module/smb135x_charger/parameters/use_wlock "N"
WK=$(( ${WK} + 1 ))
fi
if [ -e "/sys/module/wakeup/parameters/enable_smb135x_wake_ws" ]; then
ctl /sys/module/wakeup/parameters/enable_smb135x_wake_ws "N"
WK=$(( ${WK} + 1 ))
fi
if [ -e "/sys/module/wakeup/parameters/enable_si_ws" ]; then
ctl /sys/module/wakeup/parameters/enable_si_wsk "N"
WK=$(( ${WK} + 1 ))
fi
if [ -e "/sys/module/wakeup/parameters/enable_bluesleep_ws" ]; then
ctl /sys/module/wakeup/parameters/enable_bluesleep_ws "N"
WK=$(( ${WK} + 1 ))
fi
if [ -e "/sys/module/bcmdhd/parameters/wlrx_divide" ]; then
ctl /sys/module/bcmdhd/parameters/wlrx_divide "N"
WK=$(( ${WK} + 1 ))
fi
if [ -e "/sys/module/bcmdhd/parameters/wlctrl_divide" ]; then
ctl /sys/module/bcmdhd/parameters/wlctrl_divide "N"
WK=$(( ${WK} + 1 ))
fi
if [ -e "/sys/module/xhci_hcd/parameters/wl_divide" ]; then
ctl /sys/module/xhci_hcd/parameters/wl_divide "N"
WK=$(( ${WK} + 1 ))
fi
if [ -e "/sys/module/smb135x_charger/parameters/use_wlock" ]; then
ctl /sys/module/smb135x_charger/parameters/use_wlock "N"
WK=$(( ${WK} + 1 ))
fi
if [ ${WK} -gt 0 ] ;then
kmsg "=======================================================================
BLOCKING ${WK} WAKELOCKS
============================================================================="
fi
if [ -e "/sys/class/misc/boeffla_wakelock_blocker/wakelock_blocker" ]; then
kmsg "=======================================================================
ENABLING WAKELOCK BLOCKER
============================================================================="
ctl /sys/class/misc/boeffla_wakelock_blocker/wakelock_blocker "wlan_pno_wl;wlan_ipa;wcnss_filter_lock;[timerfd];hal_bluetooth_lock;IPA_WS;sensor_ind;wlan;netmgr_wl;qcom_rx_wakelock;wlan_wow_wl;wlan_extscan_wl;NETLINK"
fi
# =========
# Google Services Drain fix by @Alcolawl @Oreganoian
# =========
kmsg "=======================================================================
FIXING GSERVICE DRAIN
============================================================================="
pm enable com.google.android.gms/.update.SystemUpdateActivity
pm enable com.google.android.gms/.update.SystemUpdateService
pm enable com.google.android.gms/.update.SystemUpdateService$ActiveReceiver
pm enable com.google.android.gms/.update.SystemUpdateService$Receiver
pm enable com.google.android.gms/.update.SystemUpdateService$SecretCodeReceiver
pm enable com.google.android.gsf/.update.SystemUpdateActivity
pm enable com.google.android.gsf/.update.SystemUpdatePanoActivity
pm enable com.google.android.gsf/.update.SystemUpdateService
pm enable com.google.android.gsf/.update.SystemUpdateService$Receiver
pm enable com.google.android.gsf/.update.SystemUpdateService$SecretCodeReceiver
# FS-TRIM
fstrim -v /cache
fstrim -v /data
fstrim -v /system
kmsg "=======================================================================
FSTRIM DONE
============================================================================="
boot_run_once=false
spectrum_mode=$(getprop persist.spectrum.profile)
setprop persist.spectrum.profile 0
(
while true
do
sleep 15
if $boot_run_once
then
[ "$(getprop persist.spectrum.profile)" == "$spectrum_mode" ] && continue
else
boot_run_once=true
fi
spectrum_mode=$(getprop persist.spectrum.profile)
case "$spectrum_mode" in
# Lazy Profile
"0") {
kmsg "=======================================================================
LAZY MODE IS STARTING --
============================================================================="
#GPU Tunables
ctl /sys/class/kgsl/kgsl-3d0/devfreq/polling_interval 10
ctl /sys/class/kgsl/kgsl-3d0/idle_timer 62
ctl /sys/class/kgsl/kgsl-3d0/force_clk_on 0
ctl /sys/class/kgsl/kgsl-3d0/thermal_pwrlevel 3
ctl /sys/class/kgsl/kgsl-3d0/force_bus_on 0
ctl /sys/class/kgsl/kgsl-3d0/force_no_nap 0
ctl /sys/class/kgsl/kgsl-3d0/devfreq/adrenoboost 2
ctl /sys/class/kgsl/kgsl-3d0/force_rail_on 0
ctl /sys/class/kgsl/kgsl-3d0/bus_split 1
ctl /sys/class/kgsl/kgsl-3d0/throttling 0
for EAS in /sys/devices/system/cpu/cpu*/cpufreq/
do
avail_govs=`cat "${EAS}scaling_available_governors"`
if [[ "$avail_govs" == *"schedutil"* ]]
then
ctl "${EAS}scaling_governor" schedutil
ctl "${EAS}schedutil/up_rate_limit_us" 500
ctl "${EAS}schedutil/down_rate_limit_us" 20000
ctl "${EAS}schedutil/rate_limit_us" 20000
ctl "${EAS}schedutil/hispeed_load" 90
ctl "${EAS}schedutil/pl" 1
ctl "${EAS}schedutil/iowait_boost_enable" 1
elif [[ "$avail_govs" == *"interactive"* ]]
then
ctl "${EAS}scaling_governor" interactive
ctl "${EAS}interactive/min_sample_time" 20000
ctl "${EAS}interactive/go_hispeed_load" 90
fi
done
ctl $VM/vfs_cache_pressure 30
ctl $VM/dirty_background_ratio 5
ctl $VM/dirty_ratio 20
ctl $VM/dirty_expire_centisecs 200
ctl $VM/dirty_writeback_centisecs 5000
# Pwrlvl of Adreno GPU (0 is max and 6 is less active)
ctl /sys/class/kgsl/kgsl-3d0/max_pwrlevel 0
ctl /sys/class/kgsl/kgsl-3d0/default_pwrlevel 3
#TOP-APP
ctl $ST_TOP/schedtune.boost 1
ctl $ST_TOP/schedtune.colocate 0
ctl $ST_TOP/schedtune.prefer_idle 1
ctl $ST_TOP/schedtune.sched_boost_enabled 1
ctl $ST_TOP/schedtune.sched_boost_no_override 1
Second=$((($RAM*4/100)*1024/4))
Hidden=$((($RAM*7/100)*1024/4))
content=$((($RAM*9/100)*1024/4))
empty=$((($RAM*11/100)*1024/4))
ctl $LMK/minfree "4096,5120,$Second,$Hidden,$content,$empty"
kmsg "=======================================================================
LAZY MODE ACTIVATED --
============================================================================="
# Sucess Message
kmsg "TIME EXECUTED $(date) "
kmsg "LAZY HAS EXECUTED TASK SUCCESSFULLY. ENJOY!"
vibrate_cmode
};;
# Performance Profile
"1") {
kmsg "=======================================================================
PERFORMANCE MODE IS STARTING --
============================================================================="
#GPU Tunables
ctl /sys/class/kgsl/kgsl-3d0/devfreq/polling_interval 36
ctl /sys/class/kgsl/kgsl-3d0/idle_timer 72
ctl /sys/class/kgsl/kgsl-3d0/force_clk_on 0
ctl /sys/class/kgsl/kgsl-3d0/thermal_pwrlevel 3
ctl /sys/class/kgsl/kgsl-3d0/force_bus_on 0
ctl /sys/class/kgsl/kgsl-3d0/force_no_nap 0
ctl /sys/class/kgsl/kgsl-3d0/devfreq/adrenoboost 2
ctl /sys/class/kgsl/kgsl-3d0/force_rail_on 0
ctl /sys/class/kgsl/kgsl-3d0/bus_split 1
ctl /sys/class/kgsl/kgsl-3d0/throttling 1
for EAS in /sys/devices/system/cpu/cpu*/cpufreq/
do
avail_govs=`cat "${EAS}scaling_available_governors"`
if [[ "$avail_govs" == *"schedutil"* ]]
then
ctl "${EAS}scaling_governor" schedutil
ctl "${EAS}schedutil/up_rate_limit_us" 1000
ctl "${EAS}schedutil/down_rate_limit_us" 4000
ctl "${EAS}schedutil/rate_limit_us" 4000
ctl "${EAS}schedutil/hispeed_load" 90
ctl "${EAS}schedutil/iowait_boost_enable" 1
ctl "${EAS}schedutil/pl" 0
elif [[ "$avail_govs" == *"interactive"* ]]
then
ctl "${EAS}scaling_governor" interactive
ctl "${EAS}interactive/min_sample_time" 4000
ctl "${EAS}interactive/go_hispeed_load" 90
fi
done
ctl $VM/vfs_cache_pressure 76
ctl $VM/dirty_background_ratio 5
ctl $VM/dirty_ratio 20
ctl $VM/dirty_expire_centisecs 200
ctl $VM/dirty_writeback_centisecs 5000
# Pwrlvl of Adreno GPU (0 is max and 6 is less active)
ctl /sys/class/kgsl/kgsl-3d0/max_pwrlevel 0
ctl /sys/class/kgsl/kgsl-3d0/default_pwrlevel 5
#TOP-APP
ctl $ST_TOP/schedtune.boost 5
ctl $ST_TOP/schedtune.colocate 0
ctl $ST_TOP/schedtune.prefer_idle 1
ctl $ST_TOP/schedtune.sched_boost_enabled 0
ctl $ST_TOP/schedtune.sched_boost_no_override 0
Second=$((($RAM*4/100)*1024/4))
Hidden=$((($RAM*6/100)*1024/4))
content=$((($RAM*8/100)*1024/4))
empty=$((($RAM*11/100)*1024/4))
ctl $LMK/minfree "4096,5120,$Second,$Hidden,$content,$empty"
kmsg "=======================================================================
PERFORMANCE MODE ACTIVATED --
============================================================================="
# Sucess Message
kmsg "TIME EXECUTED $(date) "
kmsg "LAZY HAS EXECUTED TASK SUCCESSFULLY. ENJOY!"
vibrate_cmode
};;
# Battery Profile
"2") {
kmsg "=======================================================================
BATTERY MODE IS STARTING --
============================================================================="
#GPU Tunables
ctl /sys/class/kgsl/kgsl-3d0/devfreq/polling_interval 10
ctl /sys/class/kgsl/kgsl-3d0/idle_timer 62
ctl /sys/class/kgsl/kgsl-3d0/force_clk_on 0
ctl /sys/class/kgsl/kgsl-3d0/thermal_pwrlevel 3
ctl /sys/class/kgsl/kgsl-3d0/force_bus_on 0
ctl /sys/class/kgsl/kgsl-3d0/force_no_nap 0
ctl /sys/class/kgsl/kgsl-3d0/devfreq/adrenoboost 2
ctl /sys/class/kgsl/kgsl-3d0/force_rail_on 0
ctl /sys/class/kgsl/kgsl-3d0/bus_split 1
ctl /sys/class/kgsl/kgsl-3d0/throttling 1
for EAS in /sys/devices/system/cpu/cpu*/cpufreq/
do
avail_govs=`cat "${EAS}scaling_available_governors"`
if [[ "$avail_govs" == *"schedutil"* ]]
then
ctl "${EAS}scaling_governor" schedutil
ctl "${EAS}schedutil/up_rate_limit_us" 10000
ctl "${EAS}schedutil/down_rate_limit_us" 40000
ctl "${EAS}schedutil/rate_limit_us" 40000
ctl "${EAS}schedutil/hispeed_load" 99
ctl "${EAS}schedutil/iowait_boost_enable" 0
ctl "${EAS}schedutil/pl" 0
elif [[ "$avail_govs" == *"interactive"* ]]
then
ctl "${EAS}scaling_governor" interactive
ctl "${EAS}interactive/min_sample_time" 40000
ctl "${EAS}interactive/go_hispeed_load" 99
fi
done
ctl $VM/vfs_cache_pressure 60
ctl $VM/dirty_background_ratio 10
ctl $VM/dirty_ratio 30
ctl $VM/dirty_expire_centisecs 3000
ctl $VM/dirty_writeback_centisecs 3000
# Pwrlvl of Adreno GPU (0 is max and 6 is less active)
ctl /sys/class/kgsl/kgsl-3d0/max_pwrlevel 0
ctl /sys/class/kgsl/kgsl-3d0/default_pwrlevel 5
#TOP-APP
ctl $ST_TOP/schedtune.boost 0
ctl $ST_TOP/schedtune.colocate 0
ctl $ST_TOP/schedtune.prefer_idle 0
ctl $ST_TOP/schedtune.sched_boost_enabled 0
ctl $ST_TOP/schedtune.sched_boost_no_override 0
Second=$((($RAM*5/100)*1024/4))
Hidden=$((($RAM*7/100)*1024/4))
content=$((($RAM*9/100)*1024/4))
empty=$((($RAM*12/100)*1024/4))
ctl $LMK/minfree "4096,5120,$Second,$Hidden,$content,$empty"
kmsg "=======================================================================
BATTERY MODE ACTIVATED --
============================================================================="
# Sucess Message
kmsg "TIME EXECUTED $(date) "
kmsg "LAZY HAS EXECUTED TASK SUCCESSFULLY. ENJOY!"
vibrate_cmode
};;
# Gaming Profile
"3") {
#GPU Tunables
kmsg "=======================================================================
GAMING MODE IS STARTING --
============================================================================="
ctl /sys/class/kgsl/kgsl-3d0/devfreq/polling_interval 1
ctl /sys/class/kgsl/kgsl-3d0/idle_timer 62
ctl /sys/class/kgsl/kgsl-3d0/force_clk_on 1
ctl /sys/class/kgsl/kgsl-3d0/thermal_pwrlevel 0
ctl /sys/class/kgsl/kgsl-3d0/force_bus_on 1
ctl /sys/class/kgsl/kgsl-3d0/force_no_nap 1
ctl /sys/class/kgsl/kgsl-3d0/devfreq/adrenoboost 3
ctl /sys/class/kgsl/kgsl-3d0/force_rail_on 1
ctl /sys/class/kgsl/kgsl-3d0/bus_split 0
ctl /sys/class/kgsl/kgsl-3d0/throttling 0
for EAS in /sys/devices/system/cpu/cpu*/cpufreq/
do
avail_govs=`cat "${EAS}scaling_available_governors"`
if [[ "$avail_govs" == *"schedutil"* ]]
then
ctl "${EAS}scaling_governor" schedutil
ctl "${EAS}schedutil/up_rate_limit_us" 500
ctl "${EAS}schedutil/down_rate_limit_us" 2000
ctl "${EAS}schedutil/rate_limit_us" 2000
ctl "${EAS}schedutil/hispeed_load" 90
ctl "${EAS}schedutil/iowait_boost_enable" 1
ctl "${EAS}schedutil/pl" 1
elif [[ "$avail_govs" == *"interactive"* ]]
then
ctl "${EAS}scaling_governor" interactive
ctl "${EAS}interactive/min_sample_time" 2000
ctl "${EAS}interactive/go_hispeed_load" 90
fi
done
ctl $VM/vfs_cache_pressure 200
ctl $VM/dirty_background_ratio 3
ctl $VM/dirty_ratio 15
ctl $VM/dirty_expire_centisecs 0
ctl $VM/dirty_writeback_centisecs 0
# Pwrlvl of Adreno GPU (0 is max and 6 is less active)
ctl /sys/class/kgsl/kgsl-3d0/max_pwrlevel 0
ctl /sys/class/kgsl/kgsl-3d0/default_pwrlevel 0
#TOP-APP
ctl $ST_TOP/schedtune.boost 5
ctl $ST_TOP/schedtune.colocate 0
ctl $ST_TOP/schedtune.prefer_idle 1
ctl $ST_TOP/schedtune.sched_boost_enabled 1
ctl $ST_TOP/schedtune.sched_boost_no_override 1
Second=$((($RAM*7/100)*1024/4))
Hidden=$((($RAM*8/100)*1024/4))
content=$((($RAM*9/100)*1024/4))
empty=$((($RAM*11/100)*1024/4))
ctl $LMK/minfree "4096,5120,$Second,$Hidden,$content,$empty"
kmsg "=======================================================================
GAMING MODE ACTIVATED --
============================================================================="
# Sucess Message
kmsg "TIME EXECUTED: $(date) "
kmsg "LAZY HAS EXECUTED TASK SUCCESSFULLY. ENJOY!"
vibrate_cmode
};;
esac
done
) &