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

Commit 4e65d4e0 authored by Abhishek Pandit-Subedi's avatar Abhishek Pandit-Subedi Committed by Abhishek Pandit-Subedi
Browse files

floss: Add GetName/SetName adapter api

Bug: 196886187
Tag: #floss
Test: btclient> adapter show and dbus-send to setname (which aborts)
Change-Id: Icd1ee42a24be6630eb03a53ca39da9c815318aad
parent 9a179526
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -253,8 +253,10 @@ impl CommandHandler {
                    Some(x) => x.clone(),
                    None => String::from(""),
                };
                let name = self.context.lock().unwrap().adapter_dbus.as_ref().unwrap().get_name();
                let uuids = self.context.lock().unwrap().adapter_dbus.as_ref().unwrap().get_uuids();
                print_info!("Address: {}", address);
                print_info!("Name: {}", name);
                print_info!("State: {}", if enabled { "enabled" } else { "disabled" });
                print_info!(
                    "Uuids: {}",
+8 −0
Original line number Diff line number Diff line
@@ -231,6 +231,14 @@ impl IBluetooth for BluetoothDBus {
        <Vec<Uuid128Bit> as DBusArg>::from_dbus(result, None, None, None).unwrap()
    }

    fn get_name(&self) -> String {
        self.client_proxy.method("GetName", ())
    }

    fn set_name(&self, name: String) -> bool {
        self.client_proxy.method("SetName", (name,))
    }

    fn start_discovery(&self) -> bool {
        self.client_proxy.method("StartDiscovery", ())
    }
+10 −0
Original line number Diff line number Diff line
@@ -83,6 +83,16 @@ impl IBluetooth for IBluetoothDBus {
        vec![]
    }

    #[dbus_method("GetName")]
    fn get_name(&self) -> String {
        String::new()
    }

    #[dbus_method("SetName")]
    fn set_name(&self, name: String) -> bool {
        true
    }

    #[dbus_method("StartDiscovery")]
    fn start_discovery(&self) -> bool {
        true
+20 −0
Original line number Diff line number Diff line
@@ -42,6 +42,12 @@ pub trait IBluetooth {
    /// Gets supported UUIDs by the local adapter.
    fn get_uuids(&self) -> Vec<Uuid128Bit>;

    /// Gets the local adapter name.
    fn get_name(&self) -> String;

    /// Sets the local adapter name.
    fn set_name(&self, name: String) -> bool;

    /// Starts BREDR Inquiry.
    fn start_discovery(&self) -> bool;

@@ -512,6 +518,20 @@ impl IBluetooth for Bluetooth {
        }
    }

    fn get_name(&self) -> String {
        match self.properties.get(&BtPropertyType::BdName) {
            Some(prop) => match prop {
                BluetoothProperty::BdName(name) => name.clone(),
                _ => String::new(),
            },
            _ => String::new(),
        }
    }

    fn set_name(&self, name: String) -> bool {
        self.intf.lock().unwrap().set_adapter_property(BluetoothProperty::BdName(name)) == 0
    }

    fn start_discovery(&self) -> bool {
        self.intf.lock().unwrap().start_discovery() == 0
    }