Loading system/gd/rust/linux/client/src/dbus_iface.rs +18 −3 Original line number Diff line number Diff line Loading @@ -13,7 +13,9 @@ use dbus_projection::{impl_dbus_arg_enum, DisconnectWatcher}; use dbus_macros::{dbus_method, dbus_propmap, generate_dbus_exporter}; use manager_service::iface_bluetooth_manager::{IBluetoothManager, IBluetoothManagerCallback}; use manager_service::iface_bluetooth_manager::{ AdapterWithEnabled, IBluetoothManager, IBluetoothManagerCallback, }; use num_traits::{FromPrimitive, ToPrimitive}; Loading Loading @@ -185,6 +187,12 @@ impl IBluetooth for BluetoothDBus { } } #[dbus_propmap(AdapterWithEnabled)] pub struct AdapterWithEnabledDbus { hci_interface: i32, enabled: bool, } pub(crate) struct BluetoothManagerDBus { client_proxy: ClientDBusProxy, } Loading Loading @@ -242,8 +250,15 @@ impl IBluetoothManager for BluetoothManagerDBus { self.client_proxy.method_noreturn("SetFlossEnabled", (enabled,)) } fn list_hci_devices(&mut self) -> Vec<i32> { self.client_proxy.method("ListHciDevices", ()) fn get_available_adapters(&mut self) -> Vec<AdapterWithEnabled> { let props: Vec<dbus::arg::PropMap> = self.client_proxy.method("GetAvailableAdapters", ()); <Vec<AdapterWithEnabled> as DBusArg>::from_dbus( props, self.client_proxy.conn.clone(), dbus::strings::BusName::new(":1.0").unwrap(), // unused Arc::new(Mutex::new(DisconnectWatcher::new())), ) .unwrap() } } Loading system/gd/rust/linux/mgmt/src/bin/btmanagerd/bluetooth_manager.rs +13 −4 Original line number Diff line number Diff line use log::{error, info}; use manager_service::iface_bluetooth_manager::{IBluetoothManager, IBluetoothManagerCallback}; use manager_service::iface_bluetooth_manager::{ AdapterWithEnabled, IBluetoothManager, IBluetoothManagerCallback, }; use std::collections::HashMap; use std::process::Command; Loading Loading @@ -134,8 +136,15 @@ impl IBluetoothManager for BluetoothManager { } } fn list_hci_devices(&mut self) -> Vec<i32> { let devices = config_util::list_hci_devices(); devices fn get_available_adapters(&mut self) -> Vec<AdapterWithEnabled> { let adapters = config_util::list_hci_devices() .iter() .map(|hci_interface| { let enabled: bool = *self.cached_devices.get(&hci_interface).unwrap_or(&false); AdapterWithEnabled { hci_interface: *hci_interface, enabled } }) .collect::<Vec<AdapterWithEnabled>>(); adapters } } system/gd/rust/linux/mgmt/src/bin/btmanagerd/bluetooth_manager_dbus.rs +14 −7 Original line number Diff line number Diff line use dbus::arg::RefArg; use dbus::nonblock::SyncConnection; use dbus::strings::Path; use dbus_macros::{dbus_method, dbus_proxy_obj, generate_dbus_exporter}; use dbus_macros::{dbus_method, dbus_propmap, dbus_proxy_obj, generate_dbus_exporter}; use dbus_projection::DisconnectWatcher; use manager_service::iface_bluetooth_manager::{IBluetoothManager, IBluetoothManagerCallback}; use manager_service::iface_bluetooth_manager::{ AdapterWithEnabled, IBluetoothManager, IBluetoothManagerCallback, }; use manager_service::RPCProxy; use crate::dbus_arg::DBusArg; use crate::dbus_arg::{DBusArg, DBusArgError, RefArgToRust}; #[dbus_propmap(AdapterWithEnabled)] pub struct AdapterWithEnabledDbus { hci_interface: i32, enabled: bool, } /// D-Bus projection of IBluetoothManager. struct BluetoothManagerDBus {} Loading Loading @@ -37,8 +44,8 @@ impl IBluetoothManager for BluetoothManagerDBus { #[dbus_method("SetFlossEnabled")] fn set_floss_enabled(&mut self, _enabled: bool) {} #[dbus_method("ListHciDevices")] fn list_hci_devices(&mut self) -> Vec<i32> { #[dbus_method("GetAvailableAdapters")] fn get_available_adapters(&mut self) -> Vec<AdapterWithEnabled> { vec![] } } Loading system/gd/rust/linux/mgmt/src/iface_bluetooth_manager.rs +8 −2 Original line number Diff line number Diff line use crate::RPCProxy; #[derive(Debug, Default)] pub struct AdapterWithEnabled { pub hci_interface: i32, pub enabled: bool, } /// Bluetooth stack management API. pub trait IBluetoothManager { /// Starts the Bluetooth stack. Loading @@ -20,8 +26,8 @@ pub trait IBluetoothManager { /// Enables/disables Floss. fn set_floss_enabled(&mut self, enabled: bool); /// Returns the list of available HCI devices. fn list_hci_devices(&mut self) -> Vec<i32>; /// Returns a list of available HCI devices and if they are enabled. fn get_available_adapters(&mut self) -> Vec<AdapterWithEnabled>; } /// Interface of Bluetooth Manager callbacks. Loading Loading
system/gd/rust/linux/client/src/dbus_iface.rs +18 −3 Original line number Diff line number Diff line Loading @@ -13,7 +13,9 @@ use dbus_projection::{impl_dbus_arg_enum, DisconnectWatcher}; use dbus_macros::{dbus_method, dbus_propmap, generate_dbus_exporter}; use manager_service::iface_bluetooth_manager::{IBluetoothManager, IBluetoothManagerCallback}; use manager_service::iface_bluetooth_manager::{ AdapterWithEnabled, IBluetoothManager, IBluetoothManagerCallback, }; use num_traits::{FromPrimitive, ToPrimitive}; Loading Loading @@ -185,6 +187,12 @@ impl IBluetooth for BluetoothDBus { } } #[dbus_propmap(AdapterWithEnabled)] pub struct AdapterWithEnabledDbus { hci_interface: i32, enabled: bool, } pub(crate) struct BluetoothManagerDBus { client_proxy: ClientDBusProxy, } Loading Loading @@ -242,8 +250,15 @@ impl IBluetoothManager for BluetoothManagerDBus { self.client_proxy.method_noreturn("SetFlossEnabled", (enabled,)) } fn list_hci_devices(&mut self) -> Vec<i32> { self.client_proxy.method("ListHciDevices", ()) fn get_available_adapters(&mut self) -> Vec<AdapterWithEnabled> { let props: Vec<dbus::arg::PropMap> = self.client_proxy.method("GetAvailableAdapters", ()); <Vec<AdapterWithEnabled> as DBusArg>::from_dbus( props, self.client_proxy.conn.clone(), dbus::strings::BusName::new(":1.0").unwrap(), // unused Arc::new(Mutex::new(DisconnectWatcher::new())), ) .unwrap() } } Loading
system/gd/rust/linux/mgmt/src/bin/btmanagerd/bluetooth_manager.rs +13 −4 Original line number Diff line number Diff line use log::{error, info}; use manager_service::iface_bluetooth_manager::{IBluetoothManager, IBluetoothManagerCallback}; use manager_service::iface_bluetooth_manager::{ AdapterWithEnabled, IBluetoothManager, IBluetoothManagerCallback, }; use std::collections::HashMap; use std::process::Command; Loading Loading @@ -134,8 +136,15 @@ impl IBluetoothManager for BluetoothManager { } } fn list_hci_devices(&mut self) -> Vec<i32> { let devices = config_util::list_hci_devices(); devices fn get_available_adapters(&mut self) -> Vec<AdapterWithEnabled> { let adapters = config_util::list_hci_devices() .iter() .map(|hci_interface| { let enabled: bool = *self.cached_devices.get(&hci_interface).unwrap_or(&false); AdapterWithEnabled { hci_interface: *hci_interface, enabled } }) .collect::<Vec<AdapterWithEnabled>>(); adapters } }
system/gd/rust/linux/mgmt/src/bin/btmanagerd/bluetooth_manager_dbus.rs +14 −7 Original line number Diff line number Diff line use dbus::arg::RefArg; use dbus::nonblock::SyncConnection; use dbus::strings::Path; use dbus_macros::{dbus_method, dbus_proxy_obj, generate_dbus_exporter}; use dbus_macros::{dbus_method, dbus_propmap, dbus_proxy_obj, generate_dbus_exporter}; use dbus_projection::DisconnectWatcher; use manager_service::iface_bluetooth_manager::{IBluetoothManager, IBluetoothManagerCallback}; use manager_service::iface_bluetooth_manager::{ AdapterWithEnabled, IBluetoothManager, IBluetoothManagerCallback, }; use manager_service::RPCProxy; use crate::dbus_arg::DBusArg; use crate::dbus_arg::{DBusArg, DBusArgError, RefArgToRust}; #[dbus_propmap(AdapterWithEnabled)] pub struct AdapterWithEnabledDbus { hci_interface: i32, enabled: bool, } /// D-Bus projection of IBluetoothManager. struct BluetoothManagerDBus {} Loading Loading @@ -37,8 +44,8 @@ impl IBluetoothManager for BluetoothManagerDBus { #[dbus_method("SetFlossEnabled")] fn set_floss_enabled(&mut self, _enabled: bool) {} #[dbus_method("ListHciDevices")] fn list_hci_devices(&mut self) -> Vec<i32> { #[dbus_method("GetAvailableAdapters")] fn get_available_adapters(&mut self) -> Vec<AdapterWithEnabled> { vec![] } } Loading
system/gd/rust/linux/mgmt/src/iface_bluetooth_manager.rs +8 −2 Original line number Diff line number Diff line use crate::RPCProxy; #[derive(Debug, Default)] pub struct AdapterWithEnabled { pub hci_interface: i32, pub enabled: bool, } /// Bluetooth stack management API. pub trait IBluetoothManager { /// Starts the Bluetooth stack. Loading @@ -20,8 +26,8 @@ pub trait IBluetoothManager { /// Enables/disables Floss. fn set_floss_enabled(&mut self, enabled: bool); /// Returns the list of available HCI devices. fn list_hci_devices(&mut self) -> Vec<i32>; /// Returns a list of available HCI devices and if they are enabled. fn get_available_adapters(&mut self) -> Vec<AdapterWithEnabled>; } /// Interface of Bluetooth Manager callbacks. Loading