Skip to content
This repository has been archived by the owner on May 15, 2024. It is now read-only.

[Bug] Approximate location on Android 12 doesn't work correct. #1972

Closed
orikworld opened this issue Feb 22, 2022 · 10 comments
Closed

[Bug] Approximate location on Android 12 doesn't work correct. #1972

orikworld opened this issue Feb 22, 2022 · 10 comments
Labels
bug Something isn't working

Comments

@orikworld
Copy link

orikworld commented Feb 22, 2022

Description

Can not get the approximate location on android 12 because line (Permissions.EnsureGrantedAsync<Permissions.LocationWhenInUse>()) expected only permissions granted:

await Permissions.EnsureGrantedAsync<Permissions.LocationWhenInUse>();

Steps to Reproduce

  1. Select the approximate location in popup
  2. Try to get permissions for locationInUse => Restricted
  3. Try to get the approximate location => throw a exception

Expected Behavior

 Geolocation gets the approximate location on android 12

Actual Behavior

Geolocation throws a exception

Basic Information

  • Version with issue:
  • Platform Target Frameworks:
    • Android: 12 (API 31)
@orikworld orikworld added the bug Something isn't working label Feb 22, 2022
@SharpMobileCode
Copy link

I'm seeing the same issue as you when users select "Approximate" location. The permission status comes back as Restricted, which is expected. But when we perform a Geolocation.GetLocationAsync(request), a null result comes back instead of a Location.

I'm just taking a guess here looking at the code, but I think this line:

if (status != PermissionStatus.Granted)

might need to be checking for PermissionStatus.Restricted as well?

Current Code

if (status != PermissionStatus.Granted)
    throw new PermissionException($"{typeof(TPermission).Name} permission was not granted: {status}");

Proposed Change?

if (status != PermissionStatus.Granted && status != PermissionStatus.Restricted)
    throw new PermissionException($"{typeof(TPermission).Name} permission was not granted: {status}");

Thoughts anyone?

cc: @jfversluis

@jfversluis
Copy link
Member

@aritchie I guess this might be something that came from #1937 ?

@jfversluis
Copy link
Member

@SharpMobileCode I see you have a analysis and proposal already, would you be willing and able to put it in a PR? You should be able to then also test if it actually fixes it for you :)

@aritchie
Copy link
Contributor

aritchie commented Mar 1, 2022

@jfversluis yup. I only changed the permission requests, not any of the gatekeeper methods. I just sent a PR for this: #1976

I would appreciate if the users in this issue test it please.

@SharpMobileCode
Copy link

I'll check it out this evening (CST) and will let you all know. Thank you!

@jfversluis
Copy link
Member

Let me know if you got around to this @SharpMobileCode thanks!

@SharpMobileCode
Copy link

@jfversluis Thanks! Yeah, I pulled down the PR and was able to compile locally. But when I integrate the new binaries into the project I'm working on, I'm getting compile errors in my code saying that it can't find HapticFeedback and HapticFeedbackType from the new Essentials binary. Am I missing something?

@SharpMobileCode
Copy link

Okay, I've got it integrated into my app now (using project references instead) and it doesn't appear to work as expected. Currently running through the debugger trying to figure some stuff out. Thanks!

@SharpMobileCode
Copy link

Okay, now it seems that when the user selects "Approximate Location", the locationManager.RequestUpdates(provider, 0, 0, listener, looper); call does not seem to execute the listener. This causes

var androidLocation = await tcs.Task;

to await indefinitely because:

void HandleLocation(AndroidLocation location)

is never invoked from the listener. So it just kind of freezes there. However, if the user selects "Precise" location, then everything works as expected.

I've only ever used FusedLocationProviderClient natively for geolocation, so I'm not too familiar with LocationManager. I'll have to research this further. Any insight or experiences regarding this?

Thanks!

@jfversluis
Copy link
Member

Thanks for working together on this with us @SharpMobileCode ! I'll look into this asap as well :)

jfversluis added a commit that referenced this issue Apr 5, 2022
Fix #1972 - allow restricted permissions for geolocation on android
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants