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

CommonInstaller: auto-detect whether we use official or Nanolx GmsCore/DroidGuard and migrate if required

This commit is contained in:
Christopher Roy Bratusek 2020-09-23 13:25:37 +02:00
parent 060e5a6492
commit c0c48a0780

View File

@ -451,40 +451,44 @@ detect_migrate_microg () {
GMSCORE_PATH=$(find /data/app -type d -name 'com.google.android.gms-*' 2>/dev/null)
if [ ! -z ${GMSCORE_PATH} ]; then
if [ -n "${1}" ]; then
if ! ${UNZIP} -l "${GMSCORE_PATH}/base.apk" | grep META-INF/NANOLX.RSA 2>/dev/null; then
decho " + Removing Official microG GmsCore in favor of NanoDroid microG GmsCore"
rm -rf "${GMSCORE_PATH}"
if ${UNZIP} -l "${MODPATH}/system/priv-app/GmsCore/GmsCore.apk" | grep META-INF/NANOLX.RSA 2>/dev/null; then
GMSCORE_BUILD=Nanolx
else GMSCORE_BUILD=Official
fi
decho " + Resetting GCM/FCM connection of all apps to allow re-registration"
find /data/data/*/shared_prefs -name com.google.android.gms.*.xml -delete
fi
else
if ${UNZIP} -l "${GMSCORE_PATH}/base.apk" | grep META-INF/NANOLX.RSA 2>/dev/null; then
decho " + Removing NanoDroid microG GmsCore in favor of Official microG GmsCore"
rm -rf "${GMSCORE_PATH}"
if ${UNZIP} -l "${GMSCORE_PATH}/base.apk" | grep META-INF/NANOLX.RSA 2>/dev/null; then
GMSCORE_LOCAL=Nanolx
else GMSCORE_LOCAL=Official
fi
decho " + Resetting GCM/FCM connection of all apps to allow re-registration"
find /data/data/*/shared_prefs -name com.google.android.gms.*.xml -delete
fi
if [ "${GMSCORE_LOCAL}" != "${GMSCORE_BUILD}" ]; then
decho " + Removing ${GMSCORE_LOCAL} microG GmsCore in favor of ${GMSCORE_BUILD} microG GmsCore"
rm -rf "${GMSCORE_PATH}"
decho " + Resetting GCM/FCM connection of all apps to allow re-registration"
find /data/data/*/shared_prefs -name com.google.android.gms.*.xml -delete
fi
fi
}
detect_migrate_droidguard () {
DROIDGUARD_PATH=$(find /data/app -type d -name 'org.microg.gms.droidguard-*' 2>/dev/null)
DROIDGUARD_TYPE="Nanolx"
if [ ! -z ${DROIDGUARD_PATH} ]; then
if [ -n "${1}" ]; then
if ! ${UNZIP} -l "${DROIDGUARD_PATH}/base.apk" | grep META-INF/NANOLX.RSA 2>/dev/null; then
decho " + Removing Official DroidGuard in favor of NanoDroid DroidGuard"
rm -rf "${DROIDGUARD_PATH}"
fi
else
if ${UNZIP} -l "${DROIDGUARD_PATH}/base.apk" | grep META-INF/NANOLX.RSA 2>/dev/null; then
decho " + Removing NanoDroid DroidGuard in favor of Official DroidGuard"
rm -rf "${DROIDGUARD_PATH}"
fi
if ${UNZIP} -l "${MODPATH}/system/papp/DroidGuard/DroidGuard.apk" | grep META-INF/NANOLX.RSA 2>/dev/null; then
DROIDGUARD_BUILD=Nanolx
else DROIDGUARD_BUILD=Official
fi
if ${UNZIP} -l "${DROIDGUARD_PATH}/base.apk" | grep META-INF/NANOLX.RSA 2>/dev/null; then
DROIDGUARD_LOCAL=Nanolx
else DROIDGUARD_LOCAL=Official
fi
if [ "${DROIDGUARD_LOCAL}" != "${DROIDGUARD_TYPE}" ]; then
decho " + Removing ${DROIDGUARD_LOCAL} DroidGuard in favor of ${DROIDGUARD_BUILD} DroidGuard"
rm -rf "${DROIDGUARD_PATH}"
fi
fi
}
@ -1096,20 +1100,17 @@ install_microg () {
print_info " ++ Radiocell location backend"
fi
# migrate from Nanolx microG GmsCore to Official microG GmsCore
detect_migrate_microg
# migrate from Official DroidGuard to Nanolx DroidGuard
detect_migrate_droidguard reverse
print_info " ++ microG GmsCore"
nanodroid_install_apk GmsCore
detect_migrate_microg
if [ "${nanodroid_microg}" -ne 2 ]; then
for app in GsfProxy DroidGuard; do
nanodroid_install_apk ${app}
done
detect_migrate_droidguard
${NANODROID_BINDIR}/nanodroid-overlay --add GmsDroidGuard
fi