Closed expcapitaldev closed 2 years ago
This behaviour is a quirk of Android rather than a bug with this plugin:
In step 2, you authorized "approximate" location permission and "only for this time".
In step 4, you manually changed the setting switch for "Use precise location" and you expected that means "precise location" access will now be granted to the app.
However this is not the case: the plugin is deriving the status DENIED_ALWAYS for ACCESS_FINE_LOCATION from the native permissions manager which has determined that access to ACCESS_FINE_LOCATION is not granted.
The reason for this is because you granted approximate location access "just this time" which means that enabling the switch in Settings for "Use precise location" will have no effect because that doesn't affect "this time", it affects "next time".
You can confirm this by adding a further step to your list:
requestLocationAuthorization()
again with WHEN_IN_USE
and FULL
This will show the permission dialog again, asking if you want to change location access from approximate to precise. It shows this even though you flipped the switch in Settings in step 4, because the previous permission request was temporary so subsequent changes to the permission in Settings will not affect it.
This is a quirk of the "Only this time" behaviour of Android permissions.
If you repeat your steps but instead of selecting "Only this time", select "While using the app", you will see that changing the switch in Settings in step 4 does cause the plugin to return ACCESS_FINE_LOCATION as GRANTED because in this case previous permission request was permanent.
I hope this makes sense - the permissions system in Android is a mess and sometimes unintuitive. However this plugin can't change that behaviour therefore I hope you understand why I'm now closing this issue.
@dpa99c thanks for the quick and detailed answer, good evening and good luck!
Bug report
CHECKLIST
[x] I have read the issue reporting guidelines
[x] I confirm this is a suspected bug or issue that will affect other users
[ ] I have reproduced the issue using the example project or provided the necessary information to reproduce the issue.
[x] I have read the documentation thoroughly and it does not help solve my issue.
[x] I have checked that no similar issues (open or closed) already exist.
Current behavior: https://github.com/dpa99c/cordova-diagnostic-plugin#getlocationauthorizationstatuses return WRONG statuses example:
Expected behavior: step 5: call again getlocationauthorizationstatuses and for ACCESS_FINE_LOCATION expected status is GRANTED/ GRANTED in use
Steps to reproduce: see Current behavior
Screenshots do not need
Environment information
cordova -v
10.0.0 (cordova-lib@10.1.0)cordova platform ls
cordova-android 11.0.0cordova plugin ls
cordova.plugins.diagnostic 7.1.0Runtime issue
Android build issue:
node -v
v14.17.4ls platforms/android/.gradle
7.4.2android:targetSdkVersion
inAndroidManifest.xml
32sdkmanager --list | sed -e '/Available Packages/q'
32.0.0Related code:
Console output
console output
``` // Paste any relevant JS/native console output here ```**Other information:**