[FL-2780] NFC Notifications fix (#1731)

* Show error popup when NFC chip is not init/disconnected
* Move to dialogs for the error message
* NFC notifications fixed to match the intended design
* Revert "Move to dialogs for the error message"
* Revert "Show error popup when NFC chip is not init/disconnected"

Co-authored-by: SG <who.just.the.doctor@gmail.com>
Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
Astra 2022-09-15 18:49:10 +03:00 committed by GitHub
parent 8b05bd1106
commit 60bce7b8d8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
16 changed files with 46 additions and 12 deletions

View File

@ -201,8 +201,16 @@ void nfc_text_store_clear(Nfc* nfc) {
memset(nfc->text_store, 0, sizeof(nfc->text_store)); memset(nfc->text_store, 0, sizeof(nfc->text_store));
} }
void nfc_blink_start(Nfc* nfc) { void nfc_blink_read_start(Nfc* nfc) {
notification_message(nfc->notifications, &sequence_blink_start_blue); notification_message(nfc->notifications, &sequence_blink_start_cyan);
}
void nfc_blink_emulate_start(Nfc* nfc) {
notification_message(nfc->notifications, &sequence_blink_start_magenta);
}
void nfc_blink_detect_start(Nfc* nfc) {
notification_message(nfc->notifications, &sequence_blink_start_yellow);
} }
void nfc_blink_stop(Nfc* nfc) { void nfc_blink_stop(Nfc* nfc) {

View File

@ -98,7 +98,11 @@ void nfc_text_store_set(Nfc* nfc, const char* text, ...);
void nfc_text_store_clear(Nfc* nfc); void nfc_text_store_clear(Nfc* nfc);
void nfc_blink_start(Nfc* nfc); void nfc_blink_read_start(Nfc* nfc);
void nfc_blink_emulate_start(Nfc* nfc);
void nfc_blink_detect_start(Nfc* nfc);
void nfc_blink_stop(Nfc* nfc); void nfc_blink_stop(Nfc* nfc);

View File

@ -29,7 +29,7 @@ void nfc_scene_detect_reader_on_enter(void* context) {
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewDetectReader); view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewDetectReader);
nfc_blink_start(nfc); nfc_blink_read_start(nfc);
} }
bool nfc_scene_detect_reader_on_event(void* context, SceneManagerEvent event) { bool nfc_scene_detect_reader_on_event(void* context, SceneManagerEvent event) {

View File

@ -12,7 +12,7 @@ void nfc_scene_emulate_apdu_sequence_on_enter(void* context) {
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewPopup); view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewPopup);
nfc_worker_start(nfc->worker, NfcWorkerStateEmulateApdu, &nfc->dev->dev_data, NULL, nfc); nfc_worker_start(nfc->worker, NfcWorkerStateEmulateApdu, &nfc->dev->dev_data, NULL, nfc);
nfc_blink_start(nfc); nfc_blink_emulate_start(nfc);
} }
bool nfc_scene_emulate_apdu_sequence_on_event(void* context, SceneManagerEvent event) { bool nfc_scene_emulate_apdu_sequence_on_event(void* context, SceneManagerEvent event) {

View File

@ -82,7 +82,7 @@ void nfc_scene_emulate_uid_on_enter(void* context) {
nfc_emulate_uid_worker_callback, nfc_emulate_uid_worker_callback,
nfc); nfc);
nfc_blink_start(nfc); nfc_blink_emulate_start(nfc);
} }
bool nfc_scene_emulate_uid_on_event(void* context, SceneManagerEvent event) { bool nfc_scene_emulate_uid_on_event(void* context, SceneManagerEvent event) {

View File

@ -55,6 +55,8 @@ void nfc_scene_emv_read_success_on_enter(void* context) {
string_clear(country_name); string_clear(country_name);
} }
notification_message_block(nfc->notifications, &sequence_set_green_255);
widget_add_text_scroll_element(nfc->widget, 0, 0, 128, 52, string_get_cstr(temp_str)); widget_add_text_scroll_element(nfc->widget, 0, 0, 128, 52, string_get_cstr(temp_str));
string_clear(temp_str); string_clear(temp_str);
@ -83,6 +85,8 @@ bool nfc_scene_emv_read_success_on_event(void* context, SceneManagerEvent event)
void nfc_scene_emv_read_success_on_exit(void* context) { void nfc_scene_emv_read_success_on_exit(void* context) {
Nfc* nfc = context; Nfc* nfc = context;
notification_message_block(nfc->notifications, &sequence_reset_green);
// Clear view // Clear view
widget_reset(nfc->widget); widget_reset(nfc->widget);
} }

View File

@ -90,7 +90,7 @@ void nfc_scene_mf_classic_dict_attack_on_enter(void* context) {
Nfc* nfc = context; Nfc* nfc = context;
nfc_scene_mf_classic_dict_attack_prepare_view(nfc, DictAttackStateIdle); nfc_scene_mf_classic_dict_attack_prepare_view(nfc, DictAttackStateIdle);
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewDictAttack); view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewDictAttack);
nfc_blink_start(nfc); nfc_blink_read_start(nfc);
} }
bool nfc_scene_mf_classic_dict_attack_on_event(void* context, SceneManagerEvent event) { bool nfc_scene_mf_classic_dict_attack_on_event(void* context, SceneManagerEvent event) {

View File

@ -35,7 +35,7 @@ void nfc_scene_mf_classic_emulate_on_enter(void* context) {
&nfc->dev->dev_data, &nfc->dev->dev_data,
nfc_mf_classic_emulate_worker_callback, nfc_mf_classic_emulate_worker_callback,
nfc); nfc);
nfc_blink_start(nfc); nfc_blink_emulate_start(nfc);
} }
bool nfc_scene_mf_classic_emulate_on_event(void* context, SceneManagerEvent event) { bool nfc_scene_mf_classic_emulate_on_event(void* context, SceneManagerEvent event) {

View File

@ -48,6 +48,8 @@ void nfc_scene_mf_classic_read_success_on_enter(void* context) {
widget_add_text_scroll_element(widget, 0, 0, 128, 52, string_get_cstr(temp_str)); widget_add_text_scroll_element(widget, 0, 0, 128, 52, string_get_cstr(temp_str));
string_clear(temp_str); string_clear(temp_str);
notification_message_block(nfc->notifications, &sequence_set_green_255);
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewWidget); view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewWidget);
} }
@ -76,6 +78,8 @@ bool nfc_scene_mf_classic_read_success_on_event(void* context, SceneManagerEvent
void nfc_scene_mf_classic_read_success_on_exit(void* context) { void nfc_scene_mf_classic_read_success_on_exit(void* context) {
Nfc* nfc = context; Nfc* nfc = context;
notification_message_block(nfc->notifications, &sequence_reset_green);
// Clear view // Clear view
widget_reset(nfc->widget); widget_reset(nfc->widget);
} }

View File

@ -52,6 +52,8 @@ void nfc_scene_mf_desfire_read_success_on_enter(void* context) {
string_push_back(temp_str, 's'); string_push_back(temp_str, 's');
} }
notification_message_block(nfc->notifications, &sequence_set_green_255);
// Add text scroll element // Add text scroll element
widget_add_text_scroll_element(widget, 0, 0, 128, 52, string_get_cstr(temp_str)); widget_add_text_scroll_element(widget, 0, 0, 128, 52, string_get_cstr(temp_str));
string_clear(temp_str); string_clear(temp_str);
@ -88,6 +90,8 @@ bool nfc_scene_mf_desfire_read_success_on_event(void* context, SceneManagerEvent
void nfc_scene_mf_desfire_read_success_on_exit(void* context) { void nfc_scene_mf_desfire_read_success_on_exit(void* context) {
Nfc* nfc = context; Nfc* nfc = context;
notification_message_block(nfc->notifications, &sequence_reset_green);
// Clean dialog // Clean dialog
widget_reset(nfc->widget); widget_reset(nfc->widget);
} }

View File

@ -35,7 +35,7 @@ void nfc_scene_mf_ultralight_emulate_on_enter(void* context) {
&nfc->dev->dev_data, &nfc->dev->dev_data,
nfc_mf_ultralight_emulate_worker_callback, nfc_mf_ultralight_emulate_worker_callback,
nfc); nfc);
nfc_blink_start(nfc); nfc_blink_emulate_start(nfc);
} }
bool nfc_scene_mf_ultralight_emulate_on_event(void* context, SceneManagerEvent event) { bool nfc_scene_mf_ultralight_emulate_on_event(void* context, SceneManagerEvent event) {

View File

@ -65,7 +65,7 @@ void nfc_scene_mf_ultralight_read_auth_on_enter(void* context) {
nfc_scene_mf_ultralight_read_auth_worker_callback, nfc_scene_mf_ultralight_read_auth_worker_callback,
nfc); nfc);
nfc_blink_start(nfc); nfc_blink_read_start(nfc);
} }
bool nfc_scene_mf_ultralight_read_auth_on_event(void* context, SceneManagerEvent event) { bool nfc_scene_mf_ultralight_read_auth_on_event(void* context, SceneManagerEvent event) {

View File

@ -47,6 +47,8 @@ void nfc_scene_mf_ultralight_read_success_on_enter(void* context) {
widget_add_text_scroll_element(widget, 0, 0, 128, 52, string_get_cstr(temp_str)); widget_add_text_scroll_element(widget, 0, 0, 128, 52, string_get_cstr(temp_str));
string_clear(temp_str); string_clear(temp_str);
notification_message_block(nfc->notifications, &sequence_set_green_255);
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewWidget); view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewWidget);
} }
@ -73,6 +75,8 @@ bool nfc_scene_mf_ultralight_read_success_on_event(void* context, SceneManagerEv
void nfc_scene_mf_ultralight_read_success_on_exit(void* context) { void nfc_scene_mf_ultralight_read_success_on_exit(void* context) {
Nfc* nfc = context; Nfc* nfc = context;
notification_message_block(nfc->notifications, &sequence_reset_green);
// Clean view // Clean view
widget_reset(nfc->widget); widget_reset(nfc->widget);
} }

View File

@ -25,6 +25,8 @@ void nfc_scene_nfca_read_success_on_enter(void* context) {
string_t temp_str; string_t temp_str;
string_init_set_str(temp_str, "\e#Unknown ISO tag\n"); string_init_set_str(temp_str, "\e#Unknown ISO tag\n");
notification_message_block(nfc->notifications, &sequence_set_green_255);
char iso_type = FURI_BIT(data->sak, 5) ? '4' : '3'; char iso_type = FURI_BIT(data->sak, 5) ? '4' : '3';
string_cat_printf(temp_str, "ISO 14443-%c (NFC-A)\n", iso_type); string_cat_printf(temp_str, "ISO 14443-%c (NFC-A)\n", iso_type);
string_cat_printf(temp_str, "UID:"); string_cat_printf(temp_str, "UID:");
@ -67,6 +69,8 @@ bool nfc_scene_nfca_read_success_on_event(void* context, SceneManagerEvent event
void nfc_scene_nfca_read_success_on_exit(void* context) { void nfc_scene_nfca_read_success_on_exit(void* context) {
Nfc* nfc = context; Nfc* nfc = context;
notification_message_block(nfc->notifications, &sequence_reset_green);
// Clear view // Clear view
widget_reset(nfc->widget); widget_reset(nfc->widget);
} }

View File

@ -49,7 +49,7 @@ void nfc_scene_read_on_enter(void* context) {
nfc_worker_start( nfc_worker_start(
nfc->worker, NfcWorkerStateRead, &nfc->dev->dev_data, nfc_scene_read_worker_callback, nfc); nfc->worker, NfcWorkerStateRead, &nfc->dev->dev_data, nfc_scene_read_worker_callback, nfc);
nfc_blink_start(nfc); nfc_blink_read_start(nfc);
} }
bool nfc_scene_read_on_event(void* context, SceneManagerEvent event) { bool nfc_scene_read_on_event(void* context, SceneManagerEvent event) {
@ -92,9 +92,11 @@ bool nfc_scene_read_on_event(void* context, SceneManagerEvent event) {
consumed = true; consumed = true;
} else if(event.event == NfcWorkerEventCardDetected) { } else if(event.event == NfcWorkerEventCardDetected) {
nfc_scene_read_set_state(nfc, NfcSceneReadStateReading); nfc_scene_read_set_state(nfc, NfcSceneReadStateReading);
nfc_blink_detect_start(nfc);
consumed = true; consumed = true;
} else if(event.event == NfcWorkerEventNoCardDetected) { } else if(event.event == NfcWorkerEventNoCardDetected) {
nfc_scene_read_set_state(nfc, NfcSceneReadStateDetecting); nfc_scene_read_set_state(nfc, NfcSceneReadStateDetecting);
nfc_blink_read_start(nfc);
consumed = true; consumed = true;
} }
} }

View File

@ -62,7 +62,7 @@ bool nfc_scene_rpc_on_event(void* context, SceneManagerEvent event) {
nfc->rpc_state = NfcRpcStateEmulating; nfc->rpc_state = NfcRpcStateEmulating;
result = true; result = true;
nfc_blink_start(nfc); nfc_blink_emulate_start(nfc);
nfc_text_store_set(nfc, "emulating\n%s", nfc->dev->dev_name); nfc_text_store_set(nfc, "emulating\n%s", nfc->dev->dev_name);
popup_set_text(popup, nfc->text_store, 89, 44, AlignCenter, AlignTop); popup_set_text(popup, nfc->text_store, 89, 44, AlignCenter, AlignTop);
} }