Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 65ff9dac authored by Sonny Sasaka's avatar Sonny Sasaka
Browse files

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
parent 33d07fae
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -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() {