From 65ff9dac4c71144c8b10b96a88d17bdf665b81a0 Mon Sep 17 00:00:00 2001 From: Sonny Sasaka Date: Mon, 7 Mar 2022 18:11:04 -0800 Subject: Floss: Cancel discovery before BREDR pairing/connection If BREDR connection is to be executed, e.g. in create_bond and connect_all_enabled_profiles, we should cancel discovery first because some of the connection-related HCI commands may be rejected by the Bluetooth controller when Inquiry is in progress. With background scanning migration to LE Scan API, the Discovery API is redefined to not guarantee continuous discovery forever, but instead clients are notified via callbacks when discovery is stopped by the stack. Because of this simplification of the API, we don't need to resume discovery after connection or pairing is complete. Bug: 211127013 Tag: #floss Test: Manual - Perform pairing with BREDR device via UI Change-Id: I6f4d8ecbbeb1b7a7a9dc3193431edba2b4e05e51 --- system/gd/rust/linux/stack/src/bluetooth.rs | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'system/gd/rust/linux/stack/src') diff --git a/system/gd/rust/linux/stack/src/bluetooth.rs b/system/gd/rust/linux/stack/src/bluetooth.rs index 49e9289e4d..ad92946a48 100644 --- a/system/gd/rust/linux/stack/src/bluetooth.rs +++ b/system/gd/rust/linux/stack/src/bluetooth.rs @@ -946,6 +946,10 @@ impl IBluetooth for Bluetooth { } let address = addr.unwrap(); + + // BREDR connection won't work when Inquiry is in progress. + self.cancel_discovery(); + self.intf.lock().unwrap().create_bond(&address, transport) == 0 } @@ -1137,6 +1141,9 @@ impl IBluetooth for Bluetooth { return false; } + // BREDR connection won't work when Inquiry is in progress. + self.cancel_discovery(); + // Check all remote uuids to see if they match enabled profiles and connect them. let uuids = self.get_remote_uuids(device.clone()); for uuid in uuids.iter() { -- cgit v1.2.3