Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android 11 - Physical Activity Permission Denied if Location Permission Previously Requested #1216

Closed
JackMcKew opened this issue Jan 16, 2021 · 7 comments

Comments

@JackMcKew
Copy link

Your Environment

  • Plugin version: 3.9.4
  • Platform: Android
  • OS version: 11
  • Device manufacturer / model: Google Pixel 3
  • Cordova version (cordova -v): 10.0.0
  • Cordova platform version (cordova platform ls): android 9.0.0
  • Plugin config provided to #ready: (taken from sampleApp)
await BackgroundGeolocation.ready({
      /transistorAuthorizationToken: token,
      reset: false,
      debug: true,
      locationAuthorizationRequest: 'Always',
      logLevel: BackgroundGeolocation.LOG_LEVEL_VERBOSE,
      backgroundPermissionRationale: {
        title: "Allow {applicationName} to access this device's location even when closed or not in use.",
        message: "This app collects location data to enable recording your trips to work and calculate distance-travelled.",
        positiveAction: 'Change to "{backgroundPermissionOptionLabel}"',
        negativeAction: 'Cancel'
      },
      distanceFilter: 10,
      stopTimeout: 1,
      stopOnTerminate: false,
      startOnBoot: true,
      enableHeadless: true,
      encrypt: true,
      autoSync: true,
      maxDaysToPersist: 14,
    });

Expected Behavior

If an app has already approved location permissions to be while in use or ask every time but not physical activity, upon configuring BackgroundGeolocation, the prompt for physical activity permission should appear before/after the request for background location services permission.

Actual Behavior

If an app has already approved location permissions to be while in use or ask every time but not physical activity, upon configuring BackgroundGeolocation, the request for background location services permission is shown but no physical activity permission prompt and physical activity is denied.

Steps to Reproduce

  1. Build the Sample App
  2. Run sample app on Android 11 target (I used a Pixel 4 image & and a physical Pixel 3) in Android studio
  3. Before going to 'Simple Map', head to Settings > App & notifications > BG Geo > Permissions > Location > Allow while in use
  4. Head back to BG Geo (sample app)
  5. Start simple map
  6. Enable plugin (top right corner)
  7. See background location authorization prompt but no physical activity prompt
  8. Head to permission settings and see physical activity is denied

Context

We are using this plugin for an app, but the plugin is only configured and used for a specific feature; however location services is used for all users. So upon start we prompt for location services permissions and the prompt is shown, meaning that when the user goes to start the feature that uses this plugin, they are only prompted for background geolocation permissions and not physical activity. Since the documentation so heavily references the plugins reliance on the motion API, we'd like to prompt users with a native prompt rather than having to explain how to navigate into settings.

Debug logs

Logs
2021-01-16 10:48:12.656 3846-4085/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: $ destroyTransistorToken()
2021-01-16 10:48:12.712 3846-4085/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: $ getTransistorToken()
2021-01-16 10:48:13.713 3846-4085/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: $ setConfig()
2021-01-16 10:48:17.961 3846-4085/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: $ getTransistorToken()
2021-01-16 10:48:18.070 3846-4085/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: $ addLocationListener()
2021-01-16 10:48:18.073 3846-4085/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: $ addMotionChangeListener()
2021-01-16 10:48:18.075 3846-4085/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: $ addActivityChangeListener()
2021-01-16 10:48:18.077 3846-4085/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: $ addHttpListener()
2021-01-16 10:48:18.078 3846-4085/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: $ addProviderChangeListener()
2021-01-16 10:48:18.079 3846-4085/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: $ addHeartbeatListener()
2021-01-16 10:48:18.081 3846-4085/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: $ addPowerSaveChangeListener()
2021-01-16 10:48:18.082 3846-4085/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: $ addConnectivityChangeListener()
2021-01-16 10:48:18.083 3846-4085/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: $ ready()
2021-01-16 10:48:18.093 3846-4085/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.adapter.TSConfig d] ℹ️   Persist config, dirty: [backgroundPermissionRationale, backgroundPermissionRationale.title, backgroundPermissionRationale.message, backgroundPermissionRationale.negativeAction, debug, desiredAccuracy, heartbeatInterval, logLevel, startOnBoot, stopOnTerminate, stopTimeout]
2021-01-16 10:48:19.184 3846-4085/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: $ start()
2021-01-16 10:48:19.199 3846-4085/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: [c.t.locationmanager.util.c e] 
      🔵  LocationAuthorization: Requesting Background permission
