mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-10 23:40:58 +00:00
legacy: raise error on auto-lock value out of range
This commit is contained in:
parent
fd117a0c9f
commit
48e1dc957f
@ -937,8 +937,7 @@ uint32_t config_getAutoLockDelayMs() {
|
||||
}
|
||||
|
||||
void config_setAutoLockDelayMs(uint32_t auto_lock_delay_ms) {
|
||||
const uint32_t min_delay_ms = 10 * 1000U; // 10 seconds
|
||||
auto_lock_delay_ms = MAX(auto_lock_delay_ms, min_delay_ms);
|
||||
auto_lock_delay_ms = MAX(auto_lock_delay_ms, MIN_AUTOLOCK_DELAY_MS);
|
||||
if (sectrue == storage_set(KEY_AUTO_LOCK_DELAY_MS, &auto_lock_delay_ms,
|
||||
sizeof(auto_lock_delay_ms))) {
|
||||
autoLockDelayMs = auto_lock_delay_ms;
|
||||
|
@ -85,6 +85,8 @@ extern Storage configUpdate;
|
||||
#define MAX_MNEMONIC_LEN 240
|
||||
#define HOMESCREEN_SIZE 1024
|
||||
#define UUID_SIZE 12
|
||||
#define MIN_AUTOLOCK_DELAY_MS (10 * 1000U) // 10 seconds
|
||||
#define MAX_AUTOLOCK_DELAY_MS 0x20000000U // ~6 days
|
||||
|
||||
void config_init(void);
|
||||
void session_clear(bool lock);
|
||||
|
@ -413,9 +413,19 @@ void fsm_msgApplySettings(const ApplySettings *msg) {
|
||||
}
|
||||
|
||||
if (msg->has_auto_lock_delay_ms) {
|
||||
layoutDialogSwipe(&bmp_icon_question, _("Cancel"), _("Confirm"), NULL,
|
||||
_("Do you really want to"), _("change auto-lock"),
|
||||
_("delay?"), NULL, NULL, NULL);
|
||||
if (msg->auto_lock_delay_ms < MIN_AUTOLOCK_DELAY_MS) {
|
||||
fsm_sendFailure(FailureType_Failure_ProcessError,
|
||||
_("Auto-lock delay too short"));
|
||||
layoutHome();
|
||||
return;
|
||||
}
|
||||
if (msg->auto_lock_delay_ms > MAX_AUTOLOCK_DELAY_MS) {
|
||||
fsm_sendFailure(FailureType_Failure_ProcessError,
|
||||
_("Auto-lock delay too long"));
|
||||
layoutHome();
|
||||
return;
|
||||
}
|
||||
layoutConfirmAutoLockDelay(msg->auto_lock_delay_ms);
|
||||
if (!protectButton(ButtonRequestType_ButtonRequest_ProtectCall, false)) {
|
||||
fsm_sendFailure(FailureType_Failure_ActionCancelled, NULL);
|
||||
layoutHome();
|
||||
|
@ -1022,3 +1022,32 @@ void layoutCosiCommitSign(const uint32_t *address_n, size_t address_n_count,
|
||||
layoutDialogSwipe(&bmp_icon_question, _("Cancel"), _("Confirm"), desc, str[0],
|
||||
str[1], str[2], str[3], NULL, NULL);
|
||||
}
|
||||
|
||||
void layoutConfirmAutoLockDelay(uint32_t delay_ms) {
|
||||
char line[sizeof("after 4294967296 minutes?")] = {0};
|
||||
|
||||
const char *unit = _("second");
|
||||
uint32_t num = delay_ms / 1000U;
|
||||
|
||||
if (delay_ms >= 60 * 60 * 1000) {
|
||||
unit = _("hour");
|
||||
num /= 60 * 60U;
|
||||
} else if (delay_ms >= 60 * 1000) {
|
||||
unit = _("minute");
|
||||
num /= 60U;
|
||||
}
|
||||
|
||||
strlcpy(line, _("after "), sizeof(line));
|
||||
size_t off = strlen(line);
|
||||
bn_format_uint64(num, NULL, NULL, 0, 0, false, &line[off],
|
||||
sizeof(line) - off);
|
||||
strlcat(line, " ", sizeof(line));
|
||||
strlcat(line, unit, sizeof(line));
|
||||
if (num > 1) {
|
||||
strlcat(line, "s", sizeof(line));
|
||||
}
|
||||
strlcat(line, "?", sizeof(line));
|
||||
layoutDialogSwipe(&bmp_icon_question, _("Cancel"), _("Confirm"), NULL,
|
||||
_("Do you really want to"), _("auto-lock your device"),
|
||||
line, NULL, NULL, NULL);
|
||||
}
|
||||
|
@ -90,6 +90,8 @@ void layoutNEMLevy(const NEMMosaicDefinition *definition, uint8_t network);
|
||||
void layoutCosiCommitSign(const uint32_t *address_n, size_t address_n_count,
|
||||
const uint8_t *data, uint32_t len, bool final_sign);
|
||||
|
||||
void layoutConfirmAutoLockDelay(uint32_t delay_ms);
|
||||
|
||||
const char **split_message(const uint8_t *msg, uint32_t len, uint32_t rowlen);
|
||||
const char **split_message_hex(const uint8_t *msg, uint32_t len);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user