diff --git a/common/addon/Volume-Key-Selector/README.md b/common/addon/Volume-Key-Selector/README.md new file mode 100644 index 0000000..d0477be --- /dev/null +++ b/common/addon/Volume-Key-Selector/README.md @@ -0,0 +1,16 @@ +# Volume Key Selector - Addon that allows the use of the volume keys to select option in the installer + +## Instructions: +* Use $VKSEL variable whenever you want to call the volume key selection function. The function returns true if user selected vol up and false if vol down +Ex: if $VKSEL; then + echo "true" + else + echo "false" + fi +* If you want to use the bixby button on samsung galaxy devices, [check out this post here](https://forum.xda-developers.com/showpost.php?p=77908805&postcount=16) and modify the install.sh functions accordingly + +## Notes: +* Each volume key selector method will timeout after 3 seconds in the event of incompatibility or error + +## Included Binaries/Credits: +* [keycheck binary](https://github.com/sonyxperiadev/device-sony-common-init/tree/master/keycheck) compiled by me [here](https://github.com/Zackptg5/Keycheck) diff --git a/common/addon/Volume-Key-Selector/install.sh b/common/addon/Volume-Key-Selector/install.sh new file mode 100644 index 0000000..fe7c72c --- /dev/null +++ b/common/addon/Volume-Key-Selector/install.sh @@ -0,0 +1,75 @@ +# External Tools + +chmod -R 0755 $MODPATH/common/addon/Volume-Key-Selector/tools +alias keycheck="$MODPATH/common/addon/Volume-Key-Selector/tools/$ARCH32/keycheck" + +keytest() { + ui_print "- Vol Key Test" + ui_print " Press a Vol Key:" + ui_print "" + if (timeout 3 /system/bin/getevent -lc 1 2>&1 | /system/bin/grep VOLUME | /system/bin/grep " DOWN" > $TMPDIR/events); then + return 0 + else + ui_print " Try again:" + timeout 3 keycheck + local SEL=$? + [ $SEL -eq 143 ] && abort " Vol key not detected!" || return 1 + fi +} + +chooseport() { + # Original idea by chainfire @xda-developers, improved on by ianmacd @xda-developers + #note from chainfire @xda-developers: getevent behaves weird when piped, and busybox grep likes that even less than toolbox/toybox grep + while true; do + /system/bin/getevent -lc 1 2>&1 | /system/bin/grep VOLUME | /system/bin/grep " DOWN" > $TMPDIR/events + if (`cat $TMPDIR/events 2>/dev/null | /system/bin/grep VOLUME >/dev/null`); then + break + fi + done + if (`cat $TMPDIR/events 2>/dev/null | /system/bin/grep VOLUMEUP >/dev/null`); then + return 0 + else + return 1 + fi +} + +chooseportold() { + # Keycheck binary by someone755 @Github, idea for code below by Zappo @xda-developers + # Calling it first time detects previous input. Calling it second time will do what we want + while true; do + keycheck + keycheck + local SEL=$? + if [ "$1" == "UP" ]; then + UP=$SEL + break + elif [ "$1" == "DOWN" ]; then + DOWN=$SEL + break + elif [ $SEL -eq $UP ]; then + return 0 + elif [ $SEL -eq $DOWN ]; then + return 1 + fi + done +} + +# Have user option to skip vol keys +OIFS=$IFS; IFS=\|; MID=false; NEW=false +case $(echo $(basename $ZIPFILE) | tr '[:upper:]' '[:lower:]') in + *novk*) ui_print "- Skipping Vol Keys -";; + *) if keytest; then + VKSEL=chooseport + else + VKSEL=chooseportold + ui_print " ! Legacy device detected! Using old keycheck method" + ui_print " " + ui_print "- Vol Key Programming -" + ui_print " Press Vol Up Again:" + $VKSEL "UP" + ui_print " Press Vol Down" + ui_print "" + $VKSEL "DOWN" + fi;; +esac +IFS=$OIFS diff --git a/common/addon/Volume-Key-Selector/tools/arm/keycheck b/common/addon/Volume-Key-Selector/tools/arm/keycheck new file mode 100644 index 0000000..91b56aa Binary files /dev/null and b/common/addon/Volume-Key-Selector/tools/arm/keycheck differ diff --git a/common/addon/Volume-Key-Selector/tools/x86/keycheck b/common/addon/Volume-Key-Selector/tools/x86/keycheck new file mode 100644 index 0000000..8852b0d Binary files /dev/null and b/common/addon/Volume-Key-Selector/tools/x86/keycheck differ diff --git a/common/functions.sh b/common/functions.sh index 3608af1..f92901e 100644 --- a/common/functions.sh +++ b/common/functions.sh @@ -1,5 +1,5 @@ ########################################################################################## -# Functions +# MMT Extended Utility Functions ########################################################################################## abort() { @@ -12,6 +12,8 @@ abort() { cleanup() { rm -rf $MODPATH/common 2>/dev/null + rm -rf $MODPATH/LICENSE 2>/dev/null + rm -rf $MODPATH/README.md 2>/dev/null } device_check() { @@ -103,6 +105,12 @@ prop_process() { done < $1 } +# Credits +ui_print "**************************************" +ui_print "* MMT Extended by Zackptg5 @ XDA *" +ui_print "**************************************" +ui_print " " + # Check for min/max api version [ -z $MINAPI ] || { [ $API -lt $MINAPI ] && abort "! Your system API of $API is less than the minimum api of $MINAPI! Aborting!"; } [ -z $MAXAPI ] || { [ $API -gt $MAXAPI ] && abort "! Your system API of $API is greater than the maximum api of $MAXAPI! Aborting!"; } @@ -146,7 +154,7 @@ unzip -o "$ZIPFILE" -x 'META-INF/*' 'common/functions.sh' -d $MODPATH >&2 # Run addons if [ "$(ls -A $MODPATH/common/addon/*/install.sh 2>/dev/null)" ]; then - ui_print " "; ui_print "- Running Addons -" + ui_print " "; ui_print "- Running Addons... -" for i in $MODPATH/common/addon/*/install.sh; do ui_print " Running $(echo $i | sed -r "s|$MODPATH/common/addon/(.*)/install.sh|\1|")..." . $i @@ -154,7 +162,7 @@ if [ "$(ls -A $MODPATH/common/addon/*/install.sh 2>/dev/null)" ]; then fi # Remove files outside of module directory -ui_print "- Removing old files" +ui_print "- Removing old files..." if [ -f $INFO ]; then while read LINE; do @@ -178,7 +186,7 @@ ui_print "- Installing King Tweaks Reborn..." [ -f "$MODPATH/common/install.sh" ] && . $MODPATH/common/install.sh -ui_print " Installing for $ARCH SDK $API device..." +ui_print "- Installing for $ARCH SDK $API device..." # Remove comments from files and place them, add blank line to end if not already present for i in $(find $MODPATH -type f -name "*.sh" -o -name "*.prop" -o -name "*.rule"); do [ -f $i ] && { sed -i -e "/^#/d" -e "/^ *$/d" $i; [ "$(tail -1 $i)" ] && echo "" >> $i; } || continue @@ -211,7 +219,7 @@ if $DYNLIB; then fi # Set permissions -ui_print "" +ui_print " " ui_print "- Setting Permissions..." set_perm_recursive $MODPATH 0 0 0755 0644 if [ -d $MODPATH/system/vendor ]; then diff --git a/common/install.sh b/common/install.sh new file mode 100644 index 0000000..9f71620 --- /dev/null +++ b/common/install.sh @@ -0,0 +1,123 @@ +sleep 1 +ui_print "" +ui_print "-------------------------------------------------------------------------------------------------------------------------------------------------" +ui_print " King Unlocker " +ui_print "-------------------------------------------------------------------------------------------------------------------------------------------------" +ui_print "" +ui_print " [!] Attention: This may cause problems with mi camera and other system apps " +ui_print " And also will not work if you're using magiskhideprops or other like module. " +sleep 1 +ui_print "" +ui_print " Volume + = Switch number " +ui_print " Volume - = Select " +sleep 1 +ui_print "" +ui_print " 1- Apply PUBGM 90 FPS Settings. " +ui_print "" +sleep 0.5 +ui_print " 2- Apply CODM 120 FPS Settings. " +ui_print "" +sleep 0.5 +ui_print " 3- Apply Black Desert Mobile Max Settings. " +ui_print "" +sleep 0.5 +ui_print " 4- None. " +ui_print "" +sleep 0.5 +ui_print "[*] Select which you wanna: " +ui_print "" +FU=1 +while true; do + ui_print " $FU" + if $VKSEL; then + FU=$((FU + 1)) + else + break + fi + if [ $FU -gt 4 ]; then + FU=1 + fi +done + +case $FU in +1 ) FCTEXTAD1="PUBGM 90 FPS";; +2 ) FCTEXTAD1="CODM 120 FPS";; +3 ) FCTEXTAD1="Black Desert Mobile Max Settings";; +4 ) FCTEXTAD1="None";; +esac + +ui_print "" +ui_print "[*] Selected: $FCTEXTAD1 " +ui_print "" + +if [[ "$FCTEXTAD1" == "PUBGM 90 FPS" ]] +then +sed -i '/ro.product.model=/s/.*/ro.product.model=IN2025/' $MODPATH/system.prop + +elif [[ "$FCTEXTAD1" == "CODM 120 FPS" ]] +then +sed -i '/ro.product.model=/s/.*/ro.product.model=SO-52A/' $MODPATH/system.prop + +elif [[ "$FCTEXTAD1" == "Black Desert Mobile Max Settings" ]] +then +sed -i '/ro.product.model=/s/.*/ro.product.model=SM-G975U/' $MODPATH/system.prop + +elif [[ "$FCTEXTAD1" == "None" ]] +then +busybox rm $MODPATH/system.prop +fi + +ui_print "[*] Done!" + +ui_print "-------------------------------------------------------------------------------------------------------------------------------------------------" +ui_print " DRM L1 Widevine Patch " +ui_print "-------------------------------------------------------------------------------------------------------------------------------------------------" +ui_print "" +ui_print " [!] Attention: Don't apply if your rom already have DRM L1 Widevine. " +sleep 1 +ui_print "" +ui_print " Volume + = Switch number " +ui_print " Volume - = Select " +sleep 1 +ui_print "" +ui_print " 1- Apply DRM L1 Widevine Patch. " +ui_print "" +sleep 0.5 +ui_print " 2- Don't apply DRM L1 Widevine Patch. " +ui_print "" +sleep 0.5 +ui_print "[*] Select which you wanna: " +ui_print "" +DL=1 +while true; do + ui_print " $DL" + if $VKSEL; then + DL=$((DL + 1)) + else + break + fi + if [ $DL -gt 2 ]; then + DL=1 + fi +done + +case $DL in +1 ) FCTEXTAD2="Apply";; +2 ) FCTEXTAD2="Don't apply";; +esac + +ui_print "" +ui_print "[*] Selected: $FCTEXTAD2 " +ui_print "" + + if [[ "$FCTEXTAD2" == "Apply" ]] + then + mv $MODPATH/vendor $MODPATH/system + + elif [[ "$FCTEXTAD2" == "Don't apply" ]] + then + busybox rm -rf $MODPATH/vendor + fi + + ui_print "[*] Done!" + ui_print "" diff --git a/customize.sh b/customize.sh index 5b3f64a..5fed0d5 100644 --- a/customize.sh +++ b/customize.sh @@ -1,8 +1,6 @@ # !/system/bin/sh # Written by Draco (tytydraco @ github). # Modified by pedrozzz (pedroginkgo @ telegram). -# Enable cloudflare DNS by ROM (xerta555 @github). -# MMT Extended by Zackptg5 @ XDA ui_print "" ui_print "╭╮╭━╮ ╭━━━━╮ ╭━━━╮" @@ -14,15 +12,12 @@ ui_print "╰╯╰━╯ ╱╱╰╯╱╱ ╰━━━╯" ui_print "╱╱╱╱╱ ╱╱╱╱╱╱ ╱╱╱╱╱" ui_print "╱╱╱╱╱ ╱╱╱╱╱╱ ╱╱╱╱╱" sleep 1 -ui_print " by @pedroginkgo" +ui_print "by pedrozzz (pedrozzz0 @ github)" ui_print "" sleep 1 ui_print "Thanks a lot to Eight (iamlazy123 @ github)" ui_print "" sleep 1 -ui_print "MMT Extended by (Zackptg5 @ XDA)" -ui_print "" -sleep 1 ui_print "KTweak by draco (tytydraco @ github)" ui_print "" sleep 1 @@ -127,52 +122,6 @@ SKIPUNZIP=0 unzip -qjo "$ZIPFILE" 'common/functions.sh' -d $TMPDIR >&2 . $TMPDIR/functions.sh -key_selector() { - local option - local select - - while true - do - option="$(getevent -qlc 1 | awk '{ print $3 }')" - case "$option" in - KEY_VOLUMEUP) - select="Yes" - ;; - KEY_VOLUMEDOWN) - select="No" - ;; - *) - continue - ;; - esac - - echo "$select" - break - done -} - -ui_print "" -ui_print "[*] Do you wanna install DRM L1 Patch? (Enable 1080p on Netflix) (DON'T USE IF YOU ALREADY HAVE DRM L1 WIDEVINE)." -ui_print " Volume + = Yes" -ui_print " Volume - = No" -ui_print "" -version="$(key_selector)" - -ui_print "[*] Your choice: $version" -ui_print "" - -if [ "$version" == "Yes" ] -then -ui_print "[*] You're installing DRM L1 Widevine patch..." -sleep 2 -mv $MODPATH/vendor $MODPATH/system - -else [ "$version" == "No" ] -ui_print "[*] Aborting DRM L1 Widevine patch installation..." -sleep 2 -busybox rm -rf $MODPATH/vendor -fi - ui_print "" fstrim -v /system fstrim -v /data @@ -180,7 +129,8 @@ fstrim -v /cache ui_print "" ui_print "[*] Logs are stored in your internal storage/KTS" sleep 1 -ui_print "You still can access it by writing kingtweaks in a root terminal (not recommended)." +ui_print "" +ui_print "[*] You still can access it by writing kingtweaks in a root terminal (not recommended)." sleep 1 ui_print "" echo "[*] Now, reboot." diff --git a/module.prop b/module.prop index 77d1d27..4ced15e 100644 --- a/module.prop +++ b/module.prop @@ -1,6 +1,6 @@ id=KTKSR name=King Tweaks Reborn -version=1.8 -versionCode=180 +version=1.8.1 +versionCode=181 author=pedroginkgo description=A module which have the objective of maximize user experience. \ No newline at end of file diff --git a/system.prop b/system.prop index e4a95b3..242a1e0 100644 --- a/system.prop +++ b/system.prop @@ -5,18 +5,4 @@ # King Tweaks Reborn ######################################################################################## -# Device Spoofing. -ro.product.model=IN2025 - -# Cloudflare DNS. -net.eth0.dns1=1.1.1.1 -net.eth0.dns2=1.0.0.1 -net.dns2=1.1.1.1 -net.ppp0.dns1=1.1.1.1 -net.ppp0.dns2=1.0.0.1 -net.rmnet0.dns1=1.1.1.1 -net.rmnet0.dns2=1.0.0.1 -net.rmnet1.dns1=1.1.1.1 -net.rmnet1.dns2=1.0.0.1 -net.pdpbr1.dns1=1.1.1.1 -net.pdpbr1.dns2=1.0.0.1 \ No newline at end of file +ro.product.model= \ No newline at end of file diff --git a/system/bin/kingtweaks b/system/bin/kingtweaks index 4275cfa..f921c4c 100644 --- a/system/bin/kingtweaks +++ b/system/bin/kingtweaks @@ -1,9 +1,6 @@ #!/system/bin/sh # Written by Draco (tytydraco @github). # Modified by Pedrozzz (pedroginkgo @telegram). -# Enable cloudflare DNS by ROM (xerta555 @github). -# MMT Extended by Zackptg5 @ XDA -# Thanks to iamlazy123 @ github by his lazy tweaks project. mkdir /sdcard/KTS LOG=/sdcard/KTS/KTS.log @@ -12,7 +9,7 @@ rm $LOG # Log in white and continue (unnecessary) kmsg() { echo -e "[*] `date +%Y-%m-%d.%H:%M:%S` $@" >> $LOG - echo -e "[*] $@" + echo -e "[*] `date +%Y-%m-%d.%H:%M:%S` $@" } write() { @@ -40,8 +37,9 @@ write() { } 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 +if [ -e /sys/class/leds/vibrator/duration ] && [ -e /sys/class/leds/vibrator/activate ] +then +echo 500 > /sys/class/leds/vibrator/duration && echo 1 > /sys/class/leds/vibrator/activate fi } @@ -52,24 +50,6 @@ then exit 1 fi -# Wait 60s into boot before applying changes -while [[ `cat /proc/uptime | awk '{print $1}' | awk -F. '{print $1}'` -lt 60 ]] -do - sleep 2 -done - -kmsg "" -kmsg "---------------------------------------------------------- Info --------------------------------------------------------------------------------------------" -kmsg " 🕛 Date of execution: $(date) " -kmsg " 🔧 Device kernel: `uname -a` " -kmsg " 🛠️ SOC: $(getprop ro.board.platform) " -kmsg " ⚙️ SDK: $(getprop ro.build.version.sdk) " -kmsg " 🅰️ndroid Version: $(getprop ro.build.version.release) " -kmsg " 📱 Device: $(getprop ro.product.odm.model) " -kmsg " 👑 KTS Version: 1.8 " -kmsg "------------------------------------------------------------------------------------------------------------------------------------------------------------" -kmsg "" - setprop persist.spectrum.kernel "KTS Reborn" setprop spectrum.support "1" @@ -90,8 +70,20 @@ spectrum_mode=$(getprop persist.spectrum.profile) case "$spectrum_mode" in # Balance Profile "0") { + kmsg "" +kmsg "---------------------------------------------------------- Info --------------------------------------------------------------------------------------------" +kmsg " 🕛 Date of execution: $(date) " +kmsg " 🔧 Device kernel: `uname -a` " +kmsg " 🛠️ SOC: $(getprop ro.board.platform) " +kmsg " ⚙️ SDK: $(getprop ro.build.version.sdk) " +kmsg " 🅰️ndroid Version: $(getprop ro.build.version.release) " +kmsg " 📱 Device: $(getprop ro.product.odm.model) " +kmsg " 👑 KTS Version: 1.8.1 " +kmsg "------------------------------------------------------------------------------------------------------------------------------------------------------------" +kmsg "" + kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" - kmsg " ENABLING BALANCE PROFILE... " + kmsg " ENABLING BALANCE PROFILE... " kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" # Duration in nanoseconds of one scheduling period @@ -175,6 +167,11 @@ write "${cpu}interactive/hispeed_freq" "$UINT_MAX" fi done +write "/sys/devices/system/cpu/cpu1/online" "1" +write "/sys/devices/system/cpu/cpu2/online" "1" +write "/sys/devices/system/cpu/cpu5/online" "1" +write "/sys/devices/system/cpu/cpu6/online" "1" + kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" kmsg " TWEAKING GPU... " kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" @@ -335,28 +332,18 @@ if [[ -d "/dev/stune" ]] then write "${st}/background/schedtune.boost" "0" write "${st}/background/schedtune.prefer_idle" "0" -write "${st}/background/schedtune.colocate" "0" -write "${st}/background/schedtune.sched_boost" "0" write "${st}/foreground/schedtune.boost" "1" write "${st}/foreground/schedtune.prefer_idle" "1" -write "${st}/foreground/schedtune.colocate" "0" -write "${st}/foreground/schedtune.sched_boost" "0" write "${st}/rt/schedtune.boost" "0" write "${st}/rt/schedtune.prefer_idle" "0" -write "${st}/rt/schedtune.colocate" "0" -write "${st}/rt/schedtune.sched_boost" "0" -write "${st}/top-app/schedtune.boost" "1" +write "${st}/top-app/schedtune.boost" "5" write "${st}/top-app/schedtune.prefer_idle" "1" -write "${st}/top-app/schedtune.colocate" "0" -write "${st}/top-app/schedtune.sched_boost" "1" write "${st}/schedtune.boost" "0" write "${st}/schedtune.prefer_idle" "0" -write "${st}/schedtune.colocate" "0" -write "${st}/schedtune.sched_boost" "0" fi done @@ -401,7 +388,7 @@ fi done kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" -kmsg " DISABLING ONEPLUS CHAIN " +kmsg " DISABLING ONEPLUS CHAIN... " kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" # OP Chain disable. @@ -443,10 +430,10 @@ kmsg "-------------------------------------------------------------------------- kmsg " SETTING MIN AND MAX CPU FREQUENCY... " kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" -# Set min clock in balance profile. +# Set min and max clocks. for minclk in /sys/devices/system/cpu/cpufreq/policy*/ do -if [[ -e "/sys/devices/system/cpu/cpufreq/policy*/scaling_min_freq" ]] +if [[ -e "${minclk}scaling_min_freq" ]] then write "${minclk}scaling_min_freq" "300000" write "${minclk}scaling_max_freq" "20000000" @@ -583,18 +570,6 @@ do write "$i/tx_queue_len" "128" done -# Set cloudflare DNS, thanks to ROM ( @github) -if [ -a /system/etc/resolv.conf ]; then - mkdir -p $TMPDIR/system/etc/ - printf "nameserver 1.1.1.1\nnameserver 1.0.0.1" >> $TMPDIR/system/etc/resolv.conf - touch $TMPDIR/auto_mount -fi - -iptables -t nat -A OUTPUT -p tcp --dport 53 -j DNAT --to-destination 1.1.1.1:53 -iptables -t nat -A OUTPUT -p udp --dport 53 -j DNAT --to-destination 1.0.0.1:53 -iptables -t nat -I OUTPUT -p tcp --dport 53 -j DNAT --to-destination 1.1.1.1:53 -iptables -t nat -I OUTPUT -p udp --dport 53 -j DNAT --to-destination 1.0.0.1:53 - kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" kmsg " CALIBRATING TOUCH... " kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" @@ -652,8 +627,20 @@ vibrate_cmode };; # Performance Profile "1") { + kmsg "" +kmsg "---------------------------------------------------------- Info --------------------------------------------------------------------------------------------" +kmsg " 🕛 Date of execution: $(date) " +kmsg " 🔧 Device kernel: `uname -a` " +kmsg " 🛠️ SOC: $(getprop ro.board.platform) " +kmsg " ⚙️ SDK: $(getprop ro.build.version.sdk) " +kmsg " 🅰️ndroid Version: $(getprop ro.build.version.release) " +kmsg " 📱 Device: $(getprop ro.product.odm.model) " +kmsg " 👑 KTS Version: 1.8.1 " +kmsg "------------------------------------------------------------------------------------------------------------------------------------------------------------" +kmsg "" + kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" - kmsg " ENABLING PERFORMANCE PROFILE... " + kmsg " ENABLING PERFORMANCE PROFILE... " kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" # Duration in nanoseconds of one scheduling period @@ -673,6 +660,10 @@ kmsg "-------------------------------------------------------------------------- stop thermal-engine start perfd +kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" +kmsg " TWEAKING CPU INPUT BOOST... " +kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" + # Caf CPU Boost for caf in /sys/module/cpu_boost/parameters/ do @@ -738,7 +729,7 @@ then write "${cpu}scaling_governor" schedutil write "${cpu}schedutil/up_rate_limit_us" "$((SCHED_PERIOD / 1000))" write "${cpu}schedutil/down_rate_limit_us" "$((4 * SCHED_PERIOD / 1000))" -write "${cpu}schedutil/iowait_boost_enable" "0" +write "${cpu}schedutil/iowait_boost_enable" "1" write "${cpu}schedutil/rate_limit_us" "$((SCHED_PERIOD / 1000))" write "${cpu}schedutil/hispeed_load" "80" write "${cpu}schedutil/hispeed_freq" "$UINT_MAX" @@ -759,6 +750,11 @@ write "${cpu}interactive/hispeed_freq" "$UINT_MAX" fi done +write "/sys/devices/system/cpu/cpu1/online" "1" +write "/sys/devices/system/cpu/cpu2/online" "1" +write "/sys/devices/system/cpu/cpu5/online" "1" +write "/sys/devices/system/cpu/cpu6/online" "1" + kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" kmsg " TWEAKING GPU... " kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" @@ -774,7 +770,7 @@ write "${gpu}devfreq/adrenoboost" "0" write "${gpu}force_no_nap" "0" write "${gpu}bus_split" "1" write "${gpu}devfreq/min_freq" "100000000" -write "${gpu}devfreq/max_freq" "745000000" +write "${gpu}devfreq/max_freq" "950000000" write "${gpu}default_pwrlevel" `cat /sys/class/kgsl/kgsl-3d0/min_pwrlevel` write "${gpu}force_bus_on" "0" write "${gpu}force_clk_on" "0" @@ -917,30 +913,20 @@ for st in /dev/stune do if [[ -d "/dev/stune" ]] then -write "${st}/background/schedtune.boost" "0" +write "${st}/background/schedtune.boost" "1" write "${st}/background/schedtune.prefer_idle" "0" -write "${st}/background/schedtune.colocate" "0" -write "${st}/background/schedtune.sched_boost" "0" write "${st}/foreground/schedtune.boost" "10" write "${st}/foreground/schedtune.prefer_idle" "1" -write "${st}/foreground/schedtune.colocate" "0" -write "${st}/foreground/schedtune.sched_boost" "1" write "${st}/rt/schedtune.boost" "0" write "${st}/rt/schedtune.prefer_idle" "0" -write "${st}/rt/schedtune.colocate" "0" -write "${st}/rt/schedtune.sched_boost" "0" write "${st}/top-app/schedtune.boost" "40" write "${st}/top-app/schedtune.prefer_idle" "1" -write "${st}/top-app/schedtune.colocate" "0" -write "${st}/top-app/schedtune.sched_boost" "1" write "${st}/schedtune.boost" "0" write "${st}/schedtune.prefer_idle" "0" -write "${st}/schedtune.colocate" "0" -write "${st}/schedtune.sched_boost" "0" fi done @@ -963,13 +949,15 @@ kmsg " ENABLING DYNAMIC FSYNC... kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" # Enable dynamic_fsync. -chmod 666 /sys/kernel/dyn_fsync/dyn_fsync_active -chown root /sys/kernel/dyn_fsync/dyn_fsync_active +# Enable dynamic_fsync. if [[ -e /sys/kernel/dyn_fsync/dyn_fsync_active ]] then +chmod 666 /sys/kernel/dyn_fsync/dyn_fsync_active +chown root /sys/kernel/dyn_fsync/dyn_fsync_active write "/sys/kernel/dyn_fsync/dyn_fsync_active" "1" fi + kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" kmsg " APPLYING SCHEDULER TWEAKS... " kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" @@ -986,7 +974,7 @@ fi done kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" -kmsg " DISABLING ONEPLUS CHAIN " +kmsg " DISABLING ONEPLUS CHAIN... " kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" # OP Tweaks @@ -1028,10 +1016,10 @@ kmsg "-------------------------------------------------------------------------- kmsg " SETTING MIN AND MAX CPU FREQUENCY... " kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" -# Set max freq in performance / gaming profile. +# Set max clocks in gaming / performance profile. for minclk in /sys/devices/system/cpu/cpufreq/policy*/ do -if [[ -e "/sys/devices/system/cpu/cpufreq/policy*/scaling_min_freq" ]] +if [[ -e "${minclk}scaling_min_freq" ]] then write "${minclk}scaling_min_freq" "20000000" write "${minclk}scaling_max_freq" "20000000" @@ -1162,18 +1150,6 @@ write "${tcp}tcp_low_latency" "1" fi done -# Set cloudflare DNS. -if [ -a /system/etc/resolv.conf ]; then - mkdir -p $TMPDIR/system/etc/ - printf "nameserver 1.1.1.1\nnameserver 1.0.0.1" >> $TMPDIR/system/etc/resolv.conf - touch $TMPDIR/auto_mount -fi - -iptables -t nat -A OUTPUT -p tcp --dport 53 -j DNAT --to-destination 1.1.1.1:53 -iptables -t nat -A OUTPUT -p udp --dport 53 -j DNAT --to-destination 1.0.0.1:53 -iptables -t nat -I OUTPUT -p tcp --dport 53 -j DNAT --to-destination 1.1.1.1:53 -iptables -t nat -I OUTPUT -p udp --dport 53 -j DNAT --to-destination 1.0.0.1:53 - kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" kmsg " CALIBRATING TOUCH... " kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" @@ -1230,11 +1206,23 @@ vibrate_cmode };; # Battery Profile "2") { + kmsg "" +kmsg "---------------------------------------------------------- Info --------------------------------------------------------------------------------------------" +kmsg " 🕛 Date of execution: $(date) " +kmsg " 🔧 Device kernel: `uname -a` " +kmsg " 🛠️ SOC: $(getprop ro.board.platform) " +kmsg " ⚙️ SDK: $(getprop ro.build.version.sdk) " +kmsg " 🅰️ndroid Version: $(getprop ro.build.version.release) " +kmsg " 📱 Device: $(getprop ro.product.odm.model) " +kmsg " 👑 KTS Version: 1.8.1 " +kmsg "------------------------------------------------------------------------------------------------------------------------------------------------------------" +kmsg "" + kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" - kmsg " ENABLING BATTERY PROFILE... " + kmsg " ENABLING BATTERY PROFILE... " kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" - - # Duration in nanoseconds of one scheduling period + + # Duration in nanoseconds of one scheduling period SCHED_PERIOD="$((1 * 1000 * 1000))" # How many tasks should we have at a maximum in one scheduling period @@ -1242,7 +1230,10 @@ SCHED_TASKS="8" # Maximum unsigned integer size in C UINT_MAX="4294967295" - + +# Variable to battery % +percentage=$(cat /sys/class/power_supply/battery/capacity) + kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" kmsg " ENABLING THERMAL-ENGINE AND PERFD... " kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" @@ -1315,6 +1306,20 @@ write "${cpu}interactive/hispeed_freq" "$UINT_MAX" fi done +if [[ $percentage -le "20" ]] +then +write "/sys/devices/system/cpu/cpu1/online" "0" +write "/sys/devices/system/cpu/cpu2/online" "0" +write "/sys/devices/system/cpu/cpu5/online" "0" +write "/sys/devices/system/cpu/cpu6/online" "0" + +else [[ $percentage -ge "20" ]] +write "/sys/devices/system/cpu/cpu1/online" "1" +write "/sys/devices/system/cpu/cpu2/online" "1" +write "/sys/devices/system/cpu/cpu5/online" "1" +write "/sys/devices/system/cpu/cpu6/online" "1" +fi + kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" kmsg " TWEAKING GPU... " kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" @@ -1330,7 +1335,6 @@ write "${gpu}devfreq/adrenoboost" "0" write "${gpu}force_no_nap" "0" write "${gpu}bus_split" "1" write "${gpu}devfreq/min_freq" "100000000" -write "${gpu}devfreq/max_freq" "465000000" write "${gpu}default_pwrlevel" `cat /sys/class/kgsl/kgsl-3d0/min_pwrlevel` write "${gpu}force_bus_on" "0" write "${gpu}force_clk_on" "0" @@ -1338,6 +1342,18 @@ write "${gpu}force_rail_on" "0" fi done +# Set clock to 465 mhz in battery profile if battery < than 20% and 600 mhz if > 20% +for gpu in /sys/class/kgsl/kgsl-3d0/ +do +if [[ $percentage -le "50" && -e "${gpu}devfreq/max_freq" ]] +then +write "${gpu}devfreq/max_freq" "465000000" + +else [[ $percentage -ge "50" && -e "${gpu}devfreq/max_freq" ]] +write "${gpu}devfreq/max_freq" "600000000" +fi +done + kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" kmsg " ENABLING ADRENO IDLER... " kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" @@ -1475,28 +1491,18 @@ if [[ -d "/dev/stune" ]] then write "${st}/background/schedtune.boost" "0" write "${st}/background/schedtune.prefer_idle" "0" -write "${st}/background/schedtune.colocate" "0" -write "${st}/background/schedtune.sched_boost" "0" -write "${st}/foreground/schedtune.boost" "1" +write "${st}/foreground/schedtune.boost" "0" write "${st}/foreground/schedtune.prefer_idle" "0" -write "${st}/foreground/schedtune.colocate" "0" -write "${st}/foreground/schedtune.sched_boost" "0" write "${st}/rt/schedtune.boost" "0" write "${st}/rt/schedtune.prefer_idle" "0" -write "${st}/rt/schedtune.colocate" "0" -write "${st}/rt/schedtune.sched_boost" "0" write "${st}/top-app/schedtune.boost" "1" write "${st}/top-app/schedtune.prefer_idle" "0" -write "${st}/top-app/schedtune.colocate" "0" -write "${st}/top-app/schedtune.sched_boost" "1" write "${st}/schedtune.boost" "0" write "${st}/schedtune.prefer_idle" "0" -write "${st}/schedtune.colocate" "0" -write "${st}/schedtune.sched_boost" "0" fi done @@ -1519,10 +1525,10 @@ kmsg " ENABLING DYNAMIC FSYNC... kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" # Enable dynamic_fsync. -chmod 666 /sys/kernel/dyn_fsync/dyn_fsync_active -chown root /sys/kernel/dyn_fsync/dyn_fsync_active if [[ -e /sys/kernel/dyn_fsync/dyn_fsync_active ]] then +chmod 666 /sys/kernel/dyn_fsync/dyn_fsync_active +chown root /sys/kernel/dyn_fsync/dyn_fsync_active write "/sys/kernel/dyn_fsync/dyn_fsync_active" "1" fi @@ -1542,7 +1548,7 @@ fi done kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" -kmsg " DISABLING ONEPLUS CHAIN " +kmsg " DISABLING ONEPLUS CHAIN... " kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" # OP Tweaks @@ -1553,7 +1559,7 @@ then write "${opc}chain_on" "0" fi done - + kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" kmsg " TWEAKING KERNEL SETTINGS... " kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" @@ -1584,12 +1590,16 @@ kmsg "-------------------------------------------------------------------------- kmsg " SETTING MIN AND MAX CPU FREQUENCY... " kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" -# Set min clock in balance / battery profile. +# Set min and max clocks. for minclk in /sys/devices/system/cpu/cpufreq/policy*/ do -if [[ -e "/sys/devices/system/cpu/cpufreq/policy*/scaling_min_freq" ]] +if [[ $percentage -le "20" && -e "${minclk}scaling_min_freq" ]] then write "${minclk}scaling_min_freq" "300000" +write "${minclk}scaling_max_freq" "20000000" + +else [[ $percentage -ge "20" && -e "${minclk}scaling_min_freq" ]] +write "${minclk}scaling_min_freq" "300000" write "${minclk}scaling_max_freq" "1300000" fi done @@ -1724,18 +1734,6 @@ do write "$i/tx_queue_len" "128" done -# Set cloudflare DNS. -if [ -a /system/etc/resolv.conf ]; then - mkdir -p $TMPDIR/system/etc/ - printf "nameserver 1.1.1.1\nnameserver 1.0.0.1" >> $TMPDIR/system/etc/resolv.conf - touch $TMPDIR/auto_mount -fi - -iptables -t nat -A OUTPUT -p tcp --dport 53 -j DNAT --to-destination 1.1.1.1:53 -iptables -t nat -A OUTPUT -p udp --dport 53 -j DNAT --to-destination 1.0.0.1:53 -iptables -t nat -I OUTPUT -p tcp --dport 53 -j DNAT --to-destination 1.1.1.1:53 -iptables -t nat -I OUTPUT -p udp --dport 53 -j DNAT --to-destination 1.0.0.1:53 - kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" kmsg " CALIBRATING TOUCH... " kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" @@ -1802,8 +1800,20 @@ vibrate_cmode };; # Gaming Profile "3") { + kmsg "" +kmsg "---------------------------------------------------------- Info --------------------------------------------------------------------------------------------" +kmsg " 🕛 Date of execution: $(date) " +kmsg " 🔧 Device kernel: `uname -a` " +kmsg " 🛠️ SOC: $(getprop ro.board.platform) " +kmsg " ⚙️ SDK: $(getprop ro.build.version.sdk) " +kmsg " 🅰️ndroid Version: $(getprop ro.build.version.release) " +kmsg " 📱 Device: $(getprop ro.product.odm.model) " +kmsg " 👑 KTS Version: 1.8.1 " +kmsg "------------------------------------------------------------------------------------------------------------------------------------------------------------" +kmsg "" + kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" - kmsg " ENABLING GAMING PROFILE... " + kmsg " ENABLING GAMING PROFILE... " kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" # Duration in nanoseconds of one scheduling period @@ -1823,6 +1833,10 @@ kmsg "-------------------------------------------------------------------------- stop thermal-engine stop perfd +kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" +kmsg " TWEAKING CPU INPUT BOOST... " +kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" + # Caf CPU Boost for caf in /sys/module/cpu_boost/parameters/ do @@ -1888,7 +1902,7 @@ then write "${cpu}scaling_governor" schedutil write "${cpu}schedutil/up_rate_limit_us" "$((SCHED_PERIOD / 1000))" write "${cpu}schedutil/down_rate_limit_us" "$((4 * SCHED_PERIOD / 1000))" -write "${cpu}schedutil/iowait_boost_enable" "0" +write "${cpu}schedutil/iowait_boost_enable" "1" write "${cpu}schedutil/rate_limit_us" "$((SCHED_PERIOD / 1000))" write "${cpu}schedutil/hispeed_load" "80" write "${cpu}schedutil/hispeed_freq" "$UINT_MAX" @@ -1909,6 +1923,11 @@ write "${cpu}interactive/hispeed_freq" "$UINT_MAX" fi done +write "/sys/devices/system/cpu/cpu1/online" "1" +write "/sys/devices/system/cpu/cpu2/online" "1" +write "/sys/devices/system/cpu/cpu5/online" "1" +write "/sys/devices/system/cpu/cpu6/online" "1" + kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" kmsg " TWEAKING GPU... " kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" @@ -1943,7 +1962,7 @@ write "/sys/module/adreno_idler/parameters/adreno_idler_active" "Y" fi kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" -kmsg " TWEAKING LMK... " +kmsg " TWEAKING LMK... " kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" # Low Memory Killer Tweaks. @@ -2059,7 +2078,7 @@ lock_val 'temporary none' '/sys/class/scsi_disk/$i/cache_type' done kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" -kmsg " APPLYING SCHEDTUNE TWEAKS... " +kmsg " APPLYING SCHEDTUNE TWEAKS... " kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" # Schedtune Tweaks @@ -2067,35 +2086,25 @@ for st in /dev/stune do if [[ -d "/dev/stune" ]] then -write "${st}/background/schedtune.boost" "0" +write "${st}/background/schedtune.boost" "5" write "${st}/background/schedtune.prefer_idle" "0" -write "${st}/background/schedtune.colocate" "0" -write "${st}/background/schedtune.sched_boost" "0" write "${st}/foreground/schedtune.boost" "40" write "${st}/foreground/schedtune.prefer_idle" "1" -write "${st}/foreground/schedtune.colocate" "0" -write "${st}/foreground/schedtune.sched_boost" "1" write "${st}/rt/schedtune.boost" "0" write "${st}/rt/schedtune.prefer_idle" "0" -write "${st}/rt/schedtune.colocate" "0" -write "${st}/rt/schedtune.sched_boost" "0" write "${st}/top-app/schedtune.boost" "40" write "${st}/top-app/schedtune.prefer_idle" "1" -write "${st}/top-app/schedtune.colocate" "0" -write "${st}/top-app/schedtune.sched_boost" "1" write "${st}/schedtune.boost" "0" write "${st}/schedtune.prefer_idle" "0" -write "${st}/schedtune.colocate" "0" -write "${st}/schedtune.sched_boost" "0" fi done kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" -kmsg " APPLYING FS TWEAKS... " +kmsg " APPLYING FS TWEAKS... " kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" # FS Tweaks. @@ -2113,10 +2122,10 @@ kmsg " ENABLING DYNAMIC FSYNC... kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" # Enable dynamic_fsync. -chmod 666 /sys/kernel/dyn_fsync/dyn_fsync_active -chown root /sys/kernel/dyn_fsync/dyn_fsync_active if [[ -e /sys/kernel/dyn_fsync/dyn_fsync_active ]] then +chmod 666 /sys/kernel/dyn_fsync/dyn_fsync_active +chown root /sys/kernel/dyn_fsync/dyn_fsync_active write "/sys/kernel/dyn_fsync/dyn_fsync_active" "1" fi @@ -2136,7 +2145,7 @@ fi done kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" -kmsg " DISABLING ONEPLUS CHAIN " +kmsg " DISABLING ONEPLUS CHAIN... " kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" # OP Tweaks @@ -2178,10 +2187,10 @@ kmsg "-------------------------------------------------------------------------- kmsg " SETTING MIN AND MAX CPU FREQUENCY... " kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" -# Set max freq in performance / gaming profile. +# Set max clocks in gaming / performance profile. for minclk in /sys/devices/system/cpu/cpufreq/policy*/ do -if [[ -e "/sys/devices/system/cpu/cpufreq/policy0/scaling_min_freq" ]] +if [[ -e "${minclk}scaling_min_freq" ]] then write "${minclk}scaling_min_freq" "20000000" write "${minclk}scaling_max_freq" "20000000" @@ -2312,18 +2321,6 @@ write "${tcp}tcp_low_latency" "1" fi done -# Set cloudflare DNS. -if [ -a /system/etc/resolv.conf ]; then - mkdir -p $TMPDIR/system/etc/ - printf "nameserver 1.1.1.1\nnameserver 1.0.0.1" >> $TMPDIR/system/etc/resolv.conf - touch $TMPDIR/auto_mount -fi - -iptables -t nat -A OUTPUT -p tcp --dport 53 -j DNAT --to-destination 1.1.1.1:53 -iptables -t nat -A OUTPUT -p udp --dport 53 -j DNAT --to-destination 1.0.0.1:53 -iptables -t nat -I OUTPUT -p tcp --dport 53 -j DNAT --to-destination 1.1.1.1:53 -iptables -t nat -I OUTPUT -p udp --dport 53 -j DNAT --to-destination 1.0.0.1:53 - kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" kmsg " CALIBRATING TOUCH... " kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" @@ -2350,7 +2347,7 @@ fi done kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" -kmsg " ENABLING FORCE FAST CHARGING... " +kmsg " ENABLING FORCE FAST CHARGING... " kmsg "-------------------------------------------------------------------------------------------------------------------------------------------------" # Enable Fast Charging Rate @@ -2380,5 +2377,4 @@ vibrate_cmode };; esac done -) & exit 0 \ No newline at end of file