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

[Bug] Android 12 Coarse Location Permission is returning Denied Status #1999

Closed
Cheesebaron opened this issue Apr 25, 2022 · 4 comments · Fixed by #2005
Closed

[Bug] Android 12 Coarse Location Permission is returning Denied Status #1999

Cheesebaron opened this issue Apr 25, 2022 · 4 comments · Fixed by #2005
Labels
android This issue impacts Android bug Something isn't working

Comments

@Cheesebaron
Copy link
Contributor

Cheesebaron commented Apr 25, 2022

Description

If you request LocationWhenInUse permission targeting Android 12, it shows a nice pop-up, where you can select the precision of the permission you want to grant. Either Approximate (coarse) or Precise (fine).

If you only allow Approximate, the CheckAsync will always return "Denied" status, even though permission was granted.

There is no way of defining what you want.

Both fine and coarse is requested:
https://github.com/xamarin/Essentials/blob/main/Xamarin.Essentials/Permissions/Permissions.android.cs#L232-L233

Seems like it happens in this part of the code when checking permissions: https://github.com/xamarin/Essentials/blob/main/Xamarin.Essentials/Permissions/Permissions.android.cs#L82

You simply just return the status of the first, even though there might be other permissions that have been granted.

Steps to Reproduce

  1. set android:targetSdkVersion="31" and TFM to 12 or higher
  2. Check permisison with await Permissions.CheckStatusAsync<Permissions.LocationWhenInUse>();
  3. PermissionStatus will always be "Denied" if you selected approximate location when requsting

Expected Behavior

Some kind of granularity to know which of the two requested permissions in LocationWhenInUse have been permitted by the user.

Actual Behavior

PermissionStatus is Denied if "Approximate" is selected

Basic Information

  • Version with issue:
  • Last known good version:
  • IDE:
  • Platform Target Frameworks:
    • Android: 12
  • Nuget Packages:
  • Affected Devices: All Android 12 and up when targeting Android 12

Screenshots

Screenshot_20220422-140530

Reproduction Link

@Cheesebaron Cheesebaron added the bug Something isn't working label Apr 25, 2022
@jfversluis
Copy link
Member

Are you sure you're using the latest version? We did some fixes around this.

@aritchie ?

@jfversluis jfversluis added the android This issue impacts Android label May 2, 2022
@aritchie
Copy link
Contributor

aritchie commented May 2, 2022

@jfversluis I fixed RequestAsync. This is a different method/code path.

@jfversluis
Copy link
Member

@Cheesebaron would you be able to test the resulting NuGet from the linked PR and see if that has the desired result? If so, I can add it to the next release I want to put out this week/early next week.

@Cheesebaron
Copy link
Contributor Author

Yep, will give it a spin and see how it behaves ☺️

jfversluis added a commit that referenced this issue May 6, 2022
…eckstatusasync

Fix #1999 - checkasync should return restricted for locationinuse whe…
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android This issue impacts Android bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants