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

Commit ef441674 authored by Jeremy Wu's avatar Jeremy Wu
Browse files

Floss: expose DBus method to allow HFP state query

Upon the audio stack invoking StartSCOCall, this method will be used
to periodically query the HFP state until it has transitioned to the
'Connected' state so that the audio stack can start sending data over.

Bug: 241050004
Tag: #floss
Test: Build and verify DBus method exposed
Change-Id: Idfe87944e7f2cf9916ab7dd9260305bea9634db6
parent 7d93c7e1
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -155,6 +155,11 @@ impl IBluetoothMedia for IBluetoothMediaDBus {
        dbus_generated!()
    }

    #[dbus_method("GetHfpAudioStarted")]
    fn get_hfp_audio_started(&mut self) -> bool {
        dbus_generated!()
    }

    #[dbus_method("StopScoCall")]
    fn stop_sco_call(&mut self, address: String) {
        dbus_generated!()
+13 −0
Original line number Diff line number Diff line
@@ -61,6 +61,7 @@ pub trait IBluetoothMedia {
    fn start_audio_request(&mut self);
    fn stop_audio_request(&mut self);
    fn get_a2dp_audio_started(&mut self) -> bool;
    fn get_hfp_audio_started(&mut self) -> bool;
    fn get_presentation_position(&mut self) -> PresentationPosition;

    fn start_sco_call(&mut self, address: String);
@@ -131,6 +132,7 @@ pub struct BluetoothMedia {
    a2dp_audio_state: BtavAudioState,
    hfp: Option<Hfp>,
    hfp_states: HashMap<RawAddress, BthfConnectionState>,
    hfp_audio_state: BthfAudioState,
    selectable_caps: HashMap<RawAddress, Vec<A2dpCodecConfig>>,
    hfp_caps: HashMap<RawAddress, HfpCodecCapability>,
    device_added_tasks: Arc<Mutex<HashMap<RawAddress, Option<JoinHandle<()>>>>>,
@@ -154,6 +156,7 @@ impl BluetoothMedia {
            a2dp_audio_state: BtavAudioState::RemoteSuspend,
            hfp: None,
            hfp_states: HashMap::new(),
            hfp_audio_state: BthfAudioState::Disconnected,
            selectable_caps: HashMap::new(),
            hfp_caps: HashMap::new(),
            device_added_tasks: Arc::new(Mutex::new(HashMap::new())),
@@ -274,6 +277,7 @@ impl BluetoothMedia {
                    warn!("[{}]: Unknown address hfp or slc not ready", addr.to_string());
                    return;
                }

                match state {
                    BthfAudioState::Connected => {
                        info!("[{}]: hfp audio connected.", addr.to_string());
@@ -288,6 +292,8 @@ impl BluetoothMedia {
                        info!("[{}]: hfp audio disconnecting.", addr.to_string());
                    }
                }

                self.hfp_audio_state = state;
            }
            HfpCallbacks::VolumeUpdate(volume, addr) => {
                self.callbacks.lock().unwrap().for_all_callbacks(|callback| {
@@ -623,6 +629,13 @@ impl IBluetoothMedia for BluetoothMedia {
        }
    }

    fn get_hfp_audio_started(&mut self) -> bool {
        match self.hfp_audio_state {
            BthfAudioState::Connected => true,
            _ => false,
        }
    }

    fn get_presentation_position(&mut self) -> PresentationPosition {
        let position = self.a2dp.as_mut().unwrap().get_presentation_position();
        PresentationPosition {