-
Notifications
You must be signed in to change notification settings - Fork 7
/
ktsrmenu
709 lines (691 loc) · 23.8 KB
/
ktsrmenu
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
#!/system/bin/sh
# KTSR™ by Pedro (pedrozzz0 @ GitHub)
# Thanks to veez21 @ GitHub
# If you wanna use it as part of your project, please maintain the credits to it respective's author(s).
# Magisk Module ID
ID="KTSR"
# Detect root
_name=$(basename "$0")
ls /data >/dev/null 2>&1 || {
echo "[!] $ID needs to run as root"
echo "type 'su' then '$_name'"
exit 1
}
# Import magisk util_functions.sh
[[ -f "/data/adb/magisk/util_functions.sh" ]] && . /data/adb/magisk/util_functions.sh || {
echo "[!] util_functions.sh not detected"
exit 1
}
# Magisk Mod Directory
[[ -d "/sbin/.magisk" ]] && MOUNTPATH="/sbin/.magisk/modules" || MOUNTPATH="$(find /dev -mindepth 2 -maxdepth 2 -type d -name ".magisk")/modules"
MODDIR="$MOUNTPATH/$ID"
[[ ! -d "$MODDIR" ]] && {
echo "[!] Module not detected"
exit 1
}
# Set path to your busybox if applicable
_bb=
# Load mod-util.sh
. "$MODDIR/mod-util.sh" || exit $?
# Set Log Files
mount -o remount,rw /cache 2>/dev/null
mount -o rw,remount /cache 2>/dev/null
# Logs should go in this file
LOG="/data/media/0/ktsr/$ID-CLI.log"
oldLOG="/data/media/0/ktsr/$ID-CLI-old.log"
# Verbose output goes here
VERLOG="/data/media/0/ktsr/$ID-verbose.log"
oldVERLOG="/data/media/0/ktsr/$ID-verbose-old.log"
stdoutLOG="/data/media/0/ktsr/$ID-CLI-STDOUT.log"
oldstdoutLOG="/data/media/0/ktsr/$ID-CLI-STDOUT-old.log"
# Start logging verbosely
mv -f "$VERLOG" "$oldVERLOG" 2>/dev/null
mv -f "$LOG" "$oldLOG" 2>/dev/null
mv -f "$stdoutLOG" "$oldstdoutLOG" 2>/dev/null
set -x 2>"$VERLOG"
ktsr_prof=$(getprop persist.king.tweaks.prof)
case "$ktsr_prof" in
1) ktsr_prof_en="Automatic" ;;
2) ktsr_prof_en="Power Saving" ;;
3) ktsr_prof_en="Balanced" ;;
4) ktsr_prof_en="Extreme" ;;
5) ktsr_prof_en="Gaming" ;;
6) ktsr_prof_en="Latency" ;;
esac
[[ "$(settings get global low_power)" == "1" ]] && low_power_mode="Enabled" || low_power_mode="Disabled"
[[ "$(cmd netpolicy get restrict-background | awk '{print $4}')" == "enabled" ]] && data_saver="Enabled" || data_saver="Disabled"
[[ "$(settings get secure location_providers_allowed)" == "" ]] && loc_mode_pwr_saving="Enabled" || loc_mode_pwr_saving="Disabled"
# Fetch the device SDK
sdk=$(getprop ro.build.version.sdk)
[[ "$sdk" == "" ]] && sdk=$(getprop ro.vendor.build.version.sdk)
[[ "$sdk" == "" ]] && sdk=$(getprop ro.vndk.version)
menu() {
clear
echo ""
echo "$Y*************************************$N"
echo "$Y* KTSR Command Line Interface (CLI) *$N"
echo "$Y*************************************$N"
echo ""
echo "${G}Version: 1.7.2-r16$N"
echo ""
echo "$V[*] Current Profile:$N $G$ktsr_prof_en$N"
echo ""
echo "$Bl[*] Available profiles:$N "
echo ""
echo "$C[A] Automatic: Switch between profiles automatically based on user's activity for a better user-experience.$N"
echo ""
echo "$G[P] Power Saving: Reduce overall SOC power draw, ensuring a juicy battery life.$N"
echo ""
echo "$B[B] Balanced: Balanced between power consumption and performance, perfect to be used on day-to-day activities.$N"
echo ""
echo "$Y[EX] Extreme: Tweaks both CPU / GPU for a consistent experience while dealing with heavy apps. (May consume way more power compared to Balanced, Latency.$N"
echo ""
echo "$R[G] Game: Recommended to users who wants the best performance possible while playing, tweaked to have a good mix between peak performance and stability. (May consume a lot more power than other profiles)$N"
echo ""
echo "$V[L] Latency: Recommended to users who want really silky / smooth UI.$N"
echo ""
echo "[*] Other misc options: "
echo ""
echo "$G[O] Optimize apps package$N"
echo ""
[[ "$low_power_mode" == "Disabled" ]] && {
echo "$G[LPM] Enable battery saver$N"
echo ""
} || {
echo "$G[DLPM] Disable battery saver$N"
echo ""
}
[[ "$data_saver" == "Disabled" ]] && {
echo "[DS] Enable data saver"
echo ""
} || {
echo "[DDS] Disable data saver"
echo ""
}
[[ "$loc_mode_pwr_saving" == "Disabled" ]] && {
echo "$G[LMP] Enable power-saving location mode$N"
echo ""
} || {
echo "$R[DLMP] Disable power-saving location mode$N"
echo ""
}
echo "[C] Clean trash files, E.G: System logs, debug logs, etc."
echo ""
echo "$B[T] Access our telegram group$N"
echo ""
[[ -e "/sys/module/mdss_mdp/parameters/custom_hz" ]] && {
echo "[50] 50 HZ Refresh Rate"
echo ""
} || [[ -e "/sys/module/mdss_mdp/parameters/custom_hz" ]] && [[ "$(grep -Eo '[0-9]' /sys/module/mdss_mdp/parameters/custom_hz)" ]] && {
echo "[50] 50 HZ Refresh Rate"
echo ""
echo "[55] 55 HZ Refresh Rate"
echo ""
}
[[ "$(settings get system peak_refresh_rate)" ]] && [[ "$(settings get system peak_refresh_rate | cut -c1-3 | tr -d .)" -ne "60" ]] && {
echo "[60] 60 HZ Refresh Rate"
echo ""
} || [[ "$(settings get system peak_refresh_rate)" ]] && [[ "$(settings get system peak_refresh_rate | cut -c1-3 | tr -d .)" -ne "90" ]] && {
echo "[90] 90 HZ Refresh Rate"
echo ""
} || [[ "$(settings get system peak_refresh_rate)" ]] && [[ "$(settings get system peak_refresh_rate | cut -c1-3 | tr -d .)" -ne "120" ]] && {
echo "[120] 120 HZ Refresh Rate"
echo ""
} || [[ "$(settings get system peak_refresh_rate)" ]] && echo "[RRR] Reset Refresh Rate config"
echo ""
echo "$G[FR1] Free RAM [Balanced] (Will only drop caches).$N"
echo ""
echo "$Y[FR2] Free RAM [Agressive] (Will kill background apps and drop caches)$N"
echo ""
echo "$R[FR3] Free RAM [Extreme] (Will kill all active non-system apps and drop caches)$N"
echo ""
[[ -e "/sys/class/thermal/thermal_message/sconfig" ]] && [[ "$(cat /sys/class/thermal/thermal_message/sconfig)" != "2" ]] && {
echo "[EDTP] Switch to dynamic thermal profile (May improve charging speed)"
echo ""
} || [[ -e "/sys/class/thermal/thermal_message/sconfig" ]] && [[ "$(cat /sys/class/thermal/thermal_message/sconfig)" == "2" ]] && {
echo "[DDTP] Switch to default thermal profile"
echo ""
}
echo "[RBS] Reset battery stats"
echo ""
echo "$B[H] How to use the CLI$N"
echo ""
[[ "$sdk" -ge "31" ]] && {
echo "$G[AD] Apply downscale on a app$N"
echo ""
echo "$R[RD] Reset downscale from a app$N"
echo ""
}
[[ "$(pm list package com.google.android.gms)" ]] && {
echo "$G[EG] Enable Gapps$N"
echo ""
echo "$R[DG] Disable Gapps$N"
echo ""
}
[[ "$sdk" -ge "28" ]] && {
echo "[OGL] Set renderer to OpenGL"
echo ""
echo "[SOGL] Set renderer to Skia OpenGL"
echo ""
echo "[SVK] Set renderer to Skia Vulkan"
echo ""
}
[[ "$sdk" -ge "31" ]] && [[ "$(settings get global dynamic_power_savings_enabled)" != "null" ]] && {
echo "[SDPS] Set dynamic power savings battery threshold (it will be disabled when battery is equal or more than your selected value) (Option + value you want to set to)"
echo ""
[[ "$(settings get global dynamic_power_savings_enabled)" != "null" ]] && {
echo "[EDPS] Enable dynamic power savings"
echo ""
} || {
echo "[DDPS] Disable dynamic power savings"
echo ""
}
}
[[ "$(settings get system screen_off_timeout)" != "null" ]] && {
echo "[SSOT] Set custom screen off timeout [Should be input in ms (5 sec = 5000)]"
echo ""
}
[[ ! "$(pgrep -f gameoptd)" ]] && {
echo "$G[EGOD] Enable gameoptd$N"
echo ""
} || {
echo "$R[DGOD] Disable gameoptd$N"
echo ""
}
echo "$R[E] Exit$N"
echo ""
echo -n "$Y[*] Select the desired option:$N "
read -r option
case "$option" in
"A" | "a")
echo "${B}Applying profile...$N"
setprop persist.king.tweaks.prof "1" 2>/dev/null
[[ $? == "0" ]] && echo "$G[*] Done!$N" || echo "$R[!] Something went wrong!$N"
sleep 2
menu
;;
"P" | "p")
echo "${B}Applying profile...$N"
setprop persist.king.tweaks.prof "2" 2>/dev/null
[[ $? == "0" ]] && echo "$G[*] Done!$N" || echo "$R[!] Something went wrong!$N"
sleep 2
menu
;;
"B" | "b")
echo "${B}Applying profile...$N"
setprop persist.king.tweaks.prof "3" 2>/dev/null
[[ $? == "0" ]] && echo "$G[*] Done!$N" || echo "$R[!] Something went wrong!$N"
menu
;;
"EX" | "ex")
echo "${B}Applying profile...$N"
setprop persist.king.tweaks.prof "4" 2>/dev/null
[[ $? == "0" ]] && echo "$G[*] Done!$N" || echo "$R[!] Something went wrong!$N"
sleep 2
menu
;;
"G" | "g")
echo "${B}Applying profile...$N"
setprop persist.king.tweaks.prof "5" 2>/dev/null
[[ $? == "0" ]] && echo "$G[*] Done!$N" || echo "$R[!] Something went wrong!$N"
sleep 2
menu
;;
"L" | "l")
echo "${B}Applying profile...$N"
setprop persist.king.tweaks.prof "6" 2>/dev/null
[[ $? == "0" ]] && echo "$G[*] Done!$N" || echo "$R[!] Something went wrong!$N"
sleep 2
menu
;;
"O" | "o")
echo "${B}Optimizing packages, this may take some time...$N"
pm compile -a -f --compile-layouts
cmd package bg-dexopt-job
sleep 2
menu
;;
"ELPM" | "elpm")
settings put global low_power 1 2>/dev/null
settings put global low_power_sticky 1 2>/dev/null
settings put global app_standby_enabled 1 2>/dev/null
settings put global forced_app_standby_enabled 1 2>/dev/null
settings put global app_auto_restriction_enabled true 2>/dev/null
settings put global forced_app_standby_for_small_battery_enabled 1 2>/dev/null
[[ $? == "0" ]] && echo "$G[*] Done!$N" || echo "$R[!] Something went wrong!$N"
sleep 2
menu
;;
"DLPM" | "dlpm")
settings put global low_power 0 2>/dev/null
settings reset global low_power 2>/dev/null
settings put global low_power_sticky 0 2>/dev/null
settings reset global low_power_sticky 2>/dev/null
settings put global app_standby_enabled 1 2>/dev/null
settings reset global app_standby_enabled 2>/dev/null
settings put global forced_app_standby_enabled 0 2>/dev/null
settings reset global forced_app_standby_enabled 2>/dev/null
settings put global app_auto_restriction_enabled false 2>/dev/null
settings reset global app_auto_restriction_enabled 2>/dev/null
settings put global forced_app_standby_for_small_battery_enabled 0 2>/dev/null
settings reset global forced_app_standby_for_small_battery_enabled 1 2>/dev/null
[[ $? == "0" ]] && echo "$G[*] Done!$N" || echo "$R[!] Something went wrong!$N"
sleep 2
menu
;;
"EDS" | "eds")
cmd netpolicy set restrict-background true 2>/dev/null
[[ $? == "0" ]] && echo "$G[*] Done!$N" || echo "$R[!] Something went wrong!$N"
sleep 2
menu
;;
"DDS" | "dds")
cmd netpolicy set restrict-background false 2>/dev/null
[[ $? == "0" ]] && echo "$G[*] Done!$N" || echo "$R[!] Something went wrong!$N"
sleep 2
menu
;;
"ELMP" | "elmp")
echo "${B}Applying settings...${N}"
settings put secure location_mode "0" 2>/dev/null
settings put global assisted_gps_enabled "0" 2>/dev/null
[[ $? == "0" ]] && echo "$G[*] Done!$N" || echo "$R[!] Something went wrong!"
sleep 2
menu
;;
"DLMP" | "dlmp")
settings put global assisted_gps_enabled "1" 2>/dev/null
[[ $? == "0" ]] && echo "$G[*] Done!$N" || echo "$R[!] Something went wrong!"
sleep 2
menu
;;
"C" | "c")
echo "${B}Cleaning debug logs and system trash...$N"
cleantrash 2>/dev/null
echo "$G[*] Done!$N"
sleep 2
menu
;;
"T" | "t")
am start -a android.intent.action.VIEW -d https://t.me/kingprojectzdiscussion
menu
;;
"50")
[[ -e "/sys/module/mdss_mdp/parameters/custom_hz" ]] && [[ "$(grep -Eo '[0-9]' /sys/module/mdss_mdp/parameters/custom_hz 2>/dev/null)" ]] && echo "50" >"/sys/module/mdss_mdp/parameters/custom_hz" || echo "Y" >"/sys/module/mdss_mdp/parameters/custom_hz"
[[ $? == "0" ]] && echo "$G[*] Done!$N" || echo "$R[!] Something went wrong!$N"
sleep 2
menu
;;
"55")
[[ -e "/sys/module/mdss_mdp/parameters/custom_hz" ]] && [[ "$(grep -Eo '[0-9]' /sys/module/mdss_mdp/parameters/custom_hz 2>/dev/null)" ]] && echo "55" >"/sys/module/mdss_mdp/parameters/custom_hz"
[[ $? == "0" ]] && echo "$G[*] Done!$N" || echo "$R[!] Something went wrong!$N"
sleep 2
menu
;;
"60")
[[ -e "/sys/module/mdss_mdp/parameters/custom_hz" ]] && [[ "$(grep -o -e '[0-9\.]+' /sys/module/mdss_mdp/parameters/custom_hz 2>/dev/null)" ]] && echo "60" >"/sys/module/mdss_mdp/parameters/custom_hz" || echo "N" >"/sys/module/mdss_mdp/parameters/custom_hz"
settings put system min_refresh_rate 60 2>/dev/null
settings put system peak_refresh_rate 60 2>/dev/null
settings put system user_refresh_rate 60 2>/dev/null
settings put system thermal_limit_refresh_rate 60 2>/dev/null
settings put global oneplus_screen_refresh_rate 1 2>/dev/null
settings put secure coloros_screen_refresh_rate 2 2>/dev/null
service call SurfaceFlinger 1035 i32 1 >/dev/null 2>&1
[[ $? == "0" ]] && echo "$G[*] Done!$N" || echo "$R[!] Something went wrong!$N"
sleep 2
menu
;;
"90")
settings put system min_refresh_rate 90 2>/dev/null
settings put system peak_refresh_rate 90.0 2>/dev/null
settings put system user_refresh_rate 90.0 2>/dev/null
settings put system thermal_limit_refresh_rate 90 2>/dev/null
settings put global oneplus_screen_refresh_rate 0 2>/dev/null
settings put secure coloros_screen_refresh_rate 1 2>/dev/null
service call SurfaceFlinger 1035 i32 0 >/dev/null 2>&1
[[ $? == "0" ]] && echo "$G[*] Done!$N" || echo "$R[!] Something went wrong!$N"
sleep 2
menu
;;
"120")
settings put system min_refresh_rate 120 2>/dev/null
settings put system peak_refresh_rate 120.0 2>/dev/null
settings put system user_refresh_rate 120.0 2>/dev/null
settings put system thermal_limit_refresh_rate 120 2>/dev/null
settings put global oneplus_screen_refresh_rate 0 2>/dev/null
settings put secure coloros_screen_refresh_rate 3 2>/dev/null
[[ $? == "0" ]] && echo "$G[*] Done!$N" || echo "$R[!] Something went wrong!$N"
sleep 2
menu
;;
"RRR" | "rrr")
settings reset system min_refresh_rate >/dev/null 2>&1
settings reset system peak_refresh_rate >/dev/null 2>&1
settings reset system user_refresh_rate >/dev/null 2>&1
settings reset system thermal_limit_refresh_rate >/dev/null 2>&1
settings reset global oneplus_screen_refresh_rate >/dev/null 2>&1
settings reset secure coloros_screen_refresh_rate >/dev/null 2>&1
service call SurfaceFlinger 1035 i32 1 >/dev/null 2>&1
[[ $? == "0" ]] && echo "$G[*] Done!$N" || echo "$R[!] Something went wrong!$N"
sleep 2
menu
;;
"FR1" | "fr1")
sync
echo "3" >"/proc/sys/vm/drop_caches"
[[ $? == "0" ]] && echo "$G[*] Done!$N" || echo "$R[!] Something went wrong!$N"
sleep 4
menu
;;
"FR2" | "fr2")
sync
echo "3" >"/proc/sys/vm/drop_caches"
am kill-all
[[ $? == "0" ]] && echo "$G[*] Done!$N" || echo "$R[!] Something went wrong!$N"
sleep 4
menu
;;
"FR3" | "fr3")
sync
echo "3" >"/proc/sys/vm/drop_caches"
am kill-all
sleep 3
while IFS= read -r pkg_nm; do
[[ "$pkg_nm" != "com.termux" ]] && [[ "$pkg_nm" != "jackpal.androidterm" ]] && [[ "$pkg_nm" != "yarolegovich.materialterminal" ]] && [[ "$pkg_nm" != "com.google.android.inputmethod.latin" ]] && [[ "$pkg_nm" != "com.termoneplus" ]] && [[ "$pkg_nm" != "com.pittvandewitt.viperfx" ]] && [[ "$pkg_nm" != "com.topjohnwu.magisk" ]] && [[ "$pkg_nm" != "ridmik.keyboard" ]] && [[ "$pkg_nm" != "com.maxmpz.equalizer" ]] && [[ "$pkg_nm" != "com.miui.screenrecorder" ]] && am force-stop "$pkg_nm"
done <<<"$(pm list packages -e -3 | grep package | cut -f 2 -d ":")"
echo "${G}Done!$N"
sleep 2
menu
;;
"EDTP" | "edtp")
echo "2" >"/sys/class/thermal/thermal_message/sconfig" 2>/dev/null
[[ $? == "0" ]] && echo "$G[*] Done!$N" || echo "$R[!] Something went wrong!$N"
sleep 2
menu
;;
"DDTP" | "ddtp")
echo "0" >"/sys/class/thermal/thermal_message/sconfig" 2>/dev/null
[[ $? == "0" ]] && echo "$G[*] Done!$N" || echo "$R[!] Something went wrong!$N"
sleep 2
menu
;;
"RBS" | "rbs")
dumpsys batterystats --reset >/dev/null 2>&1
rm -f /data/system/batterystats-checkin.bin 2>/dev/null
rm -f /data/system/batterystats-daily.xml 2>/dev/null
rm -f /data/system/batterystats.bin 2>/dev/null
rm -rf /data/system/battery-history 2>/dev/null
rm -rf /data/vendor/charge_logger 2>/dev/null
rm -rf /data/charge_logger 2>/dev/null
echo "${G}[*] Done!$N"
sleep 2
menu
;;
"H" | "h")
am start -a android.intent.action.VIEW -d https://github.com/pedrozzz0/King-Tweaks/wiki/KTW
;;
"AD" | "ad")
echo "Value range supported: [0.3-0.9]"
echo "A lower value means lower resolution"
echo "[*] Enter a value from the supported range: "
read -r lvl
echo "E.G: [com.android.camera]"
echo "[*] Enter a package name:"
read -r pkg
cmd game downscale "$lvl" "$pkg" 2>/dev/null
[[ $? == "0" ]] && echo "$G[*] Done!$N" || echo "$R[!] Something went wrong!$N"
sleep 2
menu
;;
"RD" | "rd")
echo "E.G: [com.android.camera]"
echo "[*] Enter a package name:"
read -r pkg
cmd game downscale disable "$pkg" 2>/dev/null
[[ $? == "0" ]] && echo "$G[*] Done!$N" || echo "$R[!] Something went wrong!$N"
sleep 2
menu
;;
"EG" | "eg")
echo "[*] Enabling Gapps..."
pm enable com.google.android.gsf 2>/dev/null
pm enable com.google.android.gsf.login 2>/dev/null
pm enable com.google.android.gms 2>/dev/null
pm enable com.google.android.ims 2>/dev/null
pm enable com.google.android.apps.carrier.log 2>/dev/null
pm enable com.android.vending 2>/dev/null
pm enable com.google.android.play.games 2>/dev/null
pm enable com.google.android.syncadapters.contacts 2>/dev/null
echo "${G}[*] Done!$N"
sleep 2
menu
;;
"DG" | "dg")
echo "Killing Gapps..."
pm disable com.google.android.gsf 2>/dev/null
pm disable com.google.android.gsf.login 2>/dev/null
pm disable com.google.android.gms 2>/dev/null
pm disable com.google.android.ims 2>/dev/null
pm disable com.google.android.apps.carrier.log 2>/dev/null
pm disable com.android.vending 2>/dev/null
pm disable com.google.android.play.games 2>/dev/null
pm disable com.google.android.syncadapters.contacts 2>/dev/null
echo "${G}[*] Done!$N"
sleep 2
menu
;;
"OGL" | "ogl")
[[ "$sdk" -ge "28" ]] && {
echo "You may need to reboot to apply the changes"
sed -i 's/debug.hwui.renderer.*/debug.hwui.renderer=opengl/' "$MODDIR/system.prop"
echo "${G}[*] Done!$N"
sleep 2
menu
} || {
echo "$R[!] Android version not supported!$N"
sleep 2
menu
}
;;
"SOGL" | "sogl")
[[ "$sdk" -ge "28" ]] && {
echo "You may need to reboot to apply the changes"
sed -i 's/debug.hwui.renderer.*/debug.hwui.renderer=skiagl/' "$MODDIR/system.prop"
echo "$G[*] Done!$N"
sleep 2
menu
} || {
echo "$R[!] Android version not supported!$N"
sleep 2
menu
}
;;
"SVK" | "svk")
[[ "$sdk" -ge "28" ]] && {
echo "You may need to reboot to apply the changes"
sed -i 's/debug.hwui.renderer.*/debug.hwui.renderer=skiavk/' "$MODDIR/system.prop"
echo "$G[*] Done!$N"
sleep 2
menu
} || {
echo "$R[!] Android version not supported!$N"
sleep 2
menu
}
;;
"SDPS" | "sdps")
[[ "$sdk" -ge "31" ]] && {
settings put global dynamic_power_savings_disable_threshold "$2"
echo "$G[*] Done!$N"
sleep 2
menu
} || {
echo "$R[!] Android version not supported!$N"
sleep 2
menu
}
;;
"EDPS" | "edps")
[[ "$sdk" -ge "31" ]] && {
settings put global dynamic_power_savings_enabled 1
echo "$G[*] Done!$N"
sleep 2
menu
} || {
echo "$R[!] Android version not supported!$N"
sleep 2
menu
}
;;
"DDPS" | "ddps")
[[ "$sdk" -ge "31" ]] && {
settings put global dynamic_power_savings_enabled 0
echo "$G[*] Done!$N"
sleep 2
menu
} || {
echo "$R[!] Android version not supported!$N"
sleep 2
menu
}
;;
"SSOT" | "ssot")
[[ "$(settings get system screen_off_timeout)" != "null" ]] && {
settings put global screen_off_timeout "$2"
echo "$G[*] Done!$N"
sleep 2
menu
} || {
echo "$R[!] Android node not supported!$N"
sleep 2
menu
}
;;
"EGOD" | "egod")
[[ ! "$(pgrep -f gameoptd)" ]] && gameoptd &
;;
"DGOD" | "dgod")
[[ "$(pgrep -f gameoptd)" ]] && killall gameoptd
;;
"E" | "e")
echo "${G}Hope that see ya soon! ;)$N"
;;
*)
abort "$R[!] Unexpected response, aborting...$N"
;;
esac
}
[[ $# -eq "0" ]] && menu
help_me() {
echo "$MODTITLE $VER($REL)
by $AUTHOR
Usage: $_name
or: $_name [options]...
Telegram group: https://t.me/kingprojectz
Supported options:
-p --profile [1-6] [switch between profiles without opening the terminal GUI, for a fast and seamless experience]
-f --free-ram [1-3] [Higher value means more agressive memory reclaim, which includes killing apps at maximum value (3)]
-h --help [show this message]
-g --game [enable game mode, which enables DND and disables automatic rotation/brightness for a optimal gaming experience]"
am start -a android.intent.action.VIEW -d https://github.com/pedrozzz0/King-Tweaks/wiki/KTW
exit
}
opts=":p:f:h:g-:"
while getopts "$opts" opt; do
case "$opt" in
-)
case "$OPTARG" in
profile)
echo "$B[*] Applying profile...$N"
setprop persist.king.tweaks.prof "$2" 2>/dev/null
echo "$G[*] Done!$N"
;;
free-ram)
[[ "$2" == "1" ]] && {
sync
echo "3" >"/proc/sys/vm/drop_caches"
echo "$G[*] Done!$N"
sleep 2
} || [[ "$2" == "2" ]] && {
sync
echo "3" >"/proc/sys/vm/drop_caches"
am kill-all
echo "$G[*] Done!$N"
sleep 3
} || [[ "$2" == "3" ]] && {
sync
echo "3" >"/proc/sys/vm/drop_caches"
am kill-all
sleep 3
while IFS= read -r pkg_nm; do
[[ "$pkg_nm" != "com.termux" ]] && [[ "$pkg_nm" != "jackpal.androidterm" ]] && [[ "$pkg_nm" != "yarolegovich.materialterminal" ]] && [[ "$pkg_nm" != "com.google.android.inputmethod.latin" ]] && [[ "$pkg_nm" != "com.termoneplus" ]] && [[ "$pkg_nm" != "com.pittvandewitt.viperfx" ]] && [[ "$pkg_nm" != "com.topjohnwu.magisk" ]] && [[ "$pkg_nm" != "ridmik.keyboard" ]] && [[ "$pkg_nm" != "com.maxmpz.equalizer" ]] && [[ "$pkg_nm" != "com.miui.screenrecorder" ]] && am force-stop "$pkg_nm"
done <<<"$(pm list packages -e -3 | grep package | cut -f 2 -d ":")"
echo "$G[*] Done!$N"
sleep 2
} || { echo "$R[!] Error: unexpected or null output!$N"; }
;;
game)
cmd notification set_dnd priority >/dev/null 2>&1
settings put system screen_brightness_mode 0 >/dev/null 2>&1
wm set-user-rotation lock >/dev/null 2>&1
wm user-rotation lock >/dev/null 2>&1
sync
echo "3" >"/proc/sys/vm/drop_caches"
am kill-all
echo "$G[*] Done!$N"
;;
help)
help_me
;;
*)
[[ "$OPTERR" == "1" ]] && [[ "${opts:0:1}" != ":" ]] && {
help_me
}
;;
esac
;;
p)
echo "$B[*] Applying profile...$N"
setprop persist.king.tweaks.prof "$2" 2>/dev/null
echo "$G[*] Done!$N"
;;
f)
[[ "$2" == "1" ]] && {
sync
echo "3" >"/proc/sys/vm/drop_caches"
echo "$G[*] Done!$N"
sleep 2
} || [[ "$2" == "2" ]] && {
sync
echo "3" >"/proc/sys/vm/drop_caches"
am kill-all
echo "$G[*] Done!$N"
sleep 3
} || [[ "$2" == "3" ]] && {
sync
echo "3" >"/proc/sys/vm/drop_caches"
am kill-all
sleep 3
while IFS= read -r pkg_nm; do
[[ "$pkg_nm" != "com.termux" ]] && [[ "$pkg_nm" != "jackpal.androidterm" ]] && [[ "$pkg_nm" != "yarolegovich.materialterminal" ]] && [[ "$pkg_nm" != "com.google.android.inputmethod.latin" ]] && [[ "$pkg_nm" != "com.termoneplus" ]] && [[ "$pkg_nm" != "com.pittvandewitt.viperfx" ]] && [[ "$pkg_nm" != "com.topjohnwu.magisk" ]] && [[ "$pkg_nm" != "ridmik.keyboard" ]] && [[ "$pkg_nm" != "com.maxmpz.equalizer" ]] && [[ "$pkg_nm" != "com.miui.screenrecorder" ]] && [[ "$pkg_nm" != "com.android.phone" ]] && am force-stop "$pkg_nm"
done <<<"$(pm list packages -e -3 | grep package | cut -f 2 -d ":")"
echo "$G[*] Done!$N"
sleep 2
}
;;
g)
cmd notification set_dnd priority >/dev/null 2>&1
settings put system screen_brightness_mode 0 >/dev/null 2>&1
wm set-user-rotation lock >/dev/null 2>&1
wm user-rotation lock >/dev/null 2>&1
sync
echo "3" >"/proc/sys/vm/drop_caches"
am kill-all
echo "$G[*] Done!$N"
;;
h)
help_me
;;
esac
done
shift $((OPTIND - 1))