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

Commit b09ded6b 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 am: b4fb20cf

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


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

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


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


        match self.a2dp.as_mut() {
        match self.a2dp_states.get(&addr) {
            Some(a2dp) => a2dp.set_active_device(addr),
            Some(BtavConnectionState::Connected) => {
            None => warn!("Uninitialized A2DP to set active device"),
                if let Some(a2dp) = self.a2dp.as_mut() {
        }
                    a2dp.set_active_device(addr);
                    self.uinput.set_active_device(addr.to_string());
                    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) {
    fn set_hfp_active_device(&mut self, address: String) {
@@ -1798,11 +1816,15 @@ impl IBluetoothMedia for BluetoothMedia {
            Some(addr) => addr,
            Some(addr) => addr,
        };
        };


        match self.hfp.as_mut() {
        match self.hfp_states.get(&addr) {
            Some(hfp) => {
            Some(BthfConnectionState::SlcConnected) => {
                if let Some(hfp) = self.hfp.as_mut() {
                    hfp.set_active_device(addr);
                    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 Original line Diff line number Diff line
@@ -818,6 +818,10 @@ impl RawAddress {
    pub fn to_byte_arr(&self) -> [u8; 6] {
    pub fn to_byte_arr(&self) -> [u8; 6] {
        self.address.clone()
        self.address.clone()
    }
    }

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


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