From 72228e35cf00f7f4d8160353b747d5bcad03afb3 Mon Sep 17 00:00:00 2001 From: Ondrej Mikle Date: Thu, 25 Aug 2022 13:13:00 +0200 Subject: [PATCH] feat(core): show red error header when USB data not connected --- core/.changelog.d/2366.added | 2 +- core/embed/unix/profile.c | 6 ++++++ core/embed/unix/profile.h | 1 + core/embed/unix/usb.c | 3 ++- core/src/apps/homescreen/homescreen.py | 2 +- 5 files changed, 11 insertions(+), 3 deletions(-) diff --git a/core/.changelog.d/2366.added b/core/.changelog.d/2366.added index 4a57faa8b4..382f4c367a 100644 --- a/core/.changelog.d/2366.added +++ b/core/.changelog.d/2366.added @@ -1 +1 @@ -Show blue dot when USB data pins are not connected +Show red error header when USB data pins are not connected diff --git a/core/embed/unix/profile.c b/core/embed/unix/profile.c index 79144650c0..6e2e0ac4c6 100644 --- a/core/embed/unix/profile.c +++ b/core/embed/unix/profile.c @@ -66,3 +66,9 @@ const char *profile_sdcard_path(void) { FILE_PATH(_sdcard_path, "/trezor.sdcard"); return _sdcard_path; } + +const char *profile_usb_disconnect_path(void) { + SVAR(_disconnect_path); + FILE_PATH(_disconnect_path, "/trezor.usb_data_disconnected"); + return _disconnect_path; +} diff --git a/core/embed/unix/profile.h b/core/embed/unix/profile.h index b75466fa79..7df834cc80 100644 --- a/core/embed/unix/profile.h +++ b/core/embed/unix/profile.h @@ -33,5 +33,6 @@ const char *profile_name(void); const char *profile_dir(void); const char *profile_flash_path(void); const char *profile_sdcard_path(void); +const char *profile_usb_disconnect_path(void); #endif // __TREZOR_PROFILE_H__ diff --git a/core/embed/unix/usb.c b/core/embed/unix/usb.c index fb3c6f7cd4..d7831219f2 100644 --- a/core/embed/unix/usb.c +++ b/core/embed/unix/usb.c @@ -27,6 +27,7 @@ #include #include +#include "profile.h" #include "touch.h" #include "usb.h" @@ -252,7 +253,7 @@ void pendsv_kbd_intr(void) {} void mp_hal_set_vcp_iface(int iface_num) {} secbool usb_configured(void) { - if (access("/var/tmp/trezor.usb_data_disconnected", F_OK) == 0) { + if (access(profile_usb_disconnect_path(), F_OK) == 0) { return secfalse; } diff --git a/core/src/apps/homescreen/homescreen.py b/core/src/apps/homescreen/homescreen.py index c2a00a6b6d..9db89d9ffa 100644 --- a/core/src/apps/homescreen/homescreen.py +++ b/core/src/apps/homescreen/homescreen.py @@ -68,7 +68,7 @@ class Homescreen(HomescreenBase): # Differs for each model if not utils.usb_data_connected(): - ui.display.bar(0, 0, 8, 8, ui.BLUE) + ui.header_error("NO USB CONNECTION") # TODO: support homescreen avatar change for R and 1 if utils.MODEL in ("T",):