Loading system/gd/rust/linux/client/src/command_handler.rs +5 −1 Original line number Diff line number Diff line Loading @@ -755,6 +755,7 @@ impl CommandHandler { name, alias, device_type, addr_type, class, appearance, bonded, Loading @@ -767,6 +768,7 @@ impl CommandHandler { let name = adapter.get_remote_name(device.clone()); let device_type = adapter.get_remote_type(device.clone()); let addr_type = adapter.get_remote_address_type(device.clone()); let alias = adapter.get_remote_alias(device.clone()); let class = adapter.get_remote_class(device.clone()); let appearance = adapter.get_remote_appearance(device.clone()); Loading @@ -783,6 +785,7 @@ impl CommandHandler { name, alias, device_type, addr_type, class, appearance, bonded, Loading @@ -795,7 +798,8 @@ impl CommandHandler { print_info!("Address: {}", &device.address); print_info!("Name: {}", name); print_info!("Alias: {}", alias); print_info!("Type: {:?}", device_type); print_info!("Device Type: {:?}", device_type); print_info!("Address Type: {:?}", addr_type); print_info!("Class: {}", class); print_info!("Appearance: {}", appearance); print_info!("Wake Allowed: {}", wake_allowed); Loading system/gd/rust/linux/client/src/dbus_iface.rs +8 −2 Original line number Diff line number Diff line //! D-Bus proxy implementations of the APIs. use bt_topshim::btif::{ BtBondState, BtConnectionState, BtDeviceType, BtDiscMode, BtPropertyType, BtSspVariant, BtStatus, BtTransport, BtVendorProductInfo, Uuid, Uuid128Bit, BtAddrType, BtBondState, BtConnectionState, BtDeviceType, BtDiscMode, BtPropertyType, BtSspVariant, BtStatus, BtTransport, BtVendorProductInfo, Uuid, Uuid128Bit, }; use bt_topshim::profiles::a2dp::{ A2dpCodecBitsPerSample, A2dpCodecChannelMode, A2dpCodecConfig, A2dpCodecIndex, Loading Loading @@ -78,6 +78,7 @@ impl_dbus_arg_enum!(AdvertisingStatus); impl_dbus_arg_enum!(BtBondState); impl_dbus_arg_enum!(BtConnectionState); impl_dbus_arg_enum!(BtDeviceType); impl_dbus_arg_enum!(BtAddrType); impl_dbus_arg_enum!(BtPropertyType); impl_dbus_arg_enum!(BtSspVariant); impl_dbus_arg_enum!(BtStatus); Loading Loading @@ -923,6 +924,11 @@ impl IBluetooth for BluetoothDBus { dbus_generated!() } #[dbus_method("GetRemoteAddressType")] fn get_remote_address_type(&self, device: BluetoothDevice) -> BtAddrType { dbus_generated!() } #[dbus_method("GetConnectedDevices")] fn get_connected_devices(&self) -> Vec<BluetoothDevice> { dbus_generated!() Loading system/gd/rust/linux/service/src/iface_bluetooth.rs +8 −2 Original line number Diff line number Diff line use bt_topshim::btif::{ BtBondState, BtConnectionState, BtDeviceType, BtDiscMode, BtPropertyType, BtSspVariant, BtStatus, BtTransport, BtVendorProductInfo, Uuid, Uuid128Bit, BtAddrType, BtBondState, BtConnectionState, BtDeviceType, BtDiscMode, BtPropertyType, BtSspVariant, BtStatus, BtTransport, BtVendorProductInfo, Uuid, Uuid128Bit, }; use bt_topshim::profiles::socket::SocketType; use bt_topshim::profiles::ProfileConnectionState; Loading Loading @@ -157,6 +157,7 @@ impl IBluetoothCallback for BluetoothCallbackDBus { impl_dbus_arg_enum!(BtBondState); impl_dbus_arg_enum!(BtConnectionState); impl_dbus_arg_enum!(BtDeviceType); impl_dbus_arg_enum!(BtAddrType); impl_dbus_arg_enum!(BtPropertyType); impl_dbus_arg_enum!(BtSspVariant); impl_dbus_arg_enum!(BtTransport); Loading Loading @@ -636,6 +637,11 @@ impl IBluetooth for IBluetoothDBus { dbus_generated!() } #[dbus_method("GetRemoteAddressType", DBusLog::Disable)] fn get_remote_address_type(&self, device: BluetoothDevice) -> BtAddrType { dbus_generated!() } #[dbus_method("GetConnectedDevices", DBusLog::Disable)] fn get_connected_devices(&self) -> Vec<BluetoothDevice> { dbus_generated!() Loading system/gd/rust/linux/stack/src/bluetooth.rs +11 −1 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ use bt_topshim::btif::{ BaseCallbacks, BaseCallbacksDispatcher, BluetoothInterface, BluetoothProperty, BtAclState, BtBondState, BtConnectionDirection, BtConnectionState, BtDeviceType, BtDiscMode, BtAddrType, BtBondState, BtConnectionDirection, BtConnectionState, BtDeviceType, BtDiscMode, BtDiscoveryState, BtHciErrorCode, BtPinCode, BtPropertyType, BtScanMode, BtSspVariant, BtState, BtStatus, BtThreadEvent, BtTransport, BtVendorProductInfo, DisplayAddress, RawAddress, ToggleableProfile, Uuid, Uuid128Bit, Loading Loading @@ -194,6 +194,9 @@ pub trait IBluetooth { /// Gets the vendor and product information of the remote device. fn get_remote_vendor_product_info(&self, device: BluetoothDevice) -> BtVendorProductInfo; /// Get the address type of the remote device. fn get_remote_address_type(&self, device: BluetoothDevice) -> BtAddrType; /// Returns a list of connected devices. fn get_connected_devices(&self) -> Vec<BluetoothDevice>; Loading Loading @@ -2371,6 +2374,13 @@ impl IBluetooth for Bluetooth { } } fn get_remote_address_type(&self, device: BluetoothDevice) -> BtAddrType { match self.get_remote_device_property(&device, &BtPropertyType::RemoteAddrType) { Some(BluetoothProperty::RemoteAddrType(addr_type)) => addr_type, _ => BtAddrType::Unknown, } } fn get_connected_devices(&self) -> Vec<BluetoothDevice> { let bonded_connected: HashMap<String, BluetoothDevice> = self .bonded_devices Loading system/gd/rust/topshim/src/btif.rs +40 −1 Original line number Diff line number Diff line Loading @@ -153,6 +153,12 @@ pub enum BtPropertyType { RemoteIsCoordinatedSetMember, Appearance, VendorProductInfo, // Unimplemented: // BT_PROPERTY_WL_MEDIA_PLAYERS_LIST, // BT_PROPERTY_REMOTE_ASHA_CAPABILITY, // BT_PROPERTY_REMOTE_ASHA_TRUNCATED_HISYNCID, // BT_PROPERTY_REMOTE_MODEL_NUM, RemoteAddrType = 0x18, Unknown = 0xFE, RemoteDeviceTimestamp = 0xFF, Loading Loading @@ -361,6 +367,29 @@ impl From<bindings::bt_io_cap_t> for BtIoCap { } } #[derive(Clone, Debug, FromPrimitive, ToPrimitive, PartialEq, PartialOrd)] #[repr(u32)] pub enum BtAddrType { Public, Random, PublicId, RandomId, Unknown = 0xfe, Anonymous = 0xff, } impl From<u32> for BtAddrType { fn from(num: u32) -> Self { BtAddrType::from_u32(num).unwrap_or(BtAddrType::Unknown) } } impl Into<u32> for BtAddrType { fn into(self) -> u32 { self.to_u32().unwrap_or(0) } } pub type BtHciErrorCode = u8; pub type BtLocalLeFeatures = bindings::bt_local_le_features_t; pub type BtPinCode = bindings::bt_pin_code_t; Loading Loading @@ -467,6 +496,7 @@ pub enum BluetoothProperty { RemoteIsCoordinatedSetMember(bool), Appearance(u16), VendorProductInfo(BtVendorProductInfo), RemoteAddrType(BtAddrType), RemoteDeviceTimestamp(), Unknown(), Loading Loading @@ -503,6 +533,7 @@ impl BluetoothProperty { BluetoothProperty::Appearance(_) => BtPropertyType::Appearance, BluetoothProperty::VendorProductInfo(_) => BtPropertyType::VendorProductInfo, BluetoothProperty::RemoteDeviceTimestamp() => BtPropertyType::RemoteDeviceTimestamp, BluetoothProperty::RemoteAddrType(_) => BtPropertyType::RemoteAddrType, BluetoothProperty::Unknown() => BtPropertyType::Unknown, } } Loading Loading @@ -533,6 +564,7 @@ impl BluetoothProperty { BluetoothProperty::RemoteIsCoordinatedSetMember(_) => mem::size_of::<bool>(), BluetoothProperty::Appearance(_) => mem::size_of::<u16>(), BluetoothProperty::VendorProductInfo(_) => mem::size_of::<BtVendorProductInfo>(), BluetoothProperty::RemoteAddrType(_) => mem::size_of::<BtAddrType>(), // TODO(abps) - Figure out sizes for these BluetoothProperty::DynamicAudioBuffer() => 0, Loading Loading @@ -641,6 +673,11 @@ impl BluetoothProperty { }; data.copy_from_slice(&slice); } BluetoothProperty::RemoteAddrType(addr_type) => { data.copy_from_slice( &BtAddrType::to_u32(addr_type).unwrap_or_default().to_ne_bytes(), ); } BluetoothProperty::DynamicAudioBuffer() => (), BluetoothProperty::RemoteDeviceTimestamp() => (), Loading Loading @@ -717,7 +754,9 @@ impl From<bindings::bt_property_t> for BluetoothProperty { let v = unsafe { (prop.val as *const BtVendorProductInfo).read_unaligned() }; BluetoothProperty::VendorProductInfo(BtVendorProductInfo::from(v)) } BtPropertyType::RemoteAddrType => BluetoothProperty::RemoteAddrType( BtAddrType::from_u32(u32_from_bytes(slice)).unwrap_or(BtAddrType::Unknown), ), // TODO(abps) - Figure out if these values should actually have contents BtPropertyType::DynamicAudioBuffer => BluetoothProperty::DynamicAudioBuffer(), BtPropertyType::RemoteDeviceTimestamp => BluetoothProperty::RemoteDeviceTimestamp(), Loading Loading
system/gd/rust/linux/client/src/command_handler.rs +5 −1 Original line number Diff line number Diff line Loading @@ -755,6 +755,7 @@ impl CommandHandler { name, alias, device_type, addr_type, class, appearance, bonded, Loading @@ -767,6 +768,7 @@ impl CommandHandler { let name = adapter.get_remote_name(device.clone()); let device_type = adapter.get_remote_type(device.clone()); let addr_type = adapter.get_remote_address_type(device.clone()); let alias = adapter.get_remote_alias(device.clone()); let class = adapter.get_remote_class(device.clone()); let appearance = adapter.get_remote_appearance(device.clone()); Loading @@ -783,6 +785,7 @@ impl CommandHandler { name, alias, device_type, addr_type, class, appearance, bonded, Loading @@ -795,7 +798,8 @@ impl CommandHandler { print_info!("Address: {}", &device.address); print_info!("Name: {}", name); print_info!("Alias: {}", alias); print_info!("Type: {:?}", device_type); print_info!("Device Type: {:?}", device_type); print_info!("Address Type: {:?}", addr_type); print_info!("Class: {}", class); print_info!("Appearance: {}", appearance); print_info!("Wake Allowed: {}", wake_allowed); Loading
system/gd/rust/linux/client/src/dbus_iface.rs +8 −2 Original line number Diff line number Diff line //! D-Bus proxy implementations of the APIs. use bt_topshim::btif::{ BtBondState, BtConnectionState, BtDeviceType, BtDiscMode, BtPropertyType, BtSspVariant, BtStatus, BtTransport, BtVendorProductInfo, Uuid, Uuid128Bit, BtAddrType, BtBondState, BtConnectionState, BtDeviceType, BtDiscMode, BtPropertyType, BtSspVariant, BtStatus, BtTransport, BtVendorProductInfo, Uuid, Uuid128Bit, }; use bt_topshim::profiles::a2dp::{ A2dpCodecBitsPerSample, A2dpCodecChannelMode, A2dpCodecConfig, A2dpCodecIndex, Loading Loading @@ -78,6 +78,7 @@ impl_dbus_arg_enum!(AdvertisingStatus); impl_dbus_arg_enum!(BtBondState); impl_dbus_arg_enum!(BtConnectionState); impl_dbus_arg_enum!(BtDeviceType); impl_dbus_arg_enum!(BtAddrType); impl_dbus_arg_enum!(BtPropertyType); impl_dbus_arg_enum!(BtSspVariant); impl_dbus_arg_enum!(BtStatus); Loading Loading @@ -923,6 +924,11 @@ impl IBluetooth for BluetoothDBus { dbus_generated!() } #[dbus_method("GetRemoteAddressType")] fn get_remote_address_type(&self, device: BluetoothDevice) -> BtAddrType { dbus_generated!() } #[dbus_method("GetConnectedDevices")] fn get_connected_devices(&self) -> Vec<BluetoothDevice> { dbus_generated!() Loading
system/gd/rust/linux/service/src/iface_bluetooth.rs +8 −2 Original line number Diff line number Diff line use bt_topshim::btif::{ BtBondState, BtConnectionState, BtDeviceType, BtDiscMode, BtPropertyType, BtSspVariant, BtStatus, BtTransport, BtVendorProductInfo, Uuid, Uuid128Bit, BtAddrType, BtBondState, BtConnectionState, BtDeviceType, BtDiscMode, BtPropertyType, BtSspVariant, BtStatus, BtTransport, BtVendorProductInfo, Uuid, Uuid128Bit, }; use bt_topshim::profiles::socket::SocketType; use bt_topshim::profiles::ProfileConnectionState; Loading Loading @@ -157,6 +157,7 @@ impl IBluetoothCallback for BluetoothCallbackDBus { impl_dbus_arg_enum!(BtBondState); impl_dbus_arg_enum!(BtConnectionState); impl_dbus_arg_enum!(BtDeviceType); impl_dbus_arg_enum!(BtAddrType); impl_dbus_arg_enum!(BtPropertyType); impl_dbus_arg_enum!(BtSspVariant); impl_dbus_arg_enum!(BtTransport); Loading Loading @@ -636,6 +637,11 @@ impl IBluetooth for IBluetoothDBus { dbus_generated!() } #[dbus_method("GetRemoteAddressType", DBusLog::Disable)] fn get_remote_address_type(&self, device: BluetoothDevice) -> BtAddrType { dbus_generated!() } #[dbus_method("GetConnectedDevices", DBusLog::Disable)] fn get_connected_devices(&self) -> Vec<BluetoothDevice> { dbus_generated!() Loading
system/gd/rust/linux/stack/src/bluetooth.rs +11 −1 Original line number Diff line number Diff line Loading @@ -2,7 +2,7 @@ use bt_topshim::btif::{ BaseCallbacks, BaseCallbacksDispatcher, BluetoothInterface, BluetoothProperty, BtAclState, BtBondState, BtConnectionDirection, BtConnectionState, BtDeviceType, BtDiscMode, BtAddrType, BtBondState, BtConnectionDirection, BtConnectionState, BtDeviceType, BtDiscMode, BtDiscoveryState, BtHciErrorCode, BtPinCode, BtPropertyType, BtScanMode, BtSspVariant, BtState, BtStatus, BtThreadEvent, BtTransport, BtVendorProductInfo, DisplayAddress, RawAddress, ToggleableProfile, Uuid, Uuid128Bit, Loading Loading @@ -194,6 +194,9 @@ pub trait IBluetooth { /// Gets the vendor and product information of the remote device. fn get_remote_vendor_product_info(&self, device: BluetoothDevice) -> BtVendorProductInfo; /// Get the address type of the remote device. fn get_remote_address_type(&self, device: BluetoothDevice) -> BtAddrType; /// Returns a list of connected devices. fn get_connected_devices(&self) -> Vec<BluetoothDevice>; Loading Loading @@ -2371,6 +2374,13 @@ impl IBluetooth for Bluetooth { } } fn get_remote_address_type(&self, device: BluetoothDevice) -> BtAddrType { match self.get_remote_device_property(&device, &BtPropertyType::RemoteAddrType) { Some(BluetoothProperty::RemoteAddrType(addr_type)) => addr_type, _ => BtAddrType::Unknown, } } fn get_connected_devices(&self) -> Vec<BluetoothDevice> { let bonded_connected: HashMap<String, BluetoothDevice> = self .bonded_devices Loading
system/gd/rust/topshim/src/btif.rs +40 −1 Original line number Diff line number Diff line Loading @@ -153,6 +153,12 @@ pub enum BtPropertyType { RemoteIsCoordinatedSetMember, Appearance, VendorProductInfo, // Unimplemented: // BT_PROPERTY_WL_MEDIA_PLAYERS_LIST, // BT_PROPERTY_REMOTE_ASHA_CAPABILITY, // BT_PROPERTY_REMOTE_ASHA_TRUNCATED_HISYNCID, // BT_PROPERTY_REMOTE_MODEL_NUM, RemoteAddrType = 0x18, Unknown = 0xFE, RemoteDeviceTimestamp = 0xFF, Loading Loading @@ -361,6 +367,29 @@ impl From<bindings::bt_io_cap_t> for BtIoCap { } } #[derive(Clone, Debug, FromPrimitive, ToPrimitive, PartialEq, PartialOrd)] #[repr(u32)] pub enum BtAddrType { Public, Random, PublicId, RandomId, Unknown = 0xfe, Anonymous = 0xff, } impl From<u32> for BtAddrType { fn from(num: u32) -> Self { BtAddrType::from_u32(num).unwrap_or(BtAddrType::Unknown) } } impl Into<u32> for BtAddrType { fn into(self) -> u32 { self.to_u32().unwrap_or(0) } } pub type BtHciErrorCode = u8; pub type BtLocalLeFeatures = bindings::bt_local_le_features_t; pub type BtPinCode = bindings::bt_pin_code_t; Loading Loading @@ -467,6 +496,7 @@ pub enum BluetoothProperty { RemoteIsCoordinatedSetMember(bool), Appearance(u16), VendorProductInfo(BtVendorProductInfo), RemoteAddrType(BtAddrType), RemoteDeviceTimestamp(), Unknown(), Loading Loading @@ -503,6 +533,7 @@ impl BluetoothProperty { BluetoothProperty::Appearance(_) => BtPropertyType::Appearance, BluetoothProperty::VendorProductInfo(_) => BtPropertyType::VendorProductInfo, BluetoothProperty::RemoteDeviceTimestamp() => BtPropertyType::RemoteDeviceTimestamp, BluetoothProperty::RemoteAddrType(_) => BtPropertyType::RemoteAddrType, BluetoothProperty::Unknown() => BtPropertyType::Unknown, } } Loading Loading @@ -533,6 +564,7 @@ impl BluetoothProperty { BluetoothProperty::RemoteIsCoordinatedSetMember(_) => mem::size_of::<bool>(), BluetoothProperty::Appearance(_) => mem::size_of::<u16>(), BluetoothProperty::VendorProductInfo(_) => mem::size_of::<BtVendorProductInfo>(), BluetoothProperty::RemoteAddrType(_) => mem::size_of::<BtAddrType>(), // TODO(abps) - Figure out sizes for these BluetoothProperty::DynamicAudioBuffer() => 0, Loading Loading @@ -641,6 +673,11 @@ impl BluetoothProperty { }; data.copy_from_slice(&slice); } BluetoothProperty::RemoteAddrType(addr_type) => { data.copy_from_slice( &BtAddrType::to_u32(addr_type).unwrap_or_default().to_ne_bytes(), ); } BluetoothProperty::DynamicAudioBuffer() => (), BluetoothProperty::RemoteDeviceTimestamp() => (), Loading Loading @@ -717,7 +754,9 @@ impl From<bindings::bt_property_t> for BluetoothProperty { let v = unsafe { (prop.val as *const BtVendorProductInfo).read_unaligned() }; BluetoothProperty::VendorProductInfo(BtVendorProductInfo::from(v)) } BtPropertyType::RemoteAddrType => BluetoothProperty::RemoteAddrType( BtAddrType::from_u32(u32_from_bytes(slice)).unwrap_or(BtAddrType::Unknown), ), // TODO(abps) - Figure out if these values should actually have contents BtPropertyType::DynamicAudioBuffer => BluetoothProperty::DynamicAudioBuffer(), BtPropertyType::RemoteDeviceTimestamp => BluetoothProperty::RemoteDeviceTimestamp(), Loading