Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
…irmware into mntm-dev --nobuild
  • Loading branch information
Willy-JL committed Apr 25, 2024
2 parents ed57426 + 43c4381 commit 41e0b47
Show file tree
Hide file tree
Showing 13 changed files with 126 additions and 97 deletions.
1 change: 0 additions & 1 deletion applications/main/ibutton/scenes/ibutton_scene_config.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,5 @@ ADD_SCENE(ibutton, delete_confirm, DeleteConfirm)
ADD_SCENE(ibutton, delete_success, DeleteSuccess)
ADD_SCENE(ibutton, retry_confirm, RetryConfirm)
ADD_SCENE(ibutton, exit_confirm, ExitConfirm)
ADD_SCENE(ibutton, read_exit_confirm, ReadExitConfirm)
ADD_SCENE(ibutton, view_data, ViewData)
ADD_SCENE(ibutton, rpc, Rpc)
59 changes: 0 additions & 59 deletions applications/main/ibutton/scenes/ibutton_scene_read_exit_confirm.c

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ bool ibutton_scene_read_success_on_event(void* context, SceneManagerEvent event)

if(event.type == SceneManagerEventTypeBack) {
consumed = true;
scene_manager_next_scene(scene_manager, iButtonSceneReadExitConfirm);
scene_manager_next_scene(scene_manager, iButtonSceneExitConfirm);
} else if(event.type == SceneManagerEventTypeCustom) {
consumed = true;
if(event.event == GuiButtonTypeRight) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ void ibutton_scene_retry_confirm_on_enter(void* context) {
Widget* widget = ibutton->widget;

widget_add_button_element(
widget, GuiButtonTypeLeft, "Exit", ibutton_scene_retry_confirm_widget_callback, ibutton);
widget, GuiButtonTypeLeft, "Retry", ibutton_scene_retry_confirm_widget_callback, ibutton);
widget_add_button_element(
widget, GuiButtonTypeRight, "Stay", ibutton_scene_retry_confirm_widget_callback, ibutton);
widget_add_string_element(
Expand Down
2 changes: 1 addition & 1 deletion applications/main/nfc/api/mosgortrans/mosgortrans_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -506,7 +506,7 @@ bool mosgortrans_parse_transport_block(const MfClassicBlock* block, FuriString*

if(data_block.valid_from_date == 0 || data_block.valid_to_date == 0) {
furi_string_cat(result, "\e#No ticket");
return true;
return false;
}
//remaining_trips
furi_string_cat_printf(result, "Trips: %d\n", data_block.total_trips);
Expand Down
31 changes: 23 additions & 8 deletions applications/main/nfc/plugins/supported_cards/troika.c
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,20 @@ static const MfClassicKeyPair troika_4k_keys[] = {
{.a = 0xBB52F8CCE07F, .b = 0x6B6119752C70}, //40
};

static void troika_render_section_header(
FuriString* str,
const char* name,
uint8_t prefix_separator_cnt,
uint8_t suffix_separator_cnt) {
for(uint8_t i = 0; i < prefix_separator_cnt; i++) {
furi_string_cat_printf(str, ":");
}
furi_string_cat_printf(str, "[ %s ]", name);
for(uint8_t i = 0; i < suffix_separator_cnt; i++) {
furi_string_cat_printf(str, ":");
}
}

static bool troika_get_card_config(TroikaCardConfig* config, MfClassicType type) {
bool success = true;

Expand Down Expand Up @@ -204,18 +218,19 @@ static bool troika_parse(const NfcDevice* device, FuriString* parsed_data) {
bool result3 = mosgortrans_parse_transport_block(&data->block[16], tat_result);

furi_string_cat_printf(parsed_data, "\e#Troyka card\n");
if(result1) {
furi_string_cat_printf(
parsed_data, "\e#Metro\n%s\n", furi_string_get_cstr(metro_result));
if(result1 && !furi_string_empty(metro_result)) {
troika_render_section_header(parsed_data, "Metro", 22, 21);
furi_string_cat_printf(parsed_data, "%s\n", furi_string_get_cstr(metro_result));
}

if(result2) {
furi_string_cat_printf(
parsed_data, "\n\e#Ediniy\n%s\n", furi_string_get_cstr(ground_result));
if(result2 && !furi_string_empty(ground_result)) {
troika_render_section_header(parsed_data, "Ediny", 22, 22);
furi_string_cat_printf(parsed_data, "%s\n", furi_string_get_cstr(ground_result));
}

if(result3) {
furi_string_cat_printf(parsed_data, "\n\e#TAT\n%s", furi_string_get_cstr(tat_result));
if(result3 && !furi_string_empty(tat_result)) {
troika_render_section_header(parsed_data, "TAT", 24, 23);
furi_string_cat_printf(parsed_data, "%s\n", furi_string_get_cstr(tat_result));
}

furi_string_free(tat_result);
Expand Down
17 changes: 13 additions & 4 deletions applications/services/desktop/desktop.c
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ Desktop* desktop_alloc(void) {
desktop->view_dispatcher, desktop_back_event_callback);

desktop->lock_menu = desktop_lock_menu_alloc();
desktop->hw_mismatch_popup = popup_alloc();
desktop->popup = popup_alloc();
desktop->locked_view = desktop_view_locked_alloc();
desktop->pin_input_view = desktop_view_pin_input_alloc();
desktop->pin_timeout_view = desktop_view_pin_timeout_alloc();
Expand Down Expand Up @@ -334,9 +334,7 @@ Desktop* desktop_alloc(void) {
DesktopViewIdLockMenu,
desktop_lock_menu_get_view(desktop->lock_menu));
view_dispatcher_add_view(
desktop->view_dispatcher,
DesktopViewIdHwMismatch,
popup_get_view(desktop->hw_mismatch_popup));
desktop->view_dispatcher, DesktopViewIdPopup, popup_get_view(desktop->popup));
view_dispatcher_add_view(
desktop->view_dispatcher,
DesktopViewIdPinTimeout,
Expand Down Expand Up @@ -519,6 +517,17 @@ int32_t desktop_srv(void* p) {
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
if(loader_is_locked(desktop->loader) &&
animation_manager_is_animation_loaded(desktop->animation_manager)) {
Expand Down
5 changes: 3 additions & 2 deletions applications/services/desktop/desktop_i.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ typedef enum {
DesktopViewIdMain,
DesktopViewIdLockMenu,
DesktopViewIdLocked,
DesktopViewIdHwMismatch,
_DesktopViewIdDebug, // Unused, kept for compatibility
DesktopViewIdPopup,
DesktopViewIdPinInput,
DesktopViewIdPinTimeout,
DesktopViewIdSlideshow,
Expand All @@ -42,7 +43,7 @@ struct Desktop {
ViewDispatcher* view_dispatcher;
SceneManager* scene_manager;

Popup* hw_mismatch_popup;
Popup* popup;
DesktopLockMenuView* lock_menu;
DesktopDebugView* _debug_view; // Unused, kept for compatibility
DesktopViewLocked* locked_view;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,4 @@ ADD_SCENE(desktop, locked, Locked)
ADD_SCENE(desktop, pin_input, PinInput)
ADD_SCENE(desktop, pin_timeout, PinTimeout)
ADD_SCENE(desktop, slideshow, Slideshow)
ADD_SCENE(desktop, secure_enclave, SecureEnclave)
18 changes: 12 additions & 6 deletions applications/services/desktop/scenes/desktop_scene_fault.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,21 @@ void desktop_scene_fault_callback(void* context) {
void desktop_scene_fault_on_enter(void* context) {
Desktop* desktop = (Desktop*)context;

Popup* popup = desktop->hw_mismatch_popup;
Popup* popup = desktop->popup;
popup_set_context(popup, desktop);
popup_set_header(
popup,
"Flipper crashed\n but has been rebooted",
60,
"Flipper crashed\n and was rebooted",
64,
14 + STATUS_BAR_Y_SHIFT,
AlignCenter,
AlignCenter);

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);
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) {
Expand All @@ -48,6 +49,11 @@ bool desktop_scene_fault_on_event(void* context, SceneManagerEvent event) {
}

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);
}
24 changes: 10 additions & 14 deletions applications/services/desktop/scenes/desktop_scene_hw_mismatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,15 @@
#include "desktop_scene.h"
#include "../desktop_i.h"

#define HW_MISMATCH_BACK_EVENT (0UL)

void desktop_scene_hw_mismatch_callback(void* 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) {
Desktop* desktop = (Desktop*)context;
furi_assert(desktop);
Popup* popup = desktop->hw_mismatch_popup;
Popup* popup = desktop->popup;

char* text_buffer = malloc(256);
scene_manager_set_scene_state(
Expand All @@ -28,10 +26,10 @@ void desktop_scene_hw_mismatch_on_enter(void* context) {
version_get_target(NULL));
popup_set_context(popup, desktop);
popup_set_header(
popup, "!!!! HW Mismatch !!!!", 60, 14 + STATUS_BAR_Y_SHIFT, AlignCenter, AlignCenter);
popup_set_text(popup, text_buffer, 60, 37 + STATUS_BAR_Y_SHIFT, AlignCenter, AlignCenter);
popup, "!!!! HW Mismatch !!!!", 64, 12 + STATUS_BAR_Y_SHIFT, AlignCenter, AlignBottom);
popup_set_text(popup, text_buffer, 64, 33 + STATUS_BAR_Y_SHIFT, AlignCenter, AlignCenter);
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) {
Expand All @@ -40,11 +38,10 @@ bool desktop_scene_hw_mismatch_on_event(void* context, SceneManagerEvent event)

if(event.type == SceneManagerEventTypeCustom) {
switch(event.event) {
case HW_MISMATCH_BACK_EVENT:
case DesktopHwMismatchExit:
scene_manager_previous_scene(desktop->scene_manager);
consumed = true;
break;

default:
break;
}
Expand All @@ -55,11 +52,10 @@ bool desktop_scene_hw_mismatch_on_event(void* context, SceneManagerEvent event)
void desktop_scene_hw_mismatch_on_exit(void* context) {
Desktop* desktop = (Desktop*)context;
furi_assert(desktop);
Popup* popup = desktop->hw_mismatch_popup;
popup_set_header(popup, NULL, 0, 0, AlignCenter, AlignBottom);
popup_set_text(popup, NULL, 0, 0, AlignCenter, AlignTop);
popup_set_callback(popup, NULL);
popup_set_context(popup, NULL);

Popup* popup = desktop->popup;
popup_reset(popup);

char* text_buffer =
(char*)scene_manager_get_scene_state(desktop->scene_manager, DesktopSceneHwMismatch);
free(text_buffer);
Expand Down
Original file line number Diff line number Diff line change
@@ -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);
}
4 changes: 4 additions & 0 deletions applications/services/desktop/views/desktop_events.h
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ typedef enum {
DesktopSlideshowCompleted,
DesktopSlideshowPoweroff,

DesktopHwMismatchExit,

DesktopEnclaveExit,

// Global events
DesktopGlobalBeforeAppStarted,
DesktopGlobalAfterAppFinished,
Expand Down

0 comments on commit 41e0b47

Please sign in to comment.