[FL-3814] Desktop: cleanup error popups (#3615)

* Desktop: cleanup error popups, add missing factory keys notification
* Desktop: enclave warning wording
This commit is contained in:
あく 2024-04-25 08:39:38 +09:00 committed by GitHub
parent 1559ee6293
commit 43c4381820
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 98 additions and 25 deletions

View file

@ -298,7 +298,7 @@ Desktop* desktop_alloc(void) {
desktop->lock_menu = desktop_lock_menu_alloc(); desktop->lock_menu = desktop_lock_menu_alloc();
desktop->debug_view = desktop_debug_alloc(); desktop->debug_view = desktop_debug_alloc();
desktop->hw_mismatch_popup = popup_alloc(); desktop->popup = popup_alloc();
desktop->locked_view = desktop_view_locked_alloc(); desktop->locked_view = desktop_view_locked_alloc();
desktop->pin_input_view = desktop_view_pin_input_alloc(); desktop->pin_input_view = desktop_view_pin_input_alloc();
desktop->pin_timeout_view = desktop_view_pin_timeout_alloc(); desktop->pin_timeout_view = desktop_view_pin_timeout_alloc();
@ -334,9 +334,7 @@ Desktop* desktop_alloc(void) {
view_dispatcher_add_view( view_dispatcher_add_view(
desktop->view_dispatcher, DesktopViewIdDebug, desktop_debug_get_view(desktop->debug_view)); desktop->view_dispatcher, DesktopViewIdDebug, desktop_debug_get_view(desktop->debug_view));
view_dispatcher_add_view( view_dispatcher_add_view(
desktop->view_dispatcher, desktop->view_dispatcher, DesktopViewIdPopup, popup_get_view(desktop->popup));
DesktopViewIdHwMismatch,
popup_get_view(desktop->hw_mismatch_popup));
view_dispatcher_add_view( view_dispatcher_add_view(
desktop->view_dispatcher, desktop->view_dispatcher,
DesktopViewIdPinTimeout, DesktopViewIdPinTimeout,
@ -476,6 +474,17 @@ int32_t desktop_srv(void* p) {
scene_manager_next_scene(desktop->scene_manager, DesktopSceneFault); scene_manager_next_scene(desktop->scene_manager, DesktopSceneFault);
} }
uint8_t keys_total, keys_valid;
if(!furi_hal_crypto_enclave_verify(&keys_total, &keys_valid)) {
FURI_LOG_E(
TAG,
"Secure Enclave verification failed: total %hhu, valid %hhu",
keys_total,
keys_valid);
scene_manager_next_scene(desktop->scene_manager, DesktopSceneSecureEnclave);
}
// Special case: autostart application is already running // Special case: autostart application is already running
if(loader_is_locked(desktop->loader) && if(loader_is_locked(desktop->loader) &&
animation_manager_is_animation_loaded(desktop->animation_manager)) { animation_manager_is_animation_loaded(desktop->animation_manager)) {

View file

@ -28,7 +28,7 @@ typedef enum {
DesktopViewIdLockMenu, DesktopViewIdLockMenu,
DesktopViewIdLocked, DesktopViewIdLocked,
DesktopViewIdDebug, DesktopViewIdDebug,
DesktopViewIdHwMismatch, DesktopViewIdPopup,
DesktopViewIdPinInput, DesktopViewIdPinInput,
DesktopViewIdPinTimeout, DesktopViewIdPinTimeout,
DesktopViewIdSlideshow, DesktopViewIdSlideshow,
@ -43,7 +43,7 @@ struct Desktop {
ViewDispatcher* view_dispatcher; ViewDispatcher* view_dispatcher;
SceneManager* scene_manager; SceneManager* scene_manager;
Popup* hw_mismatch_popup; Popup* popup;
DesktopLockMenuView* lock_menu; DesktopLockMenuView* lock_menu;
DesktopDebugView* debug_view; DesktopDebugView* debug_view;
DesktopViewLocked* locked_view; DesktopViewLocked* locked_view;

View file

@ -7,3 +7,4 @@ ADD_SCENE(desktop, locked, Locked)
ADD_SCENE(desktop, pin_input, PinInput) ADD_SCENE(desktop, pin_input, PinInput)
ADD_SCENE(desktop, pin_timeout, PinTimeout) ADD_SCENE(desktop, pin_timeout, PinTimeout)
ADD_SCENE(desktop, slideshow, Slideshow) ADD_SCENE(desktop, slideshow, Slideshow)
ADD_SCENE(desktop, secure_enclave, SecureEnclave)

View file

@ -12,20 +12,21 @@ void desktop_scene_fault_callback(void* context) {
void desktop_scene_fault_on_enter(void* context) { void desktop_scene_fault_on_enter(void* context) {
Desktop* desktop = (Desktop*)context; Desktop* desktop = (Desktop*)context;
Popup* popup = desktop->hw_mismatch_popup; Popup* popup = desktop->popup;
popup_set_context(popup, desktop); popup_set_context(popup, desktop);
popup_set_header( popup_set_header(
popup, popup,
"Flipper crashed\n and was rebooted", "Flipper crashed\n and was rebooted",
60, 64,
14 + STATUS_BAR_Y_SHIFT, 14 + STATUS_BAR_Y_SHIFT,
AlignCenter, AlignCenter,
AlignCenter); AlignCenter);
char* message = (char*)furi_hal_rtc_get_fault_data(); char* message = (char*)furi_hal_rtc_get_fault_data();
popup_set_text(popup, message, 60, 37 + STATUS_BAR_Y_SHIFT, AlignCenter, AlignCenter); popup_set_text(popup, message, 64, 37 + STATUS_BAR_Y_SHIFT, AlignCenter, AlignCenter);
popup_set_callback(popup, desktop_scene_fault_callback); popup_set_callback(popup, desktop_scene_fault_callback);
view_dispatcher_switch_to_view(desktop->view_dispatcher, DesktopViewIdHwMismatch);
view_dispatcher_switch_to_view(desktop->view_dispatcher, DesktopViewIdPopup);
} }
bool desktop_scene_fault_on_event(void* context, SceneManagerEvent event) { bool desktop_scene_fault_on_event(void* context, SceneManagerEvent event) {
@ -47,6 +48,11 @@ bool desktop_scene_fault_on_event(void* context, SceneManagerEvent event) {
} }
void desktop_scene_fault_on_exit(void* context) { void desktop_scene_fault_on_exit(void* context) {
UNUSED(context); Desktop* desktop = (Desktop*)context;
furi_assert(desktop);
Popup* popup = desktop->popup;
popup_reset(popup);
furi_hal_rtc_set_fault_data(0); furi_hal_rtc_set_fault_data(0);
} }

View file

@ -4,17 +4,15 @@
#include "desktop_scene.h" #include "desktop_scene.h"
#include "../desktop_i.h" #include "../desktop_i.h"
#define HW_MISMATCH_BACK_EVENT (0UL)
void desktop_scene_hw_mismatch_callback(void* context) { void desktop_scene_hw_mismatch_callback(void* context) {
Desktop* desktop = (Desktop*)context; Desktop* desktop = (Desktop*)context;
view_dispatcher_send_custom_event(desktop->view_dispatcher, HW_MISMATCH_BACK_EVENT); view_dispatcher_send_custom_event(desktop->view_dispatcher, DesktopHwMismatchExit);
} }
void desktop_scene_hw_mismatch_on_enter(void* context) { void desktop_scene_hw_mismatch_on_enter(void* context) {
Desktop* desktop = (Desktop*)context; Desktop* desktop = (Desktop*)context;
furi_assert(desktop); furi_assert(desktop);
Popup* popup = desktop->hw_mismatch_popup; Popup* popup = desktop->popup;
char* text_buffer = malloc(256); char* text_buffer = malloc(256);
scene_manager_set_scene_state( scene_manager_set_scene_state(
@ -28,10 +26,10 @@ void desktop_scene_hw_mismatch_on_enter(void* context) {
version_get_target(NULL)); version_get_target(NULL));
popup_set_context(popup, desktop); popup_set_context(popup, desktop);
popup_set_header( popup_set_header(
popup, "!!!! HW Mismatch !!!!", 60, 14 + STATUS_BAR_Y_SHIFT, AlignCenter, AlignCenter); popup, "!!!! HW Mismatch !!!!", 64, 12 + STATUS_BAR_Y_SHIFT, AlignCenter, AlignBottom);
popup_set_text(popup, text_buffer, 60, 37 + STATUS_BAR_Y_SHIFT, AlignCenter, AlignCenter); popup_set_text(popup, text_buffer, 64, 33 + STATUS_BAR_Y_SHIFT, AlignCenter, AlignCenter);
popup_set_callback(popup, desktop_scene_hw_mismatch_callback); popup_set_callback(popup, desktop_scene_hw_mismatch_callback);
view_dispatcher_switch_to_view(desktop->view_dispatcher, DesktopViewIdHwMismatch); view_dispatcher_switch_to_view(desktop->view_dispatcher, DesktopViewIdPopup);
} }
bool desktop_scene_hw_mismatch_on_event(void* context, SceneManagerEvent event) { bool desktop_scene_hw_mismatch_on_event(void* context, SceneManagerEvent event) {
@ -40,11 +38,10 @@ bool desktop_scene_hw_mismatch_on_event(void* context, SceneManagerEvent event)
if(event.type == SceneManagerEventTypeCustom) { if(event.type == SceneManagerEventTypeCustom) {
switch(event.event) { switch(event.event) {
case HW_MISMATCH_BACK_EVENT: case DesktopHwMismatchExit:
scene_manager_previous_scene(desktop->scene_manager); scene_manager_previous_scene(desktop->scene_manager);
consumed = true; consumed = true;
break; break;
default: default:
break; break;
} }
@ -55,11 +52,10 @@ bool desktop_scene_hw_mismatch_on_event(void* context, SceneManagerEvent event)
void desktop_scene_hw_mismatch_on_exit(void* context) { void desktop_scene_hw_mismatch_on_exit(void* context) {
Desktop* desktop = (Desktop*)context; Desktop* desktop = (Desktop*)context;
furi_assert(desktop); furi_assert(desktop);
Popup* popup = desktop->hw_mismatch_popup;
popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom); Popup* popup = desktop->popup;
popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop); popup_reset(popup);
popup_set_callback(popup, NULL);
popup_set_context(popup, NULL);
char* text_buffer = char* text_buffer =
(char*)scene_manager_get_scene_state(desktop->scene_manager, DesktopSceneHwMismatch); (char*)scene_manager_get_scene_state(desktop->scene_manager, DesktopSceneHwMismatch);
free(text_buffer); free(text_buffer);

View file

@ -0,0 +1,57 @@
#include <gui/scene_manager.h>
#include <furi_hal.h>
#include "desktop_scene.h"
#include "../desktop_i.h"
void desktop_scene_secure_enclave_callback(void* context) {
Desktop* desktop = (Desktop*)context;
view_dispatcher_send_custom_event(desktop->view_dispatcher, DesktopEnclaveExit);
}
void desktop_scene_secure_enclave_on_enter(void* context) {
Desktop* desktop = (Desktop*)context;
furi_assert(desktop);
Popup* popup = desktop->popup;
popup_set_context(popup, desktop);
popup_set_header(
popup, "No Factory Keys Found", 64, 12 + STATUS_BAR_Y_SHIFT, AlignCenter, AlignBottom);
popup_set_text(
popup,
"Secure Enclave is damaged.\n"
"Some apps will not work.",
64,
33 + STATUS_BAR_Y_SHIFT,
AlignCenter,
AlignCenter);
popup_set_callback(popup, desktop_scene_secure_enclave_callback);
view_dispatcher_switch_to_view(desktop->view_dispatcher, DesktopViewIdPopup);
}
bool desktop_scene_secure_enclave_on_event(void* context, SceneManagerEvent event) {
Desktop* desktop = (Desktop*)context;
bool consumed = false;
if(event.type == SceneManagerEventTypeCustom) {
switch(event.event) {
case DesktopEnclaveExit:
scene_manager_previous_scene(desktop->scene_manager);
consumed = true;
break;
default:
break;
}
}
return consumed;
}
void desktop_scene_secure_enclave_on_exit(void* context) {
Desktop* desktop = (Desktop*)context;
furi_assert(desktop);
Popup* popup = desktop->popup;
popup_reset(popup);
}

View file

@ -46,6 +46,10 @@ typedef enum {
DesktopSlideshowCompleted, DesktopSlideshowCompleted,
DesktopSlideshowPoweroff, DesktopSlideshowPoweroff,
DesktopHwMismatchExit,
DesktopEnclaveExit,
// Global events // Global events
DesktopGlobalBeforeAppStarted, DesktopGlobalBeforeAppStarted,
DesktopGlobalAfterAppFinished, DesktopGlobalAfterAppFinished,