[FL-3064] Skip the read when the card is not present (#2494)

Co-authored-by: あく <alleteam@gmail.com>
This commit is contained in:
Astra 2023-03-16 11:06:11 +02:00 committed by GitHub
parent e90042368f
commit 6aa0c08f3a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 1 deletions

View File

@ -115,7 +115,8 @@ bool nfc_scene_mf_classic_dict_attack_on_event(void* context, SceneManagerEvent
consumed = true; consumed = true;
} }
} else if(event.event == NfcWorkerEventAborted) { } else if(event.event == NfcWorkerEventAborted) {
if(state == DictAttackStateUserDictInProgress) { if(state == DictAttackStateUserDictInProgress &&
dict_attack_get_card_state(nfc->dict_attack)) {
nfc_scene_mf_classic_dict_attack_prepare_view(nfc, state); nfc_scene_mf_classic_dict_attack_prepare_view(nfc, state);
consumed = true; consumed = true;
} else { } else {

View File

@ -11,6 +11,7 @@ struct DictAttack {
View* view; View* view;
DictAttackCallback callback; DictAttackCallback callback;
void* context; void* context;
bool card_present;
}; };
typedef struct { typedef struct {
@ -162,6 +163,7 @@ void dict_attack_set_header(DictAttack* dict_attack, const char* header) {
void dict_attack_set_card_detected(DictAttack* dict_attack, MfClassicType type) { void dict_attack_set_card_detected(DictAttack* dict_attack, MfClassicType type) {
furi_assert(dict_attack); furi_assert(dict_attack);
dict_attack->card_present = true;
with_view_model( with_view_model(
dict_attack->view, dict_attack->view,
DictAttackViewModel * model, DictAttackViewModel * model,
@ -175,6 +177,7 @@ void dict_attack_set_card_detected(DictAttack* dict_attack, MfClassicType type)
void dict_attack_set_card_removed(DictAttack* dict_attack) { void dict_attack_set_card_removed(DictAttack* dict_attack) {
furi_assert(dict_attack); furi_assert(dict_attack);
dict_attack->card_present = false;
with_view_model( with_view_model(
dict_attack->view, dict_attack->view,
DictAttackViewModel * model, DictAttackViewModel * model,
@ -182,6 +185,11 @@ void dict_attack_set_card_removed(DictAttack* dict_attack) {
true); true);
} }
bool dict_attack_get_card_state(DictAttack* dict_attack) {
furi_assert(dict_attack);
return dict_attack->card_present;
}
void dict_attack_set_sector_read(DictAttack* dict_attack, uint8_t sec_read) { void dict_attack_set_sector_read(DictAttack* dict_attack, uint8_t sec_read) {
furi_assert(dict_attack); furi_assert(dict_attack);
with_view_model( with_view_model(

View File

@ -25,6 +25,8 @@ void dict_attack_set_card_detected(DictAttack* dict_attack, MfClassicType type);
void dict_attack_set_card_removed(DictAttack* dict_attack); void dict_attack_set_card_removed(DictAttack* dict_attack);
bool dict_attack_get_card_state(DictAttack* dict_attack);
void dict_attack_set_sector_read(DictAttack* dict_attack, uint8_t sec_read); void dict_attack_set_sector_read(DictAttack* dict_attack, uint8_t sec_read);
void dict_attack_set_keys_found(DictAttack* dict_attack, uint8_t keys_found); void dict_attack_set_keys_found(DictAttack* dict_attack, uint8_t keys_found);