Commit 90f5556e authored by Ryan Hansberry's avatar Ryan Hansberry Committed by Commit Bot

[Bluetooth] Remove IsDiscovering() check in StopScan().

Always request bluez to stop discovery; do not gate on whether or not
discovery is active.

The recent refactor crrev.com/c/1699214 in BluetoothAdapter and its
children classes resurfaced a buggy implementation of
BluetoothAdapterBluez::IsDiscovering() (crbug.com/905374) -- its
implementation in bluez can sometimes return an incorrect value. In this
particular bug, crbug.com/1013020, when ARC++ spammed BluetoothAdapterBluez
with too many Start/Stop scan calls, we entered a racy situation in which
ARC++ called StopScan(), and that StopScan() incorrectly early-returned,
failing to stop discovery, because BluetoothAdapterBluez::IsDiscovering()
incorrectly returned 'false'.

      the repro steps described in crbug.com/1013020.

Bug: 1013020, 822104, 905374
TEST: Manaully verified 5 times on both M78 branch and ToT following
Change-Id: Ide80706d77f1659cc07f457c4a524d823141f2c2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1854459
Commit-Queue: Ryan Hansberry <hansberry@chromium.org>
Reviewed-by: default avatarReilly Grant <reillyg@chromium.org>
Cr-Commit-Position: refs/heads/master@{#704863}
parent 9c8bdaaa
...@@ -1575,12 +1575,6 @@ void BluetoothAdapterBlueZ::StopScan(DiscoverySessionResultCallback callback) { ...@@ -1575,12 +1575,6 @@ void BluetoothAdapterBlueZ::StopScan(DiscoverySessionResultCallback callback) {
DCHECK_EQ(NumDiscoverySessions(), 0); DCHECK_EQ(NumDiscoverySessions(), 0);
if (!IsDiscovering()) {
std::move(callback).Run(
/*is_error=*/false, UMABluetoothDiscoverySessionOutcome::SUCCESS);
return;
}
// Confirm that there are no more discovery sessions left. // Confirm that there are no more discovery sessions left.
DCHECK_EQ(NumDiscoverySessions(), 0); DCHECK_EQ(NumDiscoverySessions(), 0);
auto copyable_callback = base::AdaptCallbackForRepeating(std::move(callback)); auto copyable_callback = base::AdaptCallbackForRepeating(std::move(callback));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment