-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Description
Description
Since Android 12, it is possible to do Bluetooth scanning without location permissions. To achieve this, one has to declare the BT scanning permission in the Android manifest like this:
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" android:usesPermissionFlags="neverForLocation" />
Requesting the permissions at runtime works well for this scenario, as long as ACCESS_FINE_LOCATION is not declared in the manifest:
PermissionStatus status = await Permissions.CheckStatusAsync<Permissions.Bluetooth>();
if (status != PermissionStatus.Granted)
status = await Permissions.RequestAsync<Permissions.Bluetooth>();
However, if ACCESS_FINE_LOCATION is declared in the manifest, but is denied at runtime (while BLUETOOTH_SCAN is granted), then the snippet above reports the status as PermissionStatus.Denied.
This wrongly signals to the application that scanning is not possible, while in fact it is.
Steps to Reproduce
- Check out the
dotnet-bluetooth-lerepository (link below). - Build the sample
BLE.Client.MAUIand run it on a Android 12+ device. - Reject the location permission, but accept the Bluetooth/Nearby devices permission at runtime.
- As a result, the app will not start scanning (although it could): "Permissions denied. Not scanning."
Link to public reproduction project repository
https://github.com/dotnet-bluetooth-le/dotnet-bluetooth-le
Version with bug
8.0.7 SR2
Is this a regression from previous behavior?
No, this is something new
Last version that worked well
Unknown/Other
Affected platforms
Android
Affected platform versions
Android 12 and up
Did you find any workaround?
Ignore the wrong permission status.
Relevant log output
No response