[#2589] Correctly aborts when correct key is found (#2590)

This commit is contained in:
Eric Betts 2023-04-16 22:36:15 -07:00 committed by GitHub
parent 37fb330b36
commit de02a0a25a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 3 deletions

View File

@ -570,7 +570,7 @@ void picopass_worker_elite_dict_attack(PicopassWorker* picopass_worker) {
picopass_worker->callback(PicopassWorkerEventFail, picopass_worker->context); picopass_worker->callback(PicopassWorkerEventFail, picopass_worker->context);
break; break;
} }
picopass_worker->callback(PicopassWorkerEventSuccess, picopass_worker->context); picopass_worker->callback(PicopassWorkerEventAborted, picopass_worker->context);
break; break;
} }
@ -596,6 +596,9 @@ int32_t picopass_worker_task(void* context) {
picopass_worker_write_key(picopass_worker); picopass_worker_write_key(picopass_worker);
} else if(picopass_worker->state == PicopassWorkerStateEliteDictAttack) { } else if(picopass_worker->state == PicopassWorkerStateEliteDictAttack) {
picopass_worker_elite_dict_attack(picopass_worker); picopass_worker_elite_dict_attack(picopass_worker);
} else if(picopass_worker->state == PicopassWorkerStateStop) {
FURI_LOG_D(TAG, "Worker state stop");
// no-op
} else { } else {
FURI_LOG_W(TAG, "Unknown state %d", picopass_worker->state); FURI_LOG_W(TAG, "Unknown state %d", picopass_worker->state);
} }

View File

@ -116,8 +116,7 @@ bool picopass_scene_elite_dict_attack_on_event(void* context, SceneManagerEvent
uint32_t state = uint32_t state =
scene_manager_get_scene_state(picopass->scene_manager, PicopassSceneEliteDictAttack); scene_manager_get_scene_state(picopass->scene_manager, PicopassSceneEliteDictAttack);
if(event.type == SceneManagerEventTypeCustom) { if(event.type == SceneManagerEventTypeCustom) {
if(event.event == PicopassWorkerEventSuccess || if(event.event == PicopassWorkerEventSuccess) {
event.event == PicopassWorkerEventAborted) {
if(state == DictAttackStateUserDictInProgress || if(state == DictAttackStateUserDictInProgress ||
state == DictAttackStateStandardDictInProgress) { state == DictAttackStateStandardDictInProgress) {
picopass_worker_stop(picopass->worker); picopass_worker_stop(picopass->worker);
@ -127,6 +126,9 @@ bool picopass_scene_elite_dict_attack_on_event(void* context, SceneManagerEvent
scene_manager_next_scene(picopass->scene_manager, PicopassSceneReadCardSuccess); scene_manager_next_scene(picopass->scene_manager, PicopassSceneReadCardSuccess);
consumed = true; consumed = true;
} }
} else if(event.event == PicopassWorkerEventAborted) {
scene_manager_next_scene(picopass->scene_manager, PicopassSceneReadCardSuccess);
consumed = true;
} else if(event.event == PicopassWorkerEventCardDetected) { } else if(event.event == PicopassWorkerEventCardDetected) {
dict_attack_set_card_detected(picopass->dict_attack); dict_attack_set_card_detected(picopass->dict_attack);
consumed = true; consumed = true;