Skip to content

Commit

Permalink
autopif.sh: retain previous Advanced Settings values, fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
osm0sis committed Aug 7, 2024
1 parent adcdd80 commit 44420c8
Showing 1 changed file with 15 additions and 4 deletions.
19 changes: 15 additions & 4 deletions module/autopif.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ esac;
DIR=$(dirname "$(readlink -f "$DIR")");

if ! which wget >/dev/null || grep -q "wget-curl" $(which wget); then
if [ -f /data/adb/magisk/busybox ]; then
if [ -f /data/adb/magisk/busybox ] && /data/adb/magisk/busybox ping -c1 -s2 sourceforge.net 2>&1 | grep -vq "bad address"; then
wget() { /data/adb/magisk/busybox wget "$@"; }
elif [ -f /data/adb/ksu/bin/busybox ]; then
wget() { /data/adb/ksu/bin/busybox wget "$@"; }
Expand Down Expand Up @@ -73,15 +73,26 @@ fi;
item "Converting inject_fields.xml to pif.json ...";
(echo '{';
grep -o '<field.*' $OUT/res/xml/inject_fields.xml | sed 's;.*name=\(".*"\) type.* value=\(".*"\).*; \1: \2,;g';
echo ' "FIRST_API_LEVEL": "25",' ) | sed '$s/,/\n}/' | tee pif.json;
echo ' "DEVICE_INITIAL_SDK_INT": "25",' ) | sed '$s/,/\n}/' | tee pif.json;

if [ -f /data/adb/modules/playintegrityfix/migrate.sh ]; then
if [ -f /data/adb/modules/playintegrityfix/custom.pif.json ]; then
grep -qE "verboseLogs|VERBOSE_LOGS" /data/adb/modules/playintegrityfix/custom.pif.json && ARGS="-a";
OLDJSON=/data/adb/modules/playintegrityfix/custom.pif.json;
if [ -f "$OLDJSON" ]; then
grep -qE "verboseLogs|VERBOSE_LOGS" $OLDJSON && ARGS="-a";
fi;
item "Converting pif.json to custom.pif.json with migrate.sh:";
rm -f custom.pif.json;
sh /data/adb/modules/playintegrityfix/migrate.sh -i $ARGS pif.json;
if [ -n "$ARGS" ]; then
grep_json() { grep -m1 "$1" $2 | cut -d\" -f4; }
verboseLogs=$(grep_json "VERBOSE_LOGS" $OLDJSON);
ADVSETTINGS="spoofBuild spoofProps spoofProvider spoofSignature verboseLogs";
for SETTING in $ADVSETTINGS; do
eval [ -z \"\$$SETTING\" ] \&\& $SETTING=$(grep_json "$SETTING" $OLDJSON);
eval TMPVAL=\$$SETTING;
[ -n "$TMPVAL" ] && sed -i "s;\($SETTING\": \"\).;\1$TMPVAL;" custom.pif.json;
done;
fi;
cat custom.pif.json;
fi;

Expand Down

0 comments on commit 44420c8

Please sign in to comment.