2021-01-16 10:48:24.459 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: [c.t.l.a.BackgroundGeolocation$y0 onReceive] 
    ╔═════════════════════════════════════════════
    ║ Location-provider change: true
    ╠═════════════════════════════════════════════
    ╟─ GPS: true
    ╟─ Network: false
2021-01-16 10:48:28.424 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: [c.t.l.a.BackgroundGeolocation$y0 onReceive] 
    ╔═════════════════════════════════════════════
    ║ Location-provider change: true
    ╠═════════════════════════════════════════════
    ╟─ GPS: true
    ╟─ Network: false
2021-01-16 10:48:29.984 3846-4102/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: [c.t.l.BootReceiver$a run] 
    ╔═════════════════════════════════════════════
    ║ BootReceiver: com.transistorsoft.backgroundgeolocation.ionic2
    ╠═════════════════════════════════════════════
    ╟─ android.intent.action.BOOT_COMPLETED
2021-01-16 10:48:29.985 3846-4102/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.g.TSGeofenceManager c] ℹ️  Persist monitored geofences: []
2021-01-16 10:48:31.322 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: [c.t.l.a.BackgroundGeolocation$y0 onReceive] 
    ╔═════════════════════════════════════════════
    ║ Location-provider change: true
    ╠═════════════════════════════════════════════
    ╟─ GPS: true
    ╟─ Network: false
2021-01-16 10:48:33.991 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: [c.t.l.a.BackgroundGeolocation$y0 onReceive] 
    ╔═════════════════════════════════════════════
    ║ Location-provider change: true
    ╠═════════════════════════════════════════════
    ╟─ GPS: true
    ╟─ Network: false
2021-01-16 10:48:42.523 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: [c.t.locationmanager.util.c$i onPermissionGranted] 
      ✅  LocationAuthorization: Permission granted
2021-01-16 10:48:42.563 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: [c.t.locationmanager.util.c d] 
      🔵  Should show backgroundPermissionRationale? true
2021-01-16 10:48:42.616 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.a.TSLocationManagerActivity execute] android.permission.ACCESS_BACKGROUND_LOCATION
2021-01-16 10:48:51.912 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.a.TSLocationManagerActivity stop] eventCount: 0
2021-01-16 10:48:51.962 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.a.TSLocationManagerActivity onDestroy] 
2021-01-16 10:48:55.298 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: [c.t.locationmanager.util.c$i onPermissionGranted] 
      ✅  LocationAuthorization: Permission granted
2021-01-16 10:48:55.301 3846-4103/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: - Enable: false → true, trackingMode: 1
2021-01-16 10:48:55.314 3846-4103/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: [c.t.l.s.ActivityRecognitionService b] 
      🎾  Start motion-activity updates
2021-01-16 10:48:55.332 3846-4103/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.http.HttpService startMonitoringConnectivityChanges] 
      🎾  Start monitoring connectivity changes
2021-01-16 10:48:55.348 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.a.TSLocationManagerActivity execute] locationsettings
2021-01-16 10:48:55.350 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.adapter.TSConfig translateDesiredAccuracy] translateDesiredAccuracy (true): -1
2021-01-16 10:48:55.379 3846-4103/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.locationmanager.device.a c] 
      🎾  Start monitoring powersave changes
2021-01-16 10:48:55.390 3846-4103/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: [c.t.l.service.HeartbeatService b] 
      🎾  Start heartbeat (60s)
2021-01-16 10:48:55.390 3846-6685/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.http.HttpService a] 
    ╔═════════════════════════════════════════════
    ║ 📶  Connectivity change: connected? true
    ╠═════════════════════════════════════════════
2021-01-16 10:48:55.395 3846-4103/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.locationmanager.util.c f] 
      ℹ️  LocationAuthorization: Permission granted
2021-01-16 10:48:55.413 3846-4103/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: [c.t.l.service.TrackingService a] 
      🔵  setPace: false → false
2021-01-16 10:48:55.649 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.a.TSLocationManagerActivity stop] eventCount: 0
2021-01-16 10:48:55.770 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService a] 
      🎾  LocationRequestService [eventCount: 1]
2021-01-16 10:48:55.771 3846-6688/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: [c.t.l.s.LocationRequestService a] 
      ℹ️  Location availability: true
