transistorsoft / cordova-background-geolocation-lt

The most sophisticated background location-tracking & geofencing module with battery-conscious motion-detection intelligence for iOS and Android.
http://www.transistorsoft.com/shop/products/cordova-background-geolocation
Other
659 stars 276 forks source link

Android app reloads if location permission changed to "dont allow" #1462

Closed malmator closed 1 week ago

malmator commented 1 week ago

Your Environment

Expected Behavior

App should not reload.

Actual Behavior

If I go to Phone settings and change the app location permission to "dont allow", then when I return to the app it has reloaded. I also see the license key warning

Steps to Reproduce

Context

I want to add functionality to prevent the user from operating the app if background location reports have been prevented eg if user sets location permission to "dont allow".

Debug logs

I have no chrome inspect log as app is in background when I change the permission

Logs ``` adb logcat | grep -F "`adb shell ps | grep trapeze | tr -s [:space:] ' ' | cut -d' ' -f2`" 09-19 17:40:08.842 3319 3319 I ViewRootImpl@8d94e44[MainActivity]: handleAppVisibility mAppVisible = true visible = false 09-19 17:40:08.889 3319 3443 D OpenGLRenderer: setSurface called with nullptr 09-19 17:40:08.889 3319 3443 D OpenGLRenderer: setSurface() destroyed EGLSurface 09-19 17:40:08.889 3319 3443 D OpenGLRenderer: destroyEglSurface 09-19 17:40:08.891 3319 3319 I ViewRootImpl@8d94e44[MainActivity]: performTraversals mFirst=false windowShouldResize=false viewVisibilityChanged=true mForceNextWindowRelayout=false params=null 09-19 17:40:08.896 1493 2435 V WindowManager: Relayout hash=504769c, pid=3319, syncId=-1: mAttrs={(0,0)(fillxfill) sim={adjust=resize} layoutInDisplayCutoutMode=shortEdges ty=BASE_APPLICATION wanim=0x1030309 09-19 17:40:08.910 3319 3319 I ViewRootImpl@8d94e44[MainActivity]: Relayout returned: old=(0,0,1080,2400) new=(0,0,1080,2400) req=(1080,2400)8 dur=17 res=0x2 s={false 0x0} ch=true seqId=0 09-19 17:40:08.913 3319 3319 I ViewRootImpl@8d94e44[MainActivity]: stopped(true) old = false 09-19 17:40:08.913 3319 3319 I ViewRootImpl@8d94e44[MainActivity]: WindowStopped on dk.trapeze.yod.tpz/dk.trapeze.yod.tpz.MainActivity set to true 09-19 17:40:08.914 3319 3319 D CordovaActivity: Stopped the activity. 09-19 17:40:08.916 3319 3319 I TSLocationManager: [c.t.l.s.TSScheduleManager oneShot] 09-19 17:40:08.916 3319 3319 I TSLocationManager: ⏰ Scheduled OneShot: TERMINATE_EVENT in 10000ms (jobID: -1708771588) 09-19 17:40:08.926 3319 3319 I MSHandlerLifeCycle: removeMultiSplitHandler: no exist. decor=DecorView@f2cba93[MainActivity] 09-19 17:40:08.927 3319 3319 D InputTransport: Input channel destroyed: 'ClientS', fd=270 09-19 17:40:08.936 1493 4305 I WindowManager: Destroying surface Surface(name=dk.trapeze.yod.tpz/dk.trapeze.yod.tpz.MainActivity$_3319)/@0x59da912 called by com.android.server.wm.WindowStateAnimator.destroySurface:942 com.android.server.wm.WindowStateAnimator.destroySurfaceLocked:536 com.android.server.wm.WindowState.destroySurfaceUnchecked:4306 com.android.server.wm.WindowState.destroySurface:4280 com.android.server.wm.ActivityRecord.destroySurfaces:6539 com.android.server.wm.ActivityRecord.destroySurfaces:6520 com.android.server.wm.ActivityRecord.notifyAppStopped:6584 com.android.server.wm.ActivityRecord.activityStopped:7172 09-19 17:40:08.950 1156 1156 I Layer : id=41663 removeFromCurrentState dk.trapeze.yod.tpz/dk.trapeze.yod.tpz.MainActivity$_3319#41663 (222) 09-19 17:40:08.950 1156 1156 I SurfaceFlinger: id=41663 Removed dk.trapeze.yod.tpz/dk.trapeze.yod.tpz.MainActivity$_3319#41663 (222) 09-19 17:40:08.951 1156 1156 I Layer : id=41663 Destroyed dk.trapeze.yod.tpz/dk.trapeze.yod.tpz.MainActivity$_3319#41663 09-19 17:40:09.537 3319 3319 D TSLocationManager: [c.t.l.l.LifecycleManager onPause] ☯️ onPause 09-19 17:40:09.537 3319 3319 D TSLocationManager: [c.t.l.l.LifecycleManager onStop] ☯️ onStop 09-19 17:40:13.350 1493 1642 I ActivityManager: Killing 3319:dk.trapeze.yod.tpz/u0a1121 (adj 50): permissions revoked 09-19 17:40:13.362 1493 1642 D ActivityManager: proc ProcessRecord{427da4c 3319:dk.trapeze.yod.tpz/u0a1121} already removed. so we skip next process. 09-19 17:40:13.371 1493 1606 I libprocessgroup: Successfully killed process cgroup uid 11121 pid 3319 in 18ms 09-19 17:40:13.426 1493 4291 V ActivityManager: Got obituary of 3319:dk.trapeze.yod.tpz 09-19 17:40:13.427 1144 14758 I AudioFlinger: removeDlbCodecCallback pid:3319 type:-1 09-19 17:40:13.429 1493 1597 W ActivityManager: setHasOverlayUi called on unknown pid: 3319 09-19 17:40:13.429 1063 1063 I Zygote : Process 3319 exited due to signal 9 (Killed) ```
malmator commented 1 week ago

in the logcat you can see a "revoked" near the end. This is me changing the app permission setting to "dont allow"

christocracy commented 1 week ago

Android app reloads if location permission changed to "dont allow

That’s correct. That’s a fundamental behaviour of any Android application. When permissions change, the app must be restarted into the new permission model.

that has nothing to do with the plug-in.

malmator commented 1 week ago

OK. I have the app location permission aspect working now

But I see that the user can also disable location services at the phone settings level (not app level)

the background process sending locations to our backend url seems to continue despite this. Maybe the location accuracy is degraded because the locations are WIFI based instead of GPS based or something

I have added locationAuthorizationRequest: 'Always', which throws up a modal if the location service is disabled. This helps the user to reconsider her choice. But this is insufficient. I need to detect Location service disabled in the app inorder to disable some app functionality. Is there any support for this in the plugin?

Thanks

christocracy commented 1 week ago

See api docs .onProviderChange. I suggest you familiarize yourself with all 13 events available to you.