From 1ed8390e17831afc5624bc7519b667eb8eea05a7 Mon Sep 17 00:00:00 2001 From: Alex Blasche Date: Thu, 15 Jun 2017 14:47:33 +0200 Subject: Android: Don't miss services if the last device discovery failed Android collects the SDP information for all devices and puts them into an sdp cache. Only when the discovery finishes the sdp cache is evaluated and the serviceDiscovered() signal is sent. The evaluation is triggerd by _q_fetchUuidsTimeout(). If it is not possible to retrieve uuids or an address for the last discovered device, the old code never triggered _q_fetchUuidsTimeout(). As a consequence QBluetoothServiceDiscoveryAgent appeared to never find any service. This patch ensures that if the last SDP discovery failed we still trigger the final UUID evaluation and subsequent serviceDiscovered() signal emissions. Change-Id: I8454dc3f7cf3688110e6c86af324d797351b5b33 Reviewed-by: Christian Stromme --- src/bluetooth/qbluetoothservicediscoveryagent_android.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp b/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp index ba5bcb0a..51db091e 100644 --- a/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp +++ b/src/bluetooth/qbluetoothservicediscoveryagent_android.cpp @@ -244,6 +244,10 @@ void QBluetoothServiceDiscoveryAgentPrivate::_q_processFetchedUuids( //could not find any service for the current address/device -> go to next one if (address.isNull() || uuids.isEmpty()) { + if (discoveredDevices.count() == 1) { + Q_Q(QBluetoothServiceDiscoveryAgent); + QTimer::singleShot(4000, q, SLOT(_q_fetchUuidsTimeout())); + } _q_serviceDiscoveryFinished(); return; } -- cgit v1.2.3