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

Commit 79197087 authored by Katherine Lai's avatar Katherine Lai
Browse files

Floss: Add DBUS API |OnDevicePropertiesChanged|

Implements API so clients can watch for property changes for
a device.

Bug: 283998413
Tag: #floss
Test: Manual test with fast pair
Change-Id: I3ef4b225904f4554732f55be10859624c860b625
parent 72d91289
Loading
Loading
Loading
Loading
+8 −0
Original line number Diff line number Diff line
@@ -119,6 +119,14 @@ impl BtCallback {
impl IBluetoothCallback for BtCallback {
    fn on_adapter_property_changed(&mut self, _prop: BtPropertyType) {}

    fn on_device_properties_changed(
        &mut self,
        remote_device: BluetoothDevice,
        props: Vec<BtPropertyType>,
    ) {
        print_info!("Bluetooth properties {:?} changed for {:?}", props, remote_device);
    }

    fn on_address_changed(&mut self, addr: String) {
        print_info!("Address changed to {}", &addr);
        self.context.lock().unwrap().adapter_address = Some(addr);
+8 −0
Original line number Diff line number Diff line
@@ -514,6 +514,14 @@ impl IBluetoothCallback for IBluetoothCallbackDBus {
    #[dbus_method("OnAdapterPropertyChanged")]
    fn on_adapter_property_changed(&mut self, prop: BtPropertyType) {}

    #[dbus_method("OnDevicePropertiesChanged")]
    fn on_device_properties_changed(
        &mut self,
        remote_device: BluetoothDevice,
        props: Vec<BtPropertyType>,
    ) {
    }

    #[dbus_method("OnAddressChanged")]
    fn on_address_changed(&mut self, addr: String) {}

+8 −0
Original line number Diff line number Diff line
@@ -79,6 +79,14 @@ impl IBluetoothCallback for BluetoothCallbackDBus {
    fn on_adapter_property_changed(&mut self, prop: BtPropertyType) {
        dbus_generated!()
    }
    #[dbus_method("OnDevicePropertiesChanged")]
    fn on_device_properties_changed(
        &mut self,
        remote_device: BluetoothDevice,
        props: Vec<BtPropertyType>,
    ) {
        dbus_generated!()
    }
    #[dbus_method("OnAddressChanged")]
    fn on_address_changed(&mut self, addr: String) {
        dbus_generated!()
+15 −0
Original line number Diff line number Diff line
@@ -378,6 +378,13 @@ pub trait IBluetoothCallback: RPCProxy {
    /// When any adapter property changes.
    fn on_adapter_property_changed(&mut self, prop: BtPropertyType);

    /// When any device properties change.
    fn on_device_properties_changed(
        &mut self,
        remote_device: BluetoothDevice,
        props: Vec<BtPropertyType>,
    );

    /// When any of the adapter local address is changed.
    fn on_address_changed(&mut self, addr: String);

@@ -1579,6 +1586,14 @@ impl BtifBluetoothCallbacks for Bluetooth {
                    });
                }

                let info = &d.info.clone();
                self.callbacks.for_all_callbacks(|callback| {
                    callback.on_device_properties_changed(
                        info.clone(),
                        properties.clone().into_iter().map(|x| x.get_type()).collect(),
                    );
                });

                self.bluetooth_admin
                    .lock()
                    .unwrap()