1
0
mirror of https://github.com/trezor/trezor-firmware.git synced 2024-11-14 03:30:02 +00:00

allow ClearSession purely via confirm button

Holding confirm button at home screen asks user whether they wish to
lock the TREZOR (clear the cached PIN and passphrase and show the
screensaver). This is identical behaviour to the ClearSession message.
This commit is contained in:
Saleem Rashid 2016-08-26 17:50:10 +01:00 committed by Pavol Rusnak
parent ea35b4bfe7
commit 0b51d060d8
No known key found for this signature in database
GPG Key ID: 91F3B339B9A02A3D
2 changed files with 44 additions and 0 deletions

View File

@ -24,6 +24,8 @@
#include "types.pb.h"
#include "bitmaps.h"
extern void *layoutLast;
void layoutDialogSwipe(const BITMAP *icon, const char *btnNo, const char *btnYes, const char *desc, const char *line1, const char *line2, const char *line3, const char *line4, const char *line5, const char *line6);
void layoutProgressSwipe(const char *desc, int permil);

View File

@ -27,6 +27,7 @@
#include "layout.h"
#include "layout2.h"
#include "rng.h"
#include "buttons.h"
uint32_t __stack_chk_guard;
@ -36,6 +37,46 @@ void __attribute__((noreturn)) __stack_chk_fail(void)
for (;;) {} // loop forever
}
void check_lock_screen(void)
{
buttonUpdate();
// wake from screensaver on any button
if (layoutLast == layoutScreensaver && (button.NoUp || button.YesUp)) {
layoutHome();
return;
}
// button held for long enough
if (layoutLast == layoutHome && button.NoDown >= 500000) {
layoutDialog(&bmp_icon_question, "Cancel", "Lock Device", NULL, "Do you really want to", "lock your TREZOR?", NULL, NULL, NULL, NULL);
// wait until NoButton is released
usbTiny(1);
do {
usbDelay(3300);
buttonUpdate();
} while (!button.NoUp);
// wait for confirmation/cancellation of the dialog
do {
usbDelay(3300);
buttonUpdate();
} while (!button.YesUp && !button.NoUp);
usbTiny(0);
if (button.YesUp) {
// lock the screen
session_clear(true);
layoutScreensaver();
} else {
// resume homescreen
layoutHome();
}
}
}
int main(void)
{
__stack_chk_guard = random32();
@ -61,6 +102,7 @@ int main(void)
usbInit();
for (;;) {
usbPoll();
check_lock_screen();
}
return 0;