openbmap / radiocells-nlp-android

radiocells.org Unified Network Location Provider
https://radiocells.org
Other
41 stars 13 forks source link

does not request the location runtime permission #40

Closed Lanchon closed 6 years ago

Lanchon commented 6 years ago

hi,

the app does not request the location runtime permission. the result is that on recent androids it crashes when the permission is denied with this exception:

05-20 18:29:06.892  9621  9621 D org.openbmap.unifiedNlp.services.RadiocellsOrgNlpService: Scanning wifis & cells
05-20 18:29:06.896  9621  9621 E org.openbmap.unifiedNlp.services.RadiocellsOrgNlpService: Error retrieving network operator, skipping cell
05-20 18:29:06.899  9621  9621 D AndroidRuntime: Shutting down VM
05-20 18:29:06.900  9621  9621 E AndroidRuntime: FATAL EXCEPTION: main
05-20 18:29:06.900  9621  9621 E AndroidRuntime: Process: org.openbmap.unifiedNlp, PID: 9621
05-20 18:29:06.900  9621  9621 E AndroidRuntime: java.lang.RuntimeException: Error receiving broadcast Intent { act=android.net.wifi.SCAN_RESULTS flg=0x4000010 (has extras) } in org.openbmap.unifiedNlp.services.RadiocellsOrgNlpService$1@34c2d8e
05-20 18:29:06.900  9621  9621 E AndroidRuntime:    at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$-android_app_LoadedApk$ReceiverDispatcher$Args_52511(LoadedApk.java:1323)
05-20 18:29:06.900  9621  9621 E AndroidRuntime:    at android.app.-$Lambda$aS31cHIhRx41653CMnd4gZqshIQ.$m$7(Unknown Source:4)
05-20 18:29:06.900  9621  9621 E AndroidRuntime:    at android.app.-$Lambda$aS31cHIhRx41653CMnd4gZqshIQ.run(Unknown Source:39)
05-20 18:29:06.900  9621  9621 E AndroidRuntime:    at android.os.Handler.handleCallback(Handler.java:790)
05-20 18:29:06.900  9621  9621 E AndroidRuntime:    at android.os.Handler.dispatchMessage(Handler.java:99)
05-20 18:29:06.900  9621  9621 E AndroidRuntime:    at android.os.Looper.loop(Looper.java:164)
05-20 18:29:06.900  9621  9621 E AndroidRuntime:    at android.app.ActivityThread.main(ActivityThread.java:6494)
05-20 18:29:06.900  9621  9621 E AndroidRuntime:    at java.lang.reflect.Method.invoke(Native Method)
05-20 18:29:06.900  9621  9621 E AndroidRuntime:    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:440)
05-20 18:29:06.900  9621  9621 E AndroidRuntime:    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
05-20 18:29:06.900  9621  9621 E AndroidRuntime: Caused by: java.lang.SecurityException: getCellLocation: Neither user 10090 nor current process has android.permission.ACCESS_COARSE_LOCATION.
05-20 18:29:06.900  9621  9621 E AndroidRuntime:    at android.os.Parcel.readException(Parcel.java:2004)
05-20 18:29:06.900  9621  9621 E AndroidRuntime:    at android.os.Parcel.readException(Parcel.java:1950)
05-20 18:29:06.900  9621  9621 E AndroidRuntime:    at com.android.internal.telephony.ITelephony$Stub$Proxy.getCellLocation(ITelephony.java:2895)
05-20 18:29:06.900  9621  9621 E AndroidRuntime:    at android.telephony.TelephonyManager.getCellLocation(TelephonyManager.java:1167)
05-20 18:29:06.900  9621  9621 E AndroidRuntime:    at org.openbmap.unifiedNlp.services.RadiocellsOrgNlpService.getCells(RadiocellsOrgNlpService.java:334)
05-20 18:29:06.900  9621  9621 E AndroidRuntime:    at org.openbmap.unifiedNlp.services.RadiocellsOrgNlpService.getLocationFromWifisAndCells(RadiocellsOrgNlpService.java:283)
05-20 18:29:06.900  9621  9621 E AndroidRuntime:    at org.openbmap.unifiedNlp.services.RadiocellsOrgNlpService.access$300(RadiocellsOrgNlpService.java:61)
05-20 18:29:06.900  9621  9621 E AndroidRuntime:    at org.openbmap.unifiedNlp.services.RadiocellsOrgNlpService$3.onWifiResultsAvailable(RadiocellsOrgNlpService.java:255)
05-20 18:29:06.900  9621  9621 E AndroidRuntime:    at org.openbmap.unifiedNlp.services.RadiocellsOrgNlpService$1.onReceive(RadiocellsOrgNlpService.java:124)
05-20 18:29:06.900  9621  9621 E AndroidRuntime:    at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$-android_app_LoadedApk$ReceiverDispatcher$Args_52511(LoadedApk.java:1313)
05-20 18:29:06.900  9621  9621 E AndroidRuntime:    ... 9 more
05-20 18:29:06.900  9621  9621 E ACRA    : ACRA is disabled for org.openbmap.unifiedNlp - forwarding uncaught Exception on to default ExceptionHandler
05-20 18:29:06.906  1345  1419 I ActivityManager: Showing crash dialog for package org.openbmap.unifiedNlp u0

how to repro

on a recent android, go to settings, find the app's permission, deny location permission. the app should fail.

how to fix

make the app request location permission if absent. if denied, pop up a message box sating something like:

The blah-blah app requires location permission to work. Please open device settings and grant the location permission to this app. (It is usually found in Settings/Apps/App permissions/Location). [Kill app] [Retry access]

requesting a runtime permission is very simple, please check out this commit: https://github.com/Lanchon/sigspoof-checker/commit/3db6c9a1c92be4ba8f36dc3ffad937eb7ba03944

and official docs are here: https://developer.android.com/training/permissions/requesting

thank you!

wish7code commented 6 years ago

Fixed with 4a3b77fab7528a1d8eacb912bef220716336bc18

Lanchon commented 6 years ago

nope, wrong commit linked, it's this one: b944a0656833248f91d2e721ca9b0ff4991b7d11

btw, please see comment in commit.