mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-03 12:00:59 +00:00
apps.management: handle ApplySettings
This commit is contained in:
parent
e8da59ced0
commit
2e34fc05a6
@ -1,7 +1,7 @@
|
||||
from trezor.wire import register_type, protobuf_handler
|
||||
from trezor.utils import unimport
|
||||
from trezor.messages.wire_types import \
|
||||
LoadDevice, ResetDevice, WipeDevice, RecoveryDevice
|
||||
LoadDevice, ResetDevice, WipeDevice, RecoveryDevice, ApplySettings
|
||||
|
||||
|
||||
@unimport
|
||||
@ -28,8 +28,15 @@ def dispatch_RecoveryDevice(*args, **kwargs):
|
||||
return layout_recovery_device(*args, **kwargs)
|
||||
|
||||
|
||||
@unimport
|
||||
def dispatch_ApplySettings(*args, **kwargs):
|
||||
from .layout_apply_settings import layout_apply_settings
|
||||
return layout_apply_settings(*args, **kwargs)
|
||||
|
||||
|
||||
def boot():
|
||||
register_type(LoadDevice, protobuf_handler, dispatch_LoadDevice)
|
||||
register_type(ResetDevice, protobuf_handler, dispatch_ResetDevice)
|
||||
register_type(WipeDevice, protobuf_handler, dispatch_WipeDevice)
|
||||
register_type(RecoveryDevice, protobuf_handler, dispatch_RecoveryDevice)
|
||||
register_type(ApplySettings, protobuf_handler, dispatch_ApplySettings)
|
||||
|
49
src/apps/management/layout_apply_settings.py
Normal file
49
src/apps/management/layout_apply_settings.py
Normal file
@ -0,0 +1,49 @@
|
||||
from trezor import ui, wire
|
||||
from trezor.utils import unimport
|
||||
|
||||
|
||||
@unimport
|
||||
async def layout_apply_settings(msg, session_id):
|
||||
from trezor.messages.Success import Success
|
||||
from trezor.messages.FailureType import Other
|
||||
from trezor.ui.text import Text
|
||||
from ..common.confirm import require_confirm
|
||||
from ..common.request_pin import protect_by_pin
|
||||
from ..common import storage
|
||||
|
||||
if msg.homescreen is not None:
|
||||
raise wire.FailureError(
|
||||
Other, 'ApplySettings.homescreen is not supported')
|
||||
|
||||
if msg.label is None and msg.language is None and msg.use_passphrase is None:
|
||||
raise wire.FailureError(Other, 'No setting provided')
|
||||
|
||||
if msg.label is not None:
|
||||
await require_confirm(session_id, Text(
|
||||
'Change label', ui.ICON_RESET,
|
||||
'Do you really want to', 'change label to',
|
||||
ui.BOLD, '%s' % msg.label,
|
||||
ui.NORMAL, '?'))
|
||||
|
||||
if msg.language is not None:
|
||||
await require_confirm(session_id, Text(
|
||||
'Change language', ui.ICON_RESET,
|
||||
'Do you really want to', 'change language to',
|
||||
ui.BOLD, '%s' % msg.language,
|
||||
ui.NORMAL, '?'))
|
||||
|
||||
if msg.use_passphrase is not None:
|
||||
await require_confirm(session_id, Text(
|
||||
'Enable passphrase' if msg.use_passphrase else 'Disable passphrase',
|
||||
ui.ICON_RESET,
|
||||
'Do you really want to',
|
||||
'enable passphrase' if msg.use_passphrase else 'disable passphrase',
|
||||
'encryption?'))
|
||||
|
||||
await protect_by_pin(session_id)
|
||||
|
||||
storage.load_settings(label=msg.label,
|
||||
language=msg.language,
|
||||
passphrase_protection=msg.use_passphrase)
|
||||
|
||||
return Success(message='Settings applied')
|
Loading…
Reference in New Issue
Block a user