mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-06-20 15:08:46 +00:00
refactor(core): device menu modules
[no changelog]
This commit is contained in:
parent
07424f1625
commit
2e5513eb9c
@ -657,7 +657,11 @@ if FROZEN:
|
|||||||
))
|
))
|
||||||
if PYOPT == '0':
|
if PYOPT == '0':
|
||||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/debug/*.py'))
|
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',
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/management/*.py',
|
||||||
exclude=[
|
exclude=[
|
||||||
SOURCE_PY_DIR + 'apps/management/sd_protect.py',
|
SOURCE_PY_DIR + 'apps/management/sd_protect.py',
|
||||||
|
@ -712,7 +712,11 @@ if FROZEN:
|
|||||||
))
|
))
|
||||||
if PYOPT == '0':
|
if PYOPT == '0':
|
||||||
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/debug/*.py'))
|
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',
|
SOURCE_PY.extend(Glob(SOURCE_PY_DIR + 'apps/management/*.py',
|
||||||
exclude=[
|
exclude=[
|
||||||
SOURCE_PY_DIR + 'apps/management/sd_protect.py',
|
SOURCE_PY_DIR + 'apps/management/sd_protect.py',
|
||||||
|
@ -4,9 +4,8 @@ import storage
|
|||||||
import storage.cache
|
import storage.cache
|
||||||
import storage.device
|
import storage.device
|
||||||
import trezorui_api
|
import trezorui_api
|
||||||
from trezor import config, wire
|
from trezor import config, utils, wire
|
||||||
from trezor.enums import MessageType
|
from trezor.enums import MessageType
|
||||||
from trezor.ui.layouts import raise_if_not_confirmed
|
|
||||||
from trezor.ui.layouts.homescreen import Busyscreen, Homescreen, Lockscreen
|
from trezor.ui.layouts.homescreen import Busyscreen, Homescreen, Lockscreen
|
||||||
|
|
||||||
from apps.base import busy_expiry_ms, lock_device
|
from apps.base import busy_expiry_ms, lock_device
|
||||||
@ -59,42 +58,12 @@ async def homescreen() -> None:
|
|||||||
finally:
|
finally:
|
||||||
obj.__del__()
|
obj.__del__()
|
||||||
|
|
||||||
if res is trezorui_api.INFO:
|
if utils.INTERNAL_MODEL == "T3W1":
|
||||||
# MOCK DATA
|
if res is trezorui_api.INFO:
|
||||||
failed_backup = True
|
from .device_menu import handle_device_menu
|
||||||
battery_percentage = 22
|
|
||||||
firmware_version = "2.3.1"
|
|
||||||
device_name = "My Trezor"
|
|
||||||
paired_devices = ["Suite on my de-Googled Phone"]
|
|
||||||
#
|
|
||||||
|
|
||||||
menu_result = await raise_if_not_confirmed(
|
return await handle_device_menu()
|
||||||
trezorui_api.show_device_menu(
|
lock_device()
|
||||||
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()
|
|
||||||
|
|
||||||
|
|
||||||
async def _lockscreen(screensaver: bool = False) -> None:
|
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