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

Commit 6d288116 authored by Abhishek Pandit-Subedi's avatar Abhishek Pandit-Subedi Committed by Abhishek Pandit-Subedi
Browse files

floss: Wire OnBondStateChanged

Wire up the bond state changed callback so that the result of a bond
state change is communicated.

Bug: 196886657
Tag: #floss
Test: btclient bond <address>
Change-Id: I06ce8624098b71da35f3f98d9d60f2f1d77e7c3b
parent 102cead6
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -124,6 +124,10 @@ impl IBluetoothCallback for BtCallback {
            );
        }
    }

    fn on_bond_state_changed(&self, status: u32, address: String, state: u32) {
        print_info!("Bonding state changed: [{}] state: {}, Status = {}", address, state, status);
    }
}

impl RPCProxy for BtCallback {
+3 −0
Original line number Diff line number Diff line
@@ -169,6 +169,9 @@ impl IBluetoothCallback for IBluetoothCallbackDBus {
        passkey: u32,
    ) {
    }

    #[dbus_method("OnBondStateChanged")]
    fn on_bond_state_changed(&self, status: u32, address: String, state: u32) {}
}

pub(crate) struct BluetoothDBus {
+2 −0
Original line number Diff line number Diff line
@@ -47,6 +47,8 @@ impl IBluetoothCallback for BluetoothCallbackDBus {
        passkey: u32,
    ) {
    }
    #[dbus_method("OnBondStateChanged")]
    fn on_bond_state_changed(&self, status: u32, address: String, state: u32) {}
}

impl_dbus_arg_enum!(BluetoothTransport);
+13 −1
Original line number Diff line number Diff line
@@ -139,6 +139,9 @@ pub trait IBluetoothCallback: RPCProxy {
        variant: BtSspVariant,
        passkey: u32,
    );

    /// When a bonding attempt has completed.
    fn on_bond_state_changed(&self, status: u32, device_address: String, state: u32);
}

/// Implementation of the adapter API.
@@ -356,7 +359,7 @@ impl BtifBluetoothCallbacks for Bluetooth {

    fn bond_state(
        &mut self,
        _status: BtStatus,
        status: BtStatus,
        mut addr: RawAddress,
        bond_state: BtBondState,
        _fail_reason: i32,
@@ -366,6 +369,15 @@ impl BtifBluetoothCallbacks for Bluetooth {
            // TODO: Only connect to enabled profiles on that device.
            self.hh.as_ref().unwrap().connect(&mut addr);
        }

        // Send bond state changed notifications
        self.for_all_callbacks(|callback| {
            callback.on_bond_state_changed(
                status.to_u32().unwrap(),
                addr.to_string(),
                bond_state.to_u32().unwrap(),
            );
        });
    }
}