-
Notifications
You must be signed in to change notification settings - Fork 27
/
install.sh
executable file
·109 lines (89 loc) · 3.28 KB
/
install.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#!/bin/sh
if [ "$1" = "" ]; then
echo "Usage: ./install.sh file.apk"
exit 0
fi
echo 'Please connect your computer with the head unit...'
adb wait-for-device
uname=`uname`
echo "OS type: $uname"
echo "Getting signature of $1..."
if [ "$uname" = "Darwin" ]; then
sig=`java -jar bin/GetAndroidSig.jar "$1" | grep "To char" | sed -E 's/^.{9}//'`
else
sig=`java -jar bin/GetAndroidSig.jar "$1" | grep "To char" | sed -r 's/^.{9}//'`
fi
echo "Signature: $sig"
echo "Getting package information... (press Control+C if you stuck here)"
if [ "$uname" = "Darwin" ]; then
package=`aapt dump permissions "$1" | head -1 | sed -E 's/^.{9}//'`
else
package=`aapt dump permissions "$1" | head -1 | sed -r 's/^.{9}//'`
fi
echo "Package name: $package"
echo "Backuping whitelist..."
adb shell "su -c 'chmod 666 /data/data/whitelist-1.0.xml'"
adb shell "cp /data/data/whitelist-1.0.xml /data/local/tmp/"
adb shell "su -c 'chmod 666 /data/local/tmp/whitelist-1.0.xml'"
adb pull /data/local/tmp/whitelist-1.0.xml whitelist-1.0.xml
echo "Preparing replacement whitelist"
cat whitelist-1.0.xml | grep -v "</applicationLists" | grep -v "</whiteList" > whitelist-1.0-new.xml
echo " <application>
<property>
<name>$package</name>
<package>$package</package>
<versionCode>1-999999999</versionCode>
<keyStoreLists> " >> whitelist-1.0-new.xml
#Need to hanlde case of sig containing multiple lines - some APKS have more than one sig
for signature in $sig; do
echo " <keyStore>$signature</keyStore> " >> whitelist-1.0-new.xml
done
echo " </keyStoreLists>
</property>
<controlData>
<withAudio>without</withAudio>
<audioStreamType>STREAM_ADA_GUIDE</audioStreamType>
<regulation>null</regulation>
<revert>no</revert>
</controlData>
</application>
</applicationLists>
</whiteList>" >> whitelist-1.0-new.xml
if [ ! -z "$sig" ]; then
echo "APK signature obtained"
else
echo "Error: APK signature NOT obtained!"
exit 1
fi
if [ ! -z "$package" ]; then
echo "Have package name: $package"
else
echo "Error: Did not get package name!"
exit 1
fi
wlcheck=`ls -al whitelist-1.0.xml | awk '{print $5}'`
if [ $wlcheck -gt 20000 ]; then
echo "Original whitelist-1.0.xml size seems okay"
else
echo "Error: Original whitelist-1.0.xml size DOES NOT seem okay!"
exit 1
fi
packagecheck=`grep $package whitelist-1.0-new.xml`
if [ ! -z "$packagecheck" ]; then
echo "Package name is present in new whitelist"
else
echo "Error: Package name is NOT present in new whitelist!"
exit 1
fi
ts=`date '+%Y-%m-%d--%H-%M-%S'`
echo "Backing up whitelist to /data/local/tmp/whitelist-1.0-$ts.xml"
adb shell "cp /data/data/whitelist-1.0.xml /data/local/tmp/whitelist-1.0-$ts.xml"
echo "Making an extra backup of whitelist on your PC..."
adb pull /data/local/tmp/whitelist-1.0-$ts.xml .
echo "Uploading whitelist to tmp..."
adb push whitelist-1.0-new.xml /data/local/tmp/whitelist-1.0-new.xml
adb shell "su -c 'cp /data/local/tmp/whitelist-1.0-new.xml /data/data/whitelist-1.0.xml'"
adb shell "su -c 'chown system:system /data/data/whitelist-1.0.xml'"
adb install -r -d $1
#adb push $1 /data/local/tmp/$1
#adb shell "su -c 'pm install -r /data/local/tmp/$1'"