mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-04-21 17:49:02 +00:00
refactor(core): device menu modules
[no changelog]
This commit is contained in:
parent
8db5278a6c
commit
38a0a8c0e2
@ -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',
|
||||
|
@ -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',
|
||||
|
@ -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:
|
||||
|
31
core/src/apps/homescreen/device_menu.py
Normal file
31
core/src/apps/homescreen/device_menu.py
Normal file
@ -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}")
|
17
core/src/apps/management/ble/pair_new_device.py
Normal file
17
core/src/apps/management/ble/pair_new_device.py
Normal file
@ -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,
|
||||
)
|
Loading…
Reference in New Issue
Block a user