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

Commit f061e69f authored by Katherine Lai's avatar Katherine Lai Committed by Gerrit Code Review
Browse files

Merge "Floss: Add get_remote_appearance API"

parents 0cb6e4d7 3064304c
Loading
Loading
Loading
Loading
+22 −2
Original line number Diff line number Diff line
@@ -595,7 +595,16 @@ impl CommandHandler {
                        name: String::from("Classic Device"),
                    };

                    let (name, alias, device_type, class, bonded, connection_state, uuids) = {
                    let (
                        name,
                        alias,
                        device_type,
                        class,
                        appearance,
                        bonded,
                        connection_state,
                        uuids,
                    ) = {
                        let ctx = self.context.lock().unwrap();
                        let adapter = ctx.adapter_dbus.as_ref().unwrap();

@@ -603,6 +612,7 @@ impl CommandHandler {
                        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 appearance = adapter.get_remote_appearance(device.clone());
                        let bonded = adapter.get_bond_state(device.clone());
                        let connection_state = match adapter.get_connection_state(device.clone()) {
                            BtConnectionState::NotConnected => "Not Connected",
@@ -611,7 +621,16 @@ impl CommandHandler {
                        };
                        let uuids = adapter.get_remote_uuids(device.clone());

                        (name, alias, device_type, class, bonded, connection_state, uuids)
                        (
                            name,
                            alias,
                            device_type,
                            class,
                            appearance,
                            bonded,
                            connection_state,
                            uuids,
                        )
                    };

                    let uuid_helper = UuidHelper::new();
@@ -620,6 +639,7 @@ impl CommandHandler {
                    print_info!("Alias: {}", alias);
                    print_info!("Type: {:?}", device_type);
                    print_info!("Class: {}", class);
                    print_info!("Appearance: {}", appearance);
                    print_info!("Bond State: {:?}", bonded);
                    print_info!("Connection State: {}", connection_state);
                    print_info!(
+5 −0
Original line number Diff line number Diff line
@@ -538,6 +538,11 @@ impl IBluetooth for BluetoothDBus {
        dbus_generated!()
    }

    #[dbus_method("GetRemoteAppearance")]
    fn get_remote_appearance(&self, device: BluetoothDevice) -> u16 {
        dbus_generated!()
    }

    #[dbus_method("GetRemoteConnected")]
    fn get_remote_connected(&self, device: BluetoothDevice) -> bool {
        dbus_generated!()
+5 −0
Original line number Diff line number Diff line
@@ -316,6 +316,11 @@ impl IBluetooth for IBluetoothDBus {
        dbus_generated!()
    }

    #[dbus_method("GetRemoteAppearance")]
    fn get_remote_appearance(&self, _device: BluetoothDevice) -> u16 {
        dbus_generated!()
    }

    #[dbus_method("GetRemoteConnected")]
    fn get_remote_connected(&self, _device: BluetoothDevice) -> bool {
        dbus_generated!()
+10 −0
Original line number Diff line number Diff line
@@ -156,6 +156,9 @@ pub trait IBluetooth {
    /// Gets the class of the remote device.
    fn get_remote_class(&self, device: BluetoothDevice) -> u32;

    /// Gets the appearance of the remote device.
    fn get_remote_appearance(&self, device: BluetoothDevice) -> u16;

    /// Gets whether the remote device is connected.
    fn get_remote_connected(&self, device: BluetoothDevice) -> bool;

@@ -1417,6 +1420,13 @@ impl IBluetooth for Bluetooth {
        }
    }

    fn get_remote_appearance(&self, device: BluetoothDevice) -> u16 {
        match self.get_remote_device_property(&device, &BtPropertyType::Appearance) {
            Some(BluetoothProperty::Appearance(appearance)) => appearance,
            _ => 0,
        }
    }

    fn get_remote_connected(&self, device: BluetoothDevice) -> bool {
        self.get_connection_state(device) != BtConnectionState::NotConnected
    }