cordova-plugin-geolocation icon indicating copy to clipboard operation
cordova-plugin-geolocation copied to clipboard

feat(android): check location service before permission

Open kumo01GitHub opened this issue 1 year ago • 2 comments

Platforms affected

Android

Motivation and Context

  • This is change for check Location Service enabled before request permission. For now when the location service is unavailable, the plugin request permission, open dialog and wait for timeout. Referencing Note: Browser permission VS OS permission in W3C, I interpreted location service availability is similar to OS permission and it should return PERMISSION_DENIED.
  • In W3C, it looks no distinction between fine and coarse location permissions. And WebView return coarse location ignoring enableHighAccuracy when denied permission for fine location.

Description

  • When request high accuracy location but only granted coarse location, onRequestPermissionResult() return PluginResult.Status.OK
  • check location service before permission.

Testing

I checked with virtual device location service on/off.

Checklist

  • [x] I've run the tests to see all new and existing tests pass
  • [x] I added automated test coverage as appropriate for this change
  • [x] Commit is prefixed with (platform) if this change only applies to one platform (e.g. (android))
  • [x] If this Pull Request resolves an issue, I linked to the issue in the text above (and used the correct keyword to close issues using keywords)
  • [x] I've updated the documentation if necessary

kumo01GitHub avatar Oct 12 '24 11:10 kumo01GitHub

image

I do agree that if the OS level has GPS disabled, then returning a PERMISSION_DENIED is more reflective of the W3C standard.

Note that the android tests is failing does not appear to be related to this PR, I think the CI configs needs to be updated. I'll try to do that sometime soon and once merged, this PR will need to be rebased.

breautek avatar Oct 17 '24 20:10 breautek

@breautek

Note that the android tests is failing does not appear to be related to this PR, I think the CI configs needs to be updated. I'll try to do that sometime soon and once merged, this PR will need to be rebased.

I rebased with PR #291 waiting for merged.

kumo01GitHub avatar Apr 25 '25 16:04 kumo01GitHub