UnifiedNlp icon indicating copy to clipboard operation
UnifiedNlp copied to clipboard

[MM] Permission Denial requires android.permission.ACCESS_COARSE_LOCATION

Open xuefer opened this issue 8 years ago • 8 comments

android 6.0.1, UnifiedNlp.apk (1.6.1)

after installing UnifiedNlp, Location perimssion default to "off" selecting any location backend raise the following exception in log

03-04 23:14:50.335  9088 10256 W ActivityManager: Permission Denial: Accessing service ComponentInfo{org.microg.nlp.backend.ichnaea/org.microg.nlp.backend.ichnaea.BackendService} from pid=12474, uid=10080 requires2 android.permission.ACCESS_COARSE_LOCATION
03-04 23:14:50.336 12474 12474 D AndroidRuntime: Shutting down VM
03-04 23:14:50.338 12474 12474 E AndroidRuntime: FATAL EXCEPTION: main
03-04 23:14:50.338 12474 12474 E AndroidRuntime: Process: org.microg.nlp, PID: 12474
03-04 23:14:50.338 12474 12474 E AndroidRuntime: Theme: themes:{}
03-04 23:14:50.338 12474 12474 E AndroidRuntime: java.lang.SecurityException: Not allowed to bind to service Intent { act=org.microg.nlp.LOCATION_BACKEND pkg=org.microg.nlp.backend.ichnaea cmp=org.microg.nlp.backend.ichnaea/.BackendService }
03-04 23:14:50.338 12474 12474 E AndroidRuntime:        at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:1334)
03-04 23:14:50.338 12474 12474 E AndroidRuntime:        at android.app.ContextImpl.bindService(ContextImpl.java:1298)
03-04 23:14:50.338 12474 12474 E AndroidRuntime:        at android.content.ContextWrapper.bindService(ContextWrapper.java:610)
03-04 23:14:50.338 12474 12474 E AndroidRuntime:        at org.microg.nlp.ui.AbstractBackendPreference.enableBackend(AbstractBackendPreference.java:208)
03-04 23:14:50.338 12474 12474 E AndroidRuntime:        at org.microg.nlp.ui.AbstractBackendPreference$Adapter$1.onClick(AbstractBackendPreference.java:175)03-04 23:14:50.338 12474 12474 E AndroidRuntime:        at android.view.View.performClick(View.java:5204)
03-04 23:14:50.338 12474 12474 E AndroidRuntime:        at android.widget.CompoundButton.performClick(CompoundButton.java:122)
03-04 23:14:50.338 12474 12474 E AndroidRuntime:        at android.view.View$PerformClick.run(View.java:21156)
03-04 23:14:50.338 12474 12474 E AndroidRuntime:        at android.os.Handler.handleCallback(Handler.java:739)
03-04 23:14:50.338 12474 12474 E AndroidRuntime:        at android.os.Handler.dispatchMessage(Handler.java:95)
03-04 23:14:50.338 12474 12474 E AndroidRuntime:        at android.os.Looper.loop(Looper.java:148)
03-04 23:14:50.338 12474 12474 E AndroidRuntime:        at android.app.ActivityThread.main(ActivityThread.java:5466)
03-04 23:14:50.338 12474 12474 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)
03-04 23:14:50.338 12474 12474 E AndroidRuntime:        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
03-04 23:14:50.338 12474 12474 E AndroidRuntime:        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
03-04 23:14:50.339  9088 10145 W ActivityManager:   Force finishing activity org.microg.nlp/.ui.SettingsActivity

UnifiedNlp is not requesting permission automatically like it should. same applies to the backend apps made by you, like IchnaeaNlpBackend which crash after selected this backend and pressing "ok"

i suppose it's called runtime permissions under 6.0 apps like org.fitchfamily.android.wifi_backend, however can request for permission at runtime

yes we can grant permission manually in app permission setting dialog but chance are only after first installation but before it is used by system (hack or custom framework-res.apk/config.xml + reboot), i can grant permission in UnifiedNlp app permission setting page to avoid this issue

after reboot, since UnifiedNlp is used as system NLP, I can no longer grant permission because it looks like permission is already granted while it's not. (seems like 6.0 bug). can't even toggle it off

xuefer avatar Mar 04 '16 15:03 xuefer

With 859fbd4 you should be able to grant the permission in self-check. Self-check is considered an intermediate fix until we have a nice setup wizard. The problem with runtime permissions is that they require a UI to ask for permission. This is why the UnifiedNlp API was updated recently with the possibility to open a UI on activation.

mar-v-in avatar Mar 04 '16 16:03 mar-v-in

