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
|
|
|
|
#
|
|
|
|
##########################################################################################
|
|
|
|
|
2018-09-08 19:42:40 +00:00
|
|
|
source /tmp/backuptool.functions
|
2018-04-10 17:58:45 +00:00
|
|
|
|
|
|
|
MODID=@MODID@
|
2018-09-08 18:02:46 +00:00
|
|
|
OUTFD=
|
2019-08-11 20:04:44 +00:00
|
|
|
VERSION=22.4.20190811
|
2019-06-09 20:12:18 +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
|
|
|
|
2019-02-04 19:19:40 +00:00
|
|
|
print_google_data ()
|
|
|
|
{
|
|
|
|
cat <<EOF
|
|
|
|
com.amap.android.location
|
2018-08-24 22:28:06 +00:00
|
|
|
com.baidu.location
|
|
|
|
com.google.android.location
|
2018-08-10 17:23:26 +00:00
|
|
|
org.microg.nlp
|
2019-02-04 19:19:40 +00:00
|
|
|
org.microg.unifiednlp
|
|
|
|
EOF
|
|
|
|
}
|
2018-08-10 17:23:26 +00:00
|
|
|
|
2018-10-06 19:05:41 +00:00
|
|
|
# check for configuration files
|
2019-06-30 05:01:23 +00:00
|
|
|
config_locations="/data/media/0 /external_sd /sdcard1 /data"
|
2018-10-06 19:05:41 +00:00
|
|
|
|
|
|
|
get_config () {
|
|
|
|
config=""
|
|
|
|
config_exists=0
|
|
|
|
for path in ${config_locations}; do
|
|
|
|
if test -r "${path}/.nanodroid-${1}"; then
|
|
|
|
config="${path}/.nanodroid-${1}"
|
|
|
|
config_exists=1
|
|
|
|
return
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2019-06-09 20:12:18 +00:00
|
|
|
is_mounted() {
|
|
|
|
if [ ! -z "$2" ]; then
|
|
|
|
cat /proc/mounts | grep $1 | grep $2, >/dev/null
|
|
|
|
else
|
|
|
|
cat /proc/mounts | grep $1 >/dev/null
|
|
|
|
fi
|
|
|
|
return $?
|
|
|
|
}
|
|
|
|
|
|
|
|
if (is_mounted /data); then
|
|
|
|
mount -orw,remount /data >/dev/null
|
|
|
|
else mount -orw /data >/dev/null
|
|
|
|
fi
|
|
|
|
|
2018-08-21 19:34:56 +00:00
|
|
|
if [ ! -d /system/xbin ]; then
|
|
|
|
NANODROID_BINDIR=/system/bin
|
|
|
|
else NANODROID_BINDIR=/system/xbin
|
|
|
|
fi
|
|
|
|
|
2018-08-21 19:59:15 +00:00
|
|
|
if [ -r /data/adb/.nanodroid-list ]; then
|
|
|
|
NANODROID_LIST=/data/adb/.nanodroid-list
|
|
|
|
elif [ -r /data/adb/NanoDroid_FileList ]; then
|
|
|
|
NANODROID_LIST=/data/adb/NanoDroid_FileList
|
|
|
|
else
|
|
|
|
echo "No installer information found!"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
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() {
|
|
|
|
REGEX="${1}"
|
|
|
|
shift
|
|
|
|
FILES="${@}"
|
|
|
|
[ -z "${@}" ] && FILES='/system/build.prop'
|
|
|
|
sed -n "s/^${REGEX}=//p" ${FILES} | \
|
|
|
|
head -n 1
|
|
|
|
}
|
2018-08-10 17:23:26 +00:00
|
|
|
|
2018-09-09 13:11:20 +00:00
|
|
|
set_ldlibrarypath () {
|
|
|
|
SDK_VERSION=$(grep_prop ro.build.version.sdk)
|
|
|
|
|
|
|
|
ABI=$(grep_prop ro.product.cpu.abi | cut -c-3)
|
|
|
|
ABI2=$(grep_prop ro.product.cpu.abi2 | cut -c-3)
|
|
|
|
ABILONG=$(grep_prop ro.product.cpu.abi)
|
|
|
|
|
|
|
|
OLD_LD=${LD_LIBRARY_PATH}
|
|
|
|
OLD_PATH=${PATH}
|
|
|
|
|
|
|
|
ARCH=arm
|
|
|
|
|
|
|
|
[ "$ABI" = "x86" ] && ARCH=x86
|
|
|
|
[ "$ABI2" = "x86" ] && ARCH=x86
|
|
|
|
[ "$ABILONG" = "arm64-v8a" ] && ARCH=arm64
|
2018-10-18 17:58:13 +00:00
|
|
|
[ "$ABILONG" = "x86_64" ] && ARCH=x86_64
|
2018-09-09 13:11:20 +00:00
|
|
|
|
|
|
|
case ${ARCH} in
|
|
|
|
arm | x86 )
|
|
|
|
export LD_LIBRARY_PATH=/system/lib:/system/vendor/lib:/vendor/lib
|
|
|
|
;;
|
|
|
|
|
|
|
|
arm64 | x86_64 )
|
|
|
|
export LD_LIBRARY_PATH=/system/lib64:/system/vendor/lib64:/vendor/lib64
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
export PATH=/system/bin:/system/xbin:${PATH}
|
2018-04-13 18:05:37 +00:00
|
|
|
}
|
|
|
|
|
2018-09-08 18:02:46 +00:00
|
|
|
detect_outfd () {
|
|
|
|
if [ -z $OUTFD ] || readlink /proc/$$/fd/$OUTFD | grep -q /tmp; then
|
|
|
|
# We will have to manually find out OUTFD
|
|
|
|
for FD in `ls /proc/$$/fd`; do
|
|
|
|
if readlink /proc/$$/fd/$FD | grep -q pipe; then
|
|
|
|
if ps | grep -v grep | grep -q " 3 $FD "; then
|
|
|
|
OUTFD=$FD
|
|
|
|
break
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2018-09-08 17:21:36 +00:00
|
|
|
detect_outfd
|
|
|
|
|
2018-09-08 19:42:40 +00:00
|
|
|
backup_action () {
|
|
|
|
sleep 5
|
|
|
|
|
2019-04-03 20:19:05 +00:00
|
|
|
mount /data
|
|
|
|
|
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
|
|
|
|
|
|
|
|
if test -h /system/fonts/Roboto-Regular.ttf; then
|
|
|
|
CUSTOM_FONT="$(basename $(readlink /system/fonts/Roboto-Regular.ttf) .ttf)"
|
2018-09-09 13:11:20 +00:00
|
|
|
ui_print " ++ ${MODID} addon.d: detected NanoDroid-Font (${CUSTOM_FONT})"
|
2018-04-10 19:54:34 +00:00
|
|
|
|
2018-09-08 19:42:40 +00:00
|
|
|
echo CUSTOM_FONT=${CUSTOM_FONT} > /tmp/nanodroid_font
|
|
|
|
fi
|
|
|
|
|
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 () {
|
|
|
|
sleep 5
|
|
|
|
|
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
|
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 () {
|
|
|
|
sleep 5
|
|
|
|
|
2018-09-09 13:11:20 +00:00
|
|
|
set_ldlibrarypath
|
|
|
|
|
2018-09-08 19:42:40 +00:00
|
|
|
if [ -f /tmp/nanodroid_font ]; then
|
|
|
|
source /tmp/nanodroid_font
|
2019-06-09 20:12:18 +00:00
|
|
|
ui_print " ++ ${MODID} ${VERSION} addon.d: restoring NanoDroid-Font (${CUSTOM_FONT})"
|
2018-09-08 19:42:40 +00:00
|
|
|
|
|
|
|
${NANODROID_BINDIR}/nanodroid-font -s "${CUSTOM_FONT}"
|
|
|
|
rm /tmp/nanodroid_font
|
|
|
|
fi
|
|
|
|
|
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
|
2018-09-09 13:11:20 +00:00
|
|
|
${NANODROID_BINDIR}/nanodroid-overlay --add ${app}
|
|
|
|
done
|
|
|
|
|
2019-02-04 19:19:40 +00:00
|
|
|
print_google_data | while read app; do
|
2018-09-09 13:11:20 +00:00
|
|
|
rm -rf /data/data/${app}
|
|
|
|
rm -rf /data/user/*/${app}
|
|
|
|
rm -rf /data/user_de/*/${app}
|
|
|
|
rm -rf /data/app/${app}-*
|
|
|
|
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
|
|
|
|
2018-10-06 19:05:41 +00:00
|
|
|
|
|
|
|
get_config setup
|
|
|
|
if [ "${config_exists}" -eq 1 ]; then
|
|
|
|
source "${config}"
|
|
|
|
if [ "${nanodroid_overlay}" -eq 1 ]; then
|
2019-06-09 20:12:18 +00:00
|
|
|
ui_print " ++ ${MODID} ${VERSION} addon.d: creating Overlays"
|
2018-10-06 19:05:41 +00:00
|
|
|
${NANODROID_BINDIR}/nanodroid-overlay --create
|
2019-06-09 20:12:18 +00:00
|
|
|
ui_print " ++ ${MODID} ${VERSION} addon.d: creating Overlays done"
|
2018-10-06 19:05:41 +00:00
|
|
|
fi
|
|
|
|
fi
|
2018-09-09 13:11:20 +00:00
|
|
|
|
|
|
|
export PATH=${OLD_PATH}
|
|
|
|
export LD_LIBRARY_PATH=${OLD_LD}
|
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
|
|
|
|
|