2021-01-16 10:48:55.771 3846-6688/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService a] ⚙️︎  finish LocationRequestService [eventCount: 0, sticky: false]
2021-01-16 10:48:55.930 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.a.TSLocationManagerActivity onDestroy] 
2021-01-16 10:48:56.024 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService onDestroy] 
      🔴  LocationRequestService destroyed
2021-01-16 10:48:56.238 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService a] 
      🎾  LocationRequestService [eventCount: 1]
2021-01-16 10:48:56.240 3846-6689/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: [c.t.l.s.LocationRequestService b] 
    ╔═════════════════════════════════════════════
    ║ motionchange LocationResult: 1
    ╠═════════════════════════════════════════════
    ╟─ 📍  Location[fused -32.881050,151.725500 hAcc=5 et=+1m50s824ms alt=10.3 vel=86.045906 bear=147.0 vAcc=1 sAcc=??? bAcc=??? {Bundle[mParcelledData.dataSize=52]}], age: 90ms, time: 1610754536132
2021-01-16 10:48:56.242 3846-6689/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: [c.t.l.l.TSLocationManager onSingleLocationResult] 
      🔵  Acquired motionchange position, isMoving: false
2021-01-16 10:48:56.242 3846-6689/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.l.TSLocationManager calculateMedianAccuracy] Median accuracy: 5.0
2021-01-16 10:48:56.256 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService a] ⚙️︎  finish LocationRequestService [eventCount: 0, sticky: false]
2021-01-16 10:48:56.259 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService onDestroy] 
      🔴  LocationRequestService destroyed
2021-01-16 10:48:56.393 3846-6705/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: [c.t.l.http.HttpService flush] 
    ╔═════════════════════════════════════════════
    ║ HTTP Service (count: 0)
    ╠═════════════════════════════════════════════
2021-01-16 10:48:56.473 3846-4103/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: [c.t.l.data.sqlite.b persist] 
      ✅  INSERT: bab7a163-ee73-461e-9cdc-7bfbbd825cdd
2021-01-16 10:48:56.474 3846-6689/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.s.LocationRequestService b] SingleLocationRequest 1 isFinished? true
2021-01-16 10:48:56.474 3846-6689/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService a] ⚙️︎  finish LocationRequestService [eventCount: 0, sticky: false]
2021-01-16 10:48:56.477 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: [c.t.l.s.ActivityRecognitionService b] 
      🎾  Start motion-activity updates
2021-01-16 10:48:56.481 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.g.TSGeofenceManager startMonitoringStationaryRegion] 
      🎾  Start monitoring stationary region (radius: 150.0m -32.88105,151.7255 hAcc=5.0)
2021-01-16 10:48:56.498 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService a] 
      🎾  TrackingService [eventCount: 1]
2021-01-16 10:48:56.499 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: [c.t.l.service.TrackingService h] 
    ╔═════════════════════════════════════════════
    ║ TrackingService motionchange: false
    ╠═════════════════════════════════════════════
2021-01-16 10:48:56.499 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService a] ⚙️︎  finish TrackingService [eventCount: 0, sticky: false]
2021-01-16 10:48:56.509 3846-4103/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: [c.t.l.http.HttpService flush] 
    ╔═════════════════════════════════════════════
    ║ HTTP Service (count: 1)
    ╠═════════════════════════════════════════════
2021-01-16 10:48:56.529 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService a] 
      🎾  BackgroundTaskService [eventCount: 1]
2021-01-16 10:48:56.530 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: [c.t.l.u.BackgroundTaskManager onStartJob] ⏳ startBackgroundTask: 1
2021-01-16 10:48:56.563 3846-6716/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.data.sqlite.b first] 
      ✅  Locked 1 records
2021-01-16 10:48:56.564 3846-6716/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: [c.t.l.http.HttpService a] 
      🔵  HTTP POST: bab7a163-ee73-461e-9cdc-7bfbbd825cdd
2021-01-16 10:48:56.750 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService onDestroy] 
      🔴  TrackingService destroyed
2021-01-16 10:48:56.838 3846-4566/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: [c.t.l.http.HttpService$i onResponse] 
      🔵  Response: 200
2021-01-16 10:48:56.841 3846-4566/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.data.sqlite.b destroy] 
      ✅  DESTROY: bab7a163-ee73-461e-9cdc-7bfbbd825cdd
