Loading system/gd/rust/linux/client/src/command_handler.rs +36 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ use bt_topshim::profiles::{gatt::LePhy, ProfileConnectionState}; use btstack::bluetooth::{BluetoothDevice, IBluetooth, IBluetoothQALegacy}; use btstack::bluetooth_gatt::{GattWriteType, IBluetoothGatt, ScanSettings, ScanType}; use btstack::bluetooth_media::IBluetoothTelephony; use btstack::bluetooth_qa::IBluetoothQA; use btstack::socket_manager::{IBluetoothSocketManager, SocketResult}; use btstack::uuid::{Profile, UuidHelper, UuidWrapper}; use manager_service::iface_bluetooth_manager::IBluetoothManager; Loading Loading @@ -267,6 +268,14 @@ fn build_commands() -> HashMap<String, CommandOption> { function_pointer: CommandHandler::cmd_get_address, }, ); command_options.insert( String::from("qa"), CommandOption { rules: vec![String::from("qa add-media-player <name> <browsing_supported>")], description: String::from("Methods for testing purposes"), function_pointer: CommandHandler::cmd_qa, }, ); command_options.insert( String::from("help"), CommandOption { Loading Loading @@ -1875,6 +1884,33 @@ impl CommandHandler { } Ok(()) } fn cmd_qa(&mut self, args: &Vec<String>) -> CommandResult { if !self.context.lock().unwrap().adapter_ready { return Err(self.adapter_not_ready()); } let command = get_arg(args, 0)?; match &command[..] { "add-media-player" => { let name = String::from(get_arg(args, 1)?); let browsing_supported = String::from(get_arg(args, 2)?) .parse::<bool>() .or(Err("Failed to parse browsing_supported"))?; self.context .lock() .unwrap() .qa_dbus .as_mut() .unwrap() .add_media_player(name, browsing_supported); } _ => return Err(CommandError::InvalidArgs), }; Ok(()) } } #[cfg(test)] Loading system/gd/rust/linux/client/src/dbus_iface.rs +8 −3 Original line number Diff line number Diff line Loading @@ -2242,13 +2242,13 @@ impl IBluetoothTelephony for BluetoothTelephonyDBus { } pub(crate) struct BluetoothQADBus { _client_proxy: ClientDBusProxy, client_proxy: ClientDBusProxy, } impl BluetoothQADBus { pub(crate) fn new(conn: Arc<SyncConnection>, index: i32) -> BluetoothQADBus { BluetoothQADBus { _client_proxy: ClientDBusProxy::new( client_proxy: ClientDBusProxy::new( conn.clone(), String::from("org.chromium.bluetooth"), make_object_path(index, "qa"), Loading @@ -2259,4 +2259,9 @@ impl BluetoothQADBus { } #[generate_dbus_interface_client] impl IBluetoothQA for BluetoothQADBus {} impl IBluetoothQA for BluetoothQADBus { #[dbus_method("AddMediaPlayer")] fn add_media_player(&self, name: String, browsing_supported: bool) { dbus_generated!() } } system/gd/rust/linux/service/src/iface_bluetooth_qa.rs +10 −2 Original line number Diff line number Diff line use btstack::bluetooth_qa::IBluetoothQA; use dbus_macros::generate_dbus_exporter; use dbus_macros::{dbus_method, generate_dbus_exporter}; use dbus_projection::dbus_generated; use crate::dbus_arg::DBusArg; struct IBluetoothQADBus {} #[generate_dbus_exporter(export_bluetooth_qa_dbus_intf, "org.chromium.bluetooth.BluetoothQA")] impl IBluetoothQA for IBluetoothQADBus {} impl IBluetoothQA for IBluetoothQADBus { #[dbus_method("AddMediaPlayer")] fn add_media_player(&self, name: String, browsing_supported: bool) { dbus_generated!() } } system/gd/rust/linux/stack/src/bluetooth_media.rs +3 −0 Original line number Diff line number Diff line Loading @@ -1601,6 +1601,9 @@ impl BluetoothMedia { self.notify_media_capability_updated(addr); self.connect(address); } pub fn add_player(&mut self, name: String, browsing_supported: bool) { self.avrcp.as_mut().unwrap().add_player(&name, browsing_supported); } } fn get_a2dp_dispatcher(tx: Sender<Message>) -> A2dpCallbacksDispatcher { Loading system/gd/rust/linux/stack/src/bluetooth_qa.rs +13 −4 Original line number Diff line number Diff line Loading @@ -4,16 +4,25 @@ use crate::Message; use tokio::sync::mpsc::Sender; /// Defines the Qualification API pub trait IBluetoothQA {} pub trait IBluetoothQA { fn add_media_player(&self, name: String, browsing_supported: bool); } pub struct BluetoothQA { _tx: Sender<Message>, tx: Sender<Message>, } impl BluetoothQA { pub fn new(tx: Sender<Message>) -> BluetoothQA { BluetoothQA { _tx: tx } BluetoothQA { tx } } } impl IBluetoothQA for BluetoothQA {} impl IBluetoothQA for BluetoothQA { fn add_media_player(&self, name: String, browsing_supported: bool) { let txl = self.tx.clone(); tokio::spawn(async move { let _ = txl.send(Message::QaAddMediaPlayer(name, browsing_supported)).await; }); } } Loading
system/gd/rust/linux/client/src/command_handler.rs +36 −0 Original line number Diff line number Diff line Loading @@ -16,6 +16,7 @@ use bt_topshim::profiles::{gatt::LePhy, ProfileConnectionState}; use btstack::bluetooth::{BluetoothDevice, IBluetooth, IBluetoothQALegacy}; use btstack::bluetooth_gatt::{GattWriteType, IBluetoothGatt, ScanSettings, ScanType}; use btstack::bluetooth_media::IBluetoothTelephony; use btstack::bluetooth_qa::IBluetoothQA; use btstack::socket_manager::{IBluetoothSocketManager, SocketResult}; use btstack::uuid::{Profile, UuidHelper, UuidWrapper}; use manager_service::iface_bluetooth_manager::IBluetoothManager; Loading Loading @@ -267,6 +268,14 @@ fn build_commands() -> HashMap<String, CommandOption> { function_pointer: CommandHandler::cmd_get_address, }, ); command_options.insert( String::from("qa"), CommandOption { rules: vec![String::from("qa add-media-player <name> <browsing_supported>")], description: String::from("Methods for testing purposes"), function_pointer: CommandHandler::cmd_qa, }, ); command_options.insert( String::from("help"), CommandOption { Loading Loading @@ -1875,6 +1884,33 @@ impl CommandHandler { } Ok(()) } fn cmd_qa(&mut self, args: &Vec<String>) -> CommandResult { if !self.context.lock().unwrap().adapter_ready { return Err(self.adapter_not_ready()); } let command = get_arg(args, 0)?; match &command[..] { "add-media-player" => { let name = String::from(get_arg(args, 1)?); let browsing_supported = String::from(get_arg(args, 2)?) .parse::<bool>() .or(Err("Failed to parse browsing_supported"))?; self.context .lock() .unwrap() .qa_dbus .as_mut() .unwrap() .add_media_player(name, browsing_supported); } _ => return Err(CommandError::InvalidArgs), }; Ok(()) } } #[cfg(test)] Loading
system/gd/rust/linux/client/src/dbus_iface.rs +8 −3 Original line number Diff line number Diff line Loading @@ -2242,13 +2242,13 @@ impl IBluetoothTelephony for BluetoothTelephonyDBus { } pub(crate) struct BluetoothQADBus { _client_proxy: ClientDBusProxy, client_proxy: ClientDBusProxy, } impl BluetoothQADBus { pub(crate) fn new(conn: Arc<SyncConnection>, index: i32) -> BluetoothQADBus { BluetoothQADBus { _client_proxy: ClientDBusProxy::new( client_proxy: ClientDBusProxy::new( conn.clone(), String::from("org.chromium.bluetooth"), make_object_path(index, "qa"), Loading @@ -2259,4 +2259,9 @@ impl BluetoothQADBus { } #[generate_dbus_interface_client] impl IBluetoothQA for BluetoothQADBus {} impl IBluetoothQA for BluetoothQADBus { #[dbus_method("AddMediaPlayer")] fn add_media_player(&self, name: String, browsing_supported: bool) { dbus_generated!() } }
system/gd/rust/linux/service/src/iface_bluetooth_qa.rs +10 −2 Original line number Diff line number Diff line use btstack::bluetooth_qa::IBluetoothQA; use dbus_macros::generate_dbus_exporter; use dbus_macros::{dbus_method, generate_dbus_exporter}; use dbus_projection::dbus_generated; use crate::dbus_arg::DBusArg; struct IBluetoothQADBus {} #[generate_dbus_exporter(export_bluetooth_qa_dbus_intf, "org.chromium.bluetooth.BluetoothQA")] impl IBluetoothQA for IBluetoothQADBus {} impl IBluetoothQA for IBluetoothQADBus { #[dbus_method("AddMediaPlayer")] fn add_media_player(&self, name: String, browsing_supported: bool) { dbus_generated!() } }
system/gd/rust/linux/stack/src/bluetooth_media.rs +3 −0 Original line number Diff line number Diff line Loading @@ -1601,6 +1601,9 @@ impl BluetoothMedia { self.notify_media_capability_updated(addr); self.connect(address); } pub fn add_player(&mut self, name: String, browsing_supported: bool) { self.avrcp.as_mut().unwrap().add_player(&name, browsing_supported); } } fn get_a2dp_dispatcher(tx: Sender<Message>) -> A2dpCallbacksDispatcher { Loading
system/gd/rust/linux/stack/src/bluetooth_qa.rs +13 −4 Original line number Diff line number Diff line Loading @@ -4,16 +4,25 @@ use crate::Message; use tokio::sync::mpsc::Sender; /// Defines the Qualification API pub trait IBluetoothQA {} pub trait IBluetoothQA { fn add_media_player(&self, name: String, browsing_supported: bool); } pub struct BluetoothQA { _tx: Sender<Message>, tx: Sender<Message>, } impl BluetoothQA { pub fn new(tx: Sender<Message>) -> BluetoothQA { BluetoothQA { _tx: tx } BluetoothQA { tx } } } impl IBluetoothQA for BluetoothQA {} impl IBluetoothQA for BluetoothQA { fn add_media_player(&self, name: String, browsing_supported: bool) { let txl = self.tx.clone(); tokio::spawn(async move { let _ = txl.send(Message::QaAddMediaPlayer(name, browsing_supported)).await; }); } }