Skip to content

Commit

Permalink
more improvements, fixes and changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
pedrozzz0 committed Nov 6, 2020
1 parent 2d84b87 commit 7cd69f7
Show file tree
Hide file tree
Showing 10 changed files with 380 additions and 226 deletions.
16 changes: 16 additions & 0 deletions common/addon/Volume-Key-Selector/README.md
Original file line number Diff line number Diff line change
@@ -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)
75 changes: 75 additions & 0 deletions common/addon/Volume-Key-Selector/install.sh
Original file line number Diff line number Diff line change
@@ -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
Binary file not shown.
Binary file not shown.
18 changes: 13 additions & 5 deletions common/functions.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
##########################################################################################
# Functions
# MMT Extended Utility Functions
##########################################################################################

abort() {
Expand All @@ -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() {
Expand Down Expand Up @@ -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!"; }
Expand Down Expand Up @@ -146,15 +154,15 @@ 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
done
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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
123 changes: 123 additions & 0 deletions common/install.sh
Original file line number Diff line number Diff line change
@@ -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 ""
56 changes: 3 additions & 53 deletions customize.sh
Original file line number Diff line number Diff line change
@@ -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 "╭╮╭━╮ ╭━━━━╮ ╭━━━╮"
Expand All @@ -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
Expand Down Expand Up @@ -127,60 +122,15 @@ 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
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."
Expand Down
4 changes: 2 additions & 2 deletions module.prop
Original file line number Diff line number Diff line change
@@ -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.
Loading

0 comments on commit 7cd69f7

Please sign in to comment.