summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlex Blasche <alexander.blasche@theqtcompany.com>2016-06-01 14:16:23 +0200
committerAlex Blasche <alexander.blasche@theqtcompany.com>2016-06-08 12:00:10 +0000
commit3bf621a5e611eb5b7585464d0453a87b688f7a4e (patch)
treed748a1db714fde20d870e1bcca560296441525c6
parentbe8c8951744558070d72665f111909fb32b70d4f (diff)
BlueZ5: Prevent premature abortion of device discovery
This may happen when the device discovery agent is quickly started and stopped and started again. If the stop-start combination is happening quicker than dbus can deliver the Discovering flag of the Adapter1 BlueZ interface, BlueZ's stop response will override the new start discovery request. Task-number: QTBUG-53715 Change-Id: I6a03fc525c7f390db009fc68a5313352ebba7f79 Reviewed-by: Frank Meerkoetter <frank.meerkoetter@basyskom.com> Reviewed-by: Alex Blasche <alexander.blasche@theqtcompany.com>
-rw-r--r--src/bluetooth/bluez/bluez5_helper.cpp20
-rw-r--r--src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp2
2 files changed, 19 insertions, 3 deletions
diff --git a/src/bluetooth/bluez/bluez5_helper.cpp b/src/bluetooth/bluez/bluez5_helper.cpp
index 14e064e1..d77e8fb6 100644
--- a/src/bluetooth/bluez/bluez5_helper.cpp
+++ b/src/bluetooth/bluez/bluez5_helper.cpp
@@ -260,8 +260,24 @@ void QtBluezDiscoveryManager::PropertiesChanged(const QString &interface,
&& d->references.contains(propIface->path())
&& changed_properties.contains(QStringLiteral("Discovering"))) {
bool isDiscovering = changed_properties.value(QStringLiteral("Discovering")).toBool();
- if (!isDiscovering)
- removeAdapterFromMonitoring(propIface->path());
+ if (!isDiscovering) {
+
+ /*
+ Once we stop the Discovering flag will switch a few ms later. This comes through this code
+ path. If a new device discovery is started while we are still
+ waiting for the flag change signal, then the new device discovery will be aborted prematurely.
+ To compensate we check whether there was renewed interest.
+ */
+
+ AdapterData *data = d->references[propIface->path()];
+ if (!data) {
+ removeAdapterFromMonitoring(propIface->path());
+ } else {
+ OrgBluezAdapter1Interface iface(QStringLiteral("org.bluez"), propIface->path(),
+ QDBusConnection::systemBus());
+ iface.StartDiscovery();
+ }
+ }
}
}
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp
index 7ff57adf..90ad2978 100644
--- a/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp
+++ b/src/bluetooth/qbluetoothdevicediscoveryagent_bluez.cpp
@@ -522,7 +522,7 @@ void QBluetoothDeviceDiscoveryAgentPrivate::_q_discoveryInterrupted(const QStrin
return;
if (path == adapterBluez5->path()) {
- qCWarning(QT_BT_BLUEZ) << "Device discovery aborted due to unexpected adapter changes";
+ qCWarning(QT_BT_BLUEZ) << "Device discovery aborted due to unexpected adapter changes from another process.";
if (discoveryTimer)
discoveryTimer->stop();