btleplug icon indicating copy to clipboard operation
btleplug copied to clipboard

NPE on Android when stopping scanning and the Bluetooth adapter has gone

Open blackspherefollower opened this issue 1 year ago • 0 comments

Describe the bug From sentry:

NullPointerException: Attempt to invoke virtual method 'void android.bluetooth.le.BluetoothLeScanner.stopScan(android.bluetooth.le.ScanCallback)' on a null object reference

I suspect that the unchecked results in https://github.com/deviceplug/btleplug/blob/master/src/droidplug/java/src/main/java/com/nonpolynomial/btleplug/android/impl/Adapter.java#L39 are to blame (it's probably safe to ignore NULL results, as that suggests the Bluetooth adapter has gone away and hence the scan has already stopped).

Whilst I can't reproduce this, the reporter stated that they had Bluetooth disabled on their phone when they experienced the crash (Android 10 running on an LG K50S)

blackspherefollower avatar Oct 03 '24 11:10 blackspherefollower