2021-01-16 10:48:56.851 3846-4566/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: [c.t.l.u.BackgroundTaskManager$Task stop] ⏳ stopBackgroundTask: 1
2021-01-16 10:48:56.854 3846-4566/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService a] ⚙️︎  finish BackgroundTaskService [eventCount: 0, sticky: false]
2021-01-16 10:48:56.872 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService onDestroy] 
      🔴  BackgroundTaskService destroyed
2021-01-16 10:50:02.950 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService a] 
      🎾  HeartbeatService [eventCount: 1]
2021-01-16 10:50:02.973 3846-7583/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.s.HeartbeatService$a run] ❤️
2021-01-16 10:50:03.022 3846-7583/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService a] ⚙️︎  finish HeartbeatService [eventCount: 0, sticky: false]
2021-01-16 10:50:03.275 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService onDestroy] 
      🔴  HeartbeatService destroyed
2021-01-16 10:50:14.711 3846-4085/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: $ stop()
2021-01-16 10:50:14.716 3846-4085/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.l.TSLocationManager clearLastOdometerLocation] 
      ℹ️  Clear last odometer location
2021-01-16 10:50:14.717 3846-7583/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.g.TSGeofenceManager c] ℹ️  Persist monitored geofences: []
2021-01-16 10:50:14.718 3846-7583/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.g.TSGeofenceManager e] 
      🔴  Stop monitoring geofences
2021-01-16 10:50:14.719 3846-4085/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.g.TSGeofenceManager stopMonitoringStationaryRegion] 
      🔴  Stop monitoring stationary region
2021-01-16 10:50:14.722 3846-4085/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: [c.t.l.s.ActivityRecognitionService c] 
      🔴  Stop motion-activity updates
2021-01-16 10:50:14.723 3846-4085/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: [c.t.l.service.HeartbeatService c] 
      🔴  Stop heartbeat
2021-01-16 10:50:14.725 3846-4085/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.http.HttpService stopMonitoringConnectivityChanges] 
      🔴  Stop monitoring connectivity changes
2021-01-16 10:50:14.727 3846-4085/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.locationmanager.device.a d] 
      🔴  Stop monitoring powersave changes
2021-01-16 10:50:14.730 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService a] ⚙️︎  finish TrackingService [eventCount: 0, sticky: false]
2021-01-16 10:50:14.750 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService a] ⚙️︎  finish GeofencingService [eventCount: 0, sticky: false]
2021-01-16 10:50:14.754 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService onDestroy] 
      🔴  TrackingService destroyed
2021-01-16 10:50:14.757 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService onDestroy] 
      🔴  GeofencingService destroyed
2021-01-16 10:50:14.780 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService a] ⚙️︎  finish ActivityRecognitionService [eventCount: 0, sticky: false]
2021-01-16 10:50:14.786 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService onDestroy] 
      🔴  ActivityRecognitionService destroyed
2021-01-16 10:50:15.564 3846-4085/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: $ start()
2021-01-16 10:50:15.567 3846-4085/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.locationmanager.util.c e] 
      ℹ️  LocationAuthorization: Permission granted
2021-01-16 10:50:15.569 3846-7749/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: - Enable: false → true, trackingMode: 1
2021-01-16 10:50:15.580 3846-7749/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: [c.t.l.s.ActivityRecognitionService b] 
      🎾  Start motion-activity updates
2021-01-16 10:50:15.584 3846-7749/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.http.HttpService startMonitoringConnectivityChanges] 
      🎾  Start monitoring connectivity changes
2021-01-16 10:50:15.586 3846-7749/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.locationmanager.device.a c] 
      🎾  Start monitoring powersave changes
2021-01-16 10:50:15.590 3846-7749/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: [c.t.l.service.HeartbeatService b] 
      🎾  Start heartbeat (60s)
2021-01-16 10:50:15.594 3846-6685/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.http.HttpService a] 
    ╔═════════════════════════════════════════════
    ║ 📶  Connectivity change: connected? true
    ╠═════════════════════════════════════════════
2021-01-16 10:50:15.598 3846-7749/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.locationmanager.util.c f] 
      ℹ️  LocationAuthorization: Permission granted
2021-01-16 10:50:15.598 3846-7749/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: [c.t.l.service.TrackingService a] 
      🔵  setPace: false → false
2021-01-16 10:50:15.603 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.a.TSLocationManagerActivity execute] locationsettings
2021-01-16 10:50:15.604 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.adapter.TSConfig translateDesiredAccuracy] translateDesiredAccuracy (true): -1
2021-01-16 10:50:15.672 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.a.TSLocationManagerActivity stop] eventCount: 0
2021-01-16 10:50:15.710 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.a.TSLocationManagerActivity onDestroy] 
2021-01-16 10:50:15.755 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService a] 
      🎾  LocationRequestService [eventCount: 1]
2021-01-16 10:50:15.757 3846-7755/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: [c.t.l.s.LocationRequestService a] 
      ℹ️  Location availability: true
2021-01-16 10:50:15.757 3846-7755/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService a] ⚙️︎  finish LocationRequestService [eventCount: 0, sticky: false]
2021-01-16 10:50:16.009 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService onDestroy] 
      🔴  LocationRequestService destroyed
2021-01-16 10:50:16.475 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService a] 
      🎾  LocationRequestService [eventCount: 1]
2021-01-16 10:50:16.476 3846-7754/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: [c.t.l.s.LocationRequestService b] 
    ╔═════════════════════════════════════════════
    ║ motionchange LocationResult: 2
    ╠═════════════════════════════════════════════
    ╟─ 📍  Location[fused -32.881050,151.725500 hAcc=5 et=+3m11s95ms alt=10.3 vel=86.045906 bear=147.0 vAcc=1 sAcc=??? bAcc=??? {Bundle[mParcelledData.dataSize=52]}], age: 55ms, time: 1610754616414
2021-01-16 10:50:16.488 3846-7754/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: [c.t.l.l.TSLocationManager onSingleLocationResult] 
      🔵  Acquired motionchange position, isMoving: false
2021-01-16 10:50:16.489 3846-7754/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.l.TSLocationManager calculateMedianAccuracy] Median accuracy: 5.0
2021-01-16 10:50:16.498 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService a] ⚙️︎  finish LocationRequestService [eventCount: 0, sticky: false]
2021-01-16 10:50:16.504 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService onDestroy] 
      🔴  LocationRequestService destroyed
2021-01-16 10:50:16.546 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: [c.t.l.s.ActivityRecognitionService b] 
      🎾  Start motion-activity updates
2021-01-16 10:50:16.546 3846-7754/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.s.LocationRequestService b] SingleLocationRequest 2 isFinished? true
2021-01-16 10:50:16.547 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.g.TSGeofenceManager startMonitoringStationaryRegion] 
      🎾  Start monitoring stationary region (radius: 150.0m -32.88105,151.7255 hAcc=5.0)
2021-01-16 10:50:16.548 3846-7749/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: [c.t.l.data.sqlite.b persist] 
      ✅  INSERT: d6177db0-3b6a-4d40-bbc7-4c40aea0f0da
2021-01-16 10:50:16.552 3846-7754/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService a] ⚙️︎  finish LocationRequestService [eventCount: 0, sticky: false]
2021-01-16 10:50:16.557 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService a] 
      🎾  TrackingService [eventCount: 1]
2021-01-16 10:50:16.558 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: [c.t.l.service.TrackingService h] 
    ╔═════════════════════════════════════════════
    ║ TrackingService motionchange: false
    ╠═════════════════════════════════════════════
2021-01-16 10:50:16.558 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService a] ⚙️︎  finish TrackingService [eventCount: 0, sticky: false]
2021-01-16 10:50:16.562 3846-7749/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: [c.t.l.http.HttpService flush] 
    ╔═════════════════════════════════════════════
    ║ HTTP Service (count: 1)
    ╠═════════════════════════════════════════════
2021-01-16 10:50:16.571 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService a] 
      🎾  BackgroundTaskService [eventCount: 1]
2021-01-16 10:50:16.571 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: [c.t.l.u.BackgroundTaskManager onStartJob] ⏳ startBackgroundTask: 2
2021-01-16 10:50:16.593 3846-7792/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.data.sqlite.b first] 
      ✅  Locked 1 records
2021-01-16 10:50:16.596 3846-7583/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: [c.t.l.http.HttpService flush] 
      ℹ️  HttpService is busy
2021-01-16 10:50:16.597 3846-7792/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: [c.t.l.http.HttpService a] 
      🔵  HTTP POST: d6177db0-3b6a-4d40-bbc7-4c40aea0f0da
2021-01-16 10:50:16.810 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService onDestroy] 
      🔴  TrackingService destroyed
2021-01-16 10:50:17.171 3846-7793/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: [c.t.l.http.HttpService$i onResponse] 
      🔵  Response: 200
2021-01-16 10:50:17.172 3846-7793/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.data.sqlite.b destroy] 
      ✅  DESTROY: d6177db0-3b6a-4d40-bbc7-4c40aea0f0da
2021-01-16 10:50:17.186 3846-7793/com.transistorsoft.backgroundgeolocation.ionic2 I/TSLocationManager: [c.t.l.u.BackgroundTaskManager$Task stop] ⏳ stopBackgroundTask: 2
2021-01-16 10:50:17.187 3846-7793/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService a] ⚙️︎  finish BackgroundTaskService [eventCount: 0, sticky: false]
2021-01-16 10:50:17.189 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService onDestroy] 
      🔴  BackgroundTaskService destroyed
2021-01-16 10:50:33.573 3846-4085/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: $ getState()
2021-01-16 10:51:40.490 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService a] 
      🎾  HeartbeatService [eventCount: 1]
2021-01-16 10:51:40.492 3846-8522/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.s.HeartbeatService$a run] ❤️
2021-01-16 10:51:40.549 3846-8522/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService a] ⚙️︎  finish HeartbeatService [eventCount: 0, sticky: false]
2021-01-16 10:51:40.803 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService onDestroy] 
      🔴  HeartbeatService destroyed
2021-01-16 10:52:21.536 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService a] 
      🎾  HeartbeatService [eventCount: 1]
2021-01-16 10:52:21.537 3846-8522/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.s.HeartbeatService$a run] ❤️
2021-01-16 10:52:21.593 3846-8522/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService a] ⚙️︎  finish HeartbeatService [eventCount: 0, sticky: false]
2021-01-16 10:52:21.846 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService onDestroy] 
      🔴  HeartbeatService destroyed
2021-01-16 10:53:47.998 3846-3846/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService a] 
      🎾  HeartbeatService [eventCount: 1]
2021-01-16 10:53:48.010 3846-9819/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.s.HeartbeatService$a run] ❤️
2021-01-16 10:53:48.049 3846-9819/com.transistorsoft.backgroundgeolocation.ionic2 D/TSLocationManager: [c.t.l.service.AbstractService a] ⚙️︎  finish HeartbeatService [eventCount: 0, sticky: false]

@JackMcKew
Copy link
Author

I have a suspicion that it actually is prompting, but the prompts are stacked on each other and then since the 'allow all the time' prompt is above the physical activity, when it navigates to settings it sets the physical activity permission as denied.

@JackMcKew
Copy link
Author

I've whittled this down to the scenario if BackgroundGeolocation.getCurrentPosition() is called before BackgroundGeolocation.start() or BackgroundGeolocation.requestPermission() then the prompt for permission for physical activity is skipped. I note that requestPermission is invoked on each of these methods, so it is strange that the physical activity prompt is missed for BackgroundGeolocation.getCurrentPosition(). I further note that the request for background permission also isn't seen with BackgroundGeolocation.getCurrentPosition().

Current workaround is to invoke BackgroundGeolocation.requestPermission() before any other method, but this also means our app requests for background location access before the feature that actually uses it is active/selected; as well as any existing user will not get the physical activity prompt only the allow all the time prompt.

@JackMcKew
Copy link
Author

From looking through the source code, as far as my understanding goes, this would live within the compiled ts-locationmanager. Could potentially be a fix as simple as the one seen: mauron85/cordova-plugin-background-geolocation#719 (comment) by adding ACTIVITY_RECOGNITION to the list of permissions requested BackgroundGeolocation.getCurrentPosition().

@JackMcKew
Copy link
Author

In the end I ended up forking cordova-diagnostic-plugin, introducing support for ACTIVITY_RECOGNITION and installing this fork into the app so we have control over when we can request Physical Activity permissions. dpa99c/cordova-diagnostic-plugin#430

@christocracy
Copy link
Member

I don't want getCurrentPosition to request motion permission. Many others have expressed they don't want it.

@christocracy
Copy link
Member

You want to use BackgroundGeolocation for requesting location permission. It's probably has better support for the new Android 11 permission policy.

See Config.backgroundPermissionRationale. I doubt 3rd party permission plugin has that implemented.

@JackMcKew
Copy link
Author

Happy to close this, I think the main part that I was missing was a method for invoking the Physical Activity permission request, but now that I've created one myself my use-case is sorted. That would be my only request for this plugin to include in it similar to requestPermission().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants