@@ -14,23 +14,31 @@ case "$0" in
14
14
esac ;
15
15
DIR=$( dirname " $( readlink -f " $DIR " ) " ) ;
16
16
17
+ item () { echo " \n- $@ " ; }
18
+ die () { echo " Error: $@ !" ; exit 1; }
19
+
20
+ find_busybox () {
21
+ [ -n " $BUSYBOX " ] && return 0;
22
+ local path;
23
+ for path in /data/adb/modules/busybox-ndk/system/* /busybox /data/adb/magisk/busybox /data/adb/ksu/bin/busybox /data/adb/ap/bin/busybox; do
24
+ if [ -f " $path " ]; then
25
+ BUSYBOX=" $path " ;
26
+ return 0;
27
+ fi ;
28
+ done ;
29
+ return 1;
30
+ }
31
+
17
32
if ! which wget > /dev/null || grep -q " wget-curl" $( which wget) ; then
18
- if [ -f /data/adb/modules/busybox-ndk/system/* /busybox ]; then
19
- wget () { /data/adb/modules/busybox-ndk/system/* /busybox wget " $@ " ; }
20
- elif [ -f /data/adb/magisk/busybox ] && /data/adb/magisk/busybox ping -c1 -s2 sourceforge.net 2>&1 | grep -vq " bad address" ; then
21
- wget () { /data/adb/magisk/busybox wget " $@ " ; }
22
- elif [ -f /data/adb/ksu/bin/busybox ]; then
23
- wget () { /data/adb/ksu/bin/busybox wget " $@ " ; }
24
- elif [ -f /data/adb/ap/bin/busybox ]; then
25
- wget () { /data/adb/ap/bin/busybox wget " $@ " ; }
33
+ if ! find_busybox; then
34
+ die " wget not found, install busybox" ;
35
+ elif $BUSYBOX ping -c1 -s2 android.com 2>&1 | grep -q " bad address" ; then
36
+ die " wget broken, install busybox" ;
26
37
else
27
- echo " Error: wget not found, install busybox!" ;
28
- exit 1;
38
+ wget () { $BUSYBOX wget " $@ " ; }
29
39
fi ;
30
40
fi ;
31
41
32
- item () { echo " \n- $@ " ; }
33
-
34
42
if [ " $DIR " = /data/adb/modules/playintegrityfix ]; then
35
43
DIR=$DIR /autopif;
36
44
mkdir -p $DIR ;
@@ -61,30 +69,31 @@ if [ ! -d $OUT ]; then
61
69
if grep -q " apex" $PREFIX /bin/dalvikvm; then
62
70
DALVIKVM=$PREFIX /bin/dalvikvm;
63
71
else
64
- echo ' Error: Outdated Termux packages, run "pkg upgrade" from a user prompt!' ;
65
- exit 1;
72
+ die ' Outdated Termux packages, run "pkg upgrade" from a user prompt' ;
66
73
fi ;
67
74
else
68
- echo " Error: Play Store Termux not supported, use GitHub/F-Droid Termux!" ;
69
- exit 1;
75
+ die " Play Store Termux not supported, use GitHub/F-Droid Termux" ;
70
76
fi ;
71
77
fi ;
72
78
$DALVIKVM -Xnoimage-dex2oat -cp apktool_2.0.3-dexed.jar brut.apktool.Main d -f --no-src -p $OUT -o $OUT $APKNAME || exit 1;
79
+ [ -f $OUT /res/xml/inject_fields.xml ] || die " inject_fields.xml not found" ;
73
80
fi ;
74
81
75
82
item " Converting inject_fields.xml to pif.json ..." ;
76
83
(echo ' {' ;
77
84
grep -o ' <field.*' $OUT /res/xml/inject_fields.xml | sed ' s;.*name=\(".*"\) type.* value=\(".*"\).*; \1: \2,;g' ;
78
85
echo ' "DEVICE_INITIAL_SDK_INT": "32",' ) | sed ' $s/,/\n}/' | tee pif.json;
86
+ grep -q " FINGERPRINT" pif.json || die " Failed to extract information from inject_fields.xml" ;
79
87
80
- if [ -f /data/adb/modules/playintegrityfix/migrate.sh ]; then
88
+ for MIGRATE in migrate.sh /data/adb/modules/playintegrityfix/migrate.sh; do
89
+ [ -f " $MIGRATE " ] && break ;
90
+ done ;
91
+ if [ -f " $MIGRATE " ]; then
81
92
OLDJSON=/data/adb/modules/playintegrityfix/custom.pif.json;
82
- if [ -f " $OLDJSON " ]; then
83
- grep -qE " verboseLogs|VERBOSE_LOGS" $OLDJSON && ARGS=" -a" ;
84
- fi ;
93
+ [ -f " $OLDJSON " ] && grep -qE " verboseLogs|VERBOSE_LOGS" $OLDJSON && ARGS=" -a" ;
85
94
item " Converting pif.json to custom.pif.json with migrate.sh:" ;
86
95
rm -f custom.pif.json;
87
- sh /data/adb/modules/playintegrityfix/migrate.sh -i $ARGS pif.json;
96
+ sh $MIGRATE -i $ARGS pif.json;
88
97
if [ -n " $ARGS " ]; then
89
98
grep_json () { grep -m1 " $1 " $2 | cut -d\" -f4; }
90
99
verboseLogs=$( grep_json " VERBOSE_LOGS" $OLDJSON ) ;
0 commit comments