regarding to "setup wizard" please also consider the permission in backends and prefer to make it "just works" after installation. let's think about the scene: after i bundle UnifiedNlp and backends in my custom rom, i don't want to every user going through setup wizard wondering what is network location provider and consequence of the choices they're making. 1st thing come to my mind would be to default selected some or all backends for those default to not selected, pop a notification like "xposed installer" do

xuefer avatar Mar 05 '16 09:03 xuefer

Please try again with 1.6.2 (first open Self-Check to verify that everything is fine).

mar-v-in avatar Mar 05 '16 13:03 mar-v-in

thanks for packing 1.6.2. no more crashing, and permission almost works

pm revoke org.microg.nlp android.permission.ACCESS_COARSE_LOCATION

(learn for your old post)

after this, open self-check, the checkbox is not checked. click on the checkbox it won't change in visually. i had to reopen self-check to see it's granted already. it's not asking me for permission, maybe because i already granted or it's being used as system nlp? maybe we can ask for permission when unified nlp is used by system, and/or when UI is opened

xuefer avatar Mar 05 '16 14:03 xuefer

upgraded AppleWifiNlpBackend has better permissin handling. as soon as i enable and press ok, it ask for location permission

but mozilla ichnaea backend on the other hand is old and crash with same steps. so you might want to update MLP like you did on AppleWifiNlpBackend

03-06 01:43:41.612 22078 22078 E AndroidRuntime: FATAL EXCEPTION: main
03-06 01:43:41.612 22078 22078 E AndroidRuntime: Process: org.microg.nlp.backend.ichnaea, PID: 22078
03-06 01:43:41.612 22078 22078 E AndroidRuntime: Theme: themes:{}
03-06 01:43:41.612 22078 22078 E AndroidRuntime: java.lang.SecurityException: Neither user 10147 nor current process has android.permission.ACCESS_COARSE_LOCATION.
03-06 01:43:41.612 22078 22078 E AndroidRuntime:        at android.os.Parcel.readException(Parcel.java:1620)
03-06 01:43:41.612 22078 22078 E AndroidRuntime:        at android.os.Parcel.readException(Parcel.java:1573)
03-06 01:43:41.612 22078 22078 E AndroidRuntime:        at com.android.internal.telephony.ITelephonyRegistry$Stub$Proxy.listenForSubscriber(ITelephonyRegistry.java:553)
03-06 01:43:41.612 22078 22078 E AndroidRuntime:        at android.telephony.TelephonyManager.listen(TelephonyManager.java:2748)
03-06 01:43:41.612 22078 22078 E AndroidRuntime:        at org.microg.nlp.api.CellBackendHelper.registerPhoneStateListener(CellBackendHelper.java:310)
03-06 01:43:41.612 22078 22078 E AndroidRuntime:        at org.microg.nlp.api.CellBackendHelper.access$400(CellBackendHelper.java:53)
03-06 01:43:41.612 22078 22078 E AndroidRuntime:        at org.microg.nlp.api.CellBackendHelper$1.run(CellBackendHelper.java:101)
03-06 01:43:41.612 22078 22078 E AndroidRuntime:        at android.os.Handler.handleCallback(Handler.java:739)
03-06 01:43:41.612 22078 22078 E AndroidRuntime:        at android.os.Handler.dispatchMessage(Handler.java:95)
03-06 01:43:41.612 22078 22078 E AndroidRuntime:        at android.os.Looper.loop(Looper.java:148)
03-06 01:43:41.612 22078 22078 E AndroidRuntime:        at android.app.ActivityThread.main(ActivityThread.java:5466)
03-06 01:43:41.612 22078 22078 E AndroidRuntime:        at java.lang.reflect.Method.invoke(Native Method)
03-06 01:43:41.612 22078 22078 E AndroidRuntime:        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)
03-06 01:43:41.612 22078 22078 E AndroidRuntime:        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)
03-06 01:43:41.612 22078 22078 E AndroidRuntime:        at de.robv.android.xposed.XposedBridge.main(XposedBridge.java:117)

xuefer avatar Mar 05 '16 17:03 xuefer

What version of Ichnaea backend are you using?

mar-v-in avatar Mar 05 '16 17:03 mar-v-in

oops, F-Droid didn't says no update today i thought 12 days was long ago. updated to v1.3.0 and fixed. now no backend left to worry about permissions. except UnifiedNlp

xuefer avatar Mar 05 '16 18:03 xuefer

UnifiedNlp 1.6.2 with IchnaeaNlpBackend 1.3 works well。Thanks

rerbin avatar Mar 09 '16 01:03 rerbin