diff options
author | Jesse Melhuish <melhuishj@google.com> | 2022-03-16 18:56:19 +0000 |
---|---|---|
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | 2022-03-16 18:56:19 +0000 |
commit | eeec29dca25514c77369ccd416347c9f72fb2d6c (patch) | |
tree | 68971934ba176d158a30297a7e0f01ca29ff8dcd /system/gd/rust/linux/stack/src/bluetooth.rs | |
parent | 9479766194bc647ae3db8343167fea911c1360da (diff) | |
parent | 564f781a7f3c81a167523044792aa537ad6d7252 (diff) |
Merge "floss: Adding remote device API methods." am: cde254dba3 am: f28f4aacc5 am: 564f781a7f
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/2006510
Change-Id: I3b5228c7af5e21e3ce7c34ed15d1884b325b01c1
Diffstat (limited to 'system/gd/rust/linux/stack/src/bluetooth.rs')
-rw-r--r-- | system/gd/rust/linux/stack/src/bluetooth.rs | 44 |
1 files changed, 42 insertions, 2 deletions
diff --git a/system/gd/rust/linux/stack/src/bluetooth.rs b/system/gd/rust/linux/stack/src/bluetooth.rs index e7bff62c5c..f2a610d83b 100644 --- a/system/gd/rust/linux/stack/src/bluetooth.rs +++ b/system/gd/rust/linux/stack/src/bluetooth.rs @@ -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, BtDeviceType, BtDiscoveryState, BtHciErrorCode, BtPinCode, BtPropertyType, + BtScanMode, BtSspVariant, BtState, BtStatus, BtTransport, RawAddress, Uuid, Uuid128Bit, }; use bt_topshim::{ profiles::hid_host::{HHCallbacksDispatcher, HidHost}, @@ -122,6 +122,18 @@ pub trait IBluetooth { /// Confirm that a pairing should be completed on a bonding device. fn set_pairing_confirmation(&self, device: BluetoothDevice, accept: bool) -> bool; + /// Gets the name of the remote device. + fn get_remote_name(&self, device: BluetoothDevice) -> String; + + /// Gets the type of the remote device. + fn get_remote_type(&self, device: BluetoothDevice) -> BtDeviceType; + + /// Gets the alias of the remote device. + fn get_remote_alias(&self, device: BluetoothDevice) -> String; + + /// Gets the class of the remote device. + fn get_remote_class(&self, device: BluetoothDevice) -> u32; + /// Gets the connection state of a single device. fn get_connection_state(&self, device: BluetoothDevice) -> u32; @@ -1082,6 +1094,34 @@ impl IBluetooth for Bluetooth { ) == 0 } + fn get_remote_name(&self, device: BluetoothDevice) -> String { + match self.get_remote_device_property(&device, &BtPropertyType::BdName) { + Some(BluetoothProperty::BdName(name)) => return name.clone(), + _ => return "".to_string(), + } + } + + fn get_remote_type(&self, device: BluetoothDevice) -> BtDeviceType { + match self.get_remote_device_property(&device, &BtPropertyType::TypeOfDevice) { + Some(BluetoothProperty::TypeOfDevice(device_type)) => return device_type, + _ => return BtDeviceType::Unknown, + } + } + + fn get_remote_alias(&self, device: BluetoothDevice) -> String { + match self.get_remote_device_property(&device, &BtPropertyType::RemoteFriendlyName) { + Some(BluetoothProperty::RemoteFriendlyName(name)) => return name.clone(), + _ => "".to_string(), + } + } + + fn get_remote_class(&self, device: BluetoothDevice) -> u32 { + match self.get_remote_device_property(&device, &BtPropertyType::ClassOfDevice) { + Some(BluetoothProperty::ClassOfDevice(class)) => return class, + _ => 0, + } + } + fn get_connection_state(&self, device: BluetoothDevice) -> u32 { let addr = RawAddress::from_string(device.address.clone()); |