diff options
author | Alex Blasche <alexander.blasche@qt.io> | 2020-02-12 15:50:37 +0100 |
---|---|---|
committer | Alex Blasche <alexander.blasche@qt.io> | 2020-02-26 10:35:17 +0100 |
commit | 08fa2adc272ae58564601e92dc5d1459d8dc89ba (patch) | |
tree | e79ff166c51f7797638593786eba47d19d1054b1 | |
parent | b4bd5c9852c1414cc45a551590fa485ade764c63 (diff) | |
download | qtconnectivity-08fa2adc272ae58564601e92dc5d1459d8dc89ba.tar.gz |
Ensure that a failing classic discovery doesn't prevent LE scan
When the classic scan does not start properly we immediately error out.
If the user has requested LE discovery in addition to the classic discovery,
we should continue with LE discovery.
By convention, we only bother the user with an error signal if none of the
two methods succeed.
Task-number: QTBUG-81875
Change-Id: Id867892210fbef6da0e4937c2aef20f726ba9a2a
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
(cherry picked from commit c81430b704e17d2f2eb5445e261ab3753bef3328)
-rw-r--r-- | src/bluetooth/qbluetoothdevicediscoveryagent_android.cpp | 24 |
1 files changed, 16 insertions, 8 deletions
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_android.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent_android.cpp index 07426f1f..e1816932 100644 --- a/src/bluetooth/qbluetoothdevicediscoveryagent_android.cpp +++ b/src/bluetooth/qbluetoothdevicediscoveryagent_android.cpp @@ -239,17 +239,25 @@ void QBluetoothDeviceDiscoveryAgentPrivate::start(QBluetoothDeviceDiscoveryAgent if (requestedMethods & QBluetoothDeviceDiscoveryAgent::ClassicMethod) { const bool success = adapter.callMethod<jboolean>("startDiscovery"); if (!success) { - lastError = QBluetoothDeviceDiscoveryAgent::InputOutputError; - errorString = QBluetoothDeviceDiscoveryAgent::tr("Classic Discovery cannot be started"); - emit q->error(lastError); + qCDebug(QT_BT_ANDROID) << "Classic Discovery cannot be started"; + if (requestedMethods == QBluetoothDeviceDiscoveryAgent::ClassicMethod) { + //only classic discovery requested -> error out + lastError = QBluetoothDeviceDiscoveryAgent::InputOutputError; + errorString = QBluetoothDeviceDiscoveryAgent::tr("Classic Discovery cannot be started"); + + emit q->error(lastError); + return; + } // else fall through to LE discovery + } else { + m_active = SDPScanActive; + qCDebug(QT_BT_ANDROID) + << "QBluetoothDeviceDiscoveryAgentPrivate::start() - Classic search successfully started."; return; } + } - m_active = SDPScanActive; - qCDebug(QT_BT_ANDROID) - << "QBluetoothDeviceDiscoveryAgentPrivate::start() - Classic search successfully started."; - } else { - // LE search only requested + if (requestedMethods & QBluetoothDeviceDiscoveryAgent::LowEnergyMethod) { + // LE search only requested or classic discovery failed but lets try LE scan anyway Q_ASSERT(requestedMethods & QBluetoothDeviceDiscoveryAgent::LowEnergyMethod); if (QtAndroidPrivate::androidSdkVersion() < 18) { |