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

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

Floss: Audit callbacks.

This CL ensures that duplicate callbacks aren't registered with
the same object path and returns the previously registed callback
ID if the same object path is used.

It also ensures that all add_callback DBUS functions also have
a corresponding remove_callback and standardizes the return type.

Bug: 287248056
Tag: #floss
Test: Unit tests and emerge-brya floss
Change-Id: I6c852f5b50ce13024e6c8f5a08238bd21d6d77b7
parent f189da44
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -649,7 +649,12 @@ impl BluetoothDBus {
#[generate_dbus_interface_client(BluetoothDBusRPC)]
impl IBluetooth for BluetoothDBus {
    #[dbus_method("RegisterCallback")]
    fn register_callback(&mut self, callback: Box<dyn IBluetoothCallback + Send>) {
    fn register_callback(&mut self, callback: Box<dyn IBluetoothCallback + Send>) -> u32 {
        dbus_generated!()
    }

    #[dbus_method("UnregisterCallback")]
    fn unregister_callback(&mut self, id: u32) -> bool {
        dbus_generated!()
    }

@@ -1355,7 +1360,7 @@ impl IBluetoothGatt for BluetoothGattDBus {
    }

    #[dbus_method("UnregisterAdvertiserCallback")]
    fn unregister_advertiser_callback(&mut self, callback_id: u32) {
    fn unregister_advertiser_callback(&mut self, callback_id: u32) -> bool {
        dbus_generated!()
    }

@@ -1960,6 +1965,11 @@ impl IBluetoothSocketManager for BluetoothSocketManagerDBus {
        dbus_generated!()
    }

    #[dbus_method("UnregisterCallback")]
    fn unregister_callback(&mut self, callback: CallbackId) -> bool {
        dbus_generated!()
    }

    #[dbus_method("ListenUsingInsecureL2capChannel")]
    fn listen_using_insecure_l2cap_channel(&mut self, callback: CallbackId) -> SocketResult {
        dbus_generated!()
+1 −1
Original line number Diff line number Diff line
@@ -44,7 +44,7 @@ impl IBatteryManager for IBatteryManagerDBus {
    }

    #[dbus_method("UnregisterBatteryCallback")]
    fn unregister_battery_callback(&mut self, callback_id: u32) {
    fn unregister_battery_callback(&mut self, callback_id: u32) -> bool {
        dbus_generated!()
    }

+11 −1
Original line number Diff line number Diff line
@@ -410,7 +410,12 @@ struct IBluetoothDBus {}
)]
impl IBluetooth for IBluetoothDBus {
    #[dbus_method("RegisterCallback")]
    fn register_callback(&mut self, callback: Box<dyn IBluetoothCallback + Send>) {
    fn register_callback(&mut self, callback: Box<dyn IBluetoothCallback + Send>) -> u32 {
        dbus_generated!()
    }

    #[dbus_method("UnregisterCallback")]
    fn unregister_callback(&mut self, id: u32) -> bool {
        dbus_generated!()
    }

@@ -742,6 +747,11 @@ impl IBluetoothSocketManager for IBluetoothSocketManagerDBus {
        dbus_generated!()
    }

    #[dbus_method("UnregisterCallback")]
    fn unregister_callback(&mut self, callback: CallbackId) -> bool {
        dbus_generated!()
    }

    #[dbus_method("ListenUsingInsecureL2capChannel")]
    fn listen_using_insecure_l2cap_channel(&mut self, callback: CallbackId) -> SocketResult {
        dbus_generated!()
+1 −1
Original line number Diff line number Diff line
@@ -655,7 +655,7 @@ impl IBluetoothGatt for IBluetoothGattDBus {
    }

    #[dbus_method("UnregisterAdvertiserCallback")]
    fn unregister_advertiser_callback(&mut self, callback_id: u32) {
    fn unregister_advertiser_callback(&mut self, callback_id: u32) -> bool {
        dbus_generated!()
    }

+5 −5
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ pub trait IBatteryManager {
    ) -> u32;

    /// Unregister a callback.
    fn unregister_battery_callback(&mut self, callback_id: u32);
    fn unregister_battery_callback(&mut self, callback_id: u32) -> bool;

    /// Returns battery information for the remote, sourced from the highest priority origin.
    fn get_battery_information(&self, remote_address: String) -> Option<BatterySet>;
@@ -72,8 +72,8 @@ impl BatteryManager {
    }

    /// Remove a callback due to disconnection or unregistration.
    pub fn remove_callback(&mut self, callback_id: u32) {
        self.callbacks.remove_callback(callback_id);
    pub fn remove_callback(&mut self, callback_id: u32) -> bool {
        self.callbacks.remove_callback(callback_id)
    }

    /// Handles a BatterySet update.
@@ -92,8 +92,8 @@ impl IBatteryManager for BatteryManager {
        self.callbacks.add_callback(battery_manager_callback)
    }

    fn unregister_battery_callback(&mut self, callback_id: u32) {
        self.remove_callback(callback_id);
    fn unregister_battery_callback(&mut self, callback_id: u32) -> bool {
        self.remove_callback(callback_id)
    }

    fn get_battery_information(&self, remote_address: String) -> Option<BatterySet> {
Loading