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

Commit 1db9c9f7 authored by Sonny Sasaka's avatar Sonny Sasaka
Browse files

Floss: Some light code clean ups

* Removes unnecessary #[allow(dead_code)]. The new macro behaves
  differently that this warning supporession is not needed anymore.

* `unregister_scanner_callback` parameter should be named `callback_id`
  instead of `scanner_id`. This becomes more important to disambiguate
  since there will be `unregister_scanner` that takes `scanner_id`.

* `callbacks` should be named `scanner_callbacks` to disambiguate with
  other types of Gatt callbacks.

* Add missing D-Bus projection RegisterScanner and UnregisterScanner in
  btclient.

Bug: 217273154
Tag: #floss
Test: Manual - Build Floss on Linux

Change-Id: I5094a3f806698fb94c0e51cf78262a26b24eeb27
parent 2bfe5169
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -102,7 +102,6 @@ pub struct BluetoothDeviceDBus {
    name: String,
}

#[allow(dead_code)]
struct IBluetoothCallbackDBus {}

impl RPCProxy for IBluetoothCallbackDBus {
@@ -159,7 +158,6 @@ impl IBluetoothCallback for IBluetoothCallbackDBus {
    fn on_bond_state_changed(&self, status: u32, address: String, state: u32) {}
}

#[allow(dead_code)]
struct IBluetoothConnectionCallbackDBus {}

impl RPCProxy for IBluetoothConnectionCallbackDBus {
@@ -501,7 +499,6 @@ impl IBluetoothManager for BluetoothManagerDBus {
    }
}

#[allow(dead_code)]
struct IBluetoothManagerCallbackDBus {}

impl RPCProxy for IBluetoothManagerCallbackDBus {
@@ -549,11 +546,13 @@ impl BluetoothGattDBus {

#[generate_dbus_interface_client]
impl IBluetoothGatt for BluetoothGattDBus {
    #[dbus_method("RegisterScannerCallback")]
    fn register_scanner_callback(&mut self, _callback: Box<dyn IScannerCallback + Send>) -> u32 {
        dbus_generated!()
    }

    fn unregister_scanner_callback(&mut self, _scanner_id: u32) -> bool {
    #[dbus_method("UnregisterScannerCallback")]
    fn unregister_scanner_callback(&mut self, _callback_id: u32) -> bool {
        dbus_generated!()
    }

@@ -719,7 +718,6 @@ impl IBluetoothGatt for BluetoothGattDBus {
    }
}

#[allow(dead_code)]
struct IBluetoothGattCallbackDBus {}

impl RPCProxy for IBluetoothGattCallbackDBus {
@@ -842,7 +840,6 @@ impl ISuspend for SuspendDBus {
    }
}

#[allow(dead_code)]
struct ISuspendCallbackDBus {}

impl RPCProxy for ISuspendCallbackDBus {
+1 −1
Original line number Diff line number Diff line
@@ -208,7 +208,7 @@ impl IBluetoothGatt for IBluetoothGattDBus {
    }

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

+7 −7
Original line number Diff line number Diff line
@@ -144,7 +144,7 @@ pub trait IBluetoothGatt {
    fn register_scanner_callback(&mut self, callback: Box<dyn IScannerCallback + Send>) -> u32;

    /// Unregisters an LE scanner callback identified by the given id.
    fn unregister_scanner_callback(&mut self, scanner_id: u32) -> bool;
    fn unregister_scanner_callback(&mut self, callback_id: u32) -> bool;

    fn start_scan(&self, scanner_id: i32, settings: ScanSettings, filters: Vec<ScanFilter>);
    fn stop_scan(&self, scanner_id: i32);
@@ -491,7 +491,7 @@ pub struct BluetoothGatt {

    context_map: ContextMap,
    reliable_queue: HashSet<String>,
    callbacks: Callbacks<dyn IScannerCallback + Send>,
    scanner_callbacks: Callbacks<dyn IScannerCallback + Send>,
}

impl BluetoothGatt {
@@ -502,7 +502,7 @@ impl BluetoothGatt {
            gatt: None,
            context_map: ContextMap::new(),
            reliable_queue: HashSet::new(),
            callbacks: Callbacks::new(tx.clone(), Message::ScannerCallbackDisconnected),
            scanner_callbacks: Callbacks::new(tx.clone(), Message::ScannerCallbackDisconnected),
        }
    }

@@ -532,7 +532,7 @@ impl BluetoothGatt {
    }

    pub fn remove_scanner_callback(&mut self, id: u32) -> bool {
        self.callbacks.remove_callback(id)
        self.scanner_callbacks.remove_callback(id)
    }
}

@@ -569,11 +569,11 @@ pub enum GattWriteRequestStatus {

impl IBluetoothGatt for BluetoothGatt {
    fn register_scanner_callback(&mut self, callback: Box<dyn IScannerCallback + Send>) -> u32 {
        self.callbacks.add_callback(callback)
        self.scanner_callbacks.add_callback(callback)
    }

    fn unregister_scanner_callback(&mut self, scanner_id: u32) -> bool {
        self.callbacks.remove_callback(scanner_id)
    fn unregister_scanner_callback(&mut self, callback_id: u32) -> bool {
        self.scanner_callbacks.remove_callback(callback_id)
    }

    fn start_scan(&self, _scanner_id: i32, _settings: ScanSettings, _filters: Vec<ScanFilter>) {