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

Commit b4fb20cf authored by En-Shuo Hsu's avatar En-Shuo Hsu Committed by Automerger Merge Worker
Browse files

Merge "Floss: Add the ResetActiveDevice interface" am: 3dbf3096

parents 1fe81f03 3dbf3096
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -175,6 +175,11 @@ impl IBluetoothMedia for IBluetoothMediaDBus {
        dbus_generated!()
    }

    #[dbus_method("ResetActiveDevice")]
    fn reset_active_device(&mut self) {
        dbus_generated!()
    }

    #[dbus_method("SetHfpActiveDevice")]
    fn set_hfp_active_device(&mut self, address: String) {
        dbus_generated!()
+30 −8
Original line number Diff line number Diff line
@@ -78,6 +78,9 @@ pub trait IBluetoothMedia {
    // Set the device as the active A2DP device
    fn set_active_device(&mut self, address: String);

    // Reset the active A2DP device
    fn reset_active_device(&mut self);

    // Set the device as the active HFP device
    fn set_hfp_active_device(&mut self, address: String);

@@ -1782,11 +1785,26 @@ impl IBluetoothMedia for BluetoothMedia {
            Some(addr) => addr,
        };

        match self.a2dp.as_mut() {
            Some(a2dp) => a2dp.set_active_device(addr),
            None => warn!("Uninitialized A2DP to set active device"),
        }
        match self.a2dp_states.get(&addr) {
            Some(BtavConnectionState::Connected) => {
                if let Some(a2dp) = self.a2dp.as_mut() {
                    a2dp.set_active_device(addr);
                    self.uinput.set_active_device(addr.to_string());
                } else {
                    warn!("Uninitialized A2DP to set active device");
                }
            }
            _ => warn!("[{}] Not connected or disconnected A2DP address", address),
        };
    }

    fn reset_active_device(&mut self) {
        if let Some(a2dp) = self.a2dp.as_mut() {
            a2dp.set_active_device(RawAddress::empty());
        } else {
            warn!("Uninitialized A2DP to set active device");
        }
        self.uinput.set_active_device(RawAddress::empty().to_string());
    }

    fn set_hfp_active_device(&mut self, address: String) {
@@ -1798,11 +1816,15 @@ impl IBluetoothMedia for BluetoothMedia {
            Some(addr) => addr,
        };

        match self.hfp.as_mut() {
            Some(hfp) => {
        match self.hfp_states.get(&addr) {
            Some(BthfConnectionState::SlcConnected) => {
                if let Some(hfp) = self.hfp.as_mut() {
                    hfp.set_active_device(addr);
                } else {
                    warn!("Uninitialized HFP to set active device");
                }
            }
            None => warn!("Uninitialized HFP to set active device"),
            _ => warn!("[{}] Not connected or disconnected HFP address", address),
        }
    }

+4 −0
Original line number Diff line number Diff line
@@ -818,6 +818,10 @@ impl RawAddress {
    pub fn to_byte_arr(&self) -> [u8; 6] {
        self.address.clone()
    }

    pub fn empty() -> RawAddress {
        unsafe { bindings::RawAddress_kEmpty }
    }
}

/// Address that is safe to display in logs.