diff --git a/src/apps/common/storage.py b/src/apps/common/storage.py index 3d51a6f333..7e77e18d34 100644 --- a/src/apps/common/storage.py +++ b/src/apps/common/storage.py @@ -14,12 +14,13 @@ _VERSION = const(0x01) # int _MNEMONIC = const(0x02) # str _LANGUAGE = const(0x03) # str _LABEL = const(0x04) # str -_USE_PASSPHRASE = const(0x05) # 0x01 or empty +_USE_PASSPHRASE = const(0x05) # bool (0x01 or empty) _HOMESCREEN = const(0x06) # bytes -_NEEDS_BACKUP = const(0x07) # 0x01 or empty +_NEEDS_BACKUP = const(0x07) # bool (0x01 or empty) _FLAGS = const(0x08) # int _U2F_COUNTER = const(0x09) # int _PASSPHRASE_SOURCE = const(0x0A) # int +_UNFINISHED_BACKUP = const(0x0B) # bool (0x01 or empty) def _new_device_id() -> str: @@ -71,6 +72,17 @@ def set_backed_up() -> None: 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: b = config.get(_APP, _PASSPHRASE_SOURCE) if b == b'\x01': diff --git a/src/apps/homescreen/__init__.py b/src/apps/homescreen/__init__.py index 7cb3fd80b6..a32129362c 100644 --- a/src/apps/homescreen/__init__.py +++ b/src/apps/homescreen/__init__.py @@ -33,6 +33,7 @@ async def respond_Features(ctx, msg): f.flags = storage.get_flags() if model() in ['T', 'EMU']: # emulator currently emulates model T f.model = 'T' + f.unfinished_backup = storage.unfinished_backup() return f diff --git a/src/apps/homescreen/homescreen.py b/src/apps/homescreen/homescreen.py index 86e790901e..2cd959186a 100644 --- a/src/apps/homescreen/homescreen.py +++ b/src/apps/homescreen/homescreen.py @@ -22,7 +22,11 @@ def display_homescreen(): if not image: 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.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) diff --git a/src/apps/management/backup_device.py b/src/apps/management/backup_device.py index 3641d0a5d6..6eb8bd4c72 100644 --- a/src/apps/management/backup_device.py +++ b/src/apps/management/backup_device.py @@ -17,6 +17,7 @@ async def backup_device(ctx, msg): # warn user about mnemonic safety await show_warning(ctx) + storage.set_unfinished_backup(True) storage.set_backed_up() while True: @@ -26,4 +27,6 @@ async def backup_device(ctx, msg): break await show_wrong_entry(ctx) + storage.set_unfinished_backup(False) + return Success(message='Seed successfully backed up') diff --git a/src/trezor/messages/Features.py b/src/trezor/messages/Features.py index 0c908ae27c..d108d0316d 100644 --- a/src/trezor/messages/Features.py +++ b/src/trezor/messages/Features.py @@ -31,6 +31,7 @@ class Features(p.MessageType): 24: ('fw_patch', p.UVarintType, 0), 25: ('fw_vendor', p.UnicodeType, 0), 26: ('fw_vendor_keys', p.BytesType, 0), + 27: ('unfinished_backup', p.BoolType, 0), } MESSAGE_WIRE_TYPE = 17 @@ -62,6 +63,7 @@ class Features(p.MessageType): fw_patch: int = None, fw_vendor: str = None, fw_vendor_keys: bytes = None, + unfinished_backup: bool = None, **kwargs, ): self.vendor = vendor @@ -90,4 +92,5 @@ class Features(p.MessageType): self.fw_patch = fw_patch self.fw_vendor = fw_vendor self.fw_vendor_keys = fw_vendor_keys + self.unfinished_backup = unfinished_backup p.MessageType.__init__(self, **kwargs) diff --git a/vendor/trezor-common b/vendor/trezor-common index 998eb4c7a7..d83bb5464c 160000 --- a/vendor/trezor-common +++ b/vendor/trezor-common @@ -1 +1 @@ -Subproject commit 998eb4c7a76bdb5190f5f9f52bf8c53d795fbb25 +Subproject commit d83bb5464c4efc1e90c9575dd3088333d1066f5f