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

Commit 59826afc authored by Michael Sun's avatar Michael Sun
Browse files

floss: add support to fetch vendor and product info

Add adapter method to support client fetching vendor and product
information for a particular remote device.

Bug: 284179714
Tag: #floss
Test: verified locally Floss responded to GetRemoteVendorProductInfo

Change-Id: I756cfbcaef1709a3a9ecc8c6f75070d11e53c8df
parent e2c4760a
Loading
Loading
Loading
Loading
+14 −1
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@

use bt_topshim::btif::{
    BtBondState, BtConnectionState, BtDeviceType, BtDiscMode, BtPropertyType, BtSspVariant,
    BtStatus, BtTransport, Uuid, Uuid128Bit,
    BtStatus, BtTransport, BtVendorProductInfo, Uuid, Uuid128Bit,
};
use bt_topshim::profiles::gatt::{AdvertisingStatus, GattStatus, LePhy};
use bt_topshim::profiles::hid_host::BthhReportType;
@@ -195,6 +195,14 @@ pub struct BtSdpMpsRecordDBus {
    supported_dependencies: SupportedDependencies,
}

#[dbus_propmap(BtVendorProductInfo)]
pub struct BtVendorProductInfoDBus {
    vendor_id_src: u8,
    vendor_id: u16,
    product_id: u16,
    version: u16,
}

fn read_propmap_value<T: 'static + DirectDBus>(
    propmap: &dbus::arg::PropMap,
    key: &str,
@@ -821,6 +829,11 @@ impl IBluetooth for BluetoothDBus {
        dbus_generated!()
    }

    #[dbus_method("GetRemoteVendorProductInfo")]
    fn get_remote_vendor_product_info(&self, _device: BluetoothDevice) -> BtVendorProductInfo {
        dbus_generated!()
    }

    #[dbus_method("GetConnectedDevices")]
    fn get_connected_devices(&self) -> Vec<BluetoothDevice> {
        dbus_generated!()
+14 −1
Original line number Diff line number Diff line
use bt_topshim::btif::{
    BtBondState, BtConnectionState, BtDeviceType, BtDiscMode, BtPropertyType, BtSspVariant,
    BtStatus, BtTransport, Uuid, Uuid128Bit,
    BtStatus, BtTransport, BtVendorProductInfo, Uuid, Uuid128Bit,
};
use bt_topshim::profiles::socket::SocketType;
use bt_topshim::profiles::ProfileConnectionState;
@@ -244,6 +244,14 @@ pub struct BtSdpMpsRecordDBus {
    supported_dependencies: SupportedDependencies,
}

#[dbus_propmap(BtVendorProductInfo)]
pub struct BtVendorProductInfoDBus {
    vendor_id_src: u8,
    vendor_id: u16,
    product_id: u16,
    version: u16,
}

fn read_propmap_value<T: 'static + DirectDBus>(
    propmap: &dbus::arg::PropMap,
    key: &str,
@@ -585,6 +593,11 @@ impl IBluetooth for IBluetoothDBus {
        dbus_generated!()
    }

    #[dbus_method("GetRemoteVendorProductInfo")]
    fn get_remote_vendor_product_info(&self, _device: BluetoothDevice) -> BtVendorProductInfo {
        dbus_generated!()
    }

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

    /// Gets the vendor and product information of the remote device.
    fn get_remote_vendor_product_info(&self, device: BluetoothDevice) -> BtVendorProductInfo;

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

@@ -2169,6 +2172,13 @@ impl IBluetooth for Bluetooth {
        }
    }

    fn get_remote_vendor_product_info(&self, device: BluetoothDevice) -> BtVendorProductInfo {
        match self.get_remote_device_property(&device, &BtPropertyType::VendorProductInfo) {
            Some(BluetoothProperty::VendorProductInfo(p)) => p.clone(),
            _ => BtVendorProductInfo { vendor_id_src: 0, vendor_id: 0, product_id: 0, version: 0 },
        }
    }

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