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

Commit 3c732fb1 authored by Sonny Sasaka's avatar Sonny Sasaka
Browse files

Remove OnBluetoothStateChanged and rename OnBluetoothAddressChanged

* OnBluetoothStateChanged is already provided by btmanagerd
* OnBluetoothAddressChanged is renamed to OnAddressChanged

Bug: 188718349
Tag: #floss
Test: Build floss on Linux

Change-Id: I028c608705360565235b49b8503515024cfd86c7
parent a06af30d
Loading
Loading
Loading
Loading
+1 −5
Original line number Diff line number Diff line
@@ -17,11 +17,7 @@ struct BtCallback {
}

impl IBluetoothCallback for BtCallback {
    fn on_bluetooth_state_changed(&self, prev_state: u32, new_state: u32) {
        print_info!("Adapter state changed from {} to {}", prev_state, new_state);
    }

    fn on_bluetooth_address_changed(&self, addr: String) {
    fn on_address_changed(&self, addr: String) {
        print_info!("Address changed to {}", addr);
    }

+2 −5
Original line number Diff line number Diff line
@@ -89,11 +89,8 @@ impl btstack::RPCProxy for IBluetoothCallbackDBus {
    "org.chromium.bluetooth.BluetoothCallback"
)]
impl IBluetoothCallback for IBluetoothCallbackDBus {
    #[dbus_method("OnBluetoothStateChanged")]
    fn on_bluetooth_state_changed(&self, prev_state: u32, new_state: u32) {}

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

    #[dbus_method("OnDeviceFound")]
    fn on_device_found(&self, remote_device: BluetoothDevice) {}
+2 −4
Original line number Diff line number Diff line
@@ -32,10 +32,8 @@ struct BluetoothCallbackDBus {}

#[dbus_proxy_obj(BluetoothCallback, "org.chromium.bluetooth.BluetoothCallback")]
impl IBluetoothCallback for BluetoothCallbackDBus {
    #[dbus_method("OnBluetoothStateChanged")]
    fn on_bluetooth_state_changed(&self, prev_state: u32, new_state: u32) {}
    #[dbus_method("OnBluetoothAddressChanged")]
    fn on_bluetooth_address_changed(&self, addr: String) {}
    #[dbus_method("OnAddressChanged")]
    fn on_address_changed(&self, addr: String) {}
    #[dbus_method("OnDeviceFound")]
    fn on_device_found(&self, remote_device: BluetoothDevice) {}
    #[dbus_method("OnDiscoveringChanged")]
+2 −10
Original line number Diff line number Diff line
@@ -85,11 +85,8 @@ impl BluetoothDevice {

/// The interface for adapter callbacks registered through `IBluetooth::register_callback`.
pub trait IBluetoothCallback: RPCProxy {
    /// When any of the adapter states is changed.
    fn on_bluetooth_state_changed(&self, prev_state: u32, new_state: u32);

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

    /// When a device is found via discovery.
    fn on_device_found(&self, remote_device: BluetoothDevice);
@@ -146,7 +143,7 @@ impl Bluetooth {
        self.local_address = BDAddr::from_byte_vec(raw);

        self.for_all_callbacks(|callback| {
            callback.on_bluetooth_address_changed(self.local_address.unwrap().to_string());
            callback.on_address_changed(self.local_address.unwrap().to_string());
        });
    }

@@ -207,11 +204,6 @@ pub fn get_bt_dispatcher(tx: Sender<Message>) -> BaseCallbacksDispatcher {

impl BtifBluetoothCallbacks for Bluetooth {
    fn adapter_state_changed(&mut self, state: BtState) {
        self.for_all_callbacks(|callback| {
            callback
                .on_bluetooth_state_changed(self.state.to_u32().unwrap(), state.to_u32().unwrap())
        });

        self.state = state;
    }