add a menu item to show a test QR code

this is useful for testing inter-device QR code scanning.
This commit is contained in:
bunnie 2026-01-28 15:10:15 +08:00
parent 3b0edbb442
commit b84ff3d351
4 changed files with 23 additions and 0 deletions

View file

@ -1444,6 +1444,10 @@ impl ActionManager {
.ok();
}
}
} else {
let mut qr_str = String::from(t!("vault.error.qr", locales::LANG));
qr_str.push_str(&format!(": {}", &qr_uri));
self.modals.show_notification(&qr_str, None).ok();
}
}
}

View file

@ -536,6 +536,16 @@ fn main() -> ! {
)
.ok();
}
Some(VaultOp::ShowQr) => {
let previous = allow_totp_rendering.load(Ordering::SeqCst);
allow_totp_rendering.store(false, Ordering::SeqCst);
let mut test_data = [0u8; 40];
let mut trng = bao1x_hal_service::trng::Trng::new(&xns).unwrap();
trng.fill_bytes_via_next(&mut test_data);
let encoded = base45::encode(&test_data);
modals.show_notification("", Some(&encoded)).ok();
allow_totp_rendering.store(previous, Ordering::SeqCst);
}
_ => {
log::error!("Got unknown message: {:?}", msg);
}

View file

@ -52,6 +52,13 @@ pub fn create_submenu(vault_conn: xous::CID, actions_conn: xous::CID, menu_mgr:
action_payload: MenuPayload::Scalar([0, 0, 0, 0]),
close_on_select: true,
});
menu_items.push(MenuItem {
name: String::from("Test QR code"),
action_conn: Some(vault_conn),
action_opcode: VaultOp::ShowQr.to_u32().unwrap(),
action_payload: MenuPayload::Scalar([0, 0, 0, 0]),
close_on_select: true,
});
menu_items.push(MenuItem {
name: String::from(t!("vault.menu_close", locales::LANG)),
action_conn: Some(actions_conn),

View file

@ -42,6 +42,8 @@ pub(crate) enum VaultOp {
MenuPwMode,
BasisChange,
ShowQr,
}
pub fn atime_to_str(req_atime: u64) -> String {