1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-18 05:28:40 +00:00

core: set a scheduler-safe maximum for autolock

This commit is contained in:
matejcik 2020-06-02 11:10:35 +02:00 committed by matejcik
parent 872e0fb0e0
commit 8fa7684a9c

View File

@ -40,6 +40,8 @@ _DEFAULT_BACKUP_TYPE = BackupType.Bip39
HOMESCREEN_MAXSIZE = 16384
AUTOLOCK_DELAY_MINIMUM = 10 * 1000 # 10 seconds
AUTOLOCK_DELAY_DEFAULT = 10 * 60 * 1000 # 10 minutes
# autolock intervals larger than AUTOLOCK_DELAY_MAXIMUM cause issues in the scheduler
AUTOLOCK_DELAY_MAXIMUM = 0x2000_0000 # ~6 days
# Length of SD salt auth tag.
# Other SD-salt-related constants are in sd_salt.py
@ -221,6 +223,7 @@ def get_autolock_delay_ms() -> int:
def set_autolock_delay_ms(delay_ms: int) -> None:
delay_ms = max(delay_ms, AUTOLOCK_DELAY_MINIMUM)
delay_ms = min(delay_ms, AUTOLOCK_DELAY_MAXIMUM)
common.set(_NAMESPACE, _AUTOLOCK_DELAY_MS, delay_ms.to_bytes(4, "big"))