summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@qt.io>2018-04-27 14:04:14 +0200
committerAlex Blasche <alexander.blasche@qt.io>2018-04-30 12:24:26 +0000
commitef332e4deedc914fe33bab68107f902182e03356 (patch)
treebd285dedfc32c570438ecbe62e89828363d86d2e /src
parentdc435c6ce0a6ecae776dc0dd032016453a0b4b56 (diff)
Fix crash when entries is empty (caused by disconnect somewhere else)
The patch fixes the obvious problem of the crash. The question is however what might have caused entries to be empty. The only theoretical explanation is the remote device being disconnected (which resets most internal data). Task-number: QTBUG-65826 Change-Id: I6b3509248f795d9cee5dcfe0c6e0caf06405b4e4 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.java39
1 files changed, 27 insertions, 12 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 1b527ae3..4063537b 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
@@ -1141,16 +1141,24 @@ public class QtBluetoothLE {
if (handle == HANDLE_FOR_MTU_EXCHANGE)
return;
- GattEntry entry = entries.get(handle);
- if (entry == null)
- return;
- if (entry.valueKnown)
- return;
- entry.valueKnown = true;
+ try {
+ synchronized (this) {
- GattEntry serviceEntry = entries.get(entry.associatedServiceHandle);
- if (serviceEntry != null && serviceEntry.endHandle == handle)
- finishCurrentServiceDiscovery(entry.associatedServiceHandle);
+ GattEntry entry = entries.get(handle);
+ if (entry == null)
+ return;
+ if (entry.valueKnown)
+ return;
+ entry.valueKnown = true;
+
+ GattEntry serviceEntry = entries.get(entry.associatedServiceHandle);
+ if (serviceEntry != null && serviceEntry.endHandle == handle)
+ finishCurrentServiceDiscovery(entry.associatedServiceHandle);
+ }
+ } catch (IndexOutOfBoundsException outOfBounds) {
+ Log.w(TAG, "interruptCurrentIO(): Unknown gatt entry, index: "
+ + handle + " size: " + entries.size());
+ }
}
/*
@@ -1271,9 +1279,16 @@ public class QtBluetoothLE {
}
// last entry of current discovery run?
- GattEntry serviceEntry = entries.get(entry.associatedServiceHandle);
- if (serviceEntry.endHandle == handle)
- finishCurrentServiceDiscovery(entry.associatedServiceHandle);
+ synchronized (this) {
+ try {
+ GattEntry serviceEntry = entries.get(entry.associatedServiceHandle);
+ if (serviceEntry.endHandle == handle)
+ finishCurrentServiceDiscovery(entry.associatedServiceHandle);
+ } catch (IndexOutOfBoundsException outOfBounds) {
+ Log.w(TAG, "performNextIO(): Unknown service for entry, index: "
+ + entry.associatedServiceHandle + " size: " + entries.size());
+ }
+ }
} else {
int errorCode = 0;