-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmove_all_system_apps_to_system.sh
49 lines (49 loc) · 1.31 KB
/
move_all_system_apps_to_system.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
noDevices=$(adb devices | wc -l)
if [ $noDevices -eq '3' ]
then
echo "Device found. Proceeding."
else
echo "no device found. Exiting"
exit 1
fi
listString=$(adb shell pm list packages -f -s | grep "/data")
regex='^package:((.*)/.*)=(.*)$'
adb remount
for i in $listString; do
if [[ $i =~ $regex ]]
then
APK_PATH=${BASH_REMATCH[1]}
APK_DIR=${BASH_REMATCH[2]}
PACKAGE_NAME=$(echo ${BASH_REMATCH[3]} | tr -cd "[:print:]")
echo 'APK_PATH:'${APK_PATH}
echo 'APK_DIR:'${APK_DIR}
echo 'PACKAGE_NAME:'${PACKAGE_NAME}
rm -rf temp
mkdir temp
cd temp
#getting the APK first
adb pull ${APK_PATH} apkfile.apk
adb pull ${APK_DIR}/lib lib
#finding all so files in lib
#uninstall the app from device first
#set -x -v
adb uninstall $PACKAGE_NAME
#push all so files to /system/lib/
find lib -name '*.so' -type f | xargs -J % -t adb push % /system/lib/
# since we have uninstalled the app, the path we will get now from pm is the system path of the APK
newString=$(adb shell pm list packages -f -s ${PACKAGE_NAME})
echo 'newString: '$newString
if [[ ${newString} =~ $regex ]]
then
SYSTEM_APK_PATH=${BASH_REMATCH[1]}
echo 'SYSTEM_APK_PATH: '${SYSTEM_APK_PATH}
#now push APK to system path
adb push apkfile.apk ${SYSTEM_APK_PATH}
fi
#set +x +v
cd ..
rm -rf temp
fi
echo
done
adb reboot