Open TontyTon opened 4 years ago
Same with lineageos 16 (android 9)
I have an extra phone running LineageOS 17.1 without GApps on which I would like to use UnifiedNlp, I would like to volunteer to do testing, is there any way where the installation process is documented? I would like to help in some way to get it working.
I put some effort to get it working on Android 9 / Pie / LineageOS 16.0 as privileged app in /system/priv-app. Unssuccessful, BUT at least I know why it's not working:
the internal package name for UnifiedNLP is "org.microg.nlp", for NetworkLocation it's "com.google.android.gms".
therefore UnifiedNLP can live BESIDE Gapps, and NetworkLocation is a REPLACEMENT for Gapps (same package name).
to make Android 9 boot with UnifiedNLP installed in priv-apps you need to use the 'permission white listing' as also described in https://github.com/microg/UnifiedNlp/issues/181, but you have to change the package name in the mentioned permission file (e.g. https://github.com/microg/UnifiedNlp/issues/181#issuecomment-626200709)
The entry point for loading / activating the location services is in LocationMangerService#L640
this goes on to LocationProviderProxy#L77 which finally creates a ServiceWatcher for org.microg.nlp with 3 important parameters:
the first one means: the OS is free to choose one from the array in initialPackageNamesResId (second one would be the packagename, if the OS wouldn't be free to choose)
the constructor of the ServiceWatcher "collects the signatures" of the allowed packages in initialPackageNamesRes.
I pulled /system/framework-res.apk from my phone, decompiled with 'java -jar apktool_2.4.1.jar d framework-res.apk' and could see, that there are 2 possible packages on my phone 'com.google.android.gms' and 'com.android.location.fused'.
the ServiceWatcher than tries to start the location service of UnifiedNLP and checks the signature
this will fail because the signature of org.microg.nlp is NOT a signature which were collected during the "collect signatures of allowed apps"
so currently the main blocker to get UnifiedNLP working is the setting for 'config_locationProviderPackageNames' in framework-res.
I already tried to alter the framework-res.apk, sign it (with my own keys) and push it back, but then my phone won't boot -> the change of framework-res could be working on phones where signature spoofing is possible. I'm not sure about that, did not look into "signature spoofing"
I already tried to create a runtime overlay which allowed me to overwrite some settings in framework-res, but not 'config_locationProviderPackageNames'. I guess the startup / creation of the location services is to early / to deep in the system to work for an overlay. (The relevant lines of code were running in "system process" early at boot)
my last idea for a possible solution is the change of the settings in the ROM
These are my findings so far.
Somebody willing to build a ROM to check this out? I'll contact the maintainer of the ROM for my phone and ask for a change framework-res. I'll update you if this works out. Maybe someone has another idea?
cc: @TontyTon
@greenflash1986 Ya, good findings. Maybe this will help @mar-v-in . I will also try overlay as I saw that stock roms add their packages to network location providers. but don't know how to compile it to apk file.
Hi there. It worked out and I already created a PR for LineageOS 16.0 here. https://review.lineageos.org/c/LineageOS/android_vendor_lineage/+/295384/2 After I figured out how the development is working in LOS I will push it up to 18.
Some additional findings: after the collection of the signatures the ServiceWatcher asks for all packages which define an implementation of the locationservice.v3 and compares them with the selected signatures. After that it checks the metadata of the package for the "serviceVersion" and the package with the highest version wins.
I had to compile version 1.6.8 with serviceVersion = 3 to get it to work together with Gapps. I were unable to find a way to change this metadata after build but I would be ok with that if I could NOT use google location provider beside Unified and simple install a version with a higher serviceVersion in the metadata.
@TontyTon you can have a look at https://github.com/greenflash1986/UnifiedNlpOverlay. There's also a description how to compile it in the readme. You have to make a difference between overlay for compile time and runtime overlay. The provided patch for LineageOS is for compile time. I could not bring the runtime overlay to work as it seems that the location provider thing is done way before any runtime overlays are loaded.
I too got unifiedNlp working with A10, just with an overlay (in vendor partition (if it makes any difference)), not making any other changes. But only adding 'org.microg.nlp' to 'config_locationProviderPackageNames' didn't work.
I added all the following to strings.xml, I think some of these are not needed.
<string name="config_geocoderProviderPackageName">org.microg.nlp</string>
<string name="config_networkLocationProviderPackageName">org.microg.nlp</string>
<string name="config_osNetworkLocationProviderPackageName">org.microg.nlp</string>
<string name="config_regionNetworkLocationProviderPackageName">org.microg.nlp</string>
<string name="config_hardwareFlpPackageName">org.microg.nlp</string>
<string name="config_fusedLocationProviderPackageName">org.microg.nlp</string>
<string name="config_defaultNetworkRecommendationProviderPackage">org.microg.nlp</string>
And added 'org.microg.nlp' to the following arrays in arrays.xml
<string-array name="config_locationProviderPackageNames">
<string-array name="config_networkLocationProviderPackageNames">
I uploaded the overlay I used in https://github.com/TontyTon/Microg-UnifiedNlp-Overlay
@TontyTon good job! After some busy weeks working I had the time to do some research with your solution. First things first: I was able to bring it to work. Thank you for your work and the proof of possibility. My findings so far by merging your and my solution: I was missing the isStatic=true
in AndroidManifest and I did not place it directly in /vendor/overlay
.
These two things were neccessary to bring the RuntimeOverlay to Work.
I removed some config variables and pushed my version to https://github.com/greenflash1986/UnifiedNlpOverlay . You could additionally omit config_locationProviderPackageNames
to bring Unified to work. Only the other four entries for the configs are neccessary if you choose the "force" way.
Explanation: with config_enableNetworkLocationOverlay=false
you tell android to just look at the entry in config_networkLocationProviderPackageName
. If the NetworkLocationOverlay is enabled android would look in config_locationProviderPackageNames
to check for "signature of allowed packages". But as we disable the overlay android looks directly for the provided package in config_networkLocationProviderPackageName
. The same applies to config_enableGeocoderOverlay
and config_geocoderProviderPackageName
. If config_enableGeocoderOverlay
would be true, android would look for the allowed pacakges in config_locationProviderPackageNames
but as it is false android looks directly for the provided package name in config_geocoderProviderPackageName
. (you can have a look at the documentation on some source )
On Android 9 it even seems to work without the "force". So just by having Unified installed in /system/priv-app/, leave the config_enableNetworkLocationOverlay=true
and just overwrite config_locationProviderPackageNames
with the overlay.
(I'm 90% sure that this was not possible in Android 10 and that I had to increase the service version of the Unified-Service-Impl to be able to use Unified, when I did some tests around the christmas holidays and Android 10)
I created a flashable zip, based on the work of WeAreFairphone Let me know, if there are any issues.
Hello @greenflash1986 !
I've tried your zip on a Samsung Galaxy XCover 4 running Android 9 (One UI 1.0) with GApps (and Magisk 23.0, FWIW), but sadly, UnifiedNlp doesn't seem to work quite yet :
However, using My Location (https://f-droid.org/packages/com.mirfatif.mylocation/), the different backends seem to be working :
Please note that for obvious privacy reason, I've disable Googled improved location precision, while still enabling wifi analysis.
(I would have liked to report on your GitHub repo, but the issue tracker seems to be deactivated.)
Hi @breversa
I activated the issue section on the repo. Did you install some additional Magisk modules respective to location backends?
The missing tick for "Unified is registered in system" normally means, that the overlay is not fully working. Can you please provide the output for adb shell cmd overlay list
together with the informations from your post in a new issue on the flashable-zip-repo? Thank you.
(One picture of the missing tick in UnifiedSettings would be enough)
I installed UnifiedNlp (org.microg.nlp) in /system/priv-app/ on a Android 10 device, but in 'Self Check' both 'System supports location provider' and 'UnifiedNlp is registered in the system' are not checked.
I have also tried giving 'ACCESS_COARSE_LOCATION' permission to it from terminal, but no result. ('ACCESS_FINE_LOCATION' permission can't be given as the app don't ask for it.)
'UnifiedNlp Settings' option is shown in Location Settings when installed in priv-app, and not shown when installed as user app.
I also tried putting xml file to /system/etc/permissions/ , but no results(expected). privapp-permissions-unifiednlp.txt