2021-07-22 09:05:07 +03:00
|
|
|
#include "../nfc_i.h"
|
2021-08-20 22:56:43 +03:00
|
|
|
#include "../helpers/nfc_emv_parser.h"
|
[FL-2183] [FL-2209] Dolphin Deeds, Level up, assets generation, refactoring (#965)
* Desktop: cleanup headers
* Get loader pubsub via record
* [FL-2183] Dolphin refactoring 2022.01
* Restruct animations assets structure
* Rename assets
* Cleanup headers
* Update Recording animation
* Add BadBattery animation
* Provide loader's pubsub via record
* Fix load/unload animations
* Scripts: add flipper format support, initial dolphin packager rework. Assets: internal and external dolphin.
* Sync internal meta.txt and manifest.txt
* Reorder, rename dolphin assets
* Split essential generated assets
* Add ReadMe for dolphin assets
* Separate essential blocking animations
* Scripts: full dolphin validation before packaging
* Assets, Scripts: dolphin external resources packer
* Github: update codeowners
* Scripts: proper slots handling in dolphin animation meta
* Scripts: correct frames enumeration and fix compiled assets.
* [FL-2209] Add Dolphin Deeds points and many more
* Remove excess frame_rate
* Change dolphin assets directory
* Scripts: add internal resource support to dolphin compiler
* Scripts: add internal assets generation, renaming
* Scripts: correct assert, renaming
* Code cleanup, documentation, fixes
* Update Levelup animations
* Rename essential -> blocking
* Fix Unlocked hint
* Scripts: rewrite Templite compiller, replace regexps with token parser, split block types into code and variable blocks. Update dolphin templates.
* Documentation: add key combos description and use information
* Scripts: cleanup templit, more debug info and add dev comment
Co-authored-by: あく <alleteam@gmail.com>
2022-01-29 12:20:41 +03:00
|
|
|
#include <dolphin/dolphin.h>
|
2021-07-22 09:05:07 +03:00
|
|
|
|
2022-04-19 18:23:58 +03:00
|
|
|
void nfc_scene_read_emv_app_widget_callback(GuiButtonType result, InputType type, void* context) {
|
|
|
|
Nfc* nfc = context;
|
|
|
|
if(type == InputTypeShort) {
|
|
|
|
view_dispatcher_send_custom_event(nfc->view_dispatcher, result);
|
|
|
|
}
|
2021-07-22 09:05:07 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
void nfc_scene_read_emv_app_success_on_enter(void* context) {
|
2022-04-19 18:23:58 +03:00
|
|
|
Nfc* nfc = context;
|
[FL-2183] [FL-2209] Dolphin Deeds, Level up, assets generation, refactoring (#965)
* Desktop: cleanup headers
* Get loader pubsub via record
* [FL-2183] Dolphin refactoring 2022.01
* Restruct animations assets structure
* Rename assets
* Cleanup headers
* Update Recording animation
* Add BadBattery animation
* Provide loader's pubsub via record
* Fix load/unload animations
* Scripts: add flipper format support, initial dolphin packager rework. Assets: internal and external dolphin.
* Sync internal meta.txt and manifest.txt
* Reorder, rename dolphin assets
* Split essential generated assets
* Add ReadMe for dolphin assets
* Separate essential blocking animations
* Scripts: full dolphin validation before packaging
* Assets, Scripts: dolphin external resources packer
* Github: update codeowners
* Scripts: proper slots handling in dolphin animation meta
* Scripts: correct frames enumeration and fix compiled assets.
* [FL-2209] Add Dolphin Deeds points and many more
* Remove excess frame_rate
* Change dolphin assets directory
* Scripts: add internal resource support to dolphin compiler
* Scripts: add internal assets generation, renaming
* Scripts: correct assert, renaming
* Code cleanup, documentation, fixes
* Update Levelup animations
* Rename essential -> blocking
* Fix Unlocked hint
* Scripts: rewrite Templite compiller, replace regexps with token parser, split block types into code and variable blocks. Update dolphin templates.
* Documentation: add key combos description and use information
* Scripts: cleanup templit, more debug info and add dev comment
Co-authored-by: あく <alleteam@gmail.com>
2022-01-29 12:20:41 +03:00
|
|
|
DOLPHIN_DEED(DolphinDeedNfcReadSuccess);
|
2021-07-22 09:05:07 +03:00
|
|
|
|
|
|
|
// Setup view
|
2022-04-19 18:23:58 +03:00
|
|
|
FuriHalNfcDevData* nfc_data = &nfc->dev->dev_data.nfc_data;
|
|
|
|
EmvData* emv_data = &nfc->dev->dev_data.emv_data;
|
|
|
|
Widget* widget = nfc->widget;
|
|
|
|
widget_add_button_element(
|
|
|
|
widget, GuiButtonTypeLeft, "Retry", nfc_scene_read_emv_app_widget_callback, nfc);
|
|
|
|
widget_add_button_element(
|
|
|
|
widget, GuiButtonTypeRight, "Run app", nfc_scene_read_emv_app_widget_callback, nfc);
|
|
|
|
widget_add_string_element(widget, 36, 5, AlignLeft, AlignTop, FontPrimary, "Found EMV App");
|
|
|
|
widget_add_icon_element(widget, 8, 5, &I_Medium_chip_22x21);
|
|
|
|
// Display UID
|
|
|
|
string_t temp_str;
|
|
|
|
string_init_printf(temp_str, "UID:");
|
|
|
|
for(size_t i = 0; i < nfc_data->uid_len; i++) {
|
|
|
|
string_cat_printf(temp_str, " %02X", nfc_data->uid[i]);
|
|
|
|
}
|
|
|
|
widget_add_string_element(
|
|
|
|
widget, 36, 18, AlignLeft, AlignTop, FontSecondary, string_get_cstr(temp_str));
|
|
|
|
string_reset(temp_str);
|
|
|
|
// Display application
|
|
|
|
string_printf(temp_str, "App: ");
|
2021-07-22 09:05:07 +03:00
|
|
|
string_t aid;
|
2021-08-20 22:56:43 +03:00
|
|
|
string_init(aid);
|
2021-11-09 00:55:06 +03:00
|
|
|
bool aid_found =
|
|
|
|
nfc_emv_parser_get_aid_name(nfc->dev->storage, emv_data->aid, emv_data->aid_len, aid);
|
2021-08-20 22:56:43 +03:00
|
|
|
if(!aid_found) {
|
|
|
|
for(uint8_t i = 0; i < emv_data->aid_len; i++) {
|
2021-10-05 08:14:19 +03:00
|
|
|
string_cat_printf(aid, "%02X", emv_data->aid[i]);
|
2021-08-20 22:56:43 +03:00
|
|
|
}
|
2021-07-22 09:05:07 +03:00
|
|
|
}
|
2022-04-19 18:23:58 +03:00
|
|
|
string_cat(temp_str, aid);
|
|
|
|
widget_add_string_element(
|
|
|
|
widget, 7, 29, AlignLeft, AlignTop, FontSecondary, string_get_cstr(temp_str));
|
|
|
|
string_clear(temp_str);
|
2021-07-22 09:05:07 +03:00
|
|
|
string_clear(aid);
|
|
|
|
|
2021-10-05 08:14:19 +03:00
|
|
|
// Send notification
|
|
|
|
if(scene_manager_get_scene_state(nfc->scene_manager, NfcSceneReadEmvAppSuccess) ==
|
|
|
|
NFC_SEND_NOTIFICATION_TRUE) {
|
|
|
|
notification_message(nfc->notifications, &sequence_success);
|
|
|
|
scene_manager_set_scene_state(
|
|
|
|
nfc->scene_manager, NfcSceneReadEmvAppSuccess, NFC_SEND_NOTIFICATION_FALSE);
|
|
|
|
}
|
|
|
|
|
2022-04-19 18:23:58 +03:00
|
|
|
view_dispatcher_switch_to_view(nfc->view_dispatcher, NfcViewWidget);
|
2021-07-22 09:05:07 +03:00
|
|
|
}
|
|
|
|
|
2021-09-21 12:34:16 +03:00
|
|
|
bool nfc_scene_read_emv_app_success_on_event(void* context, SceneManagerEvent event) {
|
2022-04-19 18:23:58 +03:00
|
|
|
Nfc* nfc = context;
|
|
|
|
bool consumed = false;
|
2021-07-22 09:05:07 +03:00
|
|
|
|
|
|
|
if(event.type == SceneManagerEventTypeCustom) {
|
2022-04-19 18:23:58 +03:00
|
|
|
if(event.event == GuiButtonTypeLeft) {
|
|
|
|
consumed = scene_manager_previous_scene(nfc->scene_manager);
|
|
|
|
} else if(event.event == GuiButtonTypeRight) {
|
2021-07-22 09:05:07 +03:00
|
|
|
scene_manager_next_scene(nfc->scene_manager, NfcSceneRunEmvAppConfirm);
|
2022-04-19 18:23:58 +03:00
|
|
|
consumed = true;
|
2021-07-22 09:05:07 +03:00
|
|
|
}
|
|
|
|
}
|
2022-04-19 18:23:58 +03:00
|
|
|
return consumed;
|
2021-07-22 09:05:07 +03:00
|
|
|
}
|
|
|
|
|
2021-09-21 12:34:16 +03:00
|
|
|
void nfc_scene_read_emv_app_success_on_exit(void* context) {
|
2022-04-19 18:23:58 +03:00
|
|
|
Nfc* nfc = context;
|
2021-07-22 09:05:07 +03:00
|
|
|
|
2022-04-19 18:23:58 +03:00
|
|
|
// Clear views
|
|
|
|
widget_reset(nfc->widget);
|
2021-07-22 09:05:07 +03:00
|
|
|
}
|