-
-
Notifications
You must be signed in to change notification settings - Fork 350
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get scripts from PIFork by @osm0sis Co-authored-by: Chris Renshaw <[email protected]>
- Loading branch information
1 parent
d3c6e36
commit bf00dbf
Showing
9 changed files
with
433 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
RESETPROP="resetprop -n" | ||
[ -n "$MAGISK_VER_CODE" ] && [ "$MAGISK_VER_CODE" -lt "27003" ] && RESETPROP=resetprop_hexpatch | ||
|
||
# resetprop_hexpatch [-f|--force] <prop name> <new value> | ||
resetprop_hexpatch() { | ||
case "$1" in | ||
-f|--force) local FORCE=1; shift;; | ||
esac | ||
|
||
local NAME="$1" | ||
local NEWVALUE="$2" | ||
local CURVALUE="$(resetprop "$NAME")" | ||
|
||
[ ! "$NEWVALUE" -o ! "$CURVALUE" ] && return 1 | ||
[ "$NEWVALUE" = "$CURVALUE" -a ! "$FORCE" ] && return 2 | ||
|
||
local NEWLEN=${#NEWVALUE} | ||
if [ -f /dev/__properties__ ]; then | ||
local PROPFILE=/dev/__properties__ | ||
else | ||
local PROPFILE="/dev/__properties__/$(resetprop -Z "$NAME")" | ||
fi | ||
[ ! -f "$PROPFILE" ] && return 3 | ||
local NAMEOFFSET=$(echo $(strings -t d "$PROPFILE" | grep "$NAME") | cut -d ' ' -f 1) | ||
|
||
#<hex 2-byte change counter><flags byte><hex length of prop value><prop value + nul padding to 92 bytes><prop name> | ||
local NEWHEX="$(printf '%02x' "$NEWLEN")$(printf "$NEWVALUE" | od -A n -t x1 -v | tr -d ' \n')$(printf "%$((92-NEWLEN))s" | sed 's/ /00/g')" | ||
|
||
printf "Patch '$NAME' to '$NEWVALUE' in '$PROPFILE' @ 0x%08x -> \n[0000??$NEWHEX]\n" $((NAMEOFFSET-96)) | ||
|
||
echo -ne "\x00\x00" \ | ||
| dd obs=1 count=2 seek=$((NAMEOFFSET-96)) conv=notrunc of="$PROPFILE" | ||
echo -ne "$(printf "$NEWHEX" | sed -e 's/.\{2\}/&\\x/g' -e 's/^/\\x/' -e 's/\\x$//')" \ | ||
| dd obs=1 count=93 seek=$((NAMEOFFSET-93)) conv=notrunc of="$PROPFILE" | ||
} | ||
|
||
# resetprop_if_diff <prop name> <expected value> | ||
resetprop_if_diff() { | ||
local NAME="$1" | ||
local EXPECTED="$2" | ||
local CURRENT="$(resetprop "$NAME")" | ||
|
||
[ -z "$CURRENT" ] || [ "$CURRENT" = "$EXPECTED" ] || $RESETPROP "$NAME" "$EXPECTED" | ||
} | ||
|
||
# resetprop_if_match <prop name> <value match string> <new value> | ||
resetprop_if_match() { | ||
local NAME="$1" | ||
local CONTAINS="$2" | ||
local VALUE="$3" | ||
|
||
[[ "$(resetprop "$NAME")" = *"$CONTAINS"* ]] && $RESETPROP "$NAME" "$VALUE" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.