microg / UnifiedNlp

Alternative network location provider for Android, with plugin interface to easily integrate third-party location providers.
954 stars 207 forks source link

UnifiedNlp with GAPPS not working on Android 10/Q, even after installing in /system/priv-app/ #188

Open TontyTon opened 4 years ago

TontyTon commented 4 years ago

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

jedie commented 4 years ago

Same with lineageos 16 (android 9)

alexmex90 commented 3 years ago

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.

greenflash1986 commented 3 years ago

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:

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

TontyTon commented 3 years ago

@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.

greenflash1986 commented 3 years ago

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.

greenflash1986 commented 3 years ago

@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.

TontyTon commented 3 years ago

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

greenflash1986 commented 3 years ago

@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)

greenflash1986 commented 3 years ago

I created a flashable zip, based on the work of WeAreFairphone Let me know, if there are any issues.

breversa commented 2 years ago

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 : Screenshot_20211028-154939_UnifiedNlp Screenshot_20211028-154946_UnifiedNlp

However, using My Location (https://f-droid.org/packages/com.mirfatif.mylocation/), the different backends seem to be working : Screenshot_20211028-155006_My Location Screenshot_20211028-155010_My Location

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.)

greenflash1986 commented 2 years ago

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)