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

Commit 473b3c01 authored by Ying Hsu's avatar Ying Hsu Committed by Gerrit Code Review
Browse files

Merge "floss: Add GetAlias and GetModalias D-Bus methods"

parents 257bcc26 f1e126d9
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -456,6 +456,8 @@ impl CommandHandler {
                let uuids = adapter_dbus.get_uuids();
                let is_discoverable = adapter_dbus.get_discoverable();
                let is_connectable = qa_dbus.get_connectable();
                let alias = qa_dbus.get_alias();
                let modalias = qa_dbus.get_modalias();
                let discoverable_timeout = adapter_dbus.get_discoverable_timeout();
                let cod = adapter_dbus.get_bluetooth_class();
                let multi_adv_supported = adapter_dbus.is_multi_advertisement_supported();
@@ -475,6 +477,8 @@ impl CommandHandler {
                    .collect();
                print_info!("Address: {}", address);
                print_info!("Name: {}", name);
                print_info!("Alias: {}", alias);
                print_info!("Modalias: {}", modalias);
                print_info!("State: {}", if enabled { "enabled" } else { "disabled" });
                print_info!("Discoverable: {}", is_discoverable);
                print_info!("DiscoverableTimeout: {}s", discoverable_timeout);
+10 −0
Original line number Diff line number Diff line
@@ -882,6 +882,16 @@ impl IBluetoothQA for BluetoothQADBus {
        dbus_generated!()
    }

    #[dbus_method("GetAlias")]
    fn get_alias(&self) -> String {
        dbus_generated!()
    }

    #[dbus_method("GetModalias")]
    fn get_modalias(&self) -> String {
        dbus_generated!()
    }

    #[dbus_method("GetHIDReport")]
    fn get_hid_report(
        &mut self,
+10 −0
Original line number Diff line number Diff line
@@ -855,6 +855,16 @@ impl IBluetoothQA for IBluetoothQADBus {
        dbus_generated!()
    }

    #[dbus_method("GetAlias")]
    fn get_alias(&self) -> String {
        dbus_generated!()
    }

    #[dbus_method("GetModalias")]
    fn get_modalias(&self) -> String {
        dbus_generated!()
    }

    #[dbus_method("GetHIDReport")]
    fn get_hid_report(
        &mut self,
+26 −0
Original line number Diff line number Diff line
@@ -42,6 +42,7 @@ use crate::callbacks::Callbacks;
use crate::uuid::{Profile, UuidHelper, HOGP};
use crate::{Message, RPCProxy, SuspendMode};

const FLOSS_VER: u16 = 0x0001;
const DEFAULT_DISCOVERY_TIMEOUT_MS: u64 = 12800;
const MIN_ADV_INSTANCES_FOR_MULTI_ADV: u8 = 5;

@@ -219,6 +220,13 @@ pub trait IBluetoothQA {
    /// Sets connectability. Returns true on success, false otherwise.
    fn set_connectable(&mut self, mode: bool) -> bool;

    /// Returns the adapter's Bluetooth friendly name.
    fn get_alias(&self) -> String;

    /// Returns the adapter's Device ID information in modalias format
    /// used by the kernel and udev.
    fn get_modalias(&self) -> String;

    /// Gets HID report on the peer.
    fn get_hid_report(
        &mut self,
@@ -2290,6 +2298,24 @@ impl IBluetoothQA for Bluetooth {
        )) == 0
    }

    fn get_alias(&self) -> String {
        let name = self.get_name();
        if !name.is_empty() {
            return name;
        }

        // If the adapter name is empty, generate one based on local BDADDR
        // so that test programs can have a friendly name for the adapter.
        match self.local_address {
            None => "floss_0000".to_string(),
            Some(addr) => format!("floss_{:02X}{:02X}", addr.address[4], addr.address[5]),
        }
    }

    fn get_modalias(&self) -> String {
        format!("bluetooth:v00E0pC405d{:04x}", FLOSS_VER)
    }

    fn get_hid_report(
        &mut self,
        addr: String,