mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-18 19:31:04 +00:00
fix(core): increase minimum auto-lock delay to 1 minute
This commit is contained in:
parent
65a9636bb5
commit
93d45f1aba
@ -48,7 +48,11 @@ if False:
|
|||||||
# fmt: on
|
# fmt: on
|
||||||
|
|
||||||
HOMESCREEN_MAXSIZE = 16384
|
HOMESCREEN_MAXSIZE = 16384
|
||||||
|
|
||||||
|
if __debug__:
|
||||||
AUTOLOCK_DELAY_MINIMUM = 10 * 1000 # 10 seconds
|
AUTOLOCK_DELAY_MINIMUM = 10 * 1000 # 10 seconds
|
||||||
|
else:
|
||||||
|
AUTOLOCK_DELAY_MINIMUM = 60 * 1000 # 1 minute
|
||||||
AUTOLOCK_DELAY_DEFAULT = 10 * 60 * 1000 # 10 minutes
|
AUTOLOCK_DELAY_DEFAULT = 10 * 60 * 1000 # 10 minutes
|
||||||
# autolock intervals larger than AUTOLOCK_DELAY_MAXIMUM cause issues in the scheduler
|
# autolock intervals larger than AUTOLOCK_DELAY_MAXIMUM cause issues in the scheduler
|
||||||
AUTOLOCK_DELAY_MAXIMUM = 0x2000_0000 # ~6 days
|
AUTOLOCK_DELAY_MAXIMUM = 0x2000_0000 # ~6 days
|
||||||
@ -217,17 +221,22 @@ def set_flags(flags: int) -> None:
|
|||||||
common.set(_NAMESPACE, _FLAGS, flags.to_bytes(4, "big"))
|
common.set(_NAMESPACE, _FLAGS, flags.to_bytes(4, "big"))
|
||||||
|
|
||||||
|
|
||||||
|
def _normalize_autolock_delay(delay_ms: int) -> int:
|
||||||
|
delay_ms = max(delay_ms, AUTOLOCK_DELAY_MINIMUM)
|
||||||
|
delay_ms = min(delay_ms, AUTOLOCK_DELAY_MAXIMUM)
|
||||||
|
return delay_ms
|
||||||
|
|
||||||
|
|
||||||
def get_autolock_delay_ms() -> int:
|
def get_autolock_delay_ms() -> int:
|
||||||
b = common.get(_NAMESPACE, _AUTOLOCK_DELAY_MS)
|
b = common.get(_NAMESPACE, _AUTOLOCK_DELAY_MS)
|
||||||
if b is None:
|
if b is None:
|
||||||
return AUTOLOCK_DELAY_DEFAULT
|
return AUTOLOCK_DELAY_DEFAULT
|
||||||
else:
|
else:
|
||||||
return int.from_bytes(b, "big")
|
return _normalize_autolock_delay(int.from_bytes(b, "big"))
|
||||||
|
|
||||||
|
|
||||||
def set_autolock_delay_ms(delay_ms: int) -> None:
|
def set_autolock_delay_ms(delay_ms: int) -> None:
|
||||||
delay_ms = max(delay_ms, AUTOLOCK_DELAY_MINIMUM)
|
delay_ms = _normalize_autolock_delay(delay_ms)
|
||||||
delay_ms = min(delay_ms, AUTOLOCK_DELAY_MAXIMUM)
|
|
||||||
common.set(_NAMESPACE, _AUTOLOCK_DELAY_MS, delay_ms.to_bytes(4, "big"))
|
common.set(_NAMESPACE, _AUTOLOCK_DELAY_MS, delay_ms.to_bytes(4, "big"))
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user