summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@digia.com>2014-04-15 14:18:12 +0200
committerThe Qt Project <gerrit-noreply@qt-project.org>2014-04-16 13:37:25 +0200
commit9b11226f3d23dfb4c6b8457f2a839584666cda6a (patch)
tree107ba67d5994db540f1695c55aca1236b5f51c22
parentd755d1e76e8268f1de9c2006685df84e4e2728bf (diff)
Fix discovery hanging in unrecoverable state due to incorrect error handling
The discovery of services happens in a sequentiali per-device order. Once the first device's services were found, the results are processed and the discovery is started on the next device. Unfortunately if the search didn't create any results due to the remote device refusing the SDP discovery or because the given remote Bluetooth address was not valid, the discovery agent didn't continue with the next device. Now the error handling ensures that the discovery process is continued with the next device (if there is any). Task-number: QTBUG-38362 Change-Id: Ie27bbc5327eadc4bcc31b589227c51dc4fa2c7c1 Reviewed-by: Fabian Bumberger <fbumberger@rim.com>
-rw-r--r--src/bluetooth/android/servicediscoverybroadcastreceiver.cpp6
-rw-r--r--src/bluetooth/qbluetoothservicediscoveryagent_android.cpp6
2 files changed, 11 insertions, 1 deletions
diff --git a/src/bluetooth/android/servicediscoverybroadcastreceiver.cpp b/src/bluetooth/android/servicediscoverybroadcastreceiver.cpp
index 0a3f97f9..87564ce6 100644
--- a/src/bluetooth/android/servicediscoverybroadcastreceiver.cpp
+++ b/src/bluetooth/android/servicediscoverybroadcastreceiver.cpp
@@ -76,8 +76,10 @@ void ServiceDiscoveryBroadcastReceiver::onReceive(JNIEnv *env, jobject context,
"getParcelableArrayExtra",
"(Ljava/lang/String;)[Landroid/os/Parcelable;",
keyExtra.object<jstring>());
- if (!parcelableUuids.isValid())
+ if (!parcelableUuids.isValid()) {
+ emit uuidFetchFinished(QBluetoothAddress(), QList<QBluetoothUuid>());
return;
+ }
const QList<QBluetoothUuid> result = ServiceDiscoveryBroadcastReceiver::convertParcelableArray(parcelableUuids);
keyExtra = valueForStaticField(JavaNames::BluetoothDevice, JavaNames::ExtraDevice);
@@ -89,6 +91,8 @@ void ServiceDiscoveryBroadcastReceiver::onReceive(JNIEnv *env, jobject context,
if (bluetoothDevice.isValid()) {
address = QBluetoothAddress(bluetoothDevice.callObjectMethod<jstring>("getAddress").toString());
emit uuidFetchFinished(address, result);
+ } else {
+ emit uuidFetchFinished(QBluetoothAddress(), QList<QBluetoothUuid>());
}
}
}
diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp b/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp
index 4a8b62e7..2643d7a9 100644
--- a/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp
+++ b/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp
@@ -246,6 +246,12 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_processFetchedUuids(
if (discoveredDevices.count() == 0)
return;
+ //could not find any service for the current address/device -> go to next one
+ if (address.isNull() || uuids.isEmpty()) {
+ _q_serviceDiscoveryFinished();
+ return;
+ }
+
if (QT_BT_ANDROID().isDebugEnabled()) {
qCDebug(QT_BT_ANDROID) << "Found UUID for" << address.toString()
<< "\ncount: " << uuids.count();