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

core: expose storage_is_unlocked() as config.is_unlocked()

This commit is contained in:
matejcik 2020-04-21 10:23:01 +02:00 committed by matejcik
parent 87433995b0
commit 837c4df61f
2 changed files with 22 additions and 0 deletions

View File

@ -112,6 +112,19 @@ STATIC mp_obj_t mod_trezorconfig_lock(void) {
STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_trezorconfig_lock_obj,
mod_trezorconfig_lock);
/// def is_unlocked() -> bool:
/// """
/// Returns True if storage is unlocked, False otherwise.
/// """
STATIC mp_obj_t mod_trezorconfig_is_unlocked(void) {
if (sectrue != storage_is_unlocked()) {
return mp_const_false;
}
return mp_const_true;
}
STATIC MP_DEFINE_CONST_FUN_OBJ_0(mod_trezorconfig_is_unlocked_obj,
mod_trezorconfig_is_unlocked);
/// def has_pin() -> bool:
/// """
/// Returns True if storage has a configured PIN, False otherwise.
@ -374,6 +387,8 @@ STATIC const mp_rom_map_elem_t mp_module_trezorconfig_globals_table[] = {
MP_ROM_PTR(&mod_trezorconfig_check_pin_obj)},
{MP_ROM_QSTR(MP_QSTR_unlock), MP_ROM_PTR(&mod_trezorconfig_unlock_obj)},
{MP_ROM_QSTR(MP_QSTR_lock), MP_ROM_PTR(&mod_trezorconfig_lock_obj)},
{MP_ROM_QSTR(MP_QSTR_is_unlocked),
MP_ROM_PTR(&mod_trezorconfig_is_unlocked_obj)},
{MP_ROM_QSTR(MP_QSTR_has_pin), MP_ROM_PTR(&mod_trezorconfig_has_pin_obj)},
{MP_ROM_QSTR(MP_QSTR_get_pin_rem),
MP_ROM_PTR(&mod_trezorconfig_get_pin_rem_obj)},

View File

@ -34,6 +34,13 @@ def lock() -> None:
"""
# extmod/modtrezorconfig/modtrezorconfig.c
def is_unlocked() -> bool:
"""
Returns True if storage is unlocked, False otherwise.
"""
# extmod/modtrezorconfig/modtrezorconfig.c
def has_pin() -> bool:
"""