With the previous install script we'd try to mount /system
which is in fstab on lineage recovery, but on Q and up recoveries
recovery has it's own /system and all the executables are in
/system/bin rather than /sbin, resulting in tools like "chcon"
missing after mounting /system
Also on dynamic partitions devices /system is not in fstab
due to the block device being only created when logical
partitions are mapped, support that case as well
Most of the code is taken from
https://gitlab.com/MindTheGapps/vendor_gapps/-/blob/tau/build/meta/com/google/android/update-binary
Recently there have been reports of internet being inaccessible to Playstore
on dirty flashes. Android added a permission whitelist for internet, similar
to for background location, so this might fix it being missing.
I messed up with the last fix. While that solved the case where there were
both 'granted=true' and 'granted=false' entries, it introduced a regression.
It was written with the assumption that whenever a permission is not granted,
there will be 'granted=false' entries. That assumption was not tested well
at the time, and further testing has revealed that there are also many
situations where there are no 'granted=' entries for permissions at all, not
even 'false'.
Since there is no defined spec for the output of dumpsys, we just do a
pessimistic case-by-case parsing of its output.
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.
Sometimes when a permission is not granted (e.g. when a default permission
to a system app is ungranted by the user), dumpsys emits two lines about
it, one with granted=true and the GRANTED_BY_DEFAULT flag.
Since we are not properly parsing flags and getting the full context, just
reverse the check to make sure the value doesn't fall through.
A 'false negative' grant won't hurt anyway.
MinMicroG has always had to modify npem for its own apps, but now NanoDroid
seems to have gone on hiatus, and important changes are sitting in PRs.
I fgfure it'd be more convenient if we just maintain a clone in-tree and
keep it up to date with NanoDroid's changes.