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

Commit 5669e675 authored by Treehugger Robot's avatar Treehugger Robot Committed by Automerger Merge Worker
Browse files

Merge "Floss: Wire pin code request to Floss" am: e64059fb

parents 188455b9 e64059fb
Loading
Loading
Loading
Loading
+12 −0
Original line number Diff line number Diff line
@@ -199,6 +199,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
@@ -511,6 +511,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
@@ -112,6 +112,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
@@ -383,6 +383,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);

@@ -934,6 +937,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)]
@@ -1155,7 +1168,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()),
@@ -1166,6 +1179,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,