summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--system/gd/rust/linux/client/src/command_handler.rs12
-rw-r--r--system/gd/rust/linux/client/src/dbus_iface.rs27
-rw-r--r--system/gd/rust/linux/service/src/iface_bluetooth.rs25
-rw-r--r--system/gd/rust/linux/stack/src/bluetooth.rs44
-rw-r--r--system/gd/rust/topshim/src/btif.rs1
5 files changed, 100 insertions, 9 deletions
diff --git a/system/gd/rust/linux/client/src/command_handler.rs b/system/gd/rust/linux/client/src/command_handler.rs
index d10b005173..f2221cc5e8 100644
--- a/system/gd/rust/linux/client/src/command_handler.rs
+++ b/system/gd/rust/linux/client/src/command_handler.rs
@@ -487,18 +487,26 @@ impl CommandHandler {
name: String::from("Classic Device"),
};
- let (bonded, connected, uuids) = {
+ let (name, alias, device_type, class, bonded, connected, uuids) = {
let ctx = self.context.lock().unwrap();
let adapter = ctx.adapter_dbus.as_ref().unwrap();
+ let name = adapter.get_remote_name(device.clone());
+ let device_type = adapter.get_remote_type(device.clone());
+ let alias = adapter.get_remote_alias(device.clone());
+ let class = adapter.get_remote_class(device.clone());
let bonded = adapter.get_bond_state(device.clone());
let connected = adapter.get_connection_state(device.clone());
let uuids = adapter.get_remote_uuids(device.clone());
- (bonded, connected, uuids)
+ (name, alias, device_type, class, bonded, connected, uuids)
};
print_info!("Address: {}", &device.address);
+ print_info!("Name: {}", name);
+ print_info!("Alias: {}", alias);
+ print_info!("Type: {:?}", device_type);
+ print_info!("Class: {}", class);
print_info!("Bonded: {}", bonded);
print_info!("Connected: {}", connected);
print_info!(
diff --git a/system/gd/rust/linux/client/src/dbus_iface.rs b/system/gd/rust/linux/client/src/dbus_iface.rs
index 098963adda..5a93233bba 100644
--- a/system/gd/rust/linux/client/src/dbus_iface.rs
+++ b/system/gd/rust/linux/client/src/dbus_iface.rs
@@ -1,6 +1,6 @@
//! D-Bus proxy implementations of the APIs.
-use bt_topshim::btif::{BtSspVariant, BtTransport, Uuid128Bit};
+use bt_topshim::btif::{BtDeviceType, BtSspVariant, BtTransport, Uuid128Bit};
use bt_topshim::profiles::gatt::GattStatus;
use btstack::bluetooth::{
@@ -37,12 +37,13 @@ fn make_object_path(idx: i32, name: &str) -> dbus::Path {
dbus::Path::new(format!("/org/chromium/bluetooth/hci{}/{}", idx, name)).unwrap()
}
-impl_dbus_arg_enum!(BtTransport);
+impl_dbus_arg_enum!(BtDeviceType);
impl_dbus_arg_enum!(BtSspVariant);
+impl_dbus_arg_enum!(BtTransport);
impl_dbus_arg_enum!(GattStatus);
+impl_dbus_arg_enum!(GattWriteRequestStatus);
impl_dbus_arg_enum!(GattWriteType);
impl_dbus_arg_enum!(LePhy);
-impl_dbus_arg_enum!(GattWriteRequestStatus);
impl_dbus_arg_enum!(Profile);
// Represents Uuid128Bit as an array in D-Bus.
@@ -383,6 +384,26 @@ impl IBluetooth for BluetoothDBus {
dbus_generated!()
}
+ #[dbus_method("GetRemoteName")]
+ fn get_remote_name(&self, device: BluetoothDevice) -> String {
+ dbus_generated!()
+ }
+
+ #[dbus_method("GetRemoteType")]
+ fn get_remote_type(&self, device: BluetoothDevice) -> BtDeviceType {
+ dbus_generated!()
+ }
+
+ #[dbus_method("GetRemoteAlias")]
+ fn get_remote_alias(&self, device: BluetoothDevice) -> String {
+ dbus_generated!()
+ }
+
+ #[dbus_method("GetRemoteClass")]
+ fn get_remote_class(&self, device: BluetoothDevice) -> u32 {
+ dbus_generated!()
+ }
+
#[dbus_method("GetConnectionState")]
fn get_connection_state(&self, device: BluetoothDevice) -> u32 {
dbus_generated!()
diff --git a/system/gd/rust/linux/service/src/iface_bluetooth.rs b/system/gd/rust/linux/service/src/iface_bluetooth.rs
index 6ace31bf72..9d84b1d3c5 100644
--- a/system/gd/rust/linux/service/src/iface_bluetooth.rs
+++ b/system/gd/rust/linux/service/src/iface_bluetooth.rs
@@ -1,6 +1,6 @@
extern crate bt_shim;
-use bt_topshim::btif::{BtSspVariant, BtTransport, Uuid128Bit};
+use bt_topshim::btif::{BtDeviceType, BtSspVariant, BtTransport, Uuid128Bit};
use btstack::bluetooth::{
BluetoothDevice, IBluetooth, IBluetoothCallback, IBluetoothConnectionCallback,
@@ -63,8 +63,9 @@ impl IBluetoothCallback for BluetoothCallbackDBus {
}
}
-impl_dbus_arg_enum!(BtTransport);
+impl_dbus_arg_enum!(BtDeviceType);
impl_dbus_arg_enum!(BtSspVariant);
+impl_dbus_arg_enum!(BtTransport);
impl_dbus_arg_enum!(Profile);
#[allow(dead_code)]
@@ -232,6 +233,26 @@ impl IBluetooth for IBluetoothDBus {
dbus_generated!()
}
+ #[dbus_method("GetRemoteName")]
+ fn get_remote_name(&self, _device: BluetoothDevice) -> String {
+ dbus_generated!()
+ }
+
+ #[dbus_method("GetRemoteType")]
+ fn get_remote_type(&self, _device: BluetoothDevice) -> BtDeviceType {
+ dbus_generated!()
+ }
+
+ #[dbus_method("GetRemoteAlias")]
+ fn get_remote_alias(&self, _device: BluetoothDevice) -> String {
+ dbus_generated!()
+ }
+
+ #[dbus_method("GetRemoteClass")]
+ fn get_remote_class(&self, _device: BluetoothDevice) -> u32 {
+ dbus_generated!()
+ }
+
#[dbus_method("GetConnectionState")]
fn get_connection_state(&self, _device: BluetoothDevice) -> u32 {
dbus_generated!()
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());
diff --git a/system/gd/rust/topshim/src/btif.rs b/system/gd/rust/topshim/src/btif.rs
index 73a0460c91..625f815b08 100644
--- a/system/gd/rust/topshim/src/btif.rs
+++ b/system/gd/rust/topshim/src/btif.rs
@@ -121,6 +121,7 @@ pub enum BtDeviceType {
Bredr,
Ble,
Dual,
+ Unknown,
}
#[derive(Clone, Debug, Eq, Hash, FromPrimitive, ToPrimitive, PartialEq, PartialOrd)]