Loading system/gd/rust/linux/service/src/iface_bluetooth_media.rs +5 −0 Original line number Diff line number Diff line Loading @@ -130,6 +130,11 @@ impl IBluetoothMedia for IBluetoothMediaDBus { dbus_generated!() } #[dbus_method("SetHfpVolume")] fn set_hfp_volume(&mut self, volume: u8, address: String) { dbus_generated!() } #[dbus_method("StartAudioRequest")] fn start_audio_request(&mut self) { dbus_generated!() Loading system/gd/rust/linux/stack/src/bluetooth_media.rs +24 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,10 @@ pub trait IBluetoothMedia { channel_mode: i32, ) -> bool; fn set_volume(&mut self, volume: i32); // Set the HFP speaker volume. Valid volume specified by the HFP spec should // be in the range of 0-15. fn set_hfp_volume(&mut self, volume: u8, address: String); fn start_audio_request(&mut self); fn stop_audio_request(&mut self); fn get_presentation_position(&mut self) -> PresentationPosition; Loading Loading @@ -544,6 +548,26 @@ impl IBluetoothMedia for BluetoothMedia { }; } fn set_hfp_volume(&mut self, volume: u8, address: String) { if let Some(addr) = RawAddress::from_string(address.clone()) { if !self.hfp_states.get(&addr).is_none() { match i8::try_from(volume) { Ok(val) if val <= 15 => { self.hfp.as_mut().unwrap().set_volume(val, addr); } _ => warn!("[{}]: Ignore invalid volume {}", address, volume), } } else { warn!( "[{}]: Ignore volume event for unconnected or disconnected HFP device", address ); } } else { warn!("[{}]: Invalid address", address); } } fn start_audio_request(&mut self) { self.a2dp.as_mut().unwrap().start_audio_request(); } Loading system/gd/rust/topshim/hfp/hfp_shim.cc +5 −5 Original line number Diff line number Diff line Loading @@ -72,11 +72,6 @@ class DBusHeadsetCallbacks : public headset::Callbacks { switch (state) { case headset::bthf_audio_state_t::BTHF_AUDIO_STATE_CONNECTED: SetCallStatus(1, bd_addr); // This triggers a +VGS command to set the speaker volume for HFP // devices. // TODO(b/215089433): Add a set volume API and have client to handle the // set volume when start. headset_->VolumeControl(headset::bthf_volume_type_t::BTHF_VOLUME_TYPE_SPK, 5, bd_addr); return; case headset::bthf_audio_state_t::BTHF_AUDIO_STATE_DISCONNECTED: SetCallStatus(0, bd_addr); Loading Loading @@ -225,6 +220,11 @@ int HfpIntf::connect_audio(RustRawAddress bt_addr) { return intf_->ConnectAudio(&addr); } int HfpIntf::set_volume(int8_t volume, RustRawAddress bt_addr) { RawAddress addr = rusty::CopyFromRustAddress(bt_addr); return intf_->VolumeControl(headset::bthf_volume_type_t::BTHF_VOLUME_TYPE_SPK, volume, &addr); } int HfpIntf::disconnect(RustRawAddress bt_addr) { RawAddress addr = rusty::CopyFromRustAddress(bt_addr); return intf_->Disconnect(&addr); Loading system/gd/rust/topshim/hfp/hfp_shim.h +1 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ class HfpIntf { int init(); int connect(RustRawAddress bt_addr); int connect_audio(RustRawAddress bt_addr); int set_volume(int8_t volume, RustRawAddress bt_addr); int disconnect(RustRawAddress bt_addr); int disconnect_audio(RustRawAddress bt_addr); bool get_wbs_supported(); Loading system/gd/rust/topshim/src/profiles/hfp.rs +5 −0 Original line number Diff line number Diff line Loading @@ -77,6 +77,7 @@ pub mod ffi { fn init(self: Pin<&mut HfpIntf>) -> i32; fn connect(self: Pin<&mut HfpIntf>, bt_addr: RustRawAddress) -> i32; fn connect_audio(self: Pin<&mut HfpIntf>, bt_addr: RustRawAddress) -> i32; fn set_volume(self: Pin<&mut HfpIntf>, volume: i8, bt_addr: RustRawAddress) -> i32; fn disconnect(self: Pin<&mut HfpIntf>, bt_addr: RustRawAddress) -> i32; fn disconnect_audio(self: Pin<&mut HfpIntf>, bt_addr: RustRawAddress) -> i32; fn get_wbs_supported(self: Pin<&mut HfpIntf>) -> bool; Loading Loading @@ -173,6 +174,10 @@ impl Hfp { self.internal.pin_mut().connect_audio(addr.into()) } pub fn set_volume(&mut self, volume: i8, addr: RawAddress) -> i32 { self.internal.pin_mut().set_volume(volume, addr.into()) } pub fn disconnect(&mut self, addr: RawAddress) { self.internal.pin_mut().disconnect(addr.into()); } Loading Loading
system/gd/rust/linux/service/src/iface_bluetooth_media.rs +5 −0 Original line number Diff line number Diff line Loading @@ -130,6 +130,11 @@ impl IBluetoothMedia for IBluetoothMediaDBus { dbus_generated!() } #[dbus_method("SetHfpVolume")] fn set_hfp_volume(&mut self, volume: u8, address: String) { dbus_generated!() } #[dbus_method("StartAudioRequest")] fn start_audio_request(&mut self) { dbus_generated!() Loading
system/gd/rust/linux/stack/src/bluetooth_media.rs +24 −0 Original line number Diff line number Diff line Loading @@ -49,6 +49,10 @@ pub trait IBluetoothMedia { channel_mode: i32, ) -> bool; fn set_volume(&mut self, volume: i32); // Set the HFP speaker volume. Valid volume specified by the HFP spec should // be in the range of 0-15. fn set_hfp_volume(&mut self, volume: u8, address: String); fn start_audio_request(&mut self); fn stop_audio_request(&mut self); fn get_presentation_position(&mut self) -> PresentationPosition; Loading Loading @@ -544,6 +548,26 @@ impl IBluetoothMedia for BluetoothMedia { }; } fn set_hfp_volume(&mut self, volume: u8, address: String) { if let Some(addr) = RawAddress::from_string(address.clone()) { if !self.hfp_states.get(&addr).is_none() { match i8::try_from(volume) { Ok(val) if val <= 15 => { self.hfp.as_mut().unwrap().set_volume(val, addr); } _ => warn!("[{}]: Ignore invalid volume {}", address, volume), } } else { warn!( "[{}]: Ignore volume event for unconnected or disconnected HFP device", address ); } } else { warn!("[{}]: Invalid address", address); } } fn start_audio_request(&mut self) { self.a2dp.as_mut().unwrap().start_audio_request(); } Loading
system/gd/rust/topshim/hfp/hfp_shim.cc +5 −5 Original line number Diff line number Diff line Loading @@ -72,11 +72,6 @@ class DBusHeadsetCallbacks : public headset::Callbacks { switch (state) { case headset::bthf_audio_state_t::BTHF_AUDIO_STATE_CONNECTED: SetCallStatus(1, bd_addr); // This triggers a +VGS command to set the speaker volume for HFP // devices. // TODO(b/215089433): Add a set volume API and have client to handle the // set volume when start. headset_->VolumeControl(headset::bthf_volume_type_t::BTHF_VOLUME_TYPE_SPK, 5, bd_addr); return; case headset::bthf_audio_state_t::BTHF_AUDIO_STATE_DISCONNECTED: SetCallStatus(0, bd_addr); Loading Loading @@ -225,6 +220,11 @@ int HfpIntf::connect_audio(RustRawAddress bt_addr) { return intf_->ConnectAudio(&addr); } int HfpIntf::set_volume(int8_t volume, RustRawAddress bt_addr) { RawAddress addr = rusty::CopyFromRustAddress(bt_addr); return intf_->VolumeControl(headset::bthf_volume_type_t::BTHF_VOLUME_TYPE_SPK, volume, &addr); } int HfpIntf::disconnect(RustRawAddress bt_addr) { RawAddress addr = rusty::CopyFromRustAddress(bt_addr); return intf_->Disconnect(&addr); Loading
system/gd/rust/topshim/hfp/hfp_shim.h +1 −0 Original line number Diff line number Diff line Loading @@ -35,6 +35,7 @@ class HfpIntf { int init(); int connect(RustRawAddress bt_addr); int connect_audio(RustRawAddress bt_addr); int set_volume(int8_t volume, RustRawAddress bt_addr); int disconnect(RustRawAddress bt_addr); int disconnect_audio(RustRawAddress bt_addr); bool get_wbs_supported(); Loading
system/gd/rust/topshim/src/profiles/hfp.rs +5 −0 Original line number Diff line number Diff line Loading @@ -77,6 +77,7 @@ pub mod ffi { fn init(self: Pin<&mut HfpIntf>) -> i32; fn connect(self: Pin<&mut HfpIntf>, bt_addr: RustRawAddress) -> i32; fn connect_audio(self: Pin<&mut HfpIntf>, bt_addr: RustRawAddress) -> i32; fn set_volume(self: Pin<&mut HfpIntf>, volume: i8, bt_addr: RustRawAddress) -> i32; fn disconnect(self: Pin<&mut HfpIntf>, bt_addr: RustRawAddress) -> i32; fn disconnect_audio(self: Pin<&mut HfpIntf>, bt_addr: RustRawAddress) -> i32; fn get_wbs_supported(self: Pin<&mut HfpIntf>) -> bool; Loading Loading @@ -173,6 +174,10 @@ impl Hfp { self.internal.pin_mut().connect_audio(addr.into()) } pub fn set_volume(&mut self, volume: i8, addr: RawAddress) -> i32 { self.internal.pin_mut().set_volume(volume, addr.into()) } pub fn disconnect(&mut self, addr: RawAddress) { self.internal.pin_mut().disconnect(addr.into()); } Loading