diff --git a/src/apps/common/storage.py b/src/apps/common/storage.py index 6edc70f6..5b216485 100644 --- a/src/apps/common/storage.py +++ b/src/apps/common/storage.py @@ -11,6 +11,7 @@ _MNEMONIC = const(0x0002) # str _LANGUAGE = const(0x0003) # str _LABEL = const(0x0004) # str _USE_PASSPHRASE = const(0x0005) # 0x01 or empty +_HOMESCREEN = const(0x0006) # bytes def get_device_id() -> str: @@ -37,18 +38,27 @@ def has_passphrase() -> bool: return bool(config.get(_APP, _USE_PASSPHRASE)) +def get_homescreen() -> bytes: + return config.get(_APP, _HOMESCREEN) + + def load_mnemonic(mnemonic: str): config.set(_APP, _VERSION, _STORAGE_VERSION) config.set(_APP, _MNEMONIC, mnemonic.encode()) -def load_settings(label: str = None, use_passphrase: bool = None): +def load_settings(label: str=None, use_passphrase: bool=None, homescreen: bytes=None): if label is not None: config.set(_APP, _LABEL, label.encode()) if use_passphrase is True: config.set(_APP, _USE_PASSPHRASE, b'\x01') if use_passphrase is False: config.set(_APP, _USE_PASSPHRASE, b'') + if homescreen is not None: + if homescreen[:8] == b'TOIf\x90\x00\x90\x00': + config.set(_APP, _HOMESCREEN, homescreen) + else: + config.set(_APP, _HOMESCREEN, b'') def wipe(): diff --git a/src/apps/homescreen/homescreen.py b/src/apps/homescreen/homescreen.py index 42e8d5b4..b514915b 100644 --- a/src/apps/homescreen/homescreen.py +++ b/src/apps/homescreen/homescreen.py @@ -20,14 +20,18 @@ async def dim_screen(): async def display_homescreen(): from apps.common import storage - image = res.load('apps/homescreen/res/homescreen.toif') - ui.display.bar(0, 0, ui.SCREEN, ui.SCREEN, ui.BG) - ui.display.avatar((ui.SCREEN - 144) // 2, (ui.SCREEN - 144) // 2 - 10, image, ui.WHITE, ui.BLACK) - if not storage.is_initialized(): label = 'Go to trezor.io/start' + image = None else: label = storage.get_label() or 'My TREZOR' + image = storage.get_homescreen() + + if not image: + image = res.load('apps/homescreen/res/homescreen.toif') + + ui.display.bar(0, 0, ui.SCREEN, ui.SCREEN, ui.BG) + ui.display.avatar((ui.SCREEN - 144) // 2, (ui.SCREEN - 144) // 2 - 10, image, ui.WHITE, ui.BLACK) ui.display.text_center(ui.SCREEN // 2, ui.SCREEN - 20, label, ui.BOLD, ui.FG, ui.BG) await dim_screen() diff --git a/src/apps/management/apply_settings.py b/src/apps/management/apply_settings.py index 8718eeaf..098477ff 100644 --- a/src/apps/management/apply_settings.py +++ b/src/apps/management/apply_settings.py @@ -10,18 +10,20 @@ async def layout_apply_settings(ctx, msg): from ..common.confirm import require_confirm from ..common import storage - if msg.homescreen is not None: - raise wire.FailureError( - ProcessError, 'ApplySettings.homescreen is not supported') - - if msg.label is None and msg.language is None and msg.use_passphrase is None: + if msg.homescreen is None and msg.label is None and msg.language is None and msg.use_passphrase is None: raise wire.FailureError(ProcessError, 'No setting provided') + if msg.homescreen is not None: + await require_confirm(ctx, Text( + 'Change homescreen', ui.ICON_RESET, + 'Do you really want to', 'change homescreen?')) + if msg.label is not None: await require_confirm(ctx, Text( 'Change label', ui.ICON_RESET, 'Do you really want to', 'change label to', - ui.BOLD, '%s' % msg.label)) + ui.BOLD, '%s' % msg.label, + ui.NORMAL, '?')) if msg.language is not None: await require_confirm(ctx, Text( @@ -39,6 +41,7 @@ async def layout_apply_settings(ctx, msg): 'encryption?')) storage.load_settings(label=msg.label, - use_passphrase=msg.use_passphrase) + use_passphrase=msg.use_passphrase, + homescreen=msg.homescreen) return Success(message='Settings applied')