Skip to content

Commit

Permalink
src/apps/common/storage: add autolock_delay_ms variable
Browse files Browse the repository at this point in the history
  • Loading branch information
prusnak committed Apr 3, 2018
1 parent 04680f4 commit a6e8a37
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions src/apps/common/storage.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
_U2F_COUNTER = const(0x09) # int
_PASSPHRASE_SOURCE = const(0x0A) # int
_UNFINISHED_BACKUP = const(0x0B) # bool (0x01 or empty)
_AUTOLOCK_DELAY_MS = const(0x0C) # int


def _new_device_id() -> str:
Expand Down Expand Up @@ -130,6 +131,20 @@ def set_flags(flags: int) -> None:
config.set(_APP, _FLAGS, flags.to_bytes(4, 'big'))


def get_autolock_delay_ms() -> int:
b = config.get(_APP, _AUTOLOCK_DELAY_MS)
if b is None:
return 10 * 60 * 1000
else:
return int.from_bytes(b, 'big')


def set_autolock_delay_ms(delay_ms: int) -> None:
if delay_ms < 60 * 1000:
delay_ms = 60 * 1000
config.set(_APP, _AUTOLOCK_DELAY_MS, delay_ms.to_bytes(4, 'big'))


def next_u2f_counter() -> int:
b = config.get(_APP, _U2F_COUNTER)
if b is None:
Expand Down

0 comments on commit a6e8a37

Please sign in to comment.