Skip to content
Browse files

[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 in BluetoothAdapter and its
children classes resurfaced a buggy implementation of
BluetoothAdapterBluez::IsDiscovering() ( -- its
implementation in bluez can sometimes return an incorrect value. In this
particular bug,, 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

(cherry picked from commit 90f5556)

Bug: 1013020, 822104, 905374
TEST: Manaully verified 5 times on both M78 branch and ToT following
Change-Id: Ide80706d77f1659cc07f457c4a524d823141f2c2
Commit-Queue: Ryan Hansberry <>
Reviewed-by: Reilly Grant <>
Cr-Original-Commit-Position: refs/heads/master@{#704863}
Reviewed-by: Ryan Hansberry <>
Cr-Commit-Position: refs/branch-heads/3904@{#732}
Cr-Branched-From: 675968a-refs/heads/master@{#693954}
  • Loading branch information
Ryan Hansberry
Ryan Hansberry committed Oct 11, 2019
1 parent 5227e61 commit 262c1c1556313564a28e590ec558ca99a5ee5817
Showing with 0 additions and 6 deletions.
  1. +0 −6 device/bluetooth/bluez/
@@ -1575,12 +1575,6 @@ void BluetoothAdapterBlueZ::StopScan(DiscoverySessionResultCallback callback) {

DCHECK_EQ(NumDiscoverySessions(), 0);

if (!IsDiscovering()) {
/*is_error=*/false, UMABluetoothDiscoverySessionOutcome::SUCCESS);

// Confirm that there are no more discovery sessions left.
DCHECK_EQ(NumDiscoverySessions(), 0);
auto copyable_callback = base::AdaptCallbackForRepeating(std::move(callback));

0 comments on commit 262c1c1

Please sign in to comment.
You can’t perform that action at this time.