diff --git a/core/embed/rust/src/ui/api/firmware_micropython.rs b/core/embed/rust/src/ui/api/firmware_micropython.rs index b7f4300ec7..faedf35fe1 100644 --- a/core/embed/rust/src/ui/api/firmware_micropython.rs +++ b/core/embed/rust/src/ui/api/firmware_micropython.rs @@ -844,8 +844,11 @@ extern "C" fn new_show_pairing_device_name( extern "C" fn new_show_pairing_code(n_args: usize, args: *const Obj, kwargs: *mut Map) -> Obj { let block = move |_args: &[Obj], kwargs: &Map| { + let title: TString = kwargs.get(Qstr::MP_QSTR_title)?.try_into()?; + let description: TString = kwargs.get(Qstr::MP_QSTR_description)?.try_into()?; let code: TString = kwargs.get(Qstr::MP_QSTR_code)?.try_into()?; - let layout = ModelUI::show_pairing_code(code)?; + let button: bool = kwargs.get_or(Qstr::MP_QSTR_button, true)?; + let layout = ModelUI::show_pairing_code(title, description, code, button)?; let layout_obj = LayoutObj::new_root(layout)?; Ok(layout_obj.into()) }; @@ -1633,7 +1636,10 @@ pub static mp_module_trezorui_api: Module = obj_module! { /// def show_pairing_code( /// *, + /// title: str, + /// description: str, /// code: str, + /// button: bool = True, /// ) -> LayoutObj[UiResult]: /// """Pairing device: second screen (pairing code). /// Returns on BLEEvent::{PairingCanceled, Disconnected}.""" diff --git a/core/embed/rust/src/ui/layout_bolt/ui_firmware.rs b/core/embed/rust/src/ui/layout_bolt/ui_firmware.rs index 5de45d2de7..f9231fca48 100644 --- a/core/embed/rust/src/ui/layout_bolt/ui_firmware.rs +++ b/core/embed/rust/src/ui/layout_bolt/ui_firmware.rs @@ -882,10 +882,25 @@ impl FirmwareUI for UIBolt { )) } - fn show_pairing_code(_code: TString<'static>) -> Result { - Err::, Error>(Error::ValueError( - c"show_pairing_code not supported", - )) + fn show_pairing_code( + title: TString<'static>, + description: TString<'static>, + code: TString<'static>, + button: bool, + ) -> Result { + Self::confirm_action( + title, + Some(code), + Some(description), + None, + button.then_some(TR::buttons__confirm.into()), + None, + false, + false, + false, + false, + None, + ) } fn show_info( diff --git a/core/embed/rust/src/ui/layout_caesar/ui_firmware.rs b/core/embed/rust/src/ui/layout_caesar/ui_firmware.rs index 95656609a0..cae2ff17e0 100644 --- a/core/embed/rust/src/ui/layout_caesar/ui_firmware.rs +++ b/core/embed/rust/src/ui/layout_caesar/ui_firmware.rs @@ -1048,7 +1048,12 @@ impl FirmwareUI for UICaesar { )) } - fn show_pairing_code(_code: TString<'static>) -> Result { + fn show_pairing_code( + title: TString<'static>, + description: TString<'static>, + code: TString<'static>, + button: bool, + ) -> Result { Err::, Error>(Error::ValueError( c"show_pairing_code not supported", )) diff --git a/core/embed/rust/src/ui/layout_delizia/ui_firmware.rs b/core/embed/rust/src/ui/layout_delizia/ui_firmware.rs index fedbf4be70..7116aa1c02 100644 --- a/core/embed/rust/src/ui/layout_delizia/ui_firmware.rs +++ b/core/embed/rust/src/ui/layout_delizia/ui_firmware.rs @@ -905,7 +905,12 @@ impl FirmwareUI for UIDelizia { )) } - fn show_pairing_code(_code: TString<'static>) -> Result { + fn show_pairing_code( + title: TString<'static>, + description: TString<'static>, + code: TString<'static>, + button: bool, + ) -> Result { Err::, Error>(Error::ValueError( c"show_pairing_code not supported", )) diff --git a/core/embed/rust/src/ui/layout_eckhart/ui_firmware.rs b/core/embed/rust/src/ui/layout_eckhart/ui_firmware.rs index c2f77720c7..27f722ff4b 100644 --- a/core/embed/rust/src/ui/layout_eckhart/ui_firmware.rs +++ b/core/embed/rust/src/ui/layout_eckhart/ui_firmware.rs @@ -1010,16 +1010,21 @@ impl FirmwareUI for UIEckhart { Ok(layout) } - fn show_pairing_code(code: TString<'static>) -> Result { - let text: TString<'static> = "Pairing code match?".into(); + fn show_pairing_code( + title: TString<'static>, + description: TString<'static>, + code: TString<'static>, + button: bool, + ) -> Result { let mut ops = OpTextLayout::new(theme::firmware::TEXT_REGULAR); - ops = ops.text(text, fonts::FONT_SATOSHI_REGULAR_38); + ops = ops.text(description, fonts::FONT_SATOSHI_REGULAR_38); ops = ops.newline().newline().newline(); ops = ops.alignment(Alignment::Center); ops = ops.text(code, fonts::FONT_SATOSHI_EXTRALIGHT_72); - let screen = TextScreen::new(FormattedText::new(ops)) - .with_header(Header::new("Bluetooth pairing".into())) - .with_action_bar(ActionBar::new_cancel_confirm()); + let mut screen = TextScreen::new(FormattedText::new(ops)).with_header(Header::new(title)); + if button { + screen = screen.with_action_bar(ActionBar::new_cancel_confirm()); + } #[cfg(feature = "ble")] let screen = crate::ui::component::BLEHandler::new(screen, false); let layout = RootComponent::new(screen); diff --git a/core/embed/rust/src/ui/ui_firmware.rs b/core/embed/rust/src/ui/ui_firmware.rs index 9102fb8b7b..ff4032569f 100644 --- a/core/embed/rust/src/ui/ui_firmware.rs +++ b/core/embed/rust/src/ui/ui_firmware.rs @@ -316,7 +316,12 @@ pub trait FirmwareUI { device_name: TString<'static>, ) -> Result; - fn show_pairing_code(code: TString<'static>) -> Result; + fn show_pairing_code( + title: TString<'static>, + description: TString<'static>, + code: TString<'static>, + button: bool, + ) -> Result; fn show_info( title: TString<'static>, diff --git a/core/mocks/generated/trezorui_api.pyi b/core/mocks/generated/trezorui_api.pyi index 7afc89b0db..804f7bc651 100644 --- a/core/mocks/generated/trezorui_api.pyi +++ b/core/mocks/generated/trezorui_api.pyi @@ -557,7 +557,10 @@ def show_pairing_device_name( # rust/src/ui/api/firmware_micropython.rs def show_pairing_code( *, + title: str, + description: str, code: str, + button: bool = True, ) -> LayoutObj[UiResult]: """Pairing device: second screen (pairing code). Returns on BLEEvent::{PairingCanceled, Disconnected}.""" diff --git a/core/src/apps/management/ble/pair_new_device.py b/core/src/apps/management/ble/pair_new_device.py index 474047c3ce..d5b48ba75f 100644 --- a/core/src/apps/management/ble/pair_new_device.py +++ b/core/src/apps/management/ble/pair_new_device.py @@ -29,7 +29,10 @@ async def pair_new_device() -> None: try: result = await raise_if_not_confirmed( trezorui_api.show_pairing_code( + title="Bluetooth pairing", + description="Pairing code match?", code=f"{code:0>6}", + button=True, ), None, )