-
Notifications
You must be signed in to change notification settings - Fork 60
/
CommonAddon
137 lines (121 loc) · 3.17 KB
/
CommonAddon
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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
#!/sbin/sh
#
# ADDOND_VERSION=2
#
##########################################################################################
#
# NanoDroid System Mode OTA survival Script
# by Nanolx
#
# Inspired by 99-flashafterupdate.sh of osm0sis @ xda-developers
# Forked from 99-magisk.sh of topjohnwu @ xda-developers
#
##########################################################################################
source /tmp/backuptool.functions || source /postinstall/tmp/backuptool.functions
MODID=NanoDroid
OUTFD=
VERSION=23.2.99999999
NANODROID_LIST=/system/addon.d/NanoDroid_FileList
print_google_apps()
{
cat <<EOF
AMAPNetworkLocation
BaiduNetworkLocation
BlankStore
ConfigUpdater
GCS
GmsCoreSetupPrebuilt
GmsCore_update
GoogleFeedback
GoogleLoginService
GoogleOneTimeInitializer
GoogleServicesFramework
GoogleConnectivityServices
GoogleTTS
LegacyNetworkLocation
MarketUpdater
MarkupGoogle
NetworkLocation
PlayGames
PlayStore
PrebuiltGmsCore
PrebuiltGmsCorePi
PrebuiltGmsCorePix
UnifiedNlp
Velvet
Vending
WhisperPush
EOF
}
ui_print () {
echo -e "ui_print ${1}" >> /proc/self/fd/${OUTFD}
echo -e "ui_print" >> /proc/self/fd/${OUTFD}
}
detect_outfd () {
# taken from Magisk
# update-binary|updater <RECOVERY_API_VERSION> <OUTFD> <ZIPFILE>
OUTFD=$(ps | grep -v 'grep' | grep -oE 'update(.*) 3 [0-9]+' | cut -d" " -f3)
[ -z $OUTFD ] && OUTFD=$(ps -Af | grep -v 'grep' | grep -oE 'update(.*) 3 [0-9]+' | cut -d" " -f3)
# update_engine_sideload --payload=file://<ZIPFILE> --offset=<OFFSET> --headers=<HEADERS> --status_fd=<OUTFD>
[ -z $OUTFD ] && OUTFD=$(ps | grep -v 'grep' | grep -oE 'status_fd=[0-9]+' | cut -d= -f2)
[ -z $OUTFD ] && OUTFD=$(ps -Af | grep -v 'grep' | grep -oE 'status_fd=[0-9]+' | cut -d= -f2)
}
backup_action () {
ui_print " ++ ${MODID} ${VERSION} addon.d: backup"
cat ${NANODROID_LIST} | while read FILE; do
echo " + backup: ${FILE}"
backup_file "${FILE}"
done
for file in .nanodroid-apps .nanodroid-overlay .nanodroid-setup; do
[ -f /system/addon.d/${file} ] && backup_file /system/addon.d/${file}
done
ui_print " ++ ${MODID} ${VERSION} addon.d: backup done"
}
restore_action () {
ui_print " ++ ${MODID} ${VERSION} addon.d: restore"
cat ${NANODROID_LIST} | while read FILE; do
echo " + restore: ${FILE}"
restore_file "${FILE}"
done
for file in .nanodroid-apps .nanodroid-overlay .nanodroid-setup; do
restore_file /system/addon.d/${file}
done
ui_print " ++ ${MODID} ${VERSION} addon.d: restore done"
}
postrestore_action () {
ui_print " ++ ${MODID} ${VERSION} addon.d: GApps removal"
print_google_apps | while read app; do
/system/bin/nanodroid-overlay --add ${app}
done
ui_print " ++ ${MODID} ${VERSION} addon.d: GApps removal done"
if [ -f /system/addon.d/.nanodroid-overlay ]; then
ui_print " ++ ${MODID} ${VERSION} addon.d: creating Overlays"
/system/bin/nanodroid-overlay --create
ui_print " ++ ${MODID} ${VERSION} addon.d: creating Overlays done"
fi
}
detect_outfd
if [ ! -r ${NANODROID_LIST} ]; then
echo "No NanoDroid installer information found!"
exit 0
fi
case "${1}" in
backup)
backup_action
;;
restore)
restore_action
;;
pre-backup)
# Stub
;;
post-backup)
# Stub
;;
pre-restore)
# Stub
;;
post-restore)
postrestore_action
;;
esac