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

Commit dce9900e authored by Abhishek Pandit-Subedi's avatar Abhishek Pandit-Subedi Committed by Gerrit Code Review
Browse files

Merge changes I5346990b,I5a14cb33

* changes:
  floss: Implement GetRemoteWakeAllowed on adapter
  floss: Set phys attribute for uhid device
parents 5ef6f1a7 327d2041
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@
#include "bta_hh_api.h"
#include "btif_hh.h"
#include "btif_util.h"
#include "device/include/controller.h"
#include "osi/include/allocator.h"
#include "osi/include/compat.h"
#include "osi/include/osi.h"
@@ -563,6 +564,13 @@ void bta_hh_co_send_hid_info(btif_hh_device_t* p_dev, const char* dev_name,
  strlcpy((char*)ev.u.create.name, dev_name, sizeof(ev.u.create.name));
  snprintf((char*)ev.u.create.uniq, sizeof(ev.u.create.uniq), "%s",
           p_dev->bd_addr.ToString().c_str());

  // Write controller address to phys field to correlate the hid device with a
  // specific bluetooth controller.
  const controller_t* controller = controller_get_interface();
  snprintf((char*)ev.u.create.phys, sizeof(ev.u.create.phys), "%s",
           controller->get_address()->ToString().c_str());

  ev.u.create.rd_size = dscp_len;
  ev.u.create.rd_data = p_dscp;
  ev.u.create.bus = BUS_BLUETOOTH;
+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