-
Notifications
You must be signed in to change notification settings - Fork 583
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
Support Android 12 Bluetooth Permissions #752
Comments
Is there any progress on that taks or estimates? |
Are there any updates to this task? |
Btw there is also ACCESS_BACKGROUND_LOCATION missing for API 29+ (can't perform scan without it) |
Is there even a plan for this change? It would be really helpful not to force users to turn on location only for Bluetooth. |
I have it on my plate. I am currently running this project on my free time which I do not have plenty unfortunately. 🤷♂️ |
Is there any info whether on Android 12 / API 31 scan results will get returned if Location Services are turned off while the scan is running? |
@hosek You don't need background location to scan while the app is active. I agree that if you want to build an app that's scanning while the app is backgrounded you'll need it. But that should only be necessary under certain circumstances where you're maybe looking to recognize being in range of certain devices. But in general, you don't need it. |
That's a great question. Usually if you're targeting an older SDK (in this case Android 11/Api 30), you'd fallback to the previous behavior, or something compatible to that. I don't see anything in particular about this scenario though in the feature docs: https://developer.android.com/about/versions/12/features/bluetooth-permissions |
Hi @dariuszseweryn, I have access to a Pixel 5 running the current Beta of Android 12. I'm interested in RxAndroidBle supporting API 31, I wouldn't mind testing anything and provide logs that could help to close this issue. |
Awesome, thank you for the proposition. I've got some support from a Google employee and I think I have all needed knowledge about how the new OS is working. |
I will check with the appropriate people at work if i can contribute (have to go through a whole process). But there's definitely some other suggestions of things i'd like to support (like ble encryption during gatt connect via a pre-computed pin). That's definitely a big need i have coming down the pipe and i don't see anything in the library that supports it. |
@mattinger did you already work on this issue? Would be great to have this functionality in. We also need this for our flutter library. Let me know if I can help out. |
Any progress on Android 12 Bluetooth permissions? |
I have just pushed |
What target SDK? |
Originally this was targeting 29, but after updating the targetSDKVersion to 31, I'm now getting this error. LOCATION_PERMISSION_NOT_GRANTED for rxBleClient.getState() before starting the scan. I have confirmed that location permissions have been granted as my app also uses this for GPS Speed readings. Edit: I can confirm that my callbacks are showing that I have all the necessary permissions required for scanning. Edit #2: |
Yeah, I need to update two more javadocs. Could you confirm that when the app uses target SDK <31 the OS will still complain about no |
So are you saying if we want to scan, we have to request all 3 (BLUETOOTH_SCAN plus the two location permissions)? I would think if set the neverForLocation you wouldn't need that. |
Yes, on a fresh install without the BLUETOOTH_SCAN/BLUETOOTH_CONNECT permissions declared in the manifest AND manually requested, my app targeting API 29 still can't scan for devices. It errors out with
In my application we use the precise location anyways for GPS readings, but from my understanding if you're just trying to scan BT devices (and use the neverForLocation flag) that should be all you need for Android 12. |
@dariuszseweryn Just looking for some confirmation on what permissions it checks based on OS. For 30 and below: check fine location / coarse location Our app does both a scan and a connect, so we'll likely have to wait until your changes are ready for breaking the state into 2 pieces. It's just unclear to me what the behavior is for the current version that's published. |
What is being checked depends on both deviceSdk and application targetSdk |
@dariuszseweryn Is there any api which can give us the required permissions? I've written a few helper functions to do things like return the permissions we need to ask for, decide if location services needs to be on, etc, but it makes more sense for the library to have these. |
See RxBleClient#getRecommendedScanRuntimePermissions |
I can confirm it works like intended many thanks! 🙏 |
I have added the following to my manifest.xml
I am also trying to request permission for
I am getting the following error message in the Android Studio logs - Does anyone know how you request permission for BLUETOOTH_CONNECT or BLUETOOTH_SCAN? I have tried requesting both using the PermissionsAndroid.request() function but I still get the same error. Whenever I try requesting a different kind of permission I am not getting any errors - only with the bluetooth permissions. |
@williamgoodhew I am afraid that you should ask for support from the |
sorry I got confused with the ble-plx library you guys used to do. |
Update the following in your build.gradle:
|
is i possible to update the Sample-Kotlin for these fixes?Cause on OS12 it doesn't work.Thx |
@dariuszseweryn Is there any plan to add functions around permission checks for gatt connections? Maybe something like isPermissionRequiredToConnect and getRecommendedConnectRuntimePermissions |
@mattinger I am implementing this in #768 |
With Android 12 comes two new bluetooth permissions that will replace Location Permission:
The library needs to be updated to reflect these states. In addition, Bluetooth Connect is only
required if you're going to open a gatt connection to the the device, so it shouldn't block the
operation of the library. Currently the RxBleClient.state is a progressive check that ends up with an isReadyForScanning
when all permissions and services have turned on.
I'd recommend that this be broken out into two states. Once for scanning and one for connecting.
https://developer.android.com/about/versions/12/features/bluetooth-permissions
The text was updated successfully, but these errors were encountered: