mirror of
https://github.com/trezor/trezor-firmware.git
synced 2025-01-11 16:00:57 +00:00
feat(legacy): Implement SetBusy.
This commit is contained in:
parent
89993c8969
commit
300c986851
@ -48,6 +48,7 @@
|
||||
#include "secp256k1.h"
|
||||
#include "signing.h"
|
||||
#include "supervise.h"
|
||||
#include "timer.h"
|
||||
#include "transaction.h"
|
||||
#include "trezor.h"
|
||||
#include "usb.h"
|
||||
|
@ -74,6 +74,7 @@ void fsm_msgWordAck(const WordAck *msg);
|
||||
void fsm_msgSetU2FCounter(const SetU2FCounter *msg);
|
||||
void fsm_msgGetNextU2FCounter(void);
|
||||
void fsm_msgGetFirmwareHash(const GetFirmwareHash *msg);
|
||||
void fsm_msgSetBusy(const SetBusy *msg);
|
||||
|
||||
// coin
|
||||
void fsm_msgGetPublicKey(const GetPublicKey *msg);
|
||||
|
@ -71,6 +71,8 @@ bool get_features(Features *resp) {
|
||||
strlcpy(resp->model, "1", sizeof(resp->model));
|
||||
resp->has_safety_checks = true;
|
||||
resp->safety_checks = config_getSafetyCheckLevel();
|
||||
resp->has_busy = true;
|
||||
resp->busy = (system_millis_busy_deadline > timer_ms());
|
||||
if (session_isUnlocked()) {
|
||||
resp->has_wipe_code_protection = true;
|
||||
resp->wipe_code_protection = config_hasWipeCode();
|
||||
@ -572,3 +574,14 @@ void fsm_msgGetFirmwareHash(const GetFirmwareHash *msg) {
|
||||
msg_write(MessageType_MessageType_FirmwareHash, resp);
|
||||
layoutHome();
|
||||
}
|
||||
|
||||
void fsm_msgSetBusy(const SetBusy *msg) {
|
||||
if (msg->has_expiry_ms) {
|
||||
system_millis_busy_deadline = timer_ms() + msg->expiry_ms;
|
||||
} else {
|
||||
system_millis_busy_deadline = 0;
|
||||
}
|
||||
fsm_sendSuccess(NULL);
|
||||
layoutHome();
|
||||
return;
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ const char **split_message_hex(const uint8_t *msg, uint32_t len) {
|
||||
return split_message((const uint8_t *)hex, size * 2, 16);
|
||||
}
|
||||
|
||||
void *layoutLast = layoutHome;
|
||||
void *layoutLast = NULL;
|
||||
|
||||
void layoutDialogSwipe(const BITMAP *icon, const char *btnNo,
|
||||
const char *btnYes, const char *desc, const char *line1,
|
||||
@ -285,18 +285,36 @@ void layoutProgressSwipe(const char *desc, int permil) {
|
||||
}
|
||||
|
||||
void layoutScreensaver(void) {
|
||||
layoutLast = layoutScreensaver;
|
||||
oledClear();
|
||||
oledRefresh();
|
||||
if (system_millis_busy_deadline > timer_ms()) {
|
||||
// Busy screen overrides the screensaver.
|
||||
layoutBusyscreen();
|
||||
} else {
|
||||
layoutLast = layoutScreensaver;
|
||||
oledClear();
|
||||
oledRefresh();
|
||||
}
|
||||
}
|
||||
|
||||
void layoutHome(void) {
|
||||
if (layoutLast == layoutHome || layoutLast == layoutScreensaver) {
|
||||
if (layoutLast != layoutHomescreen && layoutLast != layoutBusyscreen) {
|
||||
// Reset lock screen timeout
|
||||
system_millis_lock_start = timer_ms();
|
||||
}
|
||||
|
||||
if (system_millis_busy_deadline > timer_ms()) {
|
||||
layoutBusyscreen();
|
||||
} else {
|
||||
layoutHomescreen();
|
||||
}
|
||||
}
|
||||
|
||||
void layoutHomescreen(void) {
|
||||
if (layoutLast == layoutHomescreen || layoutLast == layoutScreensaver) {
|
||||
oledClear();
|
||||
} else {
|
||||
layoutSwipe();
|
||||
}
|
||||
layoutLast = layoutHome;
|
||||
layoutLast = layoutHomescreen;
|
||||
|
||||
char label[MAX_LABEL_LEN + 1] = _("Go to trezor.io/start");
|
||||
if (config_isInitialized()) {
|
||||
@ -338,9 +356,19 @@ void layoutHome(void) {
|
||||
oledDrawStringCenter(OLED_WIDTH / 2, 0, "NEEDS BACKUP!", FONT_STANDARD);
|
||||
}
|
||||
oledRefresh();
|
||||
}
|
||||
|
||||
// Reset lock screen timeout
|
||||
system_millis_lock_start = timer_ms();
|
||||
void layoutBusyscreen(void) {
|
||||
if (layoutLast == layoutBusyscreen || layoutLast == layoutScreensaver) {
|
||||
oledClear();
|
||||
} else {
|
||||
layoutSwipe();
|
||||
}
|
||||
layoutLast = layoutBusyscreen;
|
||||
|
||||
layoutDialog(&bmp_icon_warning, NULL, NULL, NULL, _("Please wait"), NULL,
|
||||
_("Coinjoin in progress."), NULL, _("Do not disconnect"),
|
||||
_("your Trezor."));
|
||||
}
|
||||
|
||||
static void render_address_dialog(const CoinInfo *coin, const char *address,
|
||||
|
@ -51,6 +51,8 @@ void layoutDialogSwipeEx(const BITMAP *icon, const char *btnNo,
|
||||
void layoutProgressSwipe(const char *desc, int permil);
|
||||
|
||||
void layoutScreensaver(void);
|
||||
void layoutHomescreen(void);
|
||||
void layoutBusyscreen(void);
|
||||
void layoutHome(void);
|
||||
void layoutConfirmOutput(const CoinInfo *coin, AmountUnit amount_unit,
|
||||
const TxOutputType *out);
|
||||
|
@ -4,7 +4,7 @@ endif
|
||||
|
||||
SKIPPED_MESSAGES := Binance Cardano DebugMonero Eos Monero Ontology Ripple SdProtect Tezos WebAuthn \
|
||||
DebugLinkRecordScreen DebugLinkEraseSdCard DebugLinkWatchLayout \
|
||||
DebugLinkLayout GetNonce SetBusy \
|
||||
DebugLinkLayout GetNonce \
|
||||
TxAckInput TxAckOutput TxAckPrev TxAckPaymentRequest \
|
||||
EthereumSignTypedData EthereumTypedDataStructRequest EthereumTypedDataStructAck \
|
||||
EthereumTypedDataValueRequest EthereumTypedDataValueAck
|
||||
|
@ -59,6 +59,9 @@ void secp256k1_default_error_callback_fn(const char *str, void *data) {
|
||||
/* Screen timeout */
|
||||
uint32_t system_millis_lock_start = 0;
|
||||
|
||||
/* Busyscreen timeout */
|
||||
uint32_t system_millis_busy_deadline = 0;
|
||||
|
||||
void check_lock_screen(void) {
|
||||
buttonUpdate();
|
||||
|
||||
@ -69,7 +72,8 @@ void check_lock_screen(void) {
|
||||
}
|
||||
|
||||
// button held for long enough (5 seconds)
|
||||
if (layoutLast == layoutHome && button.NoDown >= 114000 * 5) {
|
||||
if ((layoutLast == layoutHomescreen || layoutLast == layoutBusyscreen) &&
|
||||
button.NoDown >= 114000 * 5) {
|
||||
layoutDialog(&bmp_icon_question, _("Cancel"), _("Lock Device"), NULL,
|
||||
_("Do you really want to"), _("lock your Trezor?"), NULL, NULL,
|
||||
NULL, NULL);
|
||||
@ -99,7 +103,7 @@ void check_lock_screen(void) {
|
||||
}
|
||||
|
||||
// if homescreen is shown for too long
|
||||
if (layoutLast == layoutHome) {
|
||||
if (layoutLast == layoutHomescreen) {
|
||||
if ((timer_ms() - system_millis_lock_start) >=
|
||||
config_getAutoLockDelayMs()) {
|
||||
// lock the screen
|
||||
@ -109,6 +113,15 @@ void check_lock_screen(void) {
|
||||
}
|
||||
}
|
||||
|
||||
void check_busy_screen(void) {
|
||||
// Clear the busy screen once it expires.
|
||||
if (system_millis_busy_deadline != 0 &&
|
||||
system_millis_busy_deadline < timer_ms()) {
|
||||
system_millis_busy_deadline = 0;
|
||||
layoutHome();
|
||||
}
|
||||
}
|
||||
|
||||
static void collect_hw_entropy(bool privileged) {
|
||||
#if EMULATOR
|
||||
(void)privileged;
|
||||
@ -184,6 +197,7 @@ int main(void) {
|
||||
usbPoll();
|
||||
#endif
|
||||
check_lock_screen();
|
||||
check_busy_screen();
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
@ -37,4 +37,7 @@
|
||||
/* Screen timeout */
|
||||
extern uint32_t system_millis_lock_start;
|
||||
|
||||
/* Busyscreen timeout */
|
||||
extern uint32_t system_millis_busy_deadline;
|
||||
|
||||
#endif
|
||||
|
@ -24,8 +24,6 @@ from trezorlib.tools import parse_path
|
||||
|
||||
PIN = "1234"
|
||||
|
||||
pytestmark = pytest.mark.skip_t1
|
||||
|
||||
|
||||
@pytest.mark.setup_client(pin=PIN)
|
||||
def test_busy_state(client: Client):
|
||||
|
@ -566,6 +566,8 @@
|
||||
"T1_test_bip32_speed.py::test_cache": "55f043b3e286b778a02baea8f7c3547208849e2e18f90837bd9374a4a14c5c0b",
|
||||
"T1_test_bip32_speed.py::test_private_ckd": "55f043b3e286b778a02baea8f7c3547208849e2e18f90837bd9374a4a14c5c0b",
|
||||
"T1_test_bip32_speed.py::test_public_ckd": "55f043b3e286b778a02baea8f7c3547208849e2e18f90837bd9374a4a14c5c0b",
|
||||
"T1_test_busy_state.py::test_busy_expiry": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
||||
"T1_test_busy_state.py::test_busy_state": "fe7e762884268cf79e211eeb7c7ed7f85b8364e8bac27bd6790fc300f9a1429c",
|
||||
"T1_test_cancel.py::test_cancel_message_via_cancel[message0]": "de7fc40b2f35e82fa486f1b97ee3e34a96d0a67412537e8a0fddacc0b0b1649d",
|
||||
"T1_test_cancel.py::test_cancel_message_via_cancel[message1]": "af93b5d0a8ae6b297391a43ff3f6382d0bea1109f4f411f5b306e2e7ced6e814",
|
||||
"T1_test_cancel.py::test_cancel_message_via_initialize[message0]": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
|
||||
|
Loading…
Reference in New Issue
Block a user