mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-04-22 10:09:04 +00:00
feat(eckhart): send device name and version to the device menu
This commit is contained in:
parent
e2d24c6a79
commit
3aae247e43
@ -269,6 +269,7 @@ static void _librust_qstrs(void) {
|
||||
MP_QSTR_fingerprint;
|
||||
MP_QSTR_firmware_update__title;
|
||||
MP_QSTR_firmware_update__title_fingerprint;
|
||||
MP_QSTR_firmware_version;
|
||||
MP_QSTR_flow_confirm_output;
|
||||
MP_QSTR_flow_confirm_set_new_pin;
|
||||
MP_QSTR_flow_get_address;
|
||||
|
@ -806,9 +806,17 @@ extern "C" fn new_show_device_menu(n_args: usize, args: *const Obj, kwargs: *mut
|
||||
let block = move |_args: &[Obj], kwargs: &Map| {
|
||||
let failed_backup: bool = kwargs.get(Qstr::MP_QSTR_failed_backup)?.try_into()?;
|
||||
let battery_percentage: u8 = kwargs.get_or(Qstr::MP_QSTR_battery_percentage, 0)?;
|
||||
let firmware_version: TString = kwargs.get(Qstr::MP_QSTR_firmware_version)?.try_into()?;
|
||||
let device_name: TString = kwargs.get(Qstr::MP_QSTR_device_name)?.try_into()?;
|
||||
let paired_devices: Obj = kwargs.get(Qstr::MP_QSTR_paired_devices)?;
|
||||
let paired_devices: Vec<TString, 1> = util::iter_into_vec(paired_devices)?;
|
||||
let layout = ModelUI::show_device_menu(failed_backup, battery_percentage, paired_devices)?;
|
||||
let layout = ModelUI::show_device_menu(
|
||||
failed_backup,
|
||||
battery_percentage,
|
||||
firmware_version,
|
||||
device_name,
|
||||
paired_devices,
|
||||
)?;
|
||||
let layout_obj = LayoutObj::new_root(layout)?;
|
||||
Ok(layout_obj.into())
|
||||
};
|
||||
@ -1602,6 +1610,8 @@ pub static mp_module_trezorui_api: Module = obj_module! {
|
||||
/// *,
|
||||
/// failed_backup: bool,
|
||||
/// battery_percentage: int,
|
||||
/// firmware_version: str,
|
||||
/// device_name: str,
|
||||
/// paired_devices: Iterable[str],
|
||||
/// ) -> LayoutObj[UiResult]:
|
||||
/// """Show the device menu."""
|
||||
|
@ -864,6 +864,8 @@ impl FirmwareUI for UIBolt {
|
||||
fn show_device_menu(
|
||||
_failed_backup: bool,
|
||||
_battery_percentage: u8,
|
||||
_firmware_version: TString<'static>,
|
||||
_device_name: TString<'static>,
|
||||
_paired_devices: heapless::Vec<TString<'static>, 1>,
|
||||
) -> Result<impl LayoutMaybeTrace, Error> {
|
||||
Err::<RootComponent<Empty, ModelUI>, Error>(Error::ValueError(
|
||||
|
@ -1030,6 +1030,8 @@ impl FirmwareUI for UICaesar {
|
||||
fn show_device_menu(
|
||||
_failed_backup: bool,
|
||||
_battery_percentage: u8,
|
||||
_firmware_version: TString<'static>,
|
||||
_device_name: TString<'static>,
|
||||
_paired_devices: Vec<TString<'static>, 1>,
|
||||
) -> Result<impl LayoutMaybeTrace, Error> {
|
||||
Err::<RootComponent<Empty, ModelUI>, Error>(Error::ValueError(
|
||||
|
@ -887,6 +887,8 @@ impl FirmwareUI for UIDelizia {
|
||||
fn show_device_menu(
|
||||
_failed_backup: bool,
|
||||
_battery_percentage: u8,
|
||||
_firmware_version: TString<'static>,
|
||||
_device_name: TString<'static>,
|
||||
_paired_devices: heapless::Vec<TString<'static>, 1>,
|
||||
) -> Result<impl LayoutMaybeTrace, Error> {
|
||||
Err::<RootComponent<Empty, ModelUI>, Error>(Error::ValueError(
|
||||
|
@ -129,6 +129,7 @@ pub struct DeviceMenuScreen<'a> {
|
||||
bounds: Rect,
|
||||
|
||||
battery_percentage: u8,
|
||||
firmware_version: TString<'static>,
|
||||
|
||||
// These correspond to the currently active subscreen,
|
||||
// which is one of the possible kinds of subscreens
|
||||
@ -153,6 +154,8 @@ impl<'a> DeviceMenuScreen<'a> {
|
||||
pub fn new(
|
||||
failed_backup: bool,
|
||||
battery_percentage: u8,
|
||||
firmware_version: TString<'static>,
|
||||
device_name: TString<'static>,
|
||||
// NB: we currently only support one device at a time.
|
||||
// if we ever increase this size, we will need a way to return the correct
|
||||
// device index on Disconnect back to uPy
|
||||
@ -163,6 +166,7 @@ impl<'a> DeviceMenuScreen<'a> {
|
||||
let mut screen = Self {
|
||||
bounds: Rect::zero(),
|
||||
battery_percentage,
|
||||
firmware_version,
|
||||
menu_screen: None,
|
||||
paired_device_screen: None,
|
||||
about_screen: None,
|
||||
@ -173,7 +177,7 @@ impl<'a> DeviceMenuScreen<'a> {
|
||||
|
||||
let about = screen.add_subscreen(Subscreen::AboutScreen);
|
||||
let security = screen.add_security_menu();
|
||||
let device = screen.add_device_menu("My device".into(), about); // TODO: device name
|
||||
let device = screen.add_device_menu(device_name, about);
|
||||
let settings = screen.add_settings_menu(security, device);
|
||||
|
||||
let mut paired_device_indices: Vec<usize, 1> = Vec::new();
|
||||
@ -407,7 +411,7 @@ impl<'a> DeviceMenuScreen<'a> {
|
||||
self.paired_device_screen = None;
|
||||
let about_content = Paragraphs::new([
|
||||
Paragraph::new(&theme::firmware::TEXT_REGULAR, "Firmware version"),
|
||||
Paragraph::new(&theme::firmware::TEXT_REGULAR, "2.3.1"), // TODO
|
||||
Paragraph::new(&theme::firmware::TEXT_REGULAR, self.firmware_version),
|
||||
]);
|
||||
|
||||
self.about_screen = Some(
|
||||
|
@ -786,11 +786,15 @@ impl FirmwareUI for UIEckhart {
|
||||
fn show_device_menu(
|
||||
failed_backup: bool,
|
||||
battery_percentage: u8,
|
||||
firmware_version: TString<'static>,
|
||||
device_name: TString<'static>,
|
||||
paired_devices: Vec<TString<'static>, 1>,
|
||||
) -> Result<impl LayoutMaybeTrace, Error> {
|
||||
let layout = RootComponent::new(DeviceMenuScreen::new(
|
||||
failed_backup,
|
||||
battery_percentage,
|
||||
firmware_version,
|
||||
device_name,
|
||||
paired_devices,
|
||||
));
|
||||
Ok(layout)
|
||||
|
@ -306,6 +306,8 @@ pub trait FirmwareUI {
|
||||
fn show_device_menu(
|
||||
failed_backup: bool,
|
||||
battery_percentage: u8,
|
||||
firmware_version: TString<'static>,
|
||||
device_name: TString<'static>,
|
||||
paired_devices: Vec<TString<'static>, 1>,
|
||||
) -> Result<impl LayoutMaybeTrace, Error>;
|
||||
|
||||
|
@ -537,6 +537,8 @@ def show_device_menu(
|
||||
*,
|
||||
failed_backup: bool,
|
||||
battery_percentage: int,
|
||||
firmware_version: str,
|
||||
device_name: str,
|
||||
paired_devices: Iterable[str],
|
||||
) -> LayoutObj[UiResult]:
|
||||
"""Show the device menu."""
|
||||
|
@ -60,10 +60,11 @@ async def homescreen() -> None:
|
||||
obj.__del__()
|
||||
|
||||
if res is trezorui_api.INFO:
|
||||
|
||||
# MOCK DATA
|
||||
failed_backup = True
|
||||
battery_percentage = 22
|
||||
firmware_version = "2.3.1"
|
||||
device_name = "My Trezor"
|
||||
paired_devices = ["Suite on my de-Googled Phone"]
|
||||
#
|
||||
|
||||
@ -71,6 +72,8 @@ async def homescreen() -> None:
|
||||
trezorui_api.show_device_menu(
|
||||
failed_backup=failed_backup,
|
||||
battery_percentage=battery_percentage,
|
||||
firmware_version=firmware_version,
|
||||
device_name=device_name,
|
||||
paired_devices=paired_devices,
|
||||
),
|
||||
"device_menu",
|
||||
@ -80,7 +83,7 @@ async def homescreen() -> None:
|
||||
|
||||
await raise_if_not_confirmed(
|
||||
trezorui_api.show_pairing_device_name(
|
||||
device_name="My Trez",
|
||||
device_name=device_name,
|
||||
),
|
||||
"device_name",
|
||||
)
|
||||
|
Loading…
Reference in New Issue
Block a user