Loading system/gd/rust/linux/client/src/command_handler.rs +10 −20 Original line number Diff line number Diff line Loading @@ -264,31 +264,21 @@ impl CommandHandler { Some(x) => x.clone(), None => String::from(""), }; let name = self.context.lock().unwrap().adapter_dbus.as_ref().unwrap().get_name(); let uuids = self.context.lock().unwrap().adapter_dbus.as_ref().unwrap().get_uuids(); let is_discoverable = self .context .lock() .unwrap() .adapter_dbus .as_ref() .unwrap() .get_discoverable(); let cod = self .context .lock() .unwrap() .adapter_dbus .as_ref() .unwrap() .get_bluetooth_class(); let context = self.context.lock().unwrap(); let adapter_dbus = context.adapter_dbus.as_ref().unwrap(); let name = adapter_dbus.get_name(); let uuids = adapter_dbus.get_uuids(); let is_discoverable = adapter_dbus.get_discoverable(); let cod = adapter_dbus.get_bluetooth_class(); let multi_adv_supported = adapter_dbus.is_multi_advertisement_supported(); let le_ext_adv_supported = adapter_dbus.is_le_extended_advertising_supported(); print_info!("Address: {}", address); print_info!("Name: {}", name); print_info!("State: {}", if enabled { "enabled" } else { "disabled" }); print_info!("Discoverable: {}", is_discoverable); print_info!("Class: {:#06x}", cod); print_info!("IsMultiAdvertisementSupported: {}", multi_adv_supported); print_info!("IsLeExtendedAdvertisingSupported: {}", le_ext_adv_supported); print_info!( "Uuids: {}", DisplayList( Loading system/gd/rust/linux/client/src/dbus_iface.rs +8 −0 Original line number Diff line number Diff line Loading @@ -317,6 +317,14 @@ impl IBluetooth for BluetoothDBus { self.client_proxy.method("SetDiscoverable", (mode, duration)) } fn is_multi_advertisement_supported(&self) -> bool { self.client_proxy.method("IsMultiAdvertisementSupported", ()) } fn is_le_extended_advertising_supported(&self) -> bool { self.client_proxy.method("IsLeExtendedAdvertisingSupported", ()) } fn start_discovery(&self) -> bool { self.client_proxy.method("StartDiscovery", ()) } Loading system/gd/rust/linux/service/src/iface_bluetooth.rs +10 −0 Original line number Diff line number Diff line Loading @@ -140,6 +140,16 @@ impl IBluetooth for IBluetoothDBus { true } #[dbus_method("IsMultiAdvertisementSupported")] fn is_multi_advertisement_supported(&self) -> bool { true } #[dbus_method("IsLeExtendedAdvertisingSupported")] fn is_le_extended_advertising_supported(&self) -> bool { true } #[dbus_method("StartDiscovery")] fn start_discovery(&self) -> bool { true Loading system/gd/rust/linux/stack/src/bluetooth.rs +32 −2 Original line number Diff line number Diff line Loading @@ -2,8 +2,8 @@ use bt_topshim::btif::{ BaseCallbacks, BaseCallbacksDispatcher, BluetoothInterface, BluetoothProperty, BtAclState, BtBondState, BtDiscoveryState, BtHciErrorCode, BtPinCode, BtPropertyType, BtScanMode, BtSspVariant, BtState, BtStatus, BtTransport, RawAddress, Uuid, Uuid128Bit, BtBondState, BtDiscoveryState, BtHciErrorCode, BtLocalLeFeatures, BtPinCode, BtPropertyType, BtScanMode, BtSspVariant, BtState, BtStatus, BtTransport, RawAddress, Uuid, Uuid128Bit, }; use bt_topshim::{ profiles::hid_host::{HHCallbacksDispatcher, HidHost}, Loading @@ -26,6 +26,7 @@ use crate::uuid::{Profile, UuidHelper}; use crate::{BluetoothCallbackType, Message, RPCProxy}; const DEFAULT_DISCOVERY_TIMEOUT_MS: u64 = 12800; const MIN_ADV_INSTANCES_FOR_MULTI_ADV: u8 = 5; /// Defines the adapter API. pub trait IBluetooth { Loading Loading @@ -75,6 +76,13 @@ pub trait IBluetooth { /// Sets discoverability. If discoverable, limits the duration with given value. fn set_discoverable(&self, mode: bool, duration: u32) -> bool; /// Returns whether multi-advertisement is supported. /// A minimum number of 5 advertising instances is required for multi-advertisment support. fn is_multi_advertisement_supported(&self) -> bool; /// Returns whether LE extended advertising is supported. fn is_le_extended_advertising_supported(&self) -> bool; /// Starts BREDR Inquiry. fn start_discovery(&self) -> bool; Loading Loading @@ -850,6 +858,28 @@ impl IBluetooth for Bluetooth { )) == 0 } fn is_multi_advertisement_supported(&self) -> bool { match self.properties.get(&BtPropertyType::LocalLeFeatures) { Some(prop) => match prop { BluetoothProperty::LocalLeFeatures(llf) => { llf.max_adv_instance >= MIN_ADV_INSTANCES_FOR_MULTI_ADV } _ => false, }, _ => false, } } fn is_le_extended_advertising_supported(&self) -> bool { match self.properties.get(&BtPropertyType::LocalLeFeatures) { Some(prop) => match prop { BluetoothProperty::LocalLeFeatures(llf) => llf.le_extended_advertising_supported, _ => false, }, _ => false, } } fn start_discovery(&self) -> bool { self.intf.lock().unwrap().start_discovery() == 0 } Loading Loading
system/gd/rust/linux/client/src/command_handler.rs +10 −20 Original line number Diff line number Diff line Loading @@ -264,31 +264,21 @@ impl CommandHandler { Some(x) => x.clone(), None => String::from(""), }; let name = self.context.lock().unwrap().adapter_dbus.as_ref().unwrap().get_name(); let uuids = self.context.lock().unwrap().adapter_dbus.as_ref().unwrap().get_uuids(); let is_discoverable = self .context .lock() .unwrap() .adapter_dbus .as_ref() .unwrap() .get_discoverable(); let cod = self .context .lock() .unwrap() .adapter_dbus .as_ref() .unwrap() .get_bluetooth_class(); let context = self.context.lock().unwrap(); let adapter_dbus = context.adapter_dbus.as_ref().unwrap(); let name = adapter_dbus.get_name(); let uuids = adapter_dbus.get_uuids(); let is_discoverable = adapter_dbus.get_discoverable(); let cod = adapter_dbus.get_bluetooth_class(); let multi_adv_supported = adapter_dbus.is_multi_advertisement_supported(); let le_ext_adv_supported = adapter_dbus.is_le_extended_advertising_supported(); print_info!("Address: {}", address); print_info!("Name: {}", name); print_info!("State: {}", if enabled { "enabled" } else { "disabled" }); print_info!("Discoverable: {}", is_discoverable); print_info!("Class: {:#06x}", cod); print_info!("IsMultiAdvertisementSupported: {}", multi_adv_supported); print_info!("IsLeExtendedAdvertisingSupported: {}", le_ext_adv_supported); print_info!( "Uuids: {}", DisplayList( Loading
system/gd/rust/linux/client/src/dbus_iface.rs +8 −0 Original line number Diff line number Diff line Loading @@ -317,6 +317,14 @@ impl IBluetooth for BluetoothDBus { self.client_proxy.method("SetDiscoverable", (mode, duration)) } fn is_multi_advertisement_supported(&self) -> bool { self.client_proxy.method("IsMultiAdvertisementSupported", ()) } fn is_le_extended_advertising_supported(&self) -> bool { self.client_proxy.method("IsLeExtendedAdvertisingSupported", ()) } fn start_discovery(&self) -> bool { self.client_proxy.method("StartDiscovery", ()) } Loading
system/gd/rust/linux/service/src/iface_bluetooth.rs +10 −0 Original line number Diff line number Diff line Loading @@ -140,6 +140,16 @@ impl IBluetooth for IBluetoothDBus { true } #[dbus_method("IsMultiAdvertisementSupported")] fn is_multi_advertisement_supported(&self) -> bool { true } #[dbus_method("IsLeExtendedAdvertisingSupported")] fn is_le_extended_advertising_supported(&self) -> bool { true } #[dbus_method("StartDiscovery")] fn start_discovery(&self) -> bool { true Loading
system/gd/rust/linux/stack/src/bluetooth.rs +32 −2 Original line number Diff line number Diff line Loading @@ -2,8 +2,8 @@ use bt_topshim::btif::{ BaseCallbacks, BaseCallbacksDispatcher, BluetoothInterface, BluetoothProperty, BtAclState, BtBondState, BtDiscoveryState, BtHciErrorCode, BtPinCode, BtPropertyType, BtScanMode, BtSspVariant, BtState, BtStatus, BtTransport, RawAddress, Uuid, Uuid128Bit, BtBondState, BtDiscoveryState, BtHciErrorCode, BtLocalLeFeatures, BtPinCode, BtPropertyType, BtScanMode, BtSspVariant, BtState, BtStatus, BtTransport, RawAddress, Uuid, Uuid128Bit, }; use bt_topshim::{ profiles::hid_host::{HHCallbacksDispatcher, HidHost}, Loading @@ -26,6 +26,7 @@ use crate::uuid::{Profile, UuidHelper}; use crate::{BluetoothCallbackType, Message, RPCProxy}; const DEFAULT_DISCOVERY_TIMEOUT_MS: u64 = 12800; const MIN_ADV_INSTANCES_FOR_MULTI_ADV: u8 = 5; /// Defines the adapter API. pub trait IBluetooth { Loading Loading @@ -75,6 +76,13 @@ pub trait IBluetooth { /// Sets discoverability. If discoverable, limits the duration with given value. fn set_discoverable(&self, mode: bool, duration: u32) -> bool; /// Returns whether multi-advertisement is supported. /// A minimum number of 5 advertising instances is required for multi-advertisment support. fn is_multi_advertisement_supported(&self) -> bool; /// Returns whether LE extended advertising is supported. fn is_le_extended_advertising_supported(&self) -> bool; /// Starts BREDR Inquiry. fn start_discovery(&self) -> bool; Loading Loading @@ -850,6 +858,28 @@ impl IBluetooth for Bluetooth { )) == 0 } fn is_multi_advertisement_supported(&self) -> bool { match self.properties.get(&BtPropertyType::LocalLeFeatures) { Some(prop) => match prop { BluetoothProperty::LocalLeFeatures(llf) => { llf.max_adv_instance >= MIN_ADV_INSTANCES_FOR_MULTI_ADV } _ => false, }, _ => false, } } fn is_le_extended_advertising_supported(&self) -> bool { match self.properties.get(&BtPropertyType::LocalLeFeatures) { Some(prop) => match prop { BluetoothProperty::LocalLeFeatures(llf) => llf.le_extended_advertising_supported, _ => false, }, _ => false, } } fn start_discovery(&self) -> bool { self.intf.lock().unwrap().start_discovery() == 0 } Loading