mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-04-23 02:29:10 +00:00
refactor(core): device menu modules
[no changelog]
This commit is contained in:
parent
9a11cb5a1d
commit
61cca96645
@ -628,7 +628,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',
|
||||
|
@ -680,7 +680,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
core/src/all_modules.py
generated
4
core/src/all_modules.py
generated
@ -367,6 +367,8 @@ apps.debug.load_device
|
||||
import apps.debug.load_device
|
||||
apps.homescreen
|
||||
import apps.homescreen
|
||||
apps.homescreen.device_menu
|
||||
import apps.homescreen.device_menu
|
||||
apps.management.apply_flags
|
||||
import apps.management.apply_flags
|
||||
apps.management.apply_settings
|
||||
@ -375,6 +377,8 @@ apps.management.authenticate_device
|
||||
import apps.management.authenticate_device
|
||||
apps.management.backup_device
|
||||
import apps.management.backup_device
|
||||
apps.management.ble.pair_new_device
|
||||
import apps.management.ble.pair_new_device
|
||||
apps.management.change_language
|
||||
import apps.management.change_language
|
||||
apps.management.change_pin
|
||||
|
@ -3,9 +3,8 @@ from typing import Coroutine
|
||||
import storage
|
||||
import storage.cache
|
||||
import storage.device
|
||||
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
|
||||
@ -22,7 +21,7 @@ async def busyscreen() -> None:
|
||||
|
||||
async def homescreen() -> None:
|
||||
from trezor import TR
|
||||
from trezorui_api import INFO, show_device_menu
|
||||
from trezorui_api import INFO
|
||||
|
||||
if storage.device.is_initialized():
|
||||
label = storage.device.get_label()
|
||||
@ -56,36 +55,16 @@ async def homescreen() -> None:
|
||||
)
|
||||
try:
|
||||
res = await obj.get_result()
|
||||
if res is INFO:
|
||||
|
||||
##### MOCK DATA
|
||||
failed_backup = True
|
||||
battery_percentage = 22
|
||||
paired_devices = ["Suite on my de-Googled Phone"]
|
||||
#####
|
||||
|
||||
menu_result = await raise_if_not_confirmed(show_device_menu(failed_backup=failed_backup, battery_percentage=battery_percentage, paired_devices=paired_devices), "device_menu")
|
||||
print(menu_result)
|
||||
if menu_result == "DevicePair":
|
||||
from trezor import ui
|
||||
import trezorui_api
|
||||
await raise_if_not_confirmed(
|
||||
trezorui_api.show_pairing_device_name(
|
||||
device_name="My Trez",
|
||||
),
|
||||
"device_name"
|
||||
)
|
||||
await raise_if_not_confirmed(
|
||||
trezorui_api.show_pairing_code(
|
||||
code="123456",
|
||||
),
|
||||
"pairing_code"
|
||||
)
|
||||
else:
|
||||
lock_device()
|
||||
finally:
|
||||
obj.__del__()
|
||||
|
||||
if utils.INTERNAL_MODEL == "T3W1":
|
||||
if res is INFO:
|
||||
from .device_menu import handle_device_menu
|
||||
|
||||
return await handle_device_menu()
|
||||
lock_device()
|
||||
|
||||
|
||||
async def _lockscreen(screensaver: bool = False) -> None:
|
||||
from apps.base import unlock_device
|
||||
|
25
core/src/apps/homescreen/device_menu.py
Normal file
25
core/src/apps/homescreen/device_menu.py
Normal file
@ -0,0 +1,25 @@
|
||||
import trezorui_api
|
||||
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"]
|
||||
# ####
|
||||
|
||||
menu_result = await raise_if_not_confirmed(
|
||||
trezorui_api.show_device_menu(
|
||||
failed_backup=failed_backup,
|
||||
battery_percentage=battery_percentage,
|
||||
paired_devices=paired_devices,
|
||||
),
|
||||
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