2
0
mirror of https://gitlab.com/Nanolx/NanoDroid synced 2024-10-31 09:20:23 +00:00
NanoDroid/CommonAddon
2018-09-08 22:00:46 +02:00

176 lines
3.4 KiB
Bash

#!/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
MODID=@MODID@
OUTFD=
GOOGLE_APPS="AMAPNetworkLocation
BaiduNetworkLocation
BlankStore
com.qualcomm.location
DejaVuBackend
DejaVuNlpBackend
FDroidPriv
GmsCoreSetupPrebuilt
GmsCore_update
GmsDroidGuard
GoogleFeedback
GoogleLoginService
GoogleOneTimeInitializer
GoogleServicesFramework
GoogleTTS
IchnaeaNlpBackend
LegacyNetworkLocation
MarketUpdater
MarkupGoogle
MozillaNlpBackend
NetworkLocation
NominatimGeocoderBackend
NominatimNlpBackend
PlayGames
PlayStore
PrebuiltGmsCore
UnifiedNlp
Velvet
Vending
WhisperPush
YouTube"
GOOGLE_DATA="com.amap.android.location
com.baidu.location
com.google.android.feedback
com.google.android.gsf.login
com.google.android.location
com.google.android.youtube
com.mgoogle.android.gms
com.qualcomm.location
org.microg.nlp
org.microg.unifiednlp"
if [ ! -d /system/xbin ]; then
NANODROID_BINDIR=/system/bin
else NANODROID_BINDIR=/system/xbin
fi
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
ui_print () {
echo -n -e "ui_print ${1}\n" >> /proc/self/fd/${OUTFD}
echo -n -e "ui_print\n" >> /proc/self/fd/${OUTFD}
}
solve_gappsconflicts () {
for app in ${GOOGLE_APPS}; do
${NANODROID_BINDIR}/nanodroid-overlay --add ${app}
done
for app in ${GOOGLE_DATA}; do
rm -rf /data/data/${app}
rm -rf /data/user/*/${app}
rm -rf /data/user_de/*/${app}
rm -rf /data/app/${app}-*
done
}
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
}
detect_outfd
backup_action () {
sleep 5
ui_print "${MODID} addon.d: backup"
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)"
ui_print " ${MODID} addon.d: detected NanoDroid-Font (${CUSTOM_FONT})"
echo CUSTOM_FONT=${CUSTOM_FONT} > /tmp/nanodroid_font
fi
ui_print "${MODID} addon.d: backup done"
}
restore_action () {
sleep 5
ui_print "${MODID} addon.d: restore"
cat ${NANODROID_LIST} | while read FILE; do
echo " + restore: ${FILE}"
restore_file "${FILE}"
done
ui_print "${MODID} addon.d: restore done"
}
postrestore_action () {
sleep 5
if [ -f /tmp/nanodroid_font ]; then
source /tmp/nanodroid_font
ui_print " ${MODID} addon.d: restoring NanoDroid-Font (${CUSTOM_FONT})"
${NANODROID_BINDIR}/nanodroid-font -s "${CUSTOM_FONT}"
rm /tmp/nanodroid_font
fi
solve_gappsconflicts
}
case "${1}" in
backup)
backup_action
;;
restore)
restore_action
;;
pre-backup)
# Stub
;;
post-backup)
# Stub
;;
pre-restore)
# Stub
;;
post-restore)
postrestore_action
;;
esac