mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-07-05 14:22:33 +00:00
src/apps/common: implement unfinished_backup flag in the storage
This commit is contained in:
parent
e6bfd192e5
commit
b83ffee3af
@ -14,12 +14,13 @@ _VERSION = const(0x01) # int
|
|||||||
_MNEMONIC = const(0x02) # str
|
_MNEMONIC = const(0x02) # str
|
||||||
_LANGUAGE = const(0x03) # str
|
_LANGUAGE = const(0x03) # str
|
||||||
_LABEL = const(0x04) # str
|
_LABEL = const(0x04) # str
|
||||||
_USE_PASSPHRASE = const(0x05) # 0x01 or empty
|
_USE_PASSPHRASE = const(0x05) # bool (0x01 or empty)
|
||||||
_HOMESCREEN = const(0x06) # bytes
|
_HOMESCREEN = const(0x06) # bytes
|
||||||
_NEEDS_BACKUP = const(0x07) # 0x01 or empty
|
_NEEDS_BACKUP = const(0x07) # bool (0x01 or empty)
|
||||||
_FLAGS = const(0x08) # int
|
_FLAGS = const(0x08) # int
|
||||||
_U2F_COUNTER = const(0x09) # int
|
_U2F_COUNTER = const(0x09) # int
|
||||||
_PASSPHRASE_SOURCE = const(0x0A) # int
|
_PASSPHRASE_SOURCE = const(0x0A) # int
|
||||||
|
_UNFINISHED_BACKUP = const(0x0B) # bool (0x01 or empty)
|
||||||
|
|
||||||
|
|
||||||
def _new_device_id() -> str:
|
def _new_device_id() -> str:
|
||||||
@ -71,6 +72,17 @@ def set_backed_up() -> None:
|
|||||||
config.set(_APP, _NEEDS_BACKUP, b'')
|
config.set(_APP, _NEEDS_BACKUP, b'')
|
||||||
|
|
||||||
|
|
||||||
|
def unfinished_backup() -> bool:
|
||||||
|
return bool(config.get(_APP, _UNFINISHED_BACKUP))
|
||||||
|
|
||||||
|
|
||||||
|
def set_unfinished_backup(state: bool) -> None:
|
||||||
|
if state:
|
||||||
|
config.set(_APP, _UNFINISHED_BACKUP, b'\x01')
|
||||||
|
else:
|
||||||
|
config.set(_APP, _UNFINISHED_BACKUP, b'')
|
||||||
|
|
||||||
|
|
||||||
def get_passphrase_source() -> int:
|
def get_passphrase_source() -> int:
|
||||||
b = config.get(_APP, _PASSPHRASE_SOURCE)
|
b = config.get(_APP, _PASSPHRASE_SOURCE)
|
||||||
if b == b'\x01':
|
if b == b'\x01':
|
||||||
|
@ -33,6 +33,7 @@ async def respond_Features(ctx, msg):
|
|||||||
f.flags = storage.get_flags()
|
f.flags = storage.get_flags()
|
||||||
if model() in ['T', 'EMU']: # emulator currently emulates model T
|
if model() in ['T', 'EMU']: # emulator currently emulates model T
|
||||||
f.model = 'T'
|
f.model = 'T'
|
||||||
|
f.unfinished_backup = storage.unfinished_backup()
|
||||||
|
|
||||||
return f
|
return f
|
||||||
|
|
||||||
|
@ -22,7 +22,11 @@ def display_homescreen():
|
|||||||
if not image:
|
if not image:
|
||||||
image = res.load('apps/homescreen/res/bg.toif')
|
image = res.load('apps/homescreen/res/bg.toif')
|
||||||
|
|
||||||
if storage.is_initialized() and storage.needs_backup():
|
if storage.is_initialized() and storage.unfinished_backup():
|
||||||
|
ui.display.bar(0, 0, ui.WIDTH, 30, ui.RED)
|
||||||
|
ui.display.text_center(ui.WIDTH // 2, 22, 'BROKEN BACKUP!', ui.BOLD, ui.WHITE, ui.RED)
|
||||||
|
ui.display.bar(0, 30, ui.WIDTH, ui.HEIGHT - 30, ui.BG)
|
||||||
|
elif storage.is_initialized() and storage.needs_backup():
|
||||||
ui.display.bar(0, 0, ui.WIDTH, 30, ui.YELLOW)
|
ui.display.bar(0, 0, ui.WIDTH, 30, ui.YELLOW)
|
||||||
ui.display.text_center(ui.WIDTH // 2, 22, 'NEEDS BACKUP!', ui.BOLD, ui.BLACK, ui.YELLOW)
|
ui.display.text_center(ui.WIDTH // 2, 22, 'NEEDS BACKUP!', ui.BOLD, ui.BLACK, ui.YELLOW)
|
||||||
ui.display.bar(0, 30, ui.WIDTH, ui.HEIGHT - 30, ui.BG)
|
ui.display.bar(0, 30, ui.WIDTH, ui.HEIGHT - 30, ui.BG)
|
||||||
|
@ -17,6 +17,7 @@ async def backup_device(ctx, msg):
|
|||||||
# warn user about mnemonic safety
|
# warn user about mnemonic safety
|
||||||
await show_warning(ctx)
|
await show_warning(ctx)
|
||||||
|
|
||||||
|
storage.set_unfinished_backup(True)
|
||||||
storage.set_backed_up()
|
storage.set_backed_up()
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
@ -26,4 +27,6 @@ async def backup_device(ctx, msg):
|
|||||||
break
|
break
|
||||||
await show_wrong_entry(ctx)
|
await show_wrong_entry(ctx)
|
||||||
|
|
||||||
|
storage.set_unfinished_backup(False)
|
||||||
|
|
||||||
return Success(message='Seed successfully backed up')
|
return Success(message='Seed successfully backed up')
|
||||||
|
@ -31,6 +31,7 @@ class Features(p.MessageType):
|
|||||||
24: ('fw_patch', p.UVarintType, 0),
|
24: ('fw_patch', p.UVarintType, 0),
|
||||||
25: ('fw_vendor', p.UnicodeType, 0),
|
25: ('fw_vendor', p.UnicodeType, 0),
|
||||||
26: ('fw_vendor_keys', p.BytesType, 0),
|
26: ('fw_vendor_keys', p.BytesType, 0),
|
||||||
|
27: ('unfinished_backup', p.BoolType, 0),
|
||||||
}
|
}
|
||||||
MESSAGE_WIRE_TYPE = 17
|
MESSAGE_WIRE_TYPE = 17
|
||||||
|
|
||||||
@ -62,6 +63,7 @@ class Features(p.MessageType):
|
|||||||
fw_patch: int = None,
|
fw_patch: int = None,
|
||||||
fw_vendor: str = None,
|
fw_vendor: str = None,
|
||||||
fw_vendor_keys: bytes = None,
|
fw_vendor_keys: bytes = None,
|
||||||
|
unfinished_backup: bool = None,
|
||||||
**kwargs,
|
**kwargs,
|
||||||
):
|
):
|
||||||
self.vendor = vendor
|
self.vendor = vendor
|
||||||
@ -90,4 +92,5 @@ class Features(p.MessageType):
|
|||||||
self.fw_patch = fw_patch
|
self.fw_patch = fw_patch
|
||||||
self.fw_vendor = fw_vendor
|
self.fw_vendor = fw_vendor
|
||||||
self.fw_vendor_keys = fw_vendor_keys
|
self.fw_vendor_keys = fw_vendor_keys
|
||||||
|
self.unfinished_backup = unfinished_backup
|
||||||
p.MessageType.__init__(self, **kwargs)
|
p.MessageType.__init__(self, **kwargs)
|
||||||
|
2
vendor/trezor-common
vendored
2
vendor/trezor-common
vendored
@ -1 +1 @@
|
|||||||
Subproject commit 998eb4c7a76bdb5190f5f9f52bf8c53d795fbb25
|
Subproject commit d83bb5464c4efc1e90c9575dd3088333d1066f5f
|
Loading…
Reference in New Issue
Block a user