Merge branch 'master' into 'master'

npem: add LOS network allowlisting

See merge request Nanolx/NanoDroid!44
master
Christopher Roy Bratusek 9 months ago
commit a8bf4fa5a4

@ -25,9 +25,6 @@ nlpDejavu="org.fitchfamily.android.dejavu"
nlpApple="org.microg.nlp.backend.apple"
nlpBmap="org.openbmap.unifiedNlp"
# GmsCore userId
gms_uid=$(dumpsys package com.google.android.gms | awk -F= '/userId/{print $2; exit}')
error () {
echo "!! ${@}"
exit 1
@ -64,6 +61,10 @@ permissions () {
fi
}
get_uid () {
dumpsys package ${1} | awk -F= '/userId/{print $2; exit}'
}
get_app_location () {
pm list packages -f ${1} | sed 's|package:\(.*\)=[^=]*|\1|g'
}
@ -85,12 +86,34 @@ user_install () {
esac
}
allow_networking () {
oldlist="$(settings get global uids_allowed_on_restricted_networks)"
newlist="$(echo "${oldlist}" | sed 's|;|\n|g')"
if echo "${newlist}" | grep -q "^${2}$"; then
echo "package ${1} already in LOS networking allowlist"
return
fi
newlist="$( { echo "${newlist}"; echo "${2}"; } | sort -nu)"
newlist="$(printf '%d;' ${newlist})"
newlist="${newlist%;}"
settings put global uids_allowed_on_restricted_networks "${newlist}"
echo "package ${1} added to LOS networking allowlist"
}
[[ $(whoami) = "root" ]] || [[ $(whoami) = "shell" ]] || error "not running as either ADB or root"
gms_uid=$(get_uid ${microG})
play_uid=$(get_uid ${PlayStore})
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}
if settings list global | grep -q "^uids_allowed_on_restricted_networks="; then
# both need this on LOS-based ROMs in some situations like it restricting their internet for no reason
allow_networking ${microG} ${gms_uid}
allow_networking ${PlayStore} ${play_uid}
fi;
fi
# Fake Package Signature

Loading…
Cancel
Save