Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f28f4aac authored by Jesse Melhuish's avatar Jesse Melhuish Committed by Automerger Merge Worker
Browse files

Merge "floss: Adding remote device API methods." am: cde254db

Original change: https://android-review.googlesource.com/c/platform/packages/modules/Bluetooth/+/2006510

Change-Id: I844141a1f29859bcb906510534af871ef233ae86
parents 17a47a46 cde254db
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -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!(
+24 −3
Original line number Diff line number Diff line
//! 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!()
+23 −2
Original line number Diff line number Diff line
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!()
+42 −2
Original line number Diff line number Diff line
@@ -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());

+1 −0
Original line number Diff line number Diff line
@@ -121,6 +121,7 @@ pub enum BtDeviceType {
    Bredr,
    Ble,
    Dual,
    Unknown,
}

#[derive(Clone, Debug, Eq, Hash, FromPrimitive, ToPrimitive, PartialEq, PartialOrd)]