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-21 10:39:30 +0100 |
commit | c81430b704e17d2f2eb5445e261ab3753bef3328 (patch) | |
tree | 4323da987882f277b7a3d462a1f7d2b0c0fa3945 /src | |
parent | fd48361a193889cdc25af8aeb311acc8ad85fa26 (diff) |
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>
Diffstat (limited to 'src')
-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 4b9e2032..fd17faee 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) { |