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

151 lines
3.6 KiB
Bash

#!/sbin/sh
##########################################################################################
#
# 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
#
##########################################################################################
. /tmp/backuptool.functions
MODID=@MODID@
OUTFD=$(ps | grep -v grep | grep -oE "update(.*)" | cut -d" " -f3)
GOOGLE_APPS="GoogleFeedback
GoogleLoginService
GoogleOneTimeInitializer
GoogleServicesFramework
MarketUpdater
PlayGames
Velvet
GmsDroidGuard
YouTube
GmsCore_update
GmsCoreSetupPrebuilt
PrebuiltGmsCore
WhisperPush
BlankStore
FDroidPriv
PlayStore
Vending
AMAPNetworkLocation
BaiduNetworkLocation
LegacyNetworkLocation
NetworkLocation
UnifiedNlp
DejaVuBackend
DejaVuNlpBackend
IchnaeaNlpBackend
MozillaNlpBackend
NominatimGeocoderBackend
NominatimNlpBackend
com.mgoogle.android.gms
com.google.android.gms
com.google.android.feedback
com.google.android.gsf.login
com.google.android.gsf
com.android.vending
org.microg.gms.droidguard
org.schabi.newpipe
com.google.android.youtube
com.qualcomm.location
com.amap.android.location
com.baidu.location
com.google.android.location
org.microg.nlp
org.microg.unifiednlp
com.google.android.maps
org.fitchfamily.android.dejavu
org.microg.nlp.backend.ichnaea
org.microg.nlp.backend.nominatim"
ui_print () {
echo -n -e "ui_print ${1}\n" >> /proc/self/fd/${OUTFD}
echo -n -e "ui_print\n" >> /proc/self/fd/${OUTFD}
}
backup_nlpconflicts () {
for app in ${GOOGLE_APPS}; do
if [ -d "/system/priv-app/${app}" ]; then
mkdir -p /sdcard/nanodroid_backups/priv-app/
rm -rf /sdcard/nanodroid_backups/priv-app/${app}
mv /system/priv-app/${app} /sdcard/nanodroid_backups/priv-app/
ui_print " "
ui_print " ++ Moving ${app} to /sdcard/nanodroid_backups/"
ui_print " ++ it conflicts with microG/location backends"
ui_print " "
elif [ -d "/system/app/${app}" ]; then
mkdir -p /sdcard/nanodroid_backups/app/
rm -rf /sdcard/nanodroid_backups/app/${app}
mv /system/app/${app} /sdcard/nanodroid_backups/app/
ui_print " "
ui_print " ++ Moving ${app} to /sdcard/nanodroid_backups/"
ui_print " ++ it conflicts with microG/location backends"
ui_print " "
fi
done
}
case "${1}" in
backup)
if [ -r /data/adb/.nanodroid-list ]; then
ui_print "${MODID} addon.d: backup"
cat /data/adb/.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"
fi
;;
restore)
if [ -r /data/adb/.nanodroid-list ]; then
ui_print "${MODID} addon.d: restore"
cat /data/adb/.nanodroid-list | while read FILE; do
echo " + restore: ${FILE}"
restore_file "${FILE}"
done
ui_print "${MODID} addon.d: restore done"
fi
;;
pre-backup)
# Stub
;;
post-backup)
# Stub
;;
pre-restore)
# Stub
;;
post-restore)
if [ -f /tmp/nanodroid_font ]; then
. /tmp/nanodroid_font
ui_print " ${MODID} addon.d: restoring NanoDroid-Font (${CUSTOM_FONT})"
if [ -f /system/xbin/nanodroid-font ]; then
/system/xbin/nanodroid-font -s "${CUSTOM_FONT}"
elif [ -f /system/bin/nanodroid-font ]; then
/system/bin/nanodroid-font -s "${CUSTOM_FONT}"
fi
rm /tmp/nanodroid_font
fi
backup_nlpconflicts
;;
esac