diff options
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-03-17 01:09:15 +0000 |
---|---|---|
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | 2022-03-17 01:09:15 +0000 |
commit | ad221bf0c86a98f68d69e06ad79e025a38563881 (patch) | |
tree | 592c23b8ee42946d534813f2a5a419197db2ba9d /system/gd/rust/linux/stack/src/bluetooth.rs | |
parent | 2d0b6d82820b623c317d4b6c08f604e521123b15 (diff) | |
parent | b25cc6990ec081ebccbd0fb62ced8073cd1a7e3d (diff) |
Snap for 8310722 from b25cc6990ec081ebccbd0fb62ced8073cd1a7e3d to tm-release
Change-Id: Ib2298a055a80baf0309b3f178c541872d709fd2e
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()); |