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

apps: improve language getters/setters

This commit is contained in:
Jan Pochyla 2016-12-15 12:48:33 +01:00
parent 3f657775e9
commit e73ff1f3c2
2 changed files with 16 additions and 2 deletions

View File

@ -96,6 +96,10 @@ def get_label() -> str:
return config_get(_LABEL).decode() return config_get(_LABEL).decode()
def get_language() -> str:
return config_get(_LANGUAGE).decode() or _DEFAULT_LANGUAGE
def get_mnemonic() -> str: def get_mnemonic() -> str:
utils.ensure(is_initialized()) utils.ensure(is_initialized())
utils.ensure(not is_locked()) utils.ensure(not is_locked())
@ -114,6 +118,10 @@ def load_mnemonic(mnemonic: str):
config_set(_MNEMONIC, mnemonic.encode()) config_set(_MNEMONIC, mnemonic.encode())
_ALLOWED_LANGUAGES = ('english')
_DEFAULT_LANGUAGE = 'english'
def load_settings(language: str=None, def load_settings(language: str=None,
label: str=None, label: str=None,
pin: str=None, pin: str=None,
@ -121,8 +129,11 @@ def load_settings(language: str=None,
utils.ensure(is_initialized()) utils.ensure(is_initialized())
utils.ensure(not is_locked()) utils.ensure(not is_locked())
if language is not None: if language is not None and language in _ALLOWED_LANGUAGES:
config_set(_LANGUAGE, language.encode()) if language is _DEFAULT_LANGUAGE:
config_set(_LANGUAGE, b'')
else:
config_set(_LANGUAGE, language.encode())
if label is not None: if label is not None:
config_set(_LABEL, label.encode()) config_set(_LABEL, label.encode())
if pin is not None: if pin is not None:

View File

@ -3,6 +3,7 @@ from trezor.utils import unimport
from trezor.messages.wire_types import Initialize, GetFeatures, Ping from trezor.messages.wire_types import Initialize, GetFeatures, Ping
@unimport
async def respond_Features(session_id, msg): async def respond_Features(session_id, msg):
from apps.common import storage, coins from apps.common import storage, coins
from trezor.messages.Features import Features from trezor.messages.Features import Features
@ -18,6 +19,7 @@ async def respond_Features(session_id, msg):
f.device_id = storage.get_device_id() f.device_id = storage.get_device_id()
f.label = storage.get_label() f.label = storage.get_label()
f.language = storage.get_language()
f.initialized = storage.is_initialized() f.initialized = storage.is_initialized()
f.pin_protection = storage.is_protected_by_pin() f.pin_protection = storage.is_protected_by_pin()
f.passphrase_protection = storage.is_protected_by_passphrase() f.passphrase_protection = storage.is_protected_by_passphrase()
@ -25,6 +27,7 @@ async def respond_Features(session_id, msg):
return f return f
@unimport
async def respond_Pong(session_id, msg): async def respond_Pong(session_id, msg):
from trezor.messages.Success import Success from trezor.messages.Success import Success