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

Commit 327d2041 authored by Abhishek Pandit-Subedi's avatar Abhishek Pandit-Subedi
Browse files

floss: Implement GetRemoteWakeAllowed on adapter

This shows whether this device is capable of waking the system from
suspend. Right now, we don't allow setting to this property so always
allow wakes from devices that either implement HID or HOGP.

Bug: 244508001
Tag: #floss
Test: Verify with btclient
Change-Id: I5346990b71da6864ffeccd9d41c99f7d4f892f5c
parent 12115e1a
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -604,6 +604,7 @@ impl CommandHandler {
                        bonded,
                        connection_state,
                        uuids,
                        wake_allowed,
                    ) = {
                        let ctx = self.context.lock().unwrap();
                        let adapter = ctx.adapter_dbus.as_ref().unwrap();
@@ -620,6 +621,7 @@ impl CommandHandler {
                            _ => "Connected and Paired",
                        };
                        let uuids = adapter.get_remote_uuids(device.clone());
                        let wake_allowed = adapter.get_remote_wake_allowed(device.clone());

                        (
                            name,
@@ -630,6 +632,7 @@ impl CommandHandler {
                            bonded,
                            connection_state,
                            uuids,
                            wake_allowed,
                        )
                    };

@@ -640,6 +643,7 @@ impl CommandHandler {
                    print_info!("Type: {:?}", device_type);
                    print_info!("Class: {}", class);
                    print_info!("Appearance: {}", appearance);
                    print_info!("Wake Allowed: {}", wake_allowed);
                    print_info!("Bond State: {:?}", bonded);
                    print_info!("Connection State: {}", connection_state);
                    print_info!(
+5 −0
Original line number Diff line number Diff line
@@ -548,6 +548,11 @@ impl IBluetooth for BluetoothDBus {
        dbus_generated!()
    }

    #[dbus_method("GetRemoteWakeAllowed")]
    fn get_remote_wake_allowed(&self, _device: BluetoothDevice) -> bool {
        dbus_generated!()
    }

    #[dbus_method("GetConnectedDevices")]
    fn get_connected_devices(&self) -> Vec<BluetoothDevice> {
        dbus_generated!()
+5 −0
Original line number Diff line number Diff line
@@ -326,6 +326,11 @@ impl IBluetooth for IBluetoothDBus {
        dbus_generated!()
    }

    #[dbus_method("GetRemoteWakeAllowed")]
    fn get_remote_wake_allowed(&self, _device: BluetoothDevice) -> bool {
        dbus_generated!()
    }

    #[dbus_method("GetConnectedDevices")]
    fn get_connected_devices(&self) -> Vec<BluetoothDevice> {
        dbus_generated!()
+18 −0
Original line number Diff line number Diff line
@@ -162,6 +162,9 @@ pub trait IBluetooth {
    /// Gets whether the remote device is connected.
    fn get_remote_connected(&self, device: BluetoothDevice) -> bool;

    /// Gets whether the remote device can wake the system.
    fn get_remote_wake_allowed(&self, device: BluetoothDevice) -> bool;

    /// Returns a list of connected devices.
    fn get_connected_devices(&self) -> Vec<BluetoothDevice>;

@@ -1431,6 +1434,21 @@ impl IBluetooth for Bluetooth {
        self.get_connection_state(device) != BtConnectionState::NotConnected
    }

    fn get_remote_wake_allowed(&self, device: BluetoothDevice) -> bool {
        // Wake is allowed if the device supports HIDP or HOGP only.
        match self.get_remote_device_property(&device, &BtPropertyType::Uuids) {
            Some(BluetoothProperty::Uuids(uuids)) => {
                let uu_helper = UuidHelper::new();
                return uuids.iter().any(|&x| {
                    uu_helper.is_known_profile(&x.uu).map_or(false, |profile| {
                        profile == &Profile::Hid || profile == &Profile::Hogp
                    })
                });
            }
            _ => false,
        }
    }

    fn get_connected_devices(&self) -> Vec<BluetoothDevice> {
        let bonded_connected: HashMap<String, BluetoothDevice> = self
            .bonded_devices