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

Commit 454a9b49 authored by Archie Pusaka's avatar Archie Pusaka
Browse files

floss: Enable profiles in a certain good order

AVRCP and A2DP races to memset and allocate avct_ccb. If we're unlucky,
we might leave it at NULL so no incoming AVRCP profile can get through.
Effect varies on the peer devices, ranging to letting us initiating the
AVRCP to outright refusing any further transactions.

The effort to fix the race is tracked in b/286991526. For now, let's
just prevent the race by initiating the profiles in a known good order.

Bug: 312489181
Test: m -j
Test: Repeatedly restart floss and try accepting connection from a
      Bose 700. Verify it always works.

Flag: EXEMPT floss only changes

Change-Id: Idac7f00ed34e2fecef1abdc650eb09bda41556a1
parent 8ff8cc86
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line Diff line number Diff line
@@ -649,7 +649,7 @@ impl Bluetooth {
    }
    }


    pub fn toggle_enabled_profiles(&mut self, allowed_services: &Vec<Uuid128Bit>) {
    pub fn toggle_enabled_profiles(&mut self, allowed_services: &Vec<Uuid128Bit>) {
        for profile in UuidHelper::get_supported_profiles().clone() {
        for profile in UuidHelper::get_ordered_supported_profiles().clone() {
            // Only toggle initializable profiles.
            // Only toggle initializable profiles.
            if let Some(enabled) = self.is_profile_enabled(&profile) {
            if let Some(enabled) = self.is_profile_enabled(&profile) {
                let allowed = allowed_services.len() == 0
                let allowed = allowed_services.len() == 0
+16 −5
Original line number Original line Diff line number Diff line
@@ -109,7 +109,10 @@ impl<'a> Display for KnownUuidWrapper<'a> {
pub struct UuidHelper {}
pub struct UuidHelper {}


lazy_static! {
lazy_static! {
    static ref SUPPORTED_PROFILES: HashSet<Profile> = [
    // AVRCP fights with A2DP when initializing, so let's initiate profiles in a known good order.
    // Specifically, A2DP must be initialized before AVRCP.
    // TODO (b/286991526): remove after issue is resolved
    static ref ORDERED_SUPPORTED_PROFILES: Vec<Profile> = vec![
        Profile::A2dpSink,
        Profile::A2dpSink,
        Profile::A2dpSource,
        Profile::A2dpSource,
        Profile::AvrcpController,
        Profile::AvrcpController,
@@ -125,10 +128,12 @@ lazy_static! {
        Profile::HearingAid,
        Profile::HearingAid,
        Profile::VolumeControl,
        Profile::VolumeControl,
        Profile::CoordinatedSet,
        Profile::CoordinatedSet,
    ]
    ];
    .iter()
}
    .cloned()

    .collect();
lazy_static! {
    static ref SUPPORTED_PROFILES: HashSet<Profile> =
        ORDERED_SUPPORTED_PROFILES.iter().cloned().collect();
}
}


lazy_static! {
lazy_static! {
@@ -185,6 +190,12 @@ impl UuidHelper {
        PROFILES.get(uuid).cloned()
        PROFILES.get(uuid).cloned()
    }
    }


    // AVRCP fights with A2DP when initializing, so let's initiate profiles in a known good order.
    // TODO (b/286991526): remove after issue is resolved
    pub fn get_ordered_supported_profiles() -> Vec<Profile> {
        ORDERED_SUPPORTED_PROFILES.clone()
    }

    pub fn get_supported_profiles() -> HashSet<Profile> {
    pub fn get_supported_profiles() -> HashSet<Profile> {
        SUPPORTED_PROFILES.clone()
        SUPPORTED_PROFILES.clone()
    }
    }