1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-27 01:48:17 +00:00

storage: implement unfinished_backup flag

This commit is contained in:
Pavol Rusnak 2018-04-04 12:42:52 +02:00
parent 27443a06c8
commit 399706ae22
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
5 changed files with 25 additions and 1 deletions

View File

@ -313,6 +313,7 @@ void fsm_msgGetFeatures(GetFeatures *msg)
resp->has_pin_cached = true; resp->pin_cached = session_isPinCached(); resp->has_pin_cached = true; resp->pin_cached = session_isPinCached();
resp->has_passphrase_cached = true; resp->passphrase_cached = session_isPassphraseCached(); resp->has_passphrase_cached = true; resp->passphrase_cached = session_isPassphraseCached();
resp->has_needs_backup = true; resp->needs_backup = storage_needsBackup(); resp->has_needs_backup = true; resp->needs_backup = storage_needsBackup();
resp->unfinished_backup = true; resp->unfinished_backup = storage_unfinishedBackup();
resp->has_flags = true; resp->flags = storage_getFlags(); resp->has_flags = true; resp->flags = storage_getFlags();
resp->has_model = true; strlcpy(resp->model, "1", sizeof(resp->model)); resp->has_model = true; strlcpy(resp->model, "1", sizeof(resp->model));

View File

@ -230,6 +230,10 @@ void layoutHome(void)
oledDrawBitmap(40, 0, &bmp_logo64); oledDrawBitmap(40, 0, &bmp_logo64);
} }
} }
if (storage_unfinishedBackup()) {
oledBox(0, 0, 127, 8, false);
oledDrawStringCenter(0, "BACKUP FAILED!", FONT_STANDARD);
} else
if (storage_needsBackup()) { if (storage_needsBackup()) {
oledBox(0, 0, 127, 8, false); oledBox(0, 0, 127, 8, false);
oledDrawStringCenter(0, "NEEDS BACKUP!", FONT_STANDARD); oledDrawStringCenter(0, "NEEDS BACKUP!", FONT_STANDARD);

View File

@ -113,6 +113,7 @@ void reset_backup(bool separated)
return; return;
} }
storage_setUnfinishedBackup(true);
storage_setNeedsBackup(false); storage_setNeedsBackup(false);
if (separated) { if (separated) {
@ -148,6 +149,8 @@ void reset_backup(bool separated)
} }
} }
storage_setUnfinishedBackup(false);
if (separated) { if (separated) {
fsm_sendSuccess(_("Seed successfully backed up")); fsm_sendSuccess(_("Seed successfully backed up"));
} else { } else {

View File

@ -173,7 +173,7 @@ bool storage_from_flash(void)
// added flags and needsBackup // added flags and needsBackup
old_storage_size = OLD_STORAGE_SIZE(flags); old_storage_size = OLD_STORAGE_SIZE(flags);
} else if (version <= 9) { } else if (version <= 9) {
// added u2froot and auto_lock_delay_ms // added u2froot, unfinished_backup and auto_lock_delay_ms
old_storage_size = OLD_STORAGE_SIZE(auto_lock_delay_ms); old_storage_size = OLD_STORAGE_SIZE(auto_lock_delay_ms);
} }
@ -830,6 +830,18 @@ void storage_setNeedsBackup(bool needs_backup)
storageUpdate.needs_backup = needs_backup; storageUpdate.needs_backup = needs_backup;
} }
bool storage_unfinishedBackup(void)
{
return storageUpdate.has_unfinished_backup ? storageUpdate.unfinished_backup
: storageRom->has_unfinished_backup && storageRom->unfinished_backup;
}
void storage_setUnfinishedBackup(bool unfinished_backup)
{
storageUpdate.has_unfinished_backup = true;
storageUpdate.unfinished_backup = unfinished_backup;
}
void storage_applyFlags(uint32_t flags) void storage_applyFlags(uint32_t flags)
{ {
if ((storageRom->flags | flags) == storageRom->flags) { if ((storageRom->flags | flags) == storageRom->flags) {

View File

@ -72,6 +72,7 @@ typedef struct _Storage {
STORAGE_BOOL (needs_backup) STORAGE_BOOL (needs_backup)
STORAGE_UINT32 (flags) STORAGE_UINT32 (flags)
STORAGE_NODE (u2froot) STORAGE_NODE (u2froot)
STORAGE_BOOL (unfinished_backup)
STORAGE_UINT32 (auto_lock_delay_ms) STORAGE_UINT32 (auto_lock_delay_ms)
} Storage; } Storage;
@ -139,6 +140,9 @@ void storage_setImported(bool imported);
bool storage_needsBackup(void); bool storage_needsBackup(void);
void storage_setNeedsBackup(bool needs_backup); void storage_setNeedsBackup(bool needs_backup);
bool storage_unfinishedBackup(void);
void storage_setUnfinishedBackup(bool unfinished_backup);
void storage_applyFlags(uint32_t flags); void storage_applyFlags(uint32_t flags);
uint32_t storage_getFlags(void); uint32_t storage_getFlags(void);