Loading system/gd/rust/linux/client/src/callbacks.rs +75 −2 Original line number Diff line number Diff line Loading @@ -3,8 +3,9 @@ use crate::dbus_iface::{ export_admin_policy_callback_dbus_intf, export_advertising_set_callback_dbus_intf, export_bluetooth_callback_dbus_intf, export_bluetooth_connection_callback_dbus_intf, export_bluetooth_gatt_callback_dbus_intf, export_bluetooth_manager_callback_dbus_intf, export_gatt_server_callback_dbus_intf, export_scanner_callback_dbus_intf, export_socket_callback_dbus_intf, export_suspend_callback_dbus_intf, export_gatt_server_callback_dbus_intf, export_qa_callback_dbus_intf, export_scanner_callback_dbus_intf, export_socket_callback_dbus_intf, export_suspend_callback_dbus_intf, }; use crate::ClientContext; use crate::{console_red, console_yellow, print_error, print_info}; Loading @@ -20,6 +21,7 @@ use btstack::bluetooth_gatt::{ BluetoothGattService, IBluetoothGattCallback, IBluetoothGattServerCallback, IScannerCallback, ScanResult, }; use btstack::bluetooth_qa::IBluetoothQACallback; use btstack::socket_manager::{ BluetoothServerSocket, BluetoothSocket, IBluetoothSocketManager, IBluetoothSocketManagerCallbacks, SocketId, Loading Loading @@ -1214,3 +1216,74 @@ impl RPCProxy for SuspendCallback { cr.lock().unwrap().insert(self.get_object_id(), &[iface], Arc::new(Mutex::new(self))); } } /// Callback container for suspend interface callbacks. pub(crate) struct QACallback { objpath: String, _context: Arc<Mutex<ClientContext>>, dbus_connection: Arc<SyncConnection>, dbus_crossroads: Arc<Mutex<Crossroads>>, } impl QACallback { pub(crate) fn new( objpath: String, _context: Arc<Mutex<ClientContext>>, dbus_connection: Arc<SyncConnection>, dbus_crossroads: Arc<Mutex<Crossroads>>, ) -> Self { Self { objpath, _context, dbus_connection, dbus_crossroads } } } impl IBluetoothQACallback for QACallback { fn on_fetch_discoverable_mode_completed(&mut self, mode: bt_topshim::btif::BtDiscMode) { print_info!("Discoverable mode: {:?}", mode); } fn on_fetch_connectable_completed(&mut self, connectable: bool) { print_info!("Connectable mode: {:?}", connectable); } fn on_set_connectable_completed(&mut self, succeed: bool) { print_info!( "Set connectable mode: {}", match succeed { true => "succeeded", false => "failed", } ); } fn on_fetch_alias_completed(&mut self, alias: String) { print_info!("Alias: {}", alias); } fn on_get_hid_report_completed(&mut self, status: BtStatus) { print_info!("Get HID report: {:?}", status); } fn on_set_hid_report_completed(&mut self, status: BtStatus) { print_info!("Set HID report: {:?}", status); } fn on_send_hid_data_completed(&mut self, status: BtStatus) { print_info!("Send HID data: {:?}", status); } } impl RPCProxy for QACallback { fn get_object_id(&self) -> String { self.objpath.clone() } fn export_for_rpc(self: Box<Self>) { let cr = self.dbus_crossroads.clone(); let iface = export_qa_callback_dbus_intf( self.dbus_connection.clone(), &mut cr.lock().unwrap(), Arc::new(Mutex::new(DisconnectWatcher::new())), ); cr.lock().unwrap().insert(self.get_object_id(), &[iface], Arc::new(Mutex::new(self))); } } system/gd/rust/linux/client/src/command_handler.rs +10 −24 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ use bt_topshim::btif::{BtConnectionState, BtDiscMode, BtStatus, BtTransport}; use bt_topshim::profiles::hid_host::BthhReportType; use bt_topshim::profiles::sdp::{BtSdpMpsRecord, BtSdpRecord}; use bt_topshim::profiles::{gatt::LePhy, ProfileConnectionState}; use btstack::bluetooth::{BluetoothDevice, IBluetooth, IBluetoothQALegacy}; use btstack::bluetooth::{BluetoothDevice, IBluetooth}; use btstack::bluetooth_gatt::{GattWriteType, IBluetoothGatt, ScanSettings, ScanType}; use btstack::bluetooth_media::IBluetoothTelephony; use btstack::bluetooth_qa::IBluetoothQA; Loading Loading @@ -481,15 +481,11 @@ impl CommandHandler { }; let context = self.lock_context(); let adapter_dbus = context.adapter_dbus.as_ref().unwrap(); let qa_legacy_dbus = context.qa_legacy_dbus.as_ref().unwrap(); let qa_dbus = context.qa_dbus.as_ref().unwrap(); let name = adapter_dbus.get_name(); let modalias = qa_dbus.get_modalias(); let uuids = adapter_dbus.get_uuids(); let is_discoverable = adapter_dbus.get_discoverable(); let is_connectable = qa_legacy_dbus.get_connectable(); let alias = qa_legacy_dbus.get_alias(); let modalias = qa_legacy_dbus.get_modalias(); let discoverable_mode = qa_dbus.get_discoverable_mode(); let discoverable_timeout = adapter_dbus.get_discoverable_timeout(); let cod = adapter_dbus.get_bluetooth_class(); let multi_adv_supported = adapter_dbus.is_multi_advertisement_supported(); Loading @@ -507,15 +503,15 @@ impl CommandHandler { }) .filter(|(_prof, state)| state != &ProfileConnectionState::Disconnected) .collect(); qa_dbus.fetch_connectable(); qa_dbus.fetch_alias(); qa_dbus.fetch_discoverable_mode(); print_info!("Address: {}", address); print_info!("Name: {}", name); print_info!("Alias: {}", alias); print_info!("Modalias: {}", modalias); print_info!("State: {}", if enabled { "enabled" } else { "disabled" }); print_info!("Discoverable: {}", is_discoverable); print_info!("Discoverable mode: {:?}", discoverable_mode); print_info!("DiscoverableTimeout: {}s", discoverable_timeout); print_info!("Connectable: {}", is_connectable); print_info!("Class: {:#06x}", cod); print_info!("IsMultiAdvertisementSupported: {}", multi_adv_supported); print_info!("IsLeExtendedAdvertisingSupported: {}", le_ext_adv_supported); Loading Loading @@ -582,14 +578,10 @@ impl CommandHandler { }, "connectable" => match &get_arg(args, 1)?[..] { "on" => { let ret = self.lock_context().qa_legacy_dbus.as_mut().unwrap().set_connectable(true); print_info!("Set connectable on {}", if ret { "succeeded" } else { "failed" }); self.lock_context().qa_dbus.as_mut().unwrap().set_connectable(true); } "off" => { let ret = self.lock_context().qa_legacy_dbus.as_mut().unwrap().set_connectable(false); print_info!("Set connectable off {}", if ret { "succeeded" } else { "failed" }); self.lock_context().qa_dbus.as_mut().unwrap().set_connectable(false); } other => println!("Invalid argument for adapter connectable '{}'", other), }, Loading Loading @@ -1652,7 +1644,7 @@ impl CommandHandler { .parse::<u8>() .or(Err("Failed parsing report_id"))?; self.context.lock().unwrap().qa_legacy_dbus.as_mut().unwrap().get_hid_report( self.context.lock().unwrap().qa_dbus.as_mut().unwrap().get_hid_report( addr, report_type, report_id, Loading @@ -1670,7 +1662,7 @@ impl CommandHandler { }; let report_value = String::from(get_arg(args, 3)?); self.context.lock().unwrap().qa_legacy_dbus.as_mut().unwrap().set_hid_report( self.context.lock().unwrap().qa_dbus.as_mut().unwrap().set_hid_report( addr, report_type, report_value, Loading @@ -1680,13 +1672,7 @@ impl CommandHandler { let addr = String::from(get_arg(args, 1)?); let data = String::from(get_arg(args, 2)?); self.context .lock() .unwrap() .qa_legacy_dbus .as_mut() .unwrap() .send_hid_data(addr, data); self.context.lock().unwrap().qa_dbus.as_mut().unwrap().send_hid_data(addr, data); } _ => return Err(CommandError::InvalidArgs), }; Loading system/gd/rust/linux/client/src/dbus_iface.rs +93 −9 Original line number Diff line number Diff line Loading @@ -60,6 +60,8 @@ use std::collections::HashMap; use std::convert::{TryFrom, TryInto}; use std::sync::Arc; use btstack::bluetooth_qa::IBluetoothQACallback; use crate::dbus_arg::{DBusArg, DBusArgError, DirectDBus, RefArgToRust}; fn make_object_path(idx: i32, name: &str) -> dbus::Path { Loading Loading @@ -2262,25 +2264,43 @@ impl IBluetoothTelephony for BluetoothTelephonyDBus { } } pub(crate) struct BluetoothQADBusRPC { client_proxy: ClientDBusProxy, } pub(crate) struct BluetoothQADBus { client_proxy: ClientDBusProxy, pub rpc: BluetoothQADBusRPC, } impl BluetoothQADBus { pub(crate) fn new(conn: Arc<SyncConnection>, index: i32) -> BluetoothQADBus { BluetoothQADBus { client_proxy: ClientDBusProxy::new( fn make_client_proxy(conn: Arc<SyncConnection>, index: i32) -> ClientDBusProxy { ClientDBusProxy::new( conn.clone(), String::from("org.chromium.bluetooth"), make_object_path(index, "qa"), String::from("org.chromium.bluetooth.BluetoothQA"), ), ) } pub(crate) fn new(conn: Arc<SyncConnection>, index: i32) -> BluetoothQADBus { BluetoothQADBus { client_proxy: Self::make_client_proxy(conn.clone(), index), rpc: BluetoothQADBusRPC { client_proxy: Self::make_client_proxy(conn.clone(), index) }, } } } #[generate_dbus_interface_client] #[generate_dbus_interface_client(BluetoothQADBusRPC)] impl IBluetoothQA for BluetoothQADBus { #[dbus_method("RegisterQACallback")] fn register_qa_callback(&mut self, callback: Box<dyn IBluetoothQACallback + Send>) -> u32 { dbus_generated!() } #[dbus_method("UnregisterQACallback")] fn unregister_qa_callback(&mut self, callback_id: u32) -> bool { dbus_generated!() } #[dbus_method("AddMediaPlayer")] fn add_media_player(&self, name: String, browsing_supported: bool) { dbus_generated!() Loading @@ -2289,8 +2309,72 @@ impl IBluetoothQA for BluetoothQADBus { fn rfcomm_send_msc(&self, dlci: u8, addr: String) { dbus_generated!() } #[dbus_method("GetDiscoverableMode")] fn get_discoverable_mode(&self) -> BtDiscMode { #[dbus_method("FetchDiscoverableMode")] fn fetch_discoverable_mode(&self) { dbus_generated!() } #[dbus_method("FetchConnectable")] fn fetch_connectable(&self) { dbus_generated!() } #[dbus_method("SetConnectable")] fn set_connectable(&self, mode: bool) { dbus_generated!() } #[dbus_method("FetchAlias")] fn fetch_alias(&self) { dbus_generated!() } #[dbus_method("GetModalias")] fn get_modalias(&self) -> String { dbus_generated!() } #[dbus_method("GetHIDReport")] fn get_hid_report(&self, addr: String, report_type: BthhReportType, report_id: u8) { dbus_generated!() } #[dbus_method("SetHIDReport")] fn set_hid_report(&self, addr: String, report_type: BthhReportType, report: String) { dbus_generated!() } #[dbus_method("SendHIDData")] fn send_hid_data(&self, addr: String, data: String) { dbus_generated!() } } struct IBluetoothQACallbackDBus {} impl RPCProxy for IBluetoothQACallbackDBus {} #[generate_dbus_exporter(export_qa_callback_dbus_intf, "org.chromium.bluetooth.QACallback")] impl IBluetoothQACallback for IBluetoothQACallbackDBus { #[dbus_method("OnFetchDiscoverableModeComplete")] fn on_fetch_discoverable_mode_completed(&mut self, disc_mode: BtDiscMode) { dbus_generated!() } #[dbus_method("OnFetchConnectableComplete")] fn on_fetch_connectable_completed(&mut self, connectable: bool) { dbus_generated!() } #[dbus_method("OnSetConnectableComplete")] fn on_set_connectable_completed(&mut self, succeed: bool) { dbus_generated!() } #[dbus_method("OnFetchAliasComplete")] fn on_fetch_alias_completed(&mut self, alias: String) { dbus_generated!() } #[dbus_method("OnGetHIDReportComplete")] fn on_get_hid_report_completed(&mut self, status: BtStatus) { dbus_generated!() } #[dbus_method("OnSetHIDReportComplete")] fn on_set_hid_report_completed(&mut self, status: BtStatus) { dbus_generated!() } #[dbus_method("OnSendHIDDataComplete")] fn on_send_hid_data_completed(&mut self, status: BtStatus) { dbus_generated!() } } system/gd/rust/linux/client/src/main.rs +24 −1 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ use crate::bt_adv::AdvSet; use crate::bt_gatt::GattClientContext; use crate::callbacks::{ AdminCallback, AdvertisingSetCallback, BtCallback, BtConnectionCallback, BtManagerCallback, BtSocketManagerCallback, ScannerCallback, SuspendCallback, BtSocketManagerCallback, QACallback, ScannerCallback, SuspendCallback, }; use crate::command_handler::{CommandHandler, SocketSchedule}; use crate::dbus_iface::{ Loading Loading @@ -122,6 +122,9 @@ pub(crate) struct ClientContext { /// Identifies the callback to receive IBluetoothSocketManagerCallback method calls. socket_manager_callback_id: Option<u32>, /// Identifies the callback to receive IBluetoothQACallback method calls. qa_callback_id: Option<u32>, /// Is btclient running in restricted mode? is_restricted: bool, Loading Loading @@ -174,6 +177,7 @@ impl ClientContext { active_scanner_ids: HashSet::new(), adv_sets: HashMap::new(), socket_manager_callback_id: None, qa_callback_id: None, is_restricted, gatt_client_context: GattClientContext::new(), socket_test_schedule: None, Loading Loading @@ -464,6 +468,8 @@ async fn start_interactive_shell( format!("/org/chromium/bluetooth/client/{}/admin_callback", adapter); let socket_manager_cb_objpath: String = format!("/org/chromium/bluetooth/client/{}/socket_manager_callback", adapter); let qa_cb_objpath: String = format!("/org/chromium/bluetooth/client/{}/qa_manager_callback", adapter); let dbus_connection = context.lock().unwrap().dbus_connection.clone(); let dbus_crossroads = context.lock().unwrap().dbus_crossroads.clone(); Loading Loading @@ -568,6 +574,23 @@ async fn start_interactive_shell( context.lock().unwrap().socket_manager_callback_id = Some(socket_manager_callback_id); let qa_callback_id = context .lock() .unwrap() .qa_dbus .as_mut() .unwrap() .rpc .register_qa_callback(Box::new(QACallback::new( qa_cb_objpath.clone(), context.clone(), dbus_connection.clone(), dbus_crossroads.clone(), ))) .await .expect("D-Bus error on IBluetoothQA::RegisterCallback"); context.lock().unwrap().qa_callback_id = Some(qa_callback_id); // When adapter is ready, Suspend API is also ready. Register as an observer. // TODO(b/224606285): Implement suspend debug utils in btclient. context.lock().unwrap().suspend_dbus.as_mut().unwrap().register_callback(Box::new( Loading system/gd/rust/linux/service/src/iface_bluetooth_qa.rs +78 −4 Original line number Diff line number Diff line use btstack::bluetooth_qa::IBluetoothQA; use btstack::bluetooth_qa::{IBluetoothQA, IBluetoothQACallback}; use bt_topshim::btif::BtDiscMode; use dbus_macros::{dbus_method, generate_dbus_exporter}; use dbus_macros::{dbus_method, dbus_proxy_obj, generate_dbus_exporter}; use dbus_projection::dbus_generated; use dbus_projection::DisconnectWatcher; use crate::dbus_arg::DBusArg; use bt_topshim::btif::BtStatus; use bt_topshim::profiles::hid_host::BthhReportType; use btstack::RPCProxy; use dbus::Path; struct IBluetoothQACallbackDBus {} struct IBluetoothQADBus {} #[generate_dbus_exporter(export_bluetooth_qa_dbus_intf, "org.chromium.bluetooth.BluetoothQA")] impl IBluetoothQA for IBluetoothQADBus { #[dbus_method("RegisterQACallback")] fn register_qa_callback(&mut self, callback: Box<dyn IBluetoothQACallback + Send>) -> u32 { dbus_generated!() } #[dbus_method("UnregisterQACallback")] fn unregister_qa_callback(&mut self, callback_id: u32) -> bool { dbus_generated!() } #[dbus_method("AddMediaPlayer")] fn add_media_player(&self, name: String, browsing_supported: bool) { dbus_generated!() Loading @@ -18,8 +32,68 @@ impl IBluetoothQA for IBluetoothQADBus { fn rfcomm_send_msc(&self, dlci: u8, addr: String) { dbus_generated!() } #[dbus_method("GetDiscoverableMode")] fn get_discoverable_mode(&self) -> BtDiscMode { #[dbus_method("FetchDiscoverableMode")] fn fetch_discoverable_mode(&self) { dbus_generated!() } #[dbus_method("FetchConnectable")] fn fetch_connectable(&self) { dbus_generated!() } #[dbus_method("SetConnectable")] fn set_connectable(&self, mode: bool) { dbus_generated!() } #[dbus_method("FetchAlias")] fn fetch_alias(&self) { dbus_generated!() } #[dbus_method("GetModalias")] fn get_modalias(&self) -> String { dbus_generated!() } #[dbus_method("FetchHIDReport")] fn get_hid_report(&self, addr: String, report_type: BthhReportType, report_id: u8) { dbus_generated!() } #[dbus_method("SetHIDReport")] fn set_hid_report(&self, addr: String, report_type: BthhReportType, report: String) { dbus_generated!() } #[dbus_method("SendHIDData")] fn send_hid_data(&self, addr: String, data: String) { dbus_generated!() } } #[dbus_proxy_obj(QACallback, "org.chromium.bluetooth.QACallback")] impl IBluetoothQACallback for IBluetoothQACallbackDBus { #[dbus_method("OnFetchDiscoverableModeComplete")] fn on_fetch_discoverable_mode_completed(&mut self, disc_mode: BtDiscMode) { dbus_generated!() } #[dbus_method("OnFetchConnectableComplete")] fn on_fetch_connectable_completed(&mut self, connectable: bool) { dbus_generated!() } #[dbus_method("OnSetConnectableComplete")] fn on_set_connectable_completed(&mut self, succeed: bool) { dbus_generated!() } #[dbus_method("OnFetchAliasComplete")] fn on_fetch_alias_completed(&mut self, alias: String) { dbus_generated!() } #[dbus_method("OnGetHIDReportComplete")] fn on_get_hid_report_completed(&mut self, status: BtStatus) { dbus_generated!() } #[dbus_method("OnSetHIDReportComplete")] fn on_set_hid_report_completed(&mut self, status: BtStatus) { dbus_generated!() } #[dbus_method("OnSendHIDDataComplete")] fn on_send_hid_data_completed(&mut self, status: BtStatus) { dbus_generated!() } } Loading
system/gd/rust/linux/client/src/callbacks.rs +75 −2 Original line number Diff line number Diff line Loading @@ -3,8 +3,9 @@ use crate::dbus_iface::{ export_admin_policy_callback_dbus_intf, export_advertising_set_callback_dbus_intf, export_bluetooth_callback_dbus_intf, export_bluetooth_connection_callback_dbus_intf, export_bluetooth_gatt_callback_dbus_intf, export_bluetooth_manager_callback_dbus_intf, export_gatt_server_callback_dbus_intf, export_scanner_callback_dbus_intf, export_socket_callback_dbus_intf, export_suspend_callback_dbus_intf, export_gatt_server_callback_dbus_intf, export_qa_callback_dbus_intf, export_scanner_callback_dbus_intf, export_socket_callback_dbus_intf, export_suspend_callback_dbus_intf, }; use crate::ClientContext; use crate::{console_red, console_yellow, print_error, print_info}; Loading @@ -20,6 +21,7 @@ use btstack::bluetooth_gatt::{ BluetoothGattService, IBluetoothGattCallback, IBluetoothGattServerCallback, IScannerCallback, ScanResult, }; use btstack::bluetooth_qa::IBluetoothQACallback; use btstack::socket_manager::{ BluetoothServerSocket, BluetoothSocket, IBluetoothSocketManager, IBluetoothSocketManagerCallbacks, SocketId, Loading Loading @@ -1214,3 +1216,74 @@ impl RPCProxy for SuspendCallback { cr.lock().unwrap().insert(self.get_object_id(), &[iface], Arc::new(Mutex::new(self))); } } /// Callback container for suspend interface callbacks. pub(crate) struct QACallback { objpath: String, _context: Arc<Mutex<ClientContext>>, dbus_connection: Arc<SyncConnection>, dbus_crossroads: Arc<Mutex<Crossroads>>, } impl QACallback { pub(crate) fn new( objpath: String, _context: Arc<Mutex<ClientContext>>, dbus_connection: Arc<SyncConnection>, dbus_crossroads: Arc<Mutex<Crossroads>>, ) -> Self { Self { objpath, _context, dbus_connection, dbus_crossroads } } } impl IBluetoothQACallback for QACallback { fn on_fetch_discoverable_mode_completed(&mut self, mode: bt_topshim::btif::BtDiscMode) { print_info!("Discoverable mode: {:?}", mode); } fn on_fetch_connectable_completed(&mut self, connectable: bool) { print_info!("Connectable mode: {:?}", connectable); } fn on_set_connectable_completed(&mut self, succeed: bool) { print_info!( "Set connectable mode: {}", match succeed { true => "succeeded", false => "failed", } ); } fn on_fetch_alias_completed(&mut self, alias: String) { print_info!("Alias: {}", alias); } fn on_get_hid_report_completed(&mut self, status: BtStatus) { print_info!("Get HID report: {:?}", status); } fn on_set_hid_report_completed(&mut self, status: BtStatus) { print_info!("Set HID report: {:?}", status); } fn on_send_hid_data_completed(&mut self, status: BtStatus) { print_info!("Send HID data: {:?}", status); } } impl RPCProxy for QACallback { fn get_object_id(&self) -> String { self.objpath.clone() } fn export_for_rpc(self: Box<Self>) { let cr = self.dbus_crossroads.clone(); let iface = export_qa_callback_dbus_intf( self.dbus_connection.clone(), &mut cr.lock().unwrap(), Arc::new(Mutex::new(DisconnectWatcher::new())), ); cr.lock().unwrap().insert(self.get_object_id(), &[iface], Arc::new(Mutex::new(self))); } }
system/gd/rust/linux/client/src/command_handler.rs +10 −24 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ use bt_topshim::btif::{BtConnectionState, BtDiscMode, BtStatus, BtTransport}; use bt_topshim::profiles::hid_host::BthhReportType; use bt_topshim::profiles::sdp::{BtSdpMpsRecord, BtSdpRecord}; use bt_topshim::profiles::{gatt::LePhy, ProfileConnectionState}; use btstack::bluetooth::{BluetoothDevice, IBluetooth, IBluetoothQALegacy}; use btstack::bluetooth::{BluetoothDevice, IBluetooth}; use btstack::bluetooth_gatt::{GattWriteType, IBluetoothGatt, ScanSettings, ScanType}; use btstack::bluetooth_media::IBluetoothTelephony; use btstack::bluetooth_qa::IBluetoothQA; Loading Loading @@ -481,15 +481,11 @@ impl CommandHandler { }; let context = self.lock_context(); let adapter_dbus = context.adapter_dbus.as_ref().unwrap(); let qa_legacy_dbus = context.qa_legacy_dbus.as_ref().unwrap(); let qa_dbus = context.qa_dbus.as_ref().unwrap(); let name = adapter_dbus.get_name(); let modalias = qa_dbus.get_modalias(); let uuids = adapter_dbus.get_uuids(); let is_discoverable = adapter_dbus.get_discoverable(); let is_connectable = qa_legacy_dbus.get_connectable(); let alias = qa_legacy_dbus.get_alias(); let modalias = qa_legacy_dbus.get_modalias(); let discoverable_mode = qa_dbus.get_discoverable_mode(); let discoverable_timeout = adapter_dbus.get_discoverable_timeout(); let cod = adapter_dbus.get_bluetooth_class(); let multi_adv_supported = adapter_dbus.is_multi_advertisement_supported(); Loading @@ -507,15 +503,15 @@ impl CommandHandler { }) .filter(|(_prof, state)| state != &ProfileConnectionState::Disconnected) .collect(); qa_dbus.fetch_connectable(); qa_dbus.fetch_alias(); qa_dbus.fetch_discoverable_mode(); print_info!("Address: {}", address); print_info!("Name: {}", name); print_info!("Alias: {}", alias); print_info!("Modalias: {}", modalias); print_info!("State: {}", if enabled { "enabled" } else { "disabled" }); print_info!("Discoverable: {}", is_discoverable); print_info!("Discoverable mode: {:?}", discoverable_mode); print_info!("DiscoverableTimeout: {}s", discoverable_timeout); print_info!("Connectable: {}", is_connectable); print_info!("Class: {:#06x}", cod); print_info!("IsMultiAdvertisementSupported: {}", multi_adv_supported); print_info!("IsLeExtendedAdvertisingSupported: {}", le_ext_adv_supported); Loading Loading @@ -582,14 +578,10 @@ impl CommandHandler { }, "connectable" => match &get_arg(args, 1)?[..] { "on" => { let ret = self.lock_context().qa_legacy_dbus.as_mut().unwrap().set_connectable(true); print_info!("Set connectable on {}", if ret { "succeeded" } else { "failed" }); self.lock_context().qa_dbus.as_mut().unwrap().set_connectable(true); } "off" => { let ret = self.lock_context().qa_legacy_dbus.as_mut().unwrap().set_connectable(false); print_info!("Set connectable off {}", if ret { "succeeded" } else { "failed" }); self.lock_context().qa_dbus.as_mut().unwrap().set_connectable(false); } other => println!("Invalid argument for adapter connectable '{}'", other), }, Loading Loading @@ -1652,7 +1644,7 @@ impl CommandHandler { .parse::<u8>() .or(Err("Failed parsing report_id"))?; self.context.lock().unwrap().qa_legacy_dbus.as_mut().unwrap().get_hid_report( self.context.lock().unwrap().qa_dbus.as_mut().unwrap().get_hid_report( addr, report_type, report_id, Loading @@ -1670,7 +1662,7 @@ impl CommandHandler { }; let report_value = String::from(get_arg(args, 3)?); self.context.lock().unwrap().qa_legacy_dbus.as_mut().unwrap().set_hid_report( self.context.lock().unwrap().qa_dbus.as_mut().unwrap().set_hid_report( addr, report_type, report_value, Loading @@ -1680,13 +1672,7 @@ impl CommandHandler { let addr = String::from(get_arg(args, 1)?); let data = String::from(get_arg(args, 2)?); self.context .lock() .unwrap() .qa_legacy_dbus .as_mut() .unwrap() .send_hid_data(addr, data); self.context.lock().unwrap().qa_dbus.as_mut().unwrap().send_hid_data(addr, data); } _ => return Err(CommandError::InvalidArgs), }; Loading
system/gd/rust/linux/client/src/dbus_iface.rs +93 −9 Original line number Diff line number Diff line Loading @@ -60,6 +60,8 @@ use std::collections::HashMap; use std::convert::{TryFrom, TryInto}; use std::sync::Arc; use btstack::bluetooth_qa::IBluetoothQACallback; use crate::dbus_arg::{DBusArg, DBusArgError, DirectDBus, RefArgToRust}; fn make_object_path(idx: i32, name: &str) -> dbus::Path { Loading Loading @@ -2262,25 +2264,43 @@ impl IBluetoothTelephony for BluetoothTelephonyDBus { } } pub(crate) struct BluetoothQADBusRPC { client_proxy: ClientDBusProxy, } pub(crate) struct BluetoothQADBus { client_proxy: ClientDBusProxy, pub rpc: BluetoothQADBusRPC, } impl BluetoothQADBus { pub(crate) fn new(conn: Arc<SyncConnection>, index: i32) -> BluetoothQADBus { BluetoothQADBus { client_proxy: ClientDBusProxy::new( fn make_client_proxy(conn: Arc<SyncConnection>, index: i32) -> ClientDBusProxy { ClientDBusProxy::new( conn.clone(), String::from("org.chromium.bluetooth"), make_object_path(index, "qa"), String::from("org.chromium.bluetooth.BluetoothQA"), ), ) } pub(crate) fn new(conn: Arc<SyncConnection>, index: i32) -> BluetoothQADBus { BluetoothQADBus { client_proxy: Self::make_client_proxy(conn.clone(), index), rpc: BluetoothQADBusRPC { client_proxy: Self::make_client_proxy(conn.clone(), index) }, } } } #[generate_dbus_interface_client] #[generate_dbus_interface_client(BluetoothQADBusRPC)] impl IBluetoothQA for BluetoothQADBus { #[dbus_method("RegisterQACallback")] fn register_qa_callback(&mut self, callback: Box<dyn IBluetoothQACallback + Send>) -> u32 { dbus_generated!() } #[dbus_method("UnregisterQACallback")] fn unregister_qa_callback(&mut self, callback_id: u32) -> bool { dbus_generated!() } #[dbus_method("AddMediaPlayer")] fn add_media_player(&self, name: String, browsing_supported: bool) { dbus_generated!() Loading @@ -2289,8 +2309,72 @@ impl IBluetoothQA for BluetoothQADBus { fn rfcomm_send_msc(&self, dlci: u8, addr: String) { dbus_generated!() } #[dbus_method("GetDiscoverableMode")] fn get_discoverable_mode(&self) -> BtDiscMode { #[dbus_method("FetchDiscoverableMode")] fn fetch_discoverable_mode(&self) { dbus_generated!() } #[dbus_method("FetchConnectable")] fn fetch_connectable(&self) { dbus_generated!() } #[dbus_method("SetConnectable")] fn set_connectable(&self, mode: bool) { dbus_generated!() } #[dbus_method("FetchAlias")] fn fetch_alias(&self) { dbus_generated!() } #[dbus_method("GetModalias")] fn get_modalias(&self) -> String { dbus_generated!() } #[dbus_method("GetHIDReport")] fn get_hid_report(&self, addr: String, report_type: BthhReportType, report_id: u8) { dbus_generated!() } #[dbus_method("SetHIDReport")] fn set_hid_report(&self, addr: String, report_type: BthhReportType, report: String) { dbus_generated!() } #[dbus_method("SendHIDData")] fn send_hid_data(&self, addr: String, data: String) { dbus_generated!() } } struct IBluetoothQACallbackDBus {} impl RPCProxy for IBluetoothQACallbackDBus {} #[generate_dbus_exporter(export_qa_callback_dbus_intf, "org.chromium.bluetooth.QACallback")] impl IBluetoothQACallback for IBluetoothQACallbackDBus { #[dbus_method("OnFetchDiscoverableModeComplete")] fn on_fetch_discoverable_mode_completed(&mut self, disc_mode: BtDiscMode) { dbus_generated!() } #[dbus_method("OnFetchConnectableComplete")] fn on_fetch_connectable_completed(&mut self, connectable: bool) { dbus_generated!() } #[dbus_method("OnSetConnectableComplete")] fn on_set_connectable_completed(&mut self, succeed: bool) { dbus_generated!() } #[dbus_method("OnFetchAliasComplete")] fn on_fetch_alias_completed(&mut self, alias: String) { dbus_generated!() } #[dbus_method("OnGetHIDReportComplete")] fn on_get_hid_report_completed(&mut self, status: BtStatus) { dbus_generated!() } #[dbus_method("OnSetHIDReportComplete")] fn on_set_hid_report_completed(&mut self, status: BtStatus) { dbus_generated!() } #[dbus_method("OnSendHIDDataComplete")] fn on_send_hid_data_completed(&mut self, status: BtStatus) { dbus_generated!() } }
system/gd/rust/linux/client/src/main.rs +24 −1 Original line number Diff line number Diff line Loading @@ -13,7 +13,7 @@ use crate::bt_adv::AdvSet; use crate::bt_gatt::GattClientContext; use crate::callbacks::{ AdminCallback, AdvertisingSetCallback, BtCallback, BtConnectionCallback, BtManagerCallback, BtSocketManagerCallback, ScannerCallback, SuspendCallback, BtSocketManagerCallback, QACallback, ScannerCallback, SuspendCallback, }; use crate::command_handler::{CommandHandler, SocketSchedule}; use crate::dbus_iface::{ Loading Loading @@ -122,6 +122,9 @@ pub(crate) struct ClientContext { /// Identifies the callback to receive IBluetoothSocketManagerCallback method calls. socket_manager_callback_id: Option<u32>, /// Identifies the callback to receive IBluetoothQACallback method calls. qa_callback_id: Option<u32>, /// Is btclient running in restricted mode? is_restricted: bool, Loading Loading @@ -174,6 +177,7 @@ impl ClientContext { active_scanner_ids: HashSet::new(), adv_sets: HashMap::new(), socket_manager_callback_id: None, qa_callback_id: None, is_restricted, gatt_client_context: GattClientContext::new(), socket_test_schedule: None, Loading Loading @@ -464,6 +468,8 @@ async fn start_interactive_shell( format!("/org/chromium/bluetooth/client/{}/admin_callback", adapter); let socket_manager_cb_objpath: String = format!("/org/chromium/bluetooth/client/{}/socket_manager_callback", adapter); let qa_cb_objpath: String = format!("/org/chromium/bluetooth/client/{}/qa_manager_callback", adapter); let dbus_connection = context.lock().unwrap().dbus_connection.clone(); let dbus_crossroads = context.lock().unwrap().dbus_crossroads.clone(); Loading Loading @@ -568,6 +574,23 @@ async fn start_interactive_shell( context.lock().unwrap().socket_manager_callback_id = Some(socket_manager_callback_id); let qa_callback_id = context .lock() .unwrap() .qa_dbus .as_mut() .unwrap() .rpc .register_qa_callback(Box::new(QACallback::new( qa_cb_objpath.clone(), context.clone(), dbus_connection.clone(), dbus_crossroads.clone(), ))) .await .expect("D-Bus error on IBluetoothQA::RegisterCallback"); context.lock().unwrap().qa_callback_id = Some(qa_callback_id); // When adapter is ready, Suspend API is also ready. Register as an observer. // TODO(b/224606285): Implement suspend debug utils in btclient. context.lock().unwrap().suspend_dbus.as_mut().unwrap().register_callback(Box::new( Loading
system/gd/rust/linux/service/src/iface_bluetooth_qa.rs +78 −4 Original line number Diff line number Diff line use btstack::bluetooth_qa::IBluetoothQA; use btstack::bluetooth_qa::{IBluetoothQA, IBluetoothQACallback}; use bt_topshim::btif::BtDiscMode; use dbus_macros::{dbus_method, generate_dbus_exporter}; use dbus_macros::{dbus_method, dbus_proxy_obj, generate_dbus_exporter}; use dbus_projection::dbus_generated; use dbus_projection::DisconnectWatcher; use crate::dbus_arg::DBusArg; use bt_topshim::btif::BtStatus; use bt_topshim::profiles::hid_host::BthhReportType; use btstack::RPCProxy; use dbus::Path; struct IBluetoothQACallbackDBus {} struct IBluetoothQADBus {} #[generate_dbus_exporter(export_bluetooth_qa_dbus_intf, "org.chromium.bluetooth.BluetoothQA")] impl IBluetoothQA for IBluetoothQADBus { #[dbus_method("RegisterQACallback")] fn register_qa_callback(&mut self, callback: Box<dyn IBluetoothQACallback + Send>) -> u32 { dbus_generated!() } #[dbus_method("UnregisterQACallback")] fn unregister_qa_callback(&mut self, callback_id: u32) -> bool { dbus_generated!() } #[dbus_method("AddMediaPlayer")] fn add_media_player(&self, name: String, browsing_supported: bool) { dbus_generated!() Loading @@ -18,8 +32,68 @@ impl IBluetoothQA for IBluetoothQADBus { fn rfcomm_send_msc(&self, dlci: u8, addr: String) { dbus_generated!() } #[dbus_method("GetDiscoverableMode")] fn get_discoverable_mode(&self) -> BtDiscMode { #[dbus_method("FetchDiscoverableMode")] fn fetch_discoverable_mode(&self) { dbus_generated!() } #[dbus_method("FetchConnectable")] fn fetch_connectable(&self) { dbus_generated!() } #[dbus_method("SetConnectable")] fn set_connectable(&self, mode: bool) { dbus_generated!() } #[dbus_method("FetchAlias")] fn fetch_alias(&self) { dbus_generated!() } #[dbus_method("GetModalias")] fn get_modalias(&self) -> String { dbus_generated!() } #[dbus_method("FetchHIDReport")] fn get_hid_report(&self, addr: String, report_type: BthhReportType, report_id: u8) { dbus_generated!() } #[dbus_method("SetHIDReport")] fn set_hid_report(&self, addr: String, report_type: BthhReportType, report: String) { dbus_generated!() } #[dbus_method("SendHIDData")] fn send_hid_data(&self, addr: String, data: String) { dbus_generated!() } } #[dbus_proxy_obj(QACallback, "org.chromium.bluetooth.QACallback")] impl IBluetoothQACallback for IBluetoothQACallbackDBus { #[dbus_method("OnFetchDiscoverableModeComplete")] fn on_fetch_discoverable_mode_completed(&mut self, disc_mode: BtDiscMode) { dbus_generated!() } #[dbus_method("OnFetchConnectableComplete")] fn on_fetch_connectable_completed(&mut self, connectable: bool) { dbus_generated!() } #[dbus_method("OnSetConnectableComplete")] fn on_set_connectable_completed(&mut self, succeed: bool) { dbus_generated!() } #[dbus_method("OnFetchAliasComplete")] fn on_fetch_alias_completed(&mut self, alias: String) { dbus_generated!() } #[dbus_method("OnGetHIDReportComplete")] fn on_get_hid_report_completed(&mut self, status: BtStatus) { dbus_generated!() } #[dbus_method("OnSetHIDReportComplete")] fn on_set_hid_report_completed(&mut self, status: BtStatus) { dbus_generated!() } #[dbus_method("OnSendHIDDataComplete")] fn on_send_hid_data_completed(&mut self, status: BtStatus) { dbus_generated!() } }