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

Commit 7c12abcf authored by howardchung's avatar howardchung Committed by Yun-hao Chung
Browse files

Floss: Wire pin code request to Floss

Implement the pin code request callback in Floss and expose it to D-Bus.

Bug: 264231864
Test: run GAP/BOND/BON/BV-01-C

Change-Id: I53717bf7f1d8a1587e745892c8cd455e7854433c
parent 66d44917
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -198,6 +198,18 @@ impl IBluetoothCallback for BtCallback {
        }
    }

    fn on_pin_request(&self, remote_device: BluetoothDevice, _cod: u32, min_16_digit: bool) {
        print_info!(
            "Device [{}: {}] would like to pair, enter pin code {}",
            &remote_device.address,
            &remote_device.name,
            match min_16_digit {
                true => "with at least 16 digits",
                false => "",
            }
        );
    }

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

+3 −0
Original line number Diff line number Diff line
@@ -299,6 +299,9 @@ impl IBluetoothCallback for IBluetoothCallbackDBus {
    ) {
    }

    #[dbus_method("OnPinRequest")]
    fn on_pin_request(&self, remote_device: BluetoothDevice, cod: u32, min_16_digit: bool) {}

    #[dbus_method("OnBondStateChanged")]
    fn on_bond_state_changed(&self, status: u32, address: String, state: u32) {}
}
+4 −0
Original line number Diff line number Diff line
@@ -107,6 +107,10 @@ impl IBluetoothCallback for BluetoothCallbackDBus {
    ) {
        dbus_generated!()
    }
    #[dbus_method("OnPinRequest")]
    fn on_pin_request(&self, remote_device: BluetoothDevice, cod: u32, min_16_digit: bool) {
        dbus_generated!()
    }
    #[dbus_method("OnBondStateChanged")]
    fn on_bond_state_changed(&self, status: u32, address: String, state: u32) {
        dbus_generated!()
+32 −1
Original line number Diff line number Diff line
@@ -368,6 +368,9 @@ pub trait IBluetoothCallback: RPCProxy {
        passkey: u32,
    );

    /// When there is a pin request to display the event to client.
    fn on_pin_request(&self, remote_device: BluetoothDevice, cod: u32, min_16_digit: bool);

    /// When a bonding attempt has completed.
    fn on_bond_state_changed(&self, status: u32, device_address: String, state: u32);
}
@@ -820,6 +823,16 @@ pub(crate) trait BtifBluetoothCallbacks {

    #[btif_callback(LeRandCallback)]
    fn le_rand_cb(&mut self, random: u64) {}

    #[btif_callback(PinRequest)]
    fn pin_request(
        &mut self,
        remote_addr: RawAddress,
        remote_name: String,
        cod: u32,
        min_16_digit: bool,
    ) {
    }
}

#[btif_callbacks_dispatcher(dispatch_hid_host_callbacks, HHCallbacks)]
@@ -1031,7 +1044,7 @@ impl BtifBluetoothCallbacks for Bluetooth {
        passkey: u32,
    ) {
        // Currently this supports many agent because we accept many callbacks.
        // TODO: We need a way to select the default agent.
        // TODO(b/274706838): We need a way to select the default agent.
        self.callbacks.for_all_callbacks(|callback| {
            callback.on_ssp_request(
                BluetoothDevice::new(remote_addr.to_string(), remote_name.clone()),
@@ -1042,6 +1055,24 @@ impl BtifBluetoothCallbacks for Bluetooth {
        });
    }

    fn pin_request(
        &mut self,
        remote_addr: RawAddress,
        remote_name: String,
        cod: u32,
        min_16_digit: bool,
    ) {
        // Currently this supports many agent because we accept many callbacks.
        // TODO(b/274706838): We need a way to select the default agent.
        self.callbacks.for_all_callbacks(|callback| {
            callback.on_pin_request(
                BluetoothDevice::new(remote_addr.to_string(), remote_name.clone()),
                cod,
                min_16_digit,
            );
        });
    }

    fn bond_state(
        &mut self,
        status: BtStatus,