mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-07-23 06:58:13 +00:00
feat(core/rust): loading UI2 homescreen bg from storage
[no changelog]
This commit is contained in:
parent
737b8d4230
commit
8a034b0960
@ -16,6 +16,7 @@ mod trezorhal;
|
||||
mod micropython;
|
||||
#[cfg(feature = "protobuf")]
|
||||
mod protobuf;
|
||||
mod storage;
|
||||
mod time;
|
||||
#[cfg(feature = "ui_debug")]
|
||||
mod trace;
|
||||
|
55
core/embed/rust/src/storage/mod.rs
Normal file
55
core/embed/rust/src/storage/mod.rs
Normal file
@ -0,0 +1,55 @@
|
||||
use crate::{
|
||||
micropython::ffi,
|
||||
trezorhal::storage::{get, get_length},
|
||||
};
|
||||
use core::slice;
|
||||
|
||||
const STORAGE_VERSION_01: u8 = 1;
|
||||
const STORAGE_VERSION_02: u8 = 2;
|
||||
const STORAGE_VERSION_CURRENT: u8 = STORAGE_VERSION_02;
|
||||
|
||||
const FLAG_PUBLIC: u16 = 0x8000;
|
||||
const FLAG_WRITE: u16 = 0xC000;
|
||||
const APP_DEVICE: u16 = 0x0100;
|
||||
|
||||
const DEVICE_ID: u16 = FLAG_PUBLIC | APP_DEVICE;
|
||||
const VERSION: u16 = APP_DEVICE | 0x0001;
|
||||
const MNEMONIC_SECRET: u16 = APP_DEVICE | 0x0002;
|
||||
// NOTE: 0x03 key was used in the past for LANGUAGE. Not used anymore.
|
||||
const LABEL: u16 = FLAG_PUBLIC | APP_DEVICE | 0x0004;
|
||||
const USE_PASSPHRASE: u16 = APP_DEVICE | 0x0005;
|
||||
const HOMESCREEN: u16 = FLAG_PUBLIC | APP_DEVICE | 0x0006;
|
||||
const NEEDS_BACKUP: u16 = APP_DEVICE | 0x0007;
|
||||
const FLAGS: u16 = APP_DEVICE | 0x0008;
|
||||
const U2F_COUNTER_PRIVATE: u16 = APP_DEVICE | 0x0009;
|
||||
const U2F_COUNTER: u16 = FLAG_PUBLIC | APP_DEVICE | 0x0009;
|
||||
const PASSPHRASE_ALWAYS_ON_DEVICE: u16 = APP_DEVICE | 0x000A;
|
||||
const UNFINISHED_BACKUP: u16 = APP_DEVICE | 0x000B;
|
||||
const AUTOLOCK_DELAY_MS: u16 = APP_DEVICE | 0x000C;
|
||||
const NO_BACKUP: u16 = APP_DEVICE | 0x000D;
|
||||
const BACKUP_TYPE: u16 = APP_DEVICE | 0x000E;
|
||||
const ROTATION: u16 = FLAG_PUBLIC | APP_DEVICE | 0x000F;
|
||||
const SLIP39_IDENTIFIER: u16 = APP_DEVICE | 0x0010;
|
||||
const SLIP39_ITERATION_EXPONENT: u16 = APP_DEVICE | 0x0011;
|
||||
const SD_SALT_AUTH_KEY: u16 = FLAG_PUBLIC | APP_DEVICE | 0x0012;
|
||||
const INITIALIZED: u16 = FLAG_PUBLIC | APP_DEVICE | 0x0013;
|
||||
const SAFETY_CHECK_LEVEL: u16 = APP_DEVICE | 0x0014;
|
||||
const EXPERIMENTAL_FEATURES: u16 = APP_DEVICE | 0x0015;
|
||||
|
||||
pub fn get_avatar() -> Result<&'static mut [u8], ()> {
|
||||
let avatar_len_res = get_length(HOMESCREEN);
|
||||
|
||||
return if let Ok(len) = avatar_len_res {
|
||||
let data_ptr_raw = unsafe { ffi::gc_alloc(len, 0) };
|
||||
let buffer = unsafe { slice::from_raw_parts_mut(data_ptr_raw as _, len) };
|
||||
|
||||
if len <= buffer.len() {
|
||||
unwrap!(get(HOMESCREEN, buffer));
|
||||
Ok(&mut buffer[..len])
|
||||
} else {
|
||||
Err(())
|
||||
}
|
||||
} else {
|
||||
Err(())
|
||||
};
|
||||
}
|
@ -1,4 +1,5 @@
|
||||
use crate::{
|
||||
storage::get_avatar,
|
||||
time::{Duration, Instant},
|
||||
trezorhal::usb::usb_configured,
|
||||
ui::{
|
||||
@ -188,7 +189,7 @@ where
|
||||
let notification = self.get_notification();
|
||||
|
||||
homescreen(
|
||||
IMAGE_HOMESCREEN,
|
||||
get_image(),
|
||||
texts,
|
||||
notification,
|
||||
self.paint_notification_only,
|
||||
@ -269,7 +270,15 @@ where
|
||||
None,
|
||||
],));
|
||||
|
||||
homescreen(IMAGE_HOMESCREEN, texts, None, false);
|
||||
homescreen(get_image(), texts, None, false);
|
||||
}
|
||||
}
|
||||
|
||||
fn get_image() -> &'static [u8] {
|
||||
if let Ok(data) = get_avatar() {
|
||||
data
|
||||
} else {
|
||||
IMAGE_HOMESCREEN
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user