Helium314 / Local-NLP-Backend

Yet another network location backend for the UnifiedNLP/microG project
GNU General Public License v3.0
64 stars 4 forks source link

Allow GPS access needs to be set manually #9

Closed yennor closed 1 year ago

yennor commented 1 year ago

When trying to activate the module in microg app, it seems like microg just reloads and the local-nlp-backend is still marked as deactivated. So the user just gets the impression of a faulty app. To make it work I needed to go to the android settings of the app, and manually give it the location permission "Allow all the time". This is on android 13. But I remember, that it was the same on android 11.

Helium314 commented 1 year ago

This is not good, because I only have Android 9, so I can't test it... Apparently there is need to request the permission twice for Android 11+ to show the "Allow all the time" setting. So far the request is handled by microG, but that may not work any more.

Is there some permission request at all when you enable the module for the first time?

yennor commented 1 year ago

There is no permission request at all. It just reloads the screen and the module is deactivated again... so I guess an exception is thrown somewhere?

I've also tried out https://gitlab.com/deveee/Local-GSM-Backend which properly shows the permission requests and works. Maybe you can get a hint there?

If you provide an apk, I can test it for you...

Helium314 commented 1 year ago

Thanks! I'll start by checking https://gitlab.com/deveee/Local-GSM-Backend and probably at some point provide some apk for testing.

Helium314 commented 1 year ago

Local-GSM-Backend actually requests location only when the settings are opened. This is fine here, as you cannot use it without configuration, but actually Local NLP Backend should work without ever entering the settings...

I have a debug version here that requests permissions when opening settings. You can install it along the normal version. Could you please test:

yennor commented 1 year ago

I've tried it out. The behaviour is the same. I've took a look at logcat. The only message which appears there and seems to have any to do with the app is:

For R+ apps, background permissions must be requested after foreground permissions are already granted

yennor commented 1 year ago

I've added a short video. so you can see what the behaviour looks like.

https://user-images.githubusercontent.com/6601243/215474367-d47e83ea-5cb5-496f-8f29-d65348bffb53.mp4

Helium314 commented 1 year ago

For R+ apps, background permissions must be requested after foreground permissions are already granted

Thanks, this is very useful. Local-GSM-Backend might not have this issue because it targets API 29 (Q).

Next attempt: local-nlp-backend_1.2.3-debug.zip Could you try the same things again? Now first the normal location permissions are requested, and only then comes background location.

yennor commented 1 year ago

Now when trying to open Location Modules in MicroG, MicroG crashes:

FATAL EXCEPTION: main
Process: com.google.android.gms:ui, PID: 6201
java.lang.NullPointerException: Can't toast on a thread that has not called Looper.prepare()
    at android.os.Parcel.createExceptionOrNull(Parcel.java:3034)
    at android.os.Parcel.createException(Parcel.java:3012)
    at android.os.Parcel.readException(Parcel.java:2995)
    at android.os.Parcel.readException(Parcel.java:2937)
    at org.microg.nlp.api.LocationBackend$Stub$Proxy.getInitIntent(LocationBackend.java:266)
    at org.microg.nlp.ui.BackendConfigurationKt$loadIntents$1.onServiceConnected(BackendConfiguration.kt:82)
    at android.app.LoadedApk$ServiceDispatcher.doConnected(LoadedApk.java:2188)
    at android.app.LoadedApk$ServiceDispatcher$RunConnection.run(LoadedApk.java:2221)
    at android.os.Handler.handleCallback(Handler.java:942)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loopOnce(Looper.java:201)
    at android.os.Looper.loop(Looper.java:288)
    at android.app.ActivityThread.main(ActivityThread.java:7872)
    at java.lang.reflect.Method.invoke(Native Method)
    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:548)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:946)
Helium314 commented 1 year ago

Oh damn... that's something I should have expected.

Here the same thing without the crash: local-nlp-backend_1.2.3-debug.zip

yennor commented 1 year ago

this one seems to work. When activating the modul for the first time, it asks in a popup for the location permission. I've chosen "While the app is running" (You can't choose always). Then it automatically deactivates the module. When activating the module the 2nd time, it goes to the property dialog and I can choose the "always" permission. Then the module stays activated. and according to https://github.com/mirfatif/MyLocation the debug version returns the current location. So it seems to work. :-). It would be more beautiful, if it would stay activated after the first activation, but I guess most user, will click it a second time when it didn-t get activated the first time...

Helium314 commented 1 year ago

Actually this is why I wanted to add a "Toast" (short popup message at the bottom that caused the crash). Maybe I'll find some other way. The main issue is that at this stage the module doesn't have an UI. Anyway, I'll try finding something here...

Thanks a lot for reporting and testing!

Helium314 commented 1 year ago

Then it automatically deactivates the module.

Actually it looks like this also happens in older versions, even in DejaVu. Never noticed this...

yennor commented 1 year ago

cool. thanks :-)