RxAndroidBle icon indicating copy to clipboard operation
RxAndroidBle copied to clipboard

Android 12 / targetSDK 31 should give hint about actual permission missing

Open danielRi opened this issue 1 year ago • 3 comments

Describe the bug Location Permission for Android 12 is optional (targetSDK needs to be >= 31). See https://developer.android.com/guide/topics/connectivity/bluetooth/permissions#declare-android12-or-higher The library however forces FINE_LOCATION to be set.

To Reproduce Steps to reproduce the behavior:

  1. Remove <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" /> from Manifest
  2. Increase targetSDK to at least 31
  3. Start App without asking for location runtime permission
  4. Perform any bluetooth related scan with the library. e.G. scanning
  5. An error is thrown Caused by: com.polidea.rxandroidble2.exceptions.BleScanException: Location Permission missing (code 3)

Expected behavior For Android 12 Devices, when targetting API 31, setting location is optional. The library should not force location permission to be set.

Smartphone (please complete the following information):

  • Device: Samsung S22 Ultra
  • OS: Android 12
  • Library version: [1.13.1]

Logs from the application when bug occurs (this will greatly help in quick understanding the problem) To turn on logs use:

`Caused by: com.polidea.rxandroidble2.exceptions.BleScanException: Location Permission missing (code 3)`

Additional context compileSdkVersion = 32 buildToolsVersion = "30.0.2" minSdkVersion = 24 targetSdkVersion = 32

danielRi avatar Jul 15 '22 05:07 danielRi

Do you have BLUETOOTH_SCAN permission granted?

dariuszseweryn avatar Jul 16 '22 08:07 dariuszseweryn

hey @dariuszseweryn :)

No I have not. I see this fixes the issue. Thank you! Maybe the error "Location Permission missing" is not ideal, but not gonna complain about it since it´s working now.

danielRi avatar Jul 18 '22 06:07 danielRi

Yeah, I will need to think if an alternative wording should be used or whether it would be a braking change

dariuszseweryn avatar Jul 19 '22 18:07 dariuszseweryn