npem: install microG APKs as user app

The init script was used to do it before, but init.d has been all but
abandoned by ROMs universally, so effectively the only situation in which
the init script runs is for Magisk.

This change will be very helpful for non-Magisk users, as they will no
longer have to extract and install the APK by hand.

Also deduplicate code from init script and make it just call npem.
pull/30/head
FriendlyNeighborhoodShane 2 years ago
parent 6489b85d56
commit dd25765cb6

@ -65,8 +65,35 @@ permissions () {
fi
}
get_app_location () {
pm list packages -f ${1} | sed 's|package:\(.*\)=[^=]*|\1|g'
}
user_install_app () {
pm install -r ${1}
}
user_install () {
check_package ${1} || return
loc=$(get_app_location ${1})
case ${loc} in
/data/* ) echo "package ${1} already is user app" ;;
* )
user_install_app ${loc} && \
echo "package ${1} installed as user app" || \
echo "failed to install package ${1} as user app"
;;
esac
}
[[ $(whoami) = "root" ]] || [[ $(whoami) = "shell" ]] || error "not running as either ADB or root"
if [ "$(getprop ro.build.version.sdk)" -ge 29 ]; then
# microG GmsCore needs to be installed as user app for all permissions to be granted
# see https://github.com/microg/android_packages_apps_GmsCore/issues/1100#issuecomment-711088518
user_install ${microG}
fi
# Fake Package Signature
permissions ${microG} ${perm_fake}
permissions ${PlayStore} ${perm_fake}

@ -4,9 +4,5 @@
# Wait for bootup
while true; do [ "$(getprop sys.boot_completed)" = "1" ] && break; sleep 5; done;
# Fix GMS permission troubles
apk="/system/priv-app/MicroGGMSCore/MicroGGMSCore.apk";
[ -f "$apk" ] && pm install -r "$apk";
# Grant permissions
npem;

Loading…
Cancel
Save