diff options
author | Andreas Buhr <andreas.buhr@qt.io> | 2022-02-28 18:27:47 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2022-06-20 12:19:39 +0000 |
commit | 095717ec21c0afa91f9472803ad971cde43f5f44 (patch) | |
tree | d1437b8e4f2100e644f0214b515a4f532e8038a5 /src | |
parent | c4ad75ea83115407b1b6aa3c878b805c57d8a380 (diff) |
Repair tst_QBluetoothDeviceDiscoveryAgent unit test on Android
tst_QBluetoothDeviceDiscoveryAgent::tst_startStopDeviceDiscoveries
was broken on Android. The sequence
QBluetoothDeviceDiscoveryAgent::start()
QBluetoothDeviceDiscoveryAgent::stop()
QBluetoothDeviceDiscoveryAgent::start()
QBluetoothDeviceDiscoveryAgent::stop()
is called rather quickly.
The first stop() results in the state
pendingCancel=true, pendingStart=false.
The second start() results in the state
pendingCancel=true, pendingStart=true.
The second stop() then did nothing because pendingCancel=true.
Then, after the whole sequence, discovery started because
pendingStart=true.
This patch repairs it by setting pendingStart=false
in the stop() method.
Change-Id: I55486b5b494265c90149e72461a1d0529adaa2f0
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
(cherry picked from commit 32b859dc9c83c7fb440e53335917021ef7eab15d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/bluetooth/qbluetoothdevicediscoveryagent_android.cpp | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/bluetooth/qbluetoothdevicediscoveryagent_android.cpp b/src/bluetooth/qbluetoothdevicediscoveryagent_android.cpp index 21187e5e..03ef0d21 100644 --- a/src/bluetooth/qbluetoothdevicediscoveryagent_android.cpp +++ b/src/bluetooth/qbluetoothdevicediscoveryagent_android.cpp @@ -285,15 +285,20 @@ void QBluetoothDeviceDiscoveryAgentPrivate::stop() { Q_Q(QBluetoothDeviceDiscoveryAgent); + pendingStart = false; + if (m_active == NoScanActive) return; if (m_active == SDPScanActive) { - if (pendingCancel) + if (pendingCancel) { + // If we had both a pending cancel and a pending start, + // we now have only a pending cancel. + // The pending start was canceled above. return; + } pendingCancel = true; - pendingStart = false; bool success = adapter.callMethod<jboolean>("cancelDiscovery"); if (!success) { lastError = QBluetoothDeviceDiscoveryAgent::InputOutputError; |