2018-04-10 17:58:45 +00:00
|
|
|
#!/sbin/sh
|
2018-09-02 13:03:32 +00:00
|
|
|
#
|
|
|
|
# ADDOND_VERSION=2
|
|
|
|
#
|
2018-04-10 17:58:45 +00:00
|
|
|
##########################################################################################
|
|
|
|
#
|
|
|
|
# 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
|
|
|
|
#
|
|
|
|
##########################################################################################
|
|
|
|
|
2020-10-04 17:00:50 +00:00
|
|
|
source /tmp/backuptool.functions || source /postinstall/tmp/backuptool.functions
|
2018-04-10 17:58:45 +00:00
|
|
|
|
2020-10-04 17:00:50 +00:00
|
|
|
MODID=NanoDroid
|
2018-09-08 18:02:46 +00:00
|
|
|
OUTFD=
|
2020-10-29 17:18:21 +00:00
|
|
|
VERSION=23.0.1.20201029
|
2019-06-09 20:12:18 +00:00
|
|
|
|
2020-10-08 20:17:09 +00:00
|
|
|
NANODROID_LIST=/system/addon.d/NanoDroid_FileList
|
2020-08-27 15:09:12 +00:00
|
|
|
|
2019-02-04 19:19:40 +00:00
|
|
|
print_google_apps()
|
|
|
|
{
|
|
|
|
cat <<EOF
|
|
|
|
AMAPNetworkLocation
|
2018-08-24 22:28:06 +00:00
|
|
|
BaiduNetworkLocation
|
|
|
|
BlankStore
|
2018-12-20 20:30:24 +00:00
|
|
|
ConfigUpdater
|
|
|
|
GCS
|
2018-08-24 22:28:06 +00:00
|
|
|
GmsCoreSetupPrebuilt
|
|
|
|
GmsCore_update
|
|
|
|
GoogleFeedback
|
2018-04-13 18:05:37 +00:00
|
|
|
GoogleLoginService
|
|
|
|
GoogleOneTimeInitializer
|
2018-08-24 22:01:20 +00:00
|
|
|
GoogleServicesFramework
|
2018-12-20 20:30:24 +00:00
|
|
|
GoogleConnectivityServices
|
2018-08-24 22:01:20 +00:00
|
|
|
GoogleTTS
|
2018-08-24 22:28:06 +00:00
|
|
|
LegacyNetworkLocation
|
|
|
|
MarketUpdater
|
|
|
|
MarkupGoogle
|
|
|
|
NetworkLocation
|
|
|
|
PlayGames
|
|
|
|
PlayStore
|
|
|
|
PrebuiltGmsCore
|
2018-12-20 20:30:24 +00:00
|
|
|
PrebuiltGmsCorePi
|
2018-11-29 21:22:07 +00:00
|
|
|
PrebuiltGmsCorePix
|
2018-08-24 22:28:06 +00:00
|
|
|
UnifiedNlp
|
|
|
|
Velvet
|
|
|
|
Vending
|
2019-02-04 19:19:40 +00:00
|
|
|
WhisperPush
|
|
|
|
EOF
|
|
|
|
}
|
2018-04-13 18:05:37 +00:00
|
|
|
|
2020-10-04 17:00:50 +00:00
|
|
|
is_mounted () {
|
|
|
|
grep -q "$(readlink -f ${1})" /proc/mounts 2>/dev/null
|
2019-06-09 20:12:18 +00:00
|
|
|
return $?
|
|
|
|
}
|
|
|
|
|
2018-04-10 17:58:45 +00:00
|
|
|
ui_print () {
|
2018-04-10 19:13:11 +00:00
|
|
|
echo -n -e "ui_print ${1}\n" >> /proc/self/fd/${OUTFD}
|
|
|
|
echo -n -e "ui_print\n" >> /proc/self/fd/${OUTFD}
|
2018-04-10 17:58:45 +00:00
|
|
|
}
|
|
|
|
|
2018-09-09 13:11:20 +00:00
|
|
|
grep_prop() {
|
2020-10-04 17:00:50 +00:00
|
|
|
sed -n "s/^${1}=//p" ${build_props} ${2} | head -n 1
|
2018-09-09 13:11:20 +00:00
|
|
|
}
|
2018-08-10 17:23:26 +00:00
|
|
|
|
2018-09-08 18:02:46 +00:00
|
|
|
detect_outfd () {
|
2020-10-17 21:11:34 +00:00
|
|
|
# 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)
|
2018-09-08 18:02:46 +00:00
|
|
|
}
|
|
|
|
|
2018-09-08 19:42:40 +00:00
|
|
|
backup_action () {
|
2019-06-09 20:12:18 +00:00
|
|
|
ui_print " ++ ${MODID} ${VERSION} addon.d: backup"
|
2018-09-08 19:42:40 +00:00
|
|
|
cat ${NANODROID_LIST} | while read FILE; do
|
|
|
|
echo " + backup: ${FILE}"
|
|
|
|
backup_file "${FILE}"
|
|
|
|
done
|
2020-11-02 19:23:28 +00:00
|
|
|
|
|
|
|
for file in .nanodroid-apps .nanodroid-overlay .nanodroid-setup; do
|
|
|
|
[ -f /system/addon.d/${file} ] && backup_file /system/addon.d/${file}
|
|
|
|
done
|
2019-06-09 20:12:18 +00:00
|
|
|
ui_print " ++ ${MODID} ${VERSION} addon.d: backup done"
|
2018-09-08 19:42:40 +00:00
|
|
|
}
|
2018-04-10 19:54:34 +00:00
|
|
|
|
2018-09-08 19:42:40 +00:00
|
|
|
restore_action () {
|
2019-06-09 20:12:18 +00:00
|
|
|
ui_print " ++ ${MODID} ${VERSION} addon.d: restore"
|
2018-09-08 19:42:40 +00:00
|
|
|
cat ${NANODROID_LIST} | while read FILE; do
|
|
|
|
echo " + restore: ${FILE}"
|
|
|
|
restore_file "${FILE}"
|
|
|
|
done
|
2020-11-02 19:23:28 +00:00
|
|
|
|
|
|
|
for file in .nanodroid-apps .nanodroid-overlay .nanodroid-setup; do
|
|
|
|
restore_file /system/addon.d/${file}
|
|
|
|
done
|
2019-06-09 20:12:18 +00:00
|
|
|
ui_print " ++ ${MODID} ${VERSION} addon.d: restore done"
|
2018-09-08 19:42:40 +00:00
|
|
|
}
|
2018-08-21 19:59:15 +00:00
|
|
|
|
2018-09-08 19:42:40 +00:00
|
|
|
postrestore_action () {
|
2019-06-09 20:12:18 +00:00
|
|
|
ui_print " ++ ${MODID} ${VERSION} addon.d: GApps removal"
|
2019-02-04 19:19:40 +00:00
|
|
|
print_google_apps | while read app; do
|
2020-10-17 21:31:07 +00:00
|
|
|
/system/bin/nanodroid-overlay --add ${app}
|
2018-09-09 13:11:20 +00:00
|
|
|
done
|
|
|
|
|
2019-06-09 20:12:18 +00:00
|
|
|
ui_print " ++ ${MODID} ${VERSION} addon.d: GApps removal done"
|
2018-09-09 13:11:20 +00:00
|
|
|
|
2020-11-02 19:23:28 +00:00
|
|
|
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"
|
2018-10-06 19:05:41 +00:00
|
|
|
fi
|
2018-09-08 19:42:40 +00:00
|
|
|
}
|
|
|
|
|
2020-10-17 21:31:07 +00:00
|
|
|
detect_outfd
|
|
|
|
|
|
|
|
if [ ! -r ${NANODROID_LIST} ]; then
|
|
|
|
echo "No NanoDroid installer information found!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2018-09-08 19:42:40 +00:00
|
|
|
case "${1}" in
|
|
|
|
backup)
|
2018-09-08 20:00:46 +00:00
|
|
|
backup_action
|
2018-04-10 17:58:45 +00:00
|
|
|
;;
|
|
|
|
restore)
|
2018-09-08 20:00:46 +00:00
|
|
|
restore_action
|
2018-04-10 17:58:45 +00:00
|
|
|
;;
|
|
|
|
pre-backup)
|
|
|
|
# Stub
|
|
|
|
;;
|
|
|
|
post-backup)
|
|
|
|
# Stub
|
|
|
|
;;
|
|
|
|
pre-restore)
|
|
|
|
# Stub
|
|
|
|
;;
|
|
|
|
post-restore)
|
2018-09-08 20:00:46 +00:00
|
|
|
postrestore_action
|
2018-04-10 17:58:45 +00:00
|
|
|
;;
|
|
|
|
esac
|