1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-12-22 14:28:07 +00:00

refactor(core): use reload_settings_from_storage on boot

This commit is contained in:
Martin Milata 2021-01-28 12:21:43 +01:00
parent 9b60cc0098
commit c28763c169
2 changed files with 13 additions and 16 deletions

View File

@ -3,7 +3,7 @@ import storage.device
import storage.recovery
import storage.sd_salt
from storage import cache
from trezor import config, sdcard, utils, wire, workflow
from trezor import config, sdcard, ui, utils, wire, workflow
from trezor.messages import Capability, MessageType
from trezor.messages.Features import Features
from trezor.messages.PreauthorizedRequest import PreauthorizedRequest
@ -260,6 +260,15 @@ def get_pinlocked_handler(
return wrapper
# this function is also called when handling ApplySettings
def reload_settings_from_storage() -> None:
workflow.idle_timer.set(
storage.device.get_autolock_delay_ms(), lock_device_if_unlocked
)
wire.experimental_enabled = storage.device.get_experimental_features()
ui.display.orientation(storage.device.get_rotation())
def boot() -> None:
wire.register(MessageType.Initialize, handle_Initialize)
wire.register(MessageType.GetFeatures, handle_GetFeatures)
@ -270,8 +279,4 @@ def boot() -> None:
wire.register(MessageType.DoPreauthorized, handle_DoPreauthorized)
wire.register(MessageType.CancelAuthorization, handle_CancelAuthorization)
wire.experimental_enabled = storage.device.get_experimental_features()
workflow.idle_timer.set(
storage.device.get_autolock_delay_ms(), lock_device_if_unlocked
)
reload_settings_from_storage()

View File

@ -1,11 +1,11 @@
import storage.device
from trezor import ui, wire, workflow
from trezor import ui, wire
from trezor.messages import ButtonRequestType, SafetyCheckLevel
from trezor.messages.Success import Success
from trezor.strings import format_duration_ms
from trezor.ui.components.tt.text import Text
from apps.base import lock_device_if_unlocked
from apps.base import reload_settings_from_storage
from apps.common import safety_checks
from apps.common.confirm import require_confirm, require_hold_to_confirm
@ -100,14 +100,6 @@ async def apply_settings(ctx: wire.Context, msg: ApplySettings):
return Success(message="Settings applied")
def reload_settings_from_storage() -> None:
workflow.idle_timer.set(
storage.device.get_autolock_delay_ms(), lock_device_if_unlocked
)
ui.display.orientation(storage.device.get_rotation())
wire.experimental_enabled = storage.device.get_experimental_features()
async def require_confirm_change_homescreen(ctx):
text = Text("Set homescreen", ui.ICON_CONFIG)
text.normal("Do you really want to", "change the homescreen", "image?")