Loading system/gd/rust/linux/service/src/iface_bluetooth_media.rs +5 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,11 @@ impl IBluetoothMediaCallback for BluetoothMediaCallbackDBus { fn on_absolute_volume_changed(&self, volume: i32) { dbus_generated!() } #[dbus_method("OnHfpVolumeChanged")] fn on_hfp_volume_changed(&self, volume: u32, addr: String) { dbus_generated!() } } #[allow(dead_code)] Loading system/gd/rust/linux/stack/src/bluetooth_media.rs +10 −0 Original line number Diff line number Diff line Loading @@ -72,6 +72,11 @@ pub trait IBluetoothMediaCallback { /// fn on_absolute_volume_changed(&self, volume: i32); /// Triggered when a Bluetooth device triggers a HFP AT command (AT+VGS) to /// notify AG about its speaker volume change. We need to notify audio /// client to reflect the change on the audio stack. fn on_hfp_volume_changed(&self, volume: u32, addr: String); } /// Serializable device used in. Loading Loading @@ -263,6 +268,11 @@ impl BluetoothMedia { } } } HfpCallbacks::VolumeUpdate(volume, addr) => { self.for_all_callbacks(|callback| { callback.on_hfp_volume_changed(volume, addr.to_string()); }); } } } Loading system/gd/rust/topshim/hfp/hfp_shim.cc +10 −4 Original line number Diff line number Diff line Loading @@ -42,6 +42,10 @@ static void audio_state_cb(bluetooth::headset::bthf_audio_state_t state, RawAddr rusty::hfp_audio_state_callback(state, raddr); } static void volume_update_cb(uint32_t volume, RawAddress* addr) { RustRawAddress raddr = rusty::CopyToRustAddress(*addr); rusty::hfp_volume_update_callback(volume, raddr); } } // namespace internal class DBusHeadsetCallbacks : public headset::Callbacks { Loading Loading @@ -89,10 +93,12 @@ class DBusHeadsetCallbacks : public headset::Callbacks { void HangupCallCallback([[maybe_unused]] RawAddress* bd_addr) override {} void VolumeControlCallback( [[maybe_unused]] headset::bthf_volume_type_t type, [[maybe_unused]] int volume, [[maybe_unused]] RawAddress* bd_addr) override {} void VolumeControlCallback(headset::bthf_volume_type_t type, int volume, RawAddress* bd_addr) override { if (type != headset::bthf_volume_type_t::BTHF_VOLUME_TYPE_SPK || volume < 0) return; if (volume > 15) volume = 15; LOG_INFO("VolumeControlCallback %d from %s", volume, bd_addr->ToString().c_str()); topshim::rust::internal::volume_update_cb(volume, bd_addr); } void DialCallCallback([[maybe_unused]] char* number, [[maybe_unused]] RawAddress* bd_addr) override {} Loading system/gd/rust/topshim/src/profiles/hfp.rs +10 −0 Original line number Diff line number Diff line Loading @@ -86,6 +86,7 @@ pub mod ffi { extern "Rust" { fn hfp_connection_state_callback(state: u32, addr: RustRawAddress); fn hfp_audio_state_callback(state: u32, addr: RustRawAddress); fn hfp_volume_update_callback(volume: u32, addr: RustRawAddress); } } Loading @@ -105,6 +106,7 @@ impl Into<RawAddress> for ffi::RustRawAddress { pub enum HfpCallbacks { ConnectionState(BthfConnectionState, RawAddress), AudioState(BthfAudioState, RawAddress), VolumeUpdate(u32, RawAddress), } pub struct HfpCallbacksDispatcher { Loading @@ -129,6 +131,14 @@ cb_variant!( } ); cb_variant!( HfpCb, hfp_volume_update_callback -> HfpCallbacks::VolumeUpdate, u32, ffi::RustRawAddress -> RawAddress, { let _1 = _1.into(); } ); pub struct Hfp { internal: cxx::UniquePtr<ffi::HfpIntf>, _is_init: bool, Loading Loading
system/gd/rust/linux/service/src/iface_bluetooth_media.rs +5 −0 Original line number Diff line number Diff line Loading @@ -65,6 +65,11 @@ impl IBluetoothMediaCallback for BluetoothMediaCallbackDBus { fn on_absolute_volume_changed(&self, volume: i32) { dbus_generated!() } #[dbus_method("OnHfpVolumeChanged")] fn on_hfp_volume_changed(&self, volume: u32, addr: String) { dbus_generated!() } } #[allow(dead_code)] Loading
system/gd/rust/linux/stack/src/bluetooth_media.rs +10 −0 Original line number Diff line number Diff line Loading @@ -72,6 +72,11 @@ pub trait IBluetoothMediaCallback { /// fn on_absolute_volume_changed(&self, volume: i32); /// Triggered when a Bluetooth device triggers a HFP AT command (AT+VGS) to /// notify AG about its speaker volume change. We need to notify audio /// client to reflect the change on the audio stack. fn on_hfp_volume_changed(&self, volume: u32, addr: String); } /// Serializable device used in. Loading Loading @@ -263,6 +268,11 @@ impl BluetoothMedia { } } } HfpCallbacks::VolumeUpdate(volume, addr) => { self.for_all_callbacks(|callback| { callback.on_hfp_volume_changed(volume, addr.to_string()); }); } } } Loading
system/gd/rust/topshim/hfp/hfp_shim.cc +10 −4 Original line number Diff line number Diff line Loading @@ -42,6 +42,10 @@ static void audio_state_cb(bluetooth::headset::bthf_audio_state_t state, RawAddr rusty::hfp_audio_state_callback(state, raddr); } static void volume_update_cb(uint32_t volume, RawAddress* addr) { RustRawAddress raddr = rusty::CopyToRustAddress(*addr); rusty::hfp_volume_update_callback(volume, raddr); } } // namespace internal class DBusHeadsetCallbacks : public headset::Callbacks { Loading Loading @@ -89,10 +93,12 @@ class DBusHeadsetCallbacks : public headset::Callbacks { void HangupCallCallback([[maybe_unused]] RawAddress* bd_addr) override {} void VolumeControlCallback( [[maybe_unused]] headset::bthf_volume_type_t type, [[maybe_unused]] int volume, [[maybe_unused]] RawAddress* bd_addr) override {} void VolumeControlCallback(headset::bthf_volume_type_t type, int volume, RawAddress* bd_addr) override { if (type != headset::bthf_volume_type_t::BTHF_VOLUME_TYPE_SPK || volume < 0) return; if (volume > 15) volume = 15; LOG_INFO("VolumeControlCallback %d from %s", volume, bd_addr->ToString().c_str()); topshim::rust::internal::volume_update_cb(volume, bd_addr); } void DialCallCallback([[maybe_unused]] char* number, [[maybe_unused]] RawAddress* bd_addr) override {} Loading
system/gd/rust/topshim/src/profiles/hfp.rs +10 −0 Original line number Diff line number Diff line Loading @@ -86,6 +86,7 @@ pub mod ffi { extern "Rust" { fn hfp_connection_state_callback(state: u32, addr: RustRawAddress); fn hfp_audio_state_callback(state: u32, addr: RustRawAddress); fn hfp_volume_update_callback(volume: u32, addr: RustRawAddress); } } Loading @@ -105,6 +106,7 @@ impl Into<RawAddress> for ffi::RustRawAddress { pub enum HfpCallbacks { ConnectionState(BthfConnectionState, RawAddress), AudioState(BthfAudioState, RawAddress), VolumeUpdate(u32, RawAddress), } pub struct HfpCallbacksDispatcher { Loading @@ -129,6 +131,14 @@ cb_variant!( } ); cb_variant!( HfpCb, hfp_volume_update_callback -> HfpCallbacks::VolumeUpdate, u32, ffi::RustRawAddress -> RawAddress, { let _1 = _1.into(); } ); pub struct Hfp { internal: cxx::UniquePtr<ffi::HfpIntf>, _is_init: bool, Loading