1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-23 06:48:16 +00:00

storage: allow auto-lock delay configuration

This commit is contained in:
Roman Zeyde 2018-03-13 12:35:49 +02:00 committed by Pavol Rusnak
parent 2553fdb11f
commit 987b686f63
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
3 changed files with 20 additions and 4 deletions

View File

@ -173,8 +173,8 @@ bool storage_from_flash(void)
// added flags and needsBackup
old_storage_size = OLD_STORAGE_SIZE(flags);
} else if (version <= 9) {
// added u2froot
old_storage_size = OLD_STORAGE_SIZE(u2froot);
// added u2froot and auto_lock_delay_ms
old_storage_size = OLD_STORAGE_SIZE(auto_lock_delay_ms);
}
// erase newly added fields
@ -868,6 +868,18 @@ void storage_setU2FCounter(uint32_t u2fcounter)
storageUpdate.u2f_counter = u2fcounter - storage_u2f_offset;
}
uint32_t storage_getAutoLockDelayMs()
{
return storageRom->has_auto_lock_delay_ms ? storageRom->auto_lock_delay_ms : (10*60*1000U);
}
void storage_setAutoLockDelayMs(uint32_t auto_lock_delay_ms)
{
storageUpdate.has_auto_lock_delay_ms = true;
auto_lock_delay_ms = MAX(auto_lock_delay_ms, 60*1000U);
storageUpdate.auto_lock_delay_ms = auto_lock_delay_ms;
}
void storage_wipe(void)
{
session_clear(true);

View File

@ -72,6 +72,7 @@ typedef struct _Storage {
STORAGE_BOOL (needs_backup)
STORAGE_UINT32 (flags)
STORAGE_NODE (u2froot)
STORAGE_UINT32 (auto_lock_delay_ms)
} Storage;
extern Storage storageUpdate;
@ -141,6 +142,9 @@ void storage_setNeedsBackup(bool needs_backup);
void storage_applyFlags(uint32_t flags);
uint32_t storage_getFlags(void);
uint32_t storage_getAutoLockDelayMs(void);
void storage_setAutoLockDelayMs(uint32_t auto_lock_delay_ms);
void storage_wipe(void);
extern char storage_uuid_str[25];

View File

@ -74,9 +74,9 @@ void check_lock_screen(void)
}
}
// if homescreen is shown for longer than 10 minutes, lock too
// if homescreen is shown for too long
if (layoutLast == layoutHome) {
if ((timer_ms() - system_millis_lock_start) >= 600000) {
if ((timer_ms() - system_millis_lock_start) >= storage_getAutoLockDelayMs()) {
// lock the screen
session_clear(true);
layoutScreensaver();