diff options
author | Alex Blasche <alexander.blasche@qt.io> | 2020-02-19 09:40:57 +0100 |
---|---|---|
committer | Alex Blasche <alexander.blasche@qt.io> | 2020-02-20 12:52:57 +0100 |
commit | 76d98250d46b4afa3d83b550bd26b33021928310 (patch) | |
tree | ad7bcade47e4b0a8c390e55c774fca5ba657476c /src | |
parent | b9502e498c1033b8334afca7808807d3b6f00926 (diff) |
Catch turned off Bluetooth adapter when stopping LE discovery
Calling stopLeScan() causes a runtime exception.
The patch prevents a crash due to the exception and progresses
as if nothing has happened. An action that turned off the
internal Bluetooth device has stopped a runnung discovery anyway.
Fixes: QTBUG-67482
Change-Id: Iff377884c50cafa1f74dafe73e0acbb31b13e9bb
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Diffstat (limited to 'src')
-rw-r--r-- | src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLE.java | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLE.java b/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLE.java index 8a69b4c7..f70ee8a4 100644 --- a/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLE.java +++ b/src/android/bluetooth/src/org/qtproject/qt5/android/bluetooth/QtBluetoothLE.java @@ -162,7 +162,13 @@ public class QtBluetoothLE { mBluetoothLeScanner.startScan(filterList, settings, leScanCallback21); mLeScanRunning = true; } else { - mBluetoothLeScanner.stopScan(leScanCallback21); + try { + mBluetoothLeScanner.stopScan(leScanCallback21); + } catch (IllegalStateException isex) { + // when trying to stop a scan while bluetooth is offline + // java.lang.IllegalStateException: BT Adapter is not turned ON + Log.d(TAG, "Stopping LE scan not possible: " + isex.getMessage()); + } mLeScanRunning = false; } |