You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
3. stop scanning in background client.getBackgroundScanner().stopScanningInBackground(PendingIntent)
Minimum code snippet reproducing the issue
Logs from the application running with setting RxBleLog.setLogLevel(RxBleLog.VERBOSE)
Attempt to invoke virtual method 'void android.bluetooth.le.BluetoothLeScanner.stopScan(android.app.PendingIntent)' on a null object reference
at com.polidea.rxandroidble2.internal.util.RxBleAdapterWrapper.stopLeScan(RxBleAdapterWrapper.java:62)
at com.polidea.rxandroidble2.internal.scan.BackgroundScannerImpl.stopBackgroundBleScan(BackgroundScannerImpl.java:74)
Actual result
Uncatchable NPE
Expected result
No Exception or BluetoothScanException with Code for Bluetooth being off
The text was updated successfully, but these errors were encountered:
Somewhat related, there is a different internal exception when trying to start scanning in the background while bluetooth is disabled.
java.lang.SecurityException: Need BLUETOOTH_PRIVILEGED permission: Neither user 10188 nor current process has android.permission.BLUETOOTH_PRIVILEGED.
at android.os.Parcel.createException(Parcel.java:1942)
at android.os.Parcel.readException(Parcel.java:1910)
at android.os.Parcel.readException(Parcel.java:1860)
at android.bluetooth.IBluetoothGatt$Stub$Proxy.startScanForIntent(IBluetoothGatt.java:977)
at android.bluetooth.le.BluetoothLeScanner.startScan(BluetoothLeScanner.java:249)
at android.bluetooth.le.BluetoothLeScanner.startScan(BluetoothLeScanner.java:166)
at com.polidea.rxandroidble2.internal.util.RxBleAdapterWrapper.startLeScan(RxBleAdapterWrapper.java:57)
at com.polidea.rxandroidble2.internal.scan.BackgroundScannerImpl.scanBleDeviceInBackground(BackgroundScannerImpl.java:56)
This case should also be handled by the fix on fix/background_scanner_npe branch as it checks if adapter is on. I have created a different issue as potentially a SecurityException may also be thrown when specific settings will be passed to the scan.
Summary
When Bluetooth is not enabled, calling client.getBackgroundScanner().stopScan(Pending) causes NPE
I assume this is due to BluetoothAdapter#getBluetoothLEScanner() returns null if the BluetoothAdapter is off.
Library version
1.7.0
Preconditions
Bluetooth is on and client returns State.READY for client state
Steps to reproduce actual result
1. startScanningWith background scanner (client.getBackgroundScanner().scanBleDeviceInBackground(settings, filter, PendingIntent)
2. turn off bluetooth
3. stop scanning in background client.getBackgroundScanner().stopScanningInBackground(PendingIntent)
Minimum code snippet reproducing the issue
Logs from the application running with setting
RxBleLog.setLogLevel(RxBleLog.VERBOSE)
Actual result
Uncatchable NPE
Expected result
No Exception or BluetoothScanException with Code for Bluetooth being off
The text was updated successfully, but these errors were encountered: