From babf0631eff0e9bfa17d7925192c7923350f455a Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Fri, 14 Jul 2017 07:58:25 +0200 Subject: Android: Avoid hanging in desc or char read during service discovery If the last entry of a service is a descriptor or characteristic and the read attempt fails early (the read could not even be initiated) ensure that the discovery state machine properly exists. So far the exit was only ever triggered by a successful read or if the async callback for the read returned with an error or timed out. Change-Id: I495982a82819aab985bc91a7e63c530b52355d9d Reviewed-by: Timur Pocheptsov --- .../src/org/qtproject/qt5/android/bluetooth/QtBluetoothLE.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 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 b82a647c..0f419ad7 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 @@ -1258,15 +1258,16 @@ public class QtBluetoothLE { break; case CharacteristicValue: // for more details see scheduleServiceDetailDiscovery(int) - // ignore and continue unless last entry - GattEntry serviceEntry = entries.get(entry.associatedServiceHandle); - if (serviceEntry.endHandle == handle) - finishCurrentServiceDiscovery(entry.associatedServiceHandle); break; case Service: Log.w(TAG, "Scheduling of Service Gatt entry for service discovery should never happen."); break; } + + // last entry of current discovery run? + GattEntry serviceEntry = entries.get(entry.associatedServiceHandle); + if (serviceEntry.endHandle == handle) + finishCurrentServiceDiscovery(entry.associatedServiceHandle); } else { int errorCode = 0; -- cgit v1.2.3