goodixmoc: Report recognized print after a match failure

The API should return the recognized print, even if none of the prints
given in the gallery (or the one passed to verify) matched. Without this
the garbage-collection of left-over prints does not work, causing issues
after reinstall.

Fixes: #444
This commit is contained in:
Benjamin Berg
2022-02-03 14:46:40 +01:00
parent e0fd178bec
commit 9ce6ed4164

View File

@@ -420,12 +420,9 @@ fp_verify_cb (FpiDeviceGoodixMoc *self,
gxfp_cmd_response_t *resp, gxfp_cmd_response_t *resp,
GError *error) GError *error)
{ {
g_autoptr(GPtrArray) templates = NULL;
FpDevice *device = FP_DEVICE (self); FpDevice *device = FP_DEVICE (self);
FpPrint *match = NULL; FpPrint *new_scan = NULL;
FpPrint *print = NULL; FpPrint *matching = NULL;
gint cnt = 0;
gboolean find = false;
if (error) if (error)
{ {
@@ -434,46 +431,34 @@ fp_verify_cb (FpiDeviceGoodixMoc *self,
} }
if (resp->verify.match) if (resp->verify.match)
{ {
match = fp_print_from_template (self, &resp->verify.template); new_scan = fp_print_from_template (self, &resp->verify.template);
if (fpi_device_get_current_action (device) == FPI_DEVICE_ACTION_VERIFY) if (fpi_device_get_current_action (device) == FPI_DEVICE_ACTION_VERIFY)
{ {
templates = g_ptr_array_sized_new (1); fpi_device_get_verify_data (device, &matching);
fpi_device_get_verify_data (device, &print); if (!fp_print_equal (matching, new_scan))
g_ptr_array_add (templates, print); matching = NULL;
} }
else else
{ {
GPtrArray *templates = NULL;
fpi_device_get_identify_data (device, &templates); fpi_device_get_identify_data (device, &templates);
g_ptr_array_ref (templates);
}
for (cnt = 0; cnt < templates->len; cnt++)
{
print = g_ptr_array_index (templates, cnt);
if (fp_print_equal (print, match)) for (gint i = 0; i < templates->len; i++)
{ {
find = true; if (fp_print_equal (g_ptr_array_index (templates, i), new_scan))
{
matching = g_ptr_array_index (templates, i);
break; break;
} }
} }
if (find)
{
if (fpi_device_get_current_action (device) == FPI_DEVICE_ACTION_VERIFY)
fpi_device_verify_report (device, FPI_MATCH_SUCCESS, match, error);
else
fpi_device_identify_report (device, print, match, error);
} }
} }
if (!find)
{
if (fpi_device_get_current_action (device) == FPI_DEVICE_ACTION_VERIFY) if (fpi_device_get_current_action (device) == FPI_DEVICE_ACTION_VERIFY)
fpi_device_verify_report (device, FPI_MATCH_FAIL, NULL, error); fpi_device_verify_report (device, matching ? FPI_MATCH_SUCCESS : FPI_MATCH_FAIL, new_scan, error);
else else
fpi_device_identify_report (device, NULL, NULL, error); fpi_device_identify_report (device, matching, new_scan, error);
}
fpi_ssm_next_state (self->task_ssm); fpi_ssm_next_state (self->task_ssm);