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

Commit 7e96b758 authored by Jeremy Wu's avatar Jeremy Wu
Browse files

Floss: dedup media connect actions

`MediaActions::Connect` is invoked as many times as the number of media
profiles supported by the device. In this CL, we dedup the number.

Bug: 257406118
Tag: #floss
Test: Build and verify
Change-Id: Ic8cc59e2097ca1b6861cd147ce3a453e36dd071b
parent 9a791fbc
Loading
Loading
Loading
Loading
+10 −5
Original line number Diff line number Diff line
@@ -1857,6 +1857,7 @@ impl IBluetooth for Bluetooth {

        // Check all remote uuids to see if they match enabled profiles and connect them.
        let mut has_enabled_uuids = false;
        let mut has_media_profile = false;
        let uuids = self.get_remote_uuids(device.clone());
        for uuid in uuids.iter() {
            match UuidHelper::is_known_profile(uuid) {
@@ -1882,10 +1883,10 @@ impl IBluetooth for Bluetooth {
                                }
                            }

                            Profile::A2dpSink
                            | Profile::A2dpSource
                            | Profile::Hfp
                            | Profile::AvrcpController => {
                            Profile::A2dpSink | Profile::A2dpSource | Profile::Hfp
                                if !has_media_profile =>
                            {
                                has_media_profile = true;
                                let txl = self.tx.clone();
                                let address = device.address.clone();
                                topstack::get_runtime().spawn(async move {
@@ -1964,6 +1965,7 @@ impl IBluetooth for Bluetooth {
        }

        let uuids = self.get_remote_uuids(device.clone());
        let mut has_media_profile = false;
        for uuid in uuids.iter() {
            match UuidHelper::is_known_profile(uuid) {
                Some(p) => {
@@ -1976,7 +1978,10 @@ impl IBluetooth for Bluetooth {
                            Profile::A2dpSink
                            | Profile::A2dpSource
                            | Profile::Hfp
                            | Profile::AvrcpController => {
                            | Profile::AvrcpController
                                if !has_media_profile =>
                            {
                                has_media_profile = true;
                                let txl = self.tx.clone();
                                let address = device.address.clone();
                                topstack::get_runtime().spawn(async move {
+1 −0
Original line number Diff line number Diff line
@@ -110,6 +110,7 @@ lazy_static! {
    static ref SUPPORTED_PROFILES: HashSet<Profile> = [
        Profile::A2dpSink,
        Profile::A2dpSource,
        Profile::AvrcpController,
        Profile::Bas,
        Profile::Hsp,
        Profile::Hfp,