diff --git a/core/SConscript.firmware b/core/SConscript.firmware index f580009b26..d0fefae55a 100644 --- a/core/SConscript.firmware +++ b/core/SConscript.firmware @@ -632,7 +632,11 @@ if FROZEN: ] if not SDCARD else [] )) SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/debug/*.py')) - SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/homescreen/*.py')) + SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/homescreen/*.py', + exclude=[ + SOURCE_PY_DIR + 'apps/homescreen/device_menu.py', + ] if TREZOR_MODEL != "T3W1" else []) + ) SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/management/*.py', exclude=[ SOURCE_PY_DIR + 'apps/management/sd_protect.py', diff --git a/core/SConscript.unix b/core/SConscript.unix index d2d60cb566..c08778d10a 100644 --- a/core/SConscript.unix +++ b/core/SConscript.unix @@ -686,7 +686,11 @@ if FROZEN: ] if "sd_card" not in FEATURES_AVAILABLE else [] )) SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/debug/*.py')) - SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/homescreen/*.py')) + SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/homescreen/*.py', + exclude=[ + SOURCE_PY_DIR + 'apps/homescreen/device_menu.py', + ] if TREZOR_MODEL != "T3W1" else []) + ) SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/management/*.py', exclude=[ SOURCE_PY_DIR + 'apps/management/sd_protect.py', diff --git a/core/src/apps/homescreen/__init__.py b/core/src/apps/homescreen/__init__.py index 7fe9c0bff3..06c814a17d 100644 --- a/core/src/apps/homescreen/__init__.py +++ b/core/src/apps/homescreen/__init__.py @@ -4,9 +4,8 @@ import storage import storage.cache import storage.device import trezorui_api -from trezor import config, wire +from trezor import config, utils, wire from trezor.enums import MessageType -from trezor.ui.layouts import raise_if_not_confirmed from trezor.ui.layouts.homescreen import Busyscreen, Homescreen, Lockscreen from apps.base import busy_expiry_ms, lock_device @@ -59,42 +58,12 @@ async def homescreen() -> None: finally: obj.__del__() - if res is trezorui_api.INFO: - # MOCK DATA - failed_backup = True - battery_percentage = 22 - firmware_version = "2.3.1" - device_name = "My Trezor" - paired_devices = ["Suite on my de-Googled Phone"] - # + if utils.INTERNAL_MODEL == "T3W1": + if res is trezorui_api.INFO: + from .device_menu import handle_device_menu - menu_result = await raise_if_not_confirmed( - trezorui_api.show_device_menu( - failed_backup=failed_backup, - battery_percentage=battery_percentage, - firmware_version=firmware_version, - device_name=device_name, - paired_devices=paired_devices, - ), - "device_menu", - ) - print(menu_result) - if menu_result == "DevicePair": - - await raise_if_not_confirmed( - trezorui_api.show_pairing_device_name( - device_name=device_name, - ), - "device_name", - ) - await raise_if_not_confirmed( - trezorui_api.show_pairing_code( - code="123456", - ), - "pairing_code", - ) - else: - lock_device() + return await handle_device_menu() + lock_device() async def _lockscreen(screensaver: bool = False) -> None: diff --git a/core/src/apps/homescreen/device_menu.py b/core/src/apps/homescreen/device_menu.py new file mode 100644 index 0000000000..4d84cbde8a --- /dev/null +++ b/core/src/apps/homescreen/device_menu.py @@ -0,0 +1,31 @@ +import storage.device +import trezorui_api +from trezor import utils +from trezor.ui.layouts import raise_if_not_confirmed + + +async def handle_device_menu() -> None: + # MOCK DATA + failed_backup = True + battery_percentage = 22 + paired_devices = ["Trezor Suite"] + # ### + firmware_version = ".".join(map(str, utils.VERSION)) + device_name = storage.device.get_label() or "Trezor" + + menu_result = await raise_if_not_confirmed( + trezorui_api.show_device_menu( + failed_backup=failed_backup, + battery_percentage=battery_percentage, + paired_devices=paired_devices, + firmware_version=firmware_version, + device_name=device_name, + ), + None, + ) + if menu_result == "DevicePair": + from apps.management.ble.pair_new_device import pair_new_device + + await pair_new_device() + else: + raise RuntimeError(f"Unknown menu {menu_result}") diff --git a/core/src/apps/management/ble/pair_new_device.py b/core/src/apps/management/ble/pair_new_device.py new file mode 100644 index 0000000000..d80daf0524 --- /dev/null +++ b/core/src/apps/management/ble/pair_new_device.py @@ -0,0 +1,17 @@ +import trezorui_api +from trezor.ui.layouts import interact + + +async def pair_new_device() -> None: + label = "Trezor T3W1" + await interact( + trezorui_api.show_pairing_device_name(device_name=label), + None, + raise_on_cancel=None, # for UI testing + ) + + code = 12345 + await interact( + trezorui_api.show_pairing_code(code=f"{code:0>6}"), + None, + )