Android/BLE: defer canceled() to match classic scan
When the classic Bluetooth scan completes quickly, the LE
scan starts automatically. A subsequent stop() then emitted
canceled() synchronously, unlike the classic path, which
defers it via Android's async DISCOVERY_FINISHED broadcast,
giving a follow-up start() time to set pendingStart.
This made tst_QBluetoothDeviceDiscoveryAgent's
tst_startStopDeviceDiscoveries scenario start-stop-start,
to fail with cancelSpy.isEmpty() returned FALSE.
Defer the LE finish into processLeDiscoveryFinished(),
which mirrors the pendingCancel/pendingStart branching
of the classic path. When the LE timer already fired,
stop() just sets pendingCancel so the queued handler
emits canceled() instead of finished().
Tag each LE scan with an epoch captured by the deferred
handler so a stale invocation from a previous scan does
not reset m_active and emit finished() for a fresh one.
Pick-to: 6.12 6.11 6.8
Task-number: QTBUG-146930
Done-with: Ivan Solovev <ivan.solovev@qt.io>
Change-Id: Ic2843efba567896194802865ea0a4939b5082f17
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>