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

Fix scan precondition verifier for Android 10 #637

Closed
dariuszseweryn opened this issue Oct 28, 2019 · 4 comments · Fixed by #640
Closed

Fix scan precondition verifier for Android 10 #637

dariuszseweryn opened this issue Oct 28, 2019 · 4 comments · Fixed by #640
Labels
bug Bug that is caused by the library

Comments

@dariuszseweryn
Copy link
Owner

Summary

On Android 10 scan needs ACCESS_FINE_LOCATION permission.

Library version

1.10.3

Preconditions

Android 10 mobile phone to run the test

Steps to reproduce actual result


1. Use an app with ACCESS_COARSE_LOCATION

2. Try to run a scan

3. Observe result

Actual result

Scan seems to be started correctly but a log is shown:

E/BluetoothUtils: Permission denial: Need ACCESS_FINE_LOCATION permission to get scan results

Expected result

A BleScanException is emitted with a desirable error code LOCATION_PERMISSION_MISSING or FINE_LOCATION_PERMISSION_MISSING (TBD)

Minimum code snippet reproducing the issue

        val scanSettings = ScanSettings.Builder()
            .setScanMode(ScanSettings.SCAN_MODE_LOW_LATENCY)
            .setCallbackType(ScanSettings.CALLBACK_TYPE_ALL_MATCHES)
            .build()

        val scanFilter = ScanFilter.Builder()
            // add custom filters if needed
            .build()

        rxBleClient.scanBleDevices(scanSettings, scanFilter).subscribe()

Logs from the application running with settings:

RxBleClient.updateLogOptions(new LogOptions.Builder()
        .setLogLevel(LogConstants.DEBUG)
        .setMacAddressLogSetting(LogConstants.MAC_ADDRESS_FULL)
        .setUuidsLogSetting(LogConstants.UUIDS_FULL)
        .setShouldLogAttributeValues(true)
        .build()
);
2019-10-28 17:29:28.364 8318-8357/com.polidea.rxandroidble.sample I/RxBle#ClientOperationQueue: RUNNING  ScanOperationApi21{ANY_MUST_MATCH -> nativeFilters=[BluetoothLeScanFilter [mDeviceName=null, MAC=null, mUuid=null, mUuidMask=null, mServiceDataUuid=null, mServiceData=null, mServiceDataMask=null, mManufacturerId=-1, mManufacturerData=null, mManufacturerDataMask=null]]}
2019-10-28 17:29:28.365 8318-8380/com.polidea.rxandroidble.sample I/RxBle#QueueOperation: Scan operation is requested to start.
2019-10-28 17:29:28.368 8318-8380/com.polidea.rxandroidble.sample D/BluetoothAdapter: isLeEnabled(): ON
2019-10-28 17:29:28.374 6276-6323/? I/bt_stack: [INFO:gatt_api.cc(946)] GATT_Register 4f95b434-3363-7845-06bf-01ea4105e510
2019-10-28 17:29:28.374 6276-6323/? I/bt_stack: [INFO:gatt_api.cc(966)] allocated gatt_if=7
2019-10-28 17:29:28.375 8318-8345/com.polidea.rxandroidble.sample D/BluetoothLeScanner: onScannerRegistered() - status=0 scannerId=7 mScannerId=0
2019-10-28 17:29:28.380 6276-6294/? E/BluetoothUtils: Permission denial: Need ACCESS_FINE_LOCATION permission to get scan results
@dariuszseweryn dariuszseweryn changed the title Add scan precondition verifier for Android 10 Fix scan precondition verifier for Android 10 Nov 7, 2019
@dariuszseweryn dariuszseweryn added bug Bug that is caused by the library and removed enhancement labels Nov 7, 2019
@Steppschuh
Copy link

This should probably be mentioned in the Permissions section of the readme.

@dariuszseweryn
Copy link
Owner Author

How would you see it?

@Steppschuh
Copy link

I just would give a heads up to users that they need to request the ACCESS_FINE_LOCATION permission on Android 10+. From the current wording one could think that ACCESS_COARSE_LOCATION would be sufficient.

@dariuszseweryn
Copy link
Owner Author

Should be better now

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug that is caused by the library
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants