drivers: Remove redundant verify implementations

As per recent changes, drivers can just avoid implementing verify vfunc
unless the driver has specific commands to do it.

So let's just drop the duplicated code in drivers that have the very
same code path for both identification and verification.
This commit is contained in:
Marco Trevisan (Treviño)
2026-07-12 12:58:52 +02:00
parent bebaa80c99
commit c5e49592cd
10 changed files with 299 additions and 513 deletions
+6 -27
View File
@@ -951,7 +951,7 @@ egis_etu905_enroll_begin_cb (FpDevice *device,
/*
* Builds the full "check" payload which includes identifiers for all
* fingerprints which currently should exist on the storage. This payload is
* used during both enrollment and verify actions.
* used during both enrollment and identify actions.
*/
static guchar *
egis_etu905_get_check_cmd (FpDevice *device,
@@ -1184,7 +1184,6 @@ egis_etu905_identify_check_cb (FpDevice *device,
FpiDeviceEgisEtu905 *self = FPI_DEVICE_EGIS_ETU905 (device);
guint8 device_print_id[EGIS_ETU905_FINGERPRINT_DATA_SIZE];
FpPrint *print = NULL;
FpPrint *verify_print = NULL;
GPtrArray *prints;
gboolean found = FALSE;
guint index;
@@ -1260,8 +1259,6 @@ egis_etu905_identify_check_cb (FpDevice *device,
fp_info ("Identify successful for: %s", fp_print_get_description (print));
if (fpi_device_get_current_action (device) == FPI_DEVICE_ACTION_IDENTIFY)
{
fpi_device_get_identify_data (device, &prints);
found = g_ptr_array_find_with_equal_func (prints,
print,
@@ -1273,17 +1270,6 @@ egis_etu905_identify_check_cb (FpDevice *device,
else
fpi_device_identify_report (device, NULL, print, NULL);
}
else
{
fpi_device_get_verify_data (device, &verify_print);
fp_info ("Verifying against: %s", fp_print_get_description (verify_print));
if (fp_print_equal (verify_print, print))
fpi_device_verify_report (device, FPI_MATCH_SUCCESS, print, NULL);
else
fpi_device_verify_report (device, FPI_MATCH_FAIL, print, NULL);
}
}
/* If device was successfully read but it was a "not matched" */
else if (egis_etu905_validate_response_suffix (buffer_in,
length_in,
@@ -1292,9 +1278,6 @@ egis_etu905_identify_check_cb (FpDevice *device,
{
fp_info ("Print was not identified by the device");
if (fpi_device_get_current_action (device) == FPI_DEVICE_ACTION_VERIFY)
fpi_device_verify_report (device, FPI_MATCH_FAIL, NULL, NULL);
else
fpi_device_identify_report (device, NULL, NULL, NULL);
}
else
@@ -1367,17 +1350,14 @@ egis_etu905_identify_run_state (FpiSsm *ssm,
/*
* In Windows, the driver seems at this point to then immediately take
* another read from the sensor; this is suspected to be an on-chip
* "verify". However, because the user's finger is still on the sensor from
* "identify". However, because the user's finger is still on the sensor from
* the identify, then it seems to always return positive. We will consider
* this extra step unnecessary and just skip it in this driver. This driver
* will instead handle matching of the FpPrint from the gallery in the
* "verify" case of the callback egis_etu905_identify_check_cb.
* callback egis_etu905_identify_check_cb.
*/
case IDENTIFY_COMPLETE:
if (fpi_device_get_current_action (device) == FPI_DEVICE_ACTION_IDENTIFY)
fpi_device_identify_complete (device, NULL);
else
fpi_device_verify_complete (device, NULL);
fpi_ssm_mark_completed (ssm);
break;
@@ -1385,9 +1365,9 @@ egis_etu905_identify_run_state (FpiSsm *ssm,
}
static void
egis_etu905_identify_verify (FpDevice *device)
egis_etu905_identify (FpDevice *device)
{
fp_dbg ("Identify or Verify");
fp_dbg ("Identify");
FpiDeviceEgisEtu905 *self = FPI_DEVICE_EGIS_ETU905 (device);
g_assert (self->task_ssm == NULL);
@@ -1656,8 +1636,7 @@ fpi_device_egis_etu905_class_init (FpiDeviceEgisEtu905Class *klass)
dev_class->probe = egis_etu905_probe;
dev_class->open = egis_etu905_open;
dev_class->close = egis_etu905_close;
dev_class->identify = egis_etu905_identify_verify;
dev_class->verify = egis_etu905_identify_verify;
dev_class->identify = egis_etu905_identify;
dev_class->enroll = egis_etu905_enroll;
dev_class->delete = egis_etu905_delete;
dev_class->clear_storage = egis_etu905_clear_storage;
+6 -27
View File
@@ -889,7 +889,7 @@ egismoc_enroll_check_cb (FpDevice *device,
/*
* Builds the full "check" payload which includes identifiers for all
* fingerprints which currently should exist on the storage. This payload is
* used during both enrollment and verify actions.
* used during both enrollment and identify actions.
*/
static guchar *
egismoc_get_check_cmd (FpDevice *device,
@@ -1157,7 +1157,6 @@ egismoc_identify_check_cb (FpDevice *device,
FpiDeviceEgisMoc *self = FPI_DEVICE_EGISMOC (device);
gchar device_print_id[EGISMOC_FINGERPRINT_DATA_SIZE];
FpPrint *print = NULL;
FpPrint *verify_print = NULL;
GPtrArray *prints;
gboolean found = FALSE;
guint index;
@@ -1199,8 +1198,6 @@ egismoc_identify_check_cb (FpDevice *device,
fp_info ("Identify successful for: %s", fp_print_get_description (print));
if (fpi_device_get_current_action (device) == FPI_DEVICE_ACTION_IDENTIFY)
{
fpi_device_get_identify_data (device, &prints);
found = g_ptr_array_find_with_equal_func (prints,
print,
@@ -1212,17 +1209,6 @@ egismoc_identify_check_cb (FpDevice *device,
else
fpi_device_identify_report (device, NULL, print, NULL);
}
else
{
fpi_device_get_verify_data (device, &verify_print);
fp_info ("Verifying against: %s", fp_print_get_description (verify_print));
if (fp_print_equal (verify_print, print))
fpi_device_verify_report (device, FPI_MATCH_SUCCESS, print, NULL);
else
fpi_device_verify_report (device, FPI_MATCH_FAIL, print, NULL);
}
}
/* If device was successfully read but it was a "not matched" */
else if (egismoc_validate_response_suffix (buffer_in,
length_in,
@@ -1231,9 +1217,6 @@ egismoc_identify_check_cb (FpDevice *device,
{
fp_info ("Print was not identified by the device");
if (fpi_device_get_current_action (device) == FPI_DEVICE_ACTION_VERIFY)
fpi_device_verify_report (device, FPI_MATCH_FAIL, NULL, NULL);
else
fpi_device_identify_report (device, NULL, NULL, NULL);
}
else
@@ -1306,17 +1289,14 @@ egismoc_identify_run_state (FpiSsm *ssm,
/*
* In Windows, the driver seems at this point to then immediately take
* another read from the sensor; this is suspected to be an on-chip
* "verify". However, because the user's finger is still on the sensor from
* "identify". However, because the user's finger is still on the sensor from
* the identify, then it seems to always return positive. We will consider
* this extra step unnecessary and just skip it in this driver. This driver
* will instead handle matching of the FpPrint from the gallery in the
* "verify" case of the callback egismoc_identify_check_cb.
* callback egismoc_identify_check_cb.
*/
case IDENTIFY_COMPLETE:
if (fpi_device_get_current_action (device) == FPI_DEVICE_ACTION_IDENTIFY)
fpi_device_identify_complete (device, NULL);
else
fpi_device_verify_complete (device, NULL);
fpi_ssm_mark_completed (ssm);
break;
@@ -1324,9 +1304,9 @@ egismoc_identify_run_state (FpiSsm *ssm,
}
static void
egismoc_identify_verify (FpDevice *device)
egismoc_identify (FpDevice *device)
{
fp_dbg ("Identify or Verify");
fp_dbg ("Identify");
FpiDeviceEgisMoc *self = FPI_DEVICE_EGISMOC (device);
g_assert (self->task_ssm == NULL);
@@ -1619,8 +1599,7 @@ fpi_device_egismoc_class_init (FpiDeviceEgisMocClass *klass)
dev_class->cancel = egismoc_cancel;
dev_class->suspend = egismoc_suspend;
dev_class->close = egismoc_close;
dev_class->identify = egismoc_identify_verify;
dev_class->verify = egismoc_identify_verify;
dev_class->identify = egismoc_identify;
dev_class->enroll = egismoc_enroll;
dev_class->delete = egismoc_delete;
dev_class->clear_storage = egismoc_clear_storage;
+2 -36
View File
@@ -639,7 +639,6 @@ elanmoc_match_report_cb (FpiDeviceElanmoc *self,
{
FpDevice *device = FP_DEVICE (self);
FpPrint *print = NULL;
FpPrint *verify_print = NULL;
GPtrArray *prints;
gboolean found = FALSE;
guint index;
@@ -668,8 +667,6 @@ elanmoc_match_report_cb (FpiDeviceElanmoc *self,
fp_info ("Verify/Identify successful for: %s", fp_print_get_description (print));
if (fpi_device_get_current_action (device) == FPI_DEVICE_ACTION_IDENTIFY)
{
fpi_device_get_identify_data (device, &prints);
found = g_ptr_array_find_with_equal_func (prints,
print,
@@ -682,17 +679,6 @@ elanmoc_match_report_cb (FpiDeviceElanmoc *self,
fpi_device_identify_report (device, NULL, print, NULL);
fpi_device_identify_complete (device, NULL);
}
else
{
fpi_device_get_verify_data (device, &verify_print);
if (fp_print_equal (verify_print, print))
fpi_device_verify_report (device, FPI_MATCH_SUCCESS, print, NULL);
else
fpi_device_verify_report (device, FPI_MATCH_FAIL, print, NULL);
fpi_device_verify_complete (device, NULL);
}
}
static void
@@ -704,9 +690,6 @@ identify_status_report (FpiDeviceElanmoc *self, int verify_status_id,
if (error)
{
if (fpi_device_get_current_action (device) == FPI_DEVICE_ACTION_VERIFY)
fpi_device_verify_complete (device, error);
else
fpi_device_identify_complete (device, error);
return;
}
@@ -716,18 +699,10 @@ identify_status_report (FpiDeviceElanmoc *self, int verify_status_id,
case RSP_VERIFY_FAIL:
{
if (data == ELAN_MSG_VERIFY_ERR)
{
if (fpi_device_get_current_action (device) == FPI_DEVICE_ACTION_VERIFY)
{
fpi_device_verify_report (device, FPI_MATCH_FAIL, NULL, NULL);
fpi_device_verify_complete (device, NULL);
}
else
{
fpi_device_identify_report (device, NULL, NULL, NULL);
fpi_device_identify_complete (device, NULL);
}
}
else
{
GError *retry_error;
@@ -745,23 +720,15 @@ identify_status_report (FpiDeviceElanmoc *self, int verify_status_id,
retry_error = fpi_device_retry_new (FP_DEVICE_RETRY_GENERAL);
}
if (fpi_device_get_current_action (device) == FPI_DEVICE_ACTION_VERIFY)
{
fpi_device_verify_report (device, FPI_MATCH_ERROR, NULL, retry_error);
fpi_device_verify_complete (device, NULL);
}
else
{
fpi_device_identify_report (device, NULL, NULL, retry_error);
fpi_device_identify_complete (device, NULL);
}
}
break;
}
case RSP_VERIFY_OK:
{
fp_dbg ("Verify was successful! for user: %d mesg_code: %d ", data, verify_status_id);
fp_dbg ("Identify was successful! for user: %d mesg_code: %d ", data, verify_status_id);
cmd_buf = elanmoc_compose_cmd (&elanmoc_get_userid_cmd);
cmd_buf[2] = data;
elanmoc_get_cmd (device, cmd_buf, elanmoc_get_userid_cmd.cmd_len, elanmoc_get_userid_cmd.resp_len, 0, elanmoc_match_report_cb);
@@ -815,7 +782,7 @@ elan_identify_run_state (FpiSsm *ssm, FpDevice *dev)
break;
case IDENTIFY_WAIT_FINGER:
fp_info ("elanmoc %s VERIFY_WAIT_FINGER", __func__);
fp_info ("elanmoc %s IDENTIFY_WAIT_FINGER", __func__);
cmd_buf = elanmoc_compose_cmd (&elanmoc_verify_cmd);
elanmoc_get_cmd (dev, cmd_buf, elanmoc_verify_cmd.cmd_len, elanmoc_verify_cmd.resp_len, 1, elanmoc_identify_cb);
break;
@@ -1175,7 +1142,6 @@ fpi_device_elanmoc_class_init (FpiDeviceElanmocClass *klass)
dev_class->open = elanmoc_open;
dev_class->close = elanmoc_close;
dev_class->verify = elanmoc_identify;
dev_class->enroll = elanmoc_enroll;
dev_class->identify = elanmoc_identify;
dev_class->delete = elanmoc_delete_print;
@@ -805,18 +805,10 @@ focaltech_moc_identify_capture_cb (FpiDeviceFocaltechMoc *self,
{
fpi_ssm_next_state (self->task_ssm);
}
else
{
if (fpi_device_get_current_action (FP_DEVICE (self)) == FPI_DEVICE_ACTION_VERIFY)
{
fpi_device_verify_report (FP_DEVICE (self), FPI_MATCH_ERROR, NULL, error);
fpi_device_verify_complete (FP_DEVICE (self), NULL);
}
else
{
fpi_device_identify_report (FP_DEVICE (self), NULL, NULL, error);
fpi_device_identify_complete (FP_DEVICE (self), NULL);
}
fpi_ssm_mark_failed (self->task_ssm, fpi_device_retry_new (FP_DEVICE_RETRY_GENERAL));
}
@@ -829,21 +821,11 @@ identify_status_report (FpiDeviceFocaltechMoc *self, FpPrint *print, GError *err
FpDevice *device = FP_DEVICE (self);
if (print == NULL)
{
if (fpi_device_get_current_action (device) == FPI_DEVICE_ACTION_IDENTIFY)
{
fpi_device_identify_report (device, NULL, NULL, NULL);
fpi_device_identify_complete (device, NULL);
}
else
{
fpi_device_verify_report (device, FPI_MATCH_FAIL, NULL, NULL);
fpi_device_verify_complete (device, NULL);
}
}
else
{
if (fpi_device_get_current_action (device) == FPI_DEVICE_ACTION_IDENTIFY)
{
GPtrArray *prints;
gboolean found = FALSE;
@@ -862,19 +844,6 @@ identify_status_report (FpiDeviceFocaltechMoc *self, FpPrint *print, GError *err
fpi_device_identify_complete (device, NULL);
}
else
{
FpPrint *verify_print = NULL;
fpi_device_get_verify_data (device, &verify_print);
if (fp_print_equal (verify_print, print))
fpi_device_verify_report (device, FPI_MATCH_SUCCESS, print, NULL);
else
fpi_device_verify_report (device, FPI_MATCH_FAIL, print, NULL);
fpi_device_verify_complete (device, NULL);
}
}
}
static void
@@ -2043,7 +2012,6 @@ fpi_device_focaltech_moc_class_init (FpiDeviceFocaltechMocClass *klass)
dev_class->probe = focaltech_moc_probe;
dev_class->open = focaltech_moc_open;
dev_class->close = focaltech_moc_close;
dev_class->verify = focaltech_moc_identify;
dev_class->enroll = focaltech_moc_enroll;
dev_class->identify = focaltech_moc_identify;
dev_class->delete = focaltech_moc_delete_print;
+22 -66
View File
@@ -1355,19 +1355,17 @@ fpc_enroll_ssm_done (FpiSsm *ssm, FpDevice *dev, GError *error)
/******************************************************************************
*
* fpc_verify_xxx function
* fpc_identify_xxx function
*
*****************************************************************************/
static void
fpc_verify_cb (FpiDeviceFpcMoc *self,
fpc_identify_cb (FpiDeviceFpcMoc *self,
void *data,
GError *error)
{
g_autoptr(GPtrArray) templates = NULL;
FpDevice *device = FP_DEVICE (self);
gboolean found = FALSE;
FpiDeviceAction current_action;
FpiByteReader reader;
gint32 status;
guint32 identity_type;
@@ -1394,18 +1392,11 @@ fpc_verify_cb (FpiDeviceFpcMoc *self,
return;
}
current_action = fpi_device_get_current_action (device);
g_assert (current_action == FPI_DEVICE_ACTION_VERIFY ||
current_action == FPI_DEVICE_ACTION_IDENTIFY);
if ((status == 0) && (subfactor == FPC_SUBTYPE_RESERVED) &&
(identity_type == FPC_IDENTITY_TYPE_RESERVED) &&
(identity_size <= SECURITY_MAX_SID_SIZE))
{
FpPrint *match = NULL;
FpPrint *print = NULL;
gint cnt = 0;
fpc_fid_data_t fid_data = {0};
fid_data.subfactor = subfactor;
@@ -1421,34 +1412,16 @@ fpc_verify_cb (FpiDeviceFpcMoc *self,
match = fpc_print_from_data (self, &fid_data);
if (current_action == FPI_DEVICE_ACTION_VERIFY)
{
templates = g_ptr_array_sized_new (1);
fpi_device_get_verify_data (device, &print);
g_ptr_array_add (templates, print);
}
else
{
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);
guint matching_index;
if (fp_print_equal (print, match))
if (g_ptr_array_find_with_equal_func (templates, match,
(GEqualFunc) fp_print_equal, &matching_index))
{
found = TRUE;
break;
}
}
FpPrint *print = g_ptr_array_index (templates, matching_index);
if (found)
{
if (current_action == FPI_DEVICE_ACTION_VERIFY)
fpi_device_verify_report (device, FPI_MATCH_SUCCESS, match, error);
else
fpi_device_identify_report (device, print, match, error);
fpi_ssm_mark_completed (self->task_ssm);
@@ -1456,27 +1429,19 @@ fpc_verify_cb (FpiDeviceFpcMoc *self,
}
}
if (!found)
{
if (current_action == FPI_DEVICE_ACTION_VERIFY)
fpi_device_verify_report (device, FPI_MATCH_FAIL, NULL, error);
else
fpi_device_identify_report (device, NULL, NULL, error);
}
/* This is the last state for verify/identify */
fpi_ssm_mark_completed (self->task_ssm);
}
static void
fpc_verify_sm_run_state (FpiSsm *ssm, FpDevice *device)
fpc_identify_sm_run_state (FpiSsm *ssm, FpDevice *device)
{
FpiDeviceFpcMoc *self = FPI_DEVICE_FPCMOC (device);
CommandData cmd_data = {0};
switch (fpi_ssm_get_cur_state (ssm))
{
case FPC_VERIFY_CAPTURE:
case FPC_IDENTIFY_CAPTURE:
{
guint8 buf[4];
FpiByteWriter writer;
@@ -1499,7 +1464,7 @@ fpc_verify_sm_run_state (FpiSsm *ssm, FpDevice *device)
}
break;
case FPC_VERIFY_GET_IMG:
case FPC_IDENTIFY_GET_IMG:
{
cmd_data.cmdtype = FPC_CMDTYPE_TO_DEVICE_EVTDATA;
cmd_data.request = FPC_CMD_GET_IMG;
@@ -1513,7 +1478,7 @@ fpc_verify_sm_run_state (FpiSsm *ssm, FpDevice *device)
}
break;
case FPC_VERIFY_IDENTIFY:
case FPC_IDENTIFY_IDENTIFY:
{
gsize recv_data_len = sizeof (FPC_IDENTIFY);
cmd_data.cmdtype = FPC_CMDTYPE_FROM_DEVICE;
@@ -1522,13 +1487,13 @@ fpc_verify_sm_run_state (FpiSsm *ssm, FpDevice *device)
cmd_data.index = 0x0;
cmd_data.data = NULL;
cmd_data.data_len = recv_data_len;
cmd_data.callback = fpc_verify_cb;
cmd_data.callback = fpc_identify_cb;
fpc_sensor_cmd (self, FALSE, &cmd_data);
}
break;
case FPC_VERIFY_CANCEL:
case FPC_IDENTIFY_CANCEL:
{
cmd_data.cmdtype = FPC_CMDTYPE_TO_DEVICE;
cmd_data.request = FPC_CMD_ABORT;
@@ -1545,23 +1510,15 @@ fpc_verify_sm_run_state (FpiSsm *ssm, FpDevice *device)
}
static void
fpc_verify_ssm_done (FpiSsm *ssm, FpDevice *dev, GError *error)
fpc_identify_ssm_done (FpiSsm *ssm, FpDevice *dev, GError *error)
{
FpiDeviceFpcMoc *self = FPI_DEVICE_FPCMOC (dev);
fp_info ("Verify_identify complete!");
if (error && error->domain == FP_DEVICE_RETRY)
{
if (fpi_device_get_current_action (dev) == FPI_DEVICE_ACTION_VERIFY)
fpi_device_verify_report (dev, FPI_MATCH_ERROR, NULL, g_steal_pointer (&error));
else
fpi_device_identify_report (dev, NULL, NULL, g_steal_pointer (&error));
}
if (fpi_device_get_current_action (dev) == FPI_DEVICE_ACTION_VERIFY)
fpi_device_verify_complete (dev, g_steal_pointer (&error));
else
fpi_device_identify_complete (dev, g_steal_pointer (&error));
self->task_ssm = NULL;
@@ -1920,17 +1877,17 @@ fpc_dev_close (FpDevice *device)
}
static void
fpc_dev_verify_identify (FpDevice *device)
fpc_dev_identify (FpDevice *device)
{
FpiDeviceFpcMoc *self = FPI_DEVICE_FPCMOC (device);
fp_dbg ("%s enter -->", G_STRFUNC);
self->task_ssm = fpi_ssm_new_full (device, fpc_verify_sm_run_state,
FPC_VERIFY_NUM_STATES,
FPC_VERIFY_CANCEL,
"verify_identify");
self->task_ssm = fpi_ssm_new_full (device, fpc_identify_sm_run_state,
FPC_IDENTIFY_NUM_STATES,
FPC_IDENTIFY_CANCEL,
"identify");
fpi_ssm_start (self->task_ssm, fpc_verify_ssm_done);
fpi_ssm_start (self->task_ssm, fpc_identify_ssm_done);
}
static void
@@ -1986,7 +1943,7 @@ fpc_dev_suspend (FpDevice *device)
fp_dbg ("%s enter -->", G_STRFUNC);
if (action != FPI_DEVICE_ACTION_VERIFY && action != FPI_DEVICE_ACTION_IDENTIFY)
if (action != FPI_DEVICE_ACTION_IDENTIFY)
{
fpi_device_suspend_complete (device, fpi_device_error_new (FP_DEVICE_ERROR_NOT_SUPPORTED));
return;
@@ -2006,7 +1963,7 @@ fpc_dev_resume (FpDevice *device)
fp_dbg ("%s enter -->", G_STRFUNC);
if (action != FPI_DEVICE_ACTION_VERIFY && action != FPI_DEVICE_ACTION_IDENTIFY)
if (action != FPI_DEVICE_ACTION_IDENTIFY)
{
g_assert_not_reached ();
fpi_device_resume_complete (device, fpi_device_error_new (FP_DEVICE_ERROR_NOT_SUPPORTED));
@@ -2118,8 +2075,7 @@ fpi_device_fpcmoc_class_init (FpiDeviceFpcMocClass *klass)
dev_class->enroll = fpc_dev_enroll;
dev_class->delete = fpc_dev_template_delete;
dev_class->list = fpc_dev_template_list;
dev_class->verify = fpc_dev_verify_identify;
dev_class->identify = fpc_dev_verify_identify;
dev_class->identify = fpc_dev_identify;
dev_class->suspend = fpc_dev_suspend;
dev_class->resume = fpc_dev_resume;
dev_class->clear_storage = fpc_dev_clear_storage;
+5 -5
View File
@@ -207,11 +207,11 @@ typedef enum {
} FpcEnrollState;
typedef enum {
FPC_VERIFY_CAPTURE = 0,
FPC_VERIFY_GET_IMG,
FPC_VERIFY_IDENTIFY,
FPC_VERIFY_CANCEL,
FPC_VERIFY_NUM_STATES,
FPC_IDENTIFY_CAPTURE = 0,
FPC_IDENTIFY_GET_IMG,
FPC_IDENTIFY_IDENTIFY,
FPC_IDENTIFY_CANCEL,
FPC_IDENTIFY_NUM_STATES,
} FpcVerifyState;
typedef enum {
+32 -56
View File
@@ -19,6 +19,7 @@
#include "glib.h"
#define FP_COMPONENT "goodixmoc"
#include "drivers_api.h"
@@ -393,11 +394,11 @@ fp_pwr_btn_shield_cb (FpiDeviceGoodixMoc *self,
}
/******************************************************************************
*
* fp_verify_xxxx Function
* fp_identify_xxxx Function
*
*****************************************************************************/
static void
fp_verify_capture_cb (FpiDeviceGoodixMoc *self,
fp_identify_capture_cb (FpiDeviceGoodixMoc *self,
gxfp_cmd_response_t *resp,
GError *error)
{
@@ -432,7 +433,7 @@ fp_verify_capture_cb (FpiDeviceGoodixMoc *self,
}
static void
fp_verify_cb (FpiDeviceGoodixMoc *self,
fp_identify_cb (FpiDeviceGoodixMoc *self,
gxfp_cmd_response_t *resp,
GError *error)
{
@@ -445,43 +446,28 @@ fp_verify_cb (FpiDeviceGoodixMoc *self,
fpi_ssm_mark_failed (self->task_ssm, error);
return;
}
if (resp->verify.match)
{
GPtrArray *templates = NULL;
guint matching_index;
fpi_device_get_identify_data (device, &templates);
new_scan = fp_print_from_template (self, &resp->verify.template);
if (fpi_device_get_current_action (device) == FPI_DEVICE_ACTION_VERIFY)
{
fpi_device_get_verify_data (device, &matching);
if (!fp_print_equal (matching, new_scan))
matching = NULL;
}
else
{
GPtrArray *templates = NULL;
fpi_device_get_identify_data (device, &templates);
for (gint i = 0; i < templates->len; i++)
{
if (fp_print_equal (g_ptr_array_index (templates, i), new_scan))
{
matching = g_ptr_array_index (templates, i);
break;
}
}
}
if (g_ptr_array_find_with_equal_func (templates, new_scan,
(GEqualFunc) fp_print_equal,
&matching_index))
matching = g_ptr_array_index (templates, matching_index);
}
if (fpi_device_get_current_action (device) == FPI_DEVICE_ACTION_VERIFY)
fpi_device_verify_report (device, matching ? FPI_MATCH_SUCCESS : FPI_MATCH_FAIL, new_scan, error);
else
fpi_device_identify_report (device, matching, new_scan, error);
fpi_ssm_next_state (self->task_ssm);
}
static void
fp_verify_finger_mode_cb (FpiDeviceGoodixMoc *self,
fp_identify_finger_mode_cb (FpiDeviceGoodixMoc *self,
gxfp_cmd_response_t *resp,
GError *error)
{
@@ -493,7 +479,7 @@ fp_verify_finger_mode_cb (FpiDeviceGoodixMoc *self,
/* if reach max timeout(5sec) finger not up, try again */
if (resp->finger_status.status == GX_ERROR_WAIT_FINGER_UP_TIMEOUT)
{
fpi_ssm_jump_to_state (self->task_ssm, GOODIX_VERIFY_WAIT_FINGER_UP);
fpi_ssm_jump_to_state (self->task_ssm, GOODIX_IDENTIFY_WAIT_FINGER_UP);
return;
}
else if (resp->finger_status.status != GX_SUCCESS)
@@ -510,7 +496,7 @@ fp_verify_finger_mode_cb (FpiDeviceGoodixMoc *self,
}
static void
fp_verify_sm_run_state (FpiSsm *ssm, FpDevice *device)
fp_identify_sm_run_state (FpiSsm *ssm, FpDevice *device)
{
FpiDeviceGoodixMoc *self = FPI_DEVICE_GOODIXMOC (device);
guint8 param[3] = { 0 };
@@ -522,7 +508,7 @@ fp_verify_sm_run_state (FpiSsm *ssm, FpDevice *device)
switch (fpi_ssm_get_cur_state (ssm))
{
case GOODIX_VERIFY_PWR_BTN_SHIELD_ON:
case GOODIX_IDENTIFY_PWR_BTN_SHIELD_ON:
goodix_sensor_cmd (self, MOC_CMD0_PWR_BTN_SHIELD, MOC_CMD1_PWR_BTN_SHIELD_ON,
false,
NULL,
@@ -530,7 +516,7 @@ fp_verify_sm_run_state (FpiSsm *ssm, FpDevice *device)
fp_pwr_btn_shield_cb);
break;
case GOODIX_VERIFY_CAPTURE:
case GOODIX_IDENTIFY_CAPTURE:
fpi_device_report_finger_status_changes (device,
FP_FINGER_STATUS_NEEDED,
FP_FINGER_STATUS_NONE);
@@ -538,29 +524,29 @@ fp_verify_sm_run_state (FpiSsm *ssm, FpDevice *device)
true,
(const guint8 *) &param,
G_N_ELEMENTS (param),
fp_verify_capture_cb);
fp_identify_capture_cb);
break;
case GOODIX_VERIFY_IDENTIFY:
case GOODIX_IDENTIFY_IDENTIFY:
goodix_sensor_cmd (self, MOC_CMD0_IDENTIFY, MOC_CMD1_DEFAULT,
false,
(const guint8 *) nonce,
TEMPLATE_ID_SIZE,
fp_verify_cb);
fp_identify_cb);
break;
case GOODIX_VERIFY_WAIT_FINGER_UP:
case GOODIX_IDENTIFY_WAIT_FINGER_UP:
{
guint8 dummy = 0;
goodix_sensor_cmd (self, MOC_CMD0_FINGER_MODE, MOC_CMD1_SET_FINGER_UP,
true,
&dummy,
1,
fp_verify_finger_mode_cb);
fp_identify_finger_mode_cb);
}
break;
case GOODIX_VERIFY_PWR_BTN_SHIELD_OFF:
case GOODIX_IDENTIFY_PWR_BTN_SHIELD_OFF:
goodix_sensor_cmd (self, MOC_CMD0_PWR_BTN_SHIELD, MOC_CMD1_PWR_BTN_SHIELD_OFF,
false,
NULL,
@@ -572,24 +558,15 @@ fp_verify_sm_run_state (FpiSsm *ssm, FpDevice *device)
}
static void
fp_verify_ssm_done (FpiSsm *ssm, FpDevice *dev, GError *error)
fp_identify_ssm_done (FpiSsm *ssm, FpDevice *dev, GError *error)
{
FpiDeviceGoodixMoc *self = FPI_DEVICE_GOODIXMOC (dev);
fp_info ("Verify complete!");
if (error && error->domain == FP_DEVICE_RETRY)
{
if (fpi_device_get_current_action (dev) == FPI_DEVICE_ACTION_VERIFY)
fpi_device_verify_report (dev, FPI_MATCH_ERROR, NULL, g_steal_pointer (&error));
else
fpi_device_identify_report (dev, NULL, NULL, g_steal_pointer (&error));
}
if (fpi_device_get_current_action (dev) == FPI_DEVICE_ACTION_VERIFY)
fpi_device_verify_complete (dev, error);
else
fpi_device_identify_complete (dev, error);
self->task_ssm = NULL;
@@ -1557,16 +1534,16 @@ gx_fp_exit (FpDevice *device)
static void
gx_fp_verify_identify (FpDevice *device)
gx_fp_identify (FpDevice *device)
{
FpiDeviceGoodixMoc *self = FPI_DEVICE_GOODIXMOC (device);
self->task_ssm = fpi_ssm_new_full (device, fp_verify_sm_run_state,
GOODIX_VERIFY_NUM_STATES,
GOODIX_VERIFY_PWR_BTN_SHIELD_OFF,
"verify");
self->task_ssm = fpi_ssm_new_full (device, fp_identify_sm_run_state,
GOODIX_IDENTIFY_NUM_STATES,
GOODIX_IDENTIFY_PWR_BTN_SHIELD_OFF,
"identify");
fpi_ssm_start (self->task_ssm, fp_verify_ssm_done);
fpi_ssm_start (self->task_ssm, fp_identify_ssm_done);
}
@@ -1730,8 +1707,7 @@ fpi_device_goodixmoc_class_init (FpiDeviceGoodixMocClass *klass)
dev_class->delete = gx_fp_template_delete;
dev_class->clear_storage = gx_fp_template_delete_all;
dev_class->list = gx_fp_template_list;
dev_class->verify = gx_fp_verify_identify;
dev_class->identify = gx_fp_verify_identify;
dev_class->identify = gx_fp_identify;
fpi_device_class_auto_initialize_features (dev_class);
dev_class->features |= FP_DEVICE_FEATURE_DUPLICATES_CHECK;
+6 -6
View File
@@ -55,10 +55,10 @@ typedef enum {
} GoodixEnrollState;
typedef enum {
GOODIX_VERIFY_PWR_BTN_SHIELD_ON = 0,
GOODIX_VERIFY_CAPTURE,
GOODIX_VERIFY_IDENTIFY,
GOODIX_VERIFY_WAIT_FINGER_UP,
GOODIX_VERIFY_PWR_BTN_SHIELD_OFF,
GOODIX_VERIFY_NUM_STATES,
GOODIX_IDENTIFY_PWR_BTN_SHIELD_ON = 0,
GOODIX_IDENTIFY_CAPTURE,
GOODIX_IDENTIFY_IDENTIFY,
GOODIX_IDENTIFY_WAIT_FINGER_UP,
GOODIX_IDENTIFY_PWR_BTN_SHIELD_OFF,
GOODIX_IDENTIFY_NUM_STATES,
} GoodixVerifyState;
+75 -113
View File
@@ -1429,7 +1429,7 @@ fp_enroll_ssm_done (FpiSsm *ssm, FpDevice *dev, GError *error)
static void
fp_verify_tpl_table_cb (FpiDeviceMafpmoc *self,
fp_identify_tpl_table_cb (FpiDeviceMafpmoc *self,
mafp_cmd_response_t *resp,
GError *error)
{
@@ -1448,13 +1448,13 @@ fp_verify_tpl_table_cb (FpiDeviceMafpmoc *self,
}
static void
fp_verify_get_image_cb (FpiDeviceMafpmoc *self,
fp_identify_get_image_cb (FpiDeviceMafpmoc *self,
mafp_cmd_response_t *resp,
GError *error)
{
g_autoptr(GError) local_error = NULL;
FpDevice *dev = FP_DEVICE (self);
MapfVerifyState nextState = MAPF_VERIFY_GET_IMAGE;
MapfIdentifyState nextState = MAPF_IDENTIFY_GET_IMAGE;
if (error)
{
@@ -1474,16 +1474,16 @@ fp_verify_get_image_cb (FpiDeviceMafpmoc *self,
fp_dbg ("wait finger down state %d", resp->result);
if (resp->result == MAFP_RE_GET_IMAGE_SUCCESS)
{
nextState = MAPF_VERIFY_GENERATE_FEATURE;
nextState = MAPF_IDENTIFY_GENERATE_FEATURE;
}
else if (resp->result == MAFP_RE_GET_IMAGE_NONE)
{
self->capture_cnt++;
fp_dbg ("self->capture_cnt %d", self->capture_cnt);
if (self->capture_cnt > MAFP_IMAGE_ERR_TRRIGER)
nextState = MAPF_VERIFY_REFRESH_INT_PARA;
nextState = MAPF_IDENTIFY_REFRESH_INT_PARA;
else
nextState = MAPF_VERIFY_DETECT_MODE;
nextState = MAPF_IDENTIFY_DETECT_MODE;
}
}
else if (self->press_state == MAFP_PRESS_WAIT_UP)
@@ -1491,13 +1491,13 @@ fp_verify_get_image_cb (FpiDeviceMafpmoc *self,
fp_dbg ("wait finger up state %d", resp->result);
if (resp->result == MAFP_RE_GET_IMAGE_SUCCESS)
{
nextState = MAPF_VERIFY_GET_IMAGE;
nextState = MAPF_IDENTIFY_GET_IMAGE;
}
else if (resp->result == MAFP_RE_GET_IMAGE_NONE)
{
self->press_state = MAFP_PRESS_WAIT_DOWN;
fpi_device_report_finger_status (dev, FP_FINGER_STATUS_NONE | FP_FINGER_STATUS_NEEDED);
nextState = MAPF_VERIFY_CHECK_INT_PARA;
nextState = MAPF_IDENTIFY_CHECK_INT_PARA;
}
}
@@ -1505,7 +1505,7 @@ fp_verify_get_image_cb (FpiDeviceMafpmoc *self,
}
static void
fp_verify_gen_feature_cb (FpiDeviceMafpmoc *self,
fp_identify_gen_feature_cb (FpiDeviceMafpmoc *self,
mafp_cmd_response_t *resp,
GError *error)
{
@@ -1521,12 +1521,12 @@ fp_verify_gen_feature_cb (FpiDeviceMafpmoc *self,
{
self->enroll_identify_index = 0;
self->press_state = MAFP_PRESS_WAIT_UP;
fpi_ssm_jump_to_state (self->task_ssm, MAPF_VERIFY_SEARCH_STEP);
fpi_ssm_jump_to_state (self->task_ssm, MAPF_IDENTIFY_SEARCH_STEP);
}
else
{
self->press_state = MAFP_PRESS_WAIT_UP;
fpi_ssm_jump_to_state (self->task_ssm, MAPF_VERIFY_GET_IMAGE);
fpi_ssm_jump_to_state (self->task_ssm, MAPF_IDENTIFY_GET_IMAGE);
}
}
@@ -1539,11 +1539,11 @@ mafp_scl_ctl_cb (FpiUsbTransfer *transfer,
if (error)
fp_dbg ("control transfer out fail, %s", error->message);
fpi_ssm_jump_to_state (transfer->ssm, MAPF_VERIFY_EXIT);
fpi_ssm_jump_to_state (transfer->ssm, MAPF_IDENTIFY_EXIT);
}
static void
fp_verify_get_tpl_info_cb (FpiDeviceMafpmoc *self,
fp_identify_get_tpl_info_cb (FpiDeviceMafpmoc *self,
mafp_cmd_response_t *resp,
GError *error)
{
@@ -1577,27 +1577,18 @@ fp_verify_get_tpl_info_cb (FpiDeviceMafpmoc *self,
memcpy (tpl.uid, resp->tpl_info.uid, sizeof (resp->tpl_info.uid));
new_scan = mafp_print_from_template (self, &tpl);
}
if (new_scan != NULL)
{
if (fpi_device_get_current_action (dev) == FPI_DEVICE_ACTION_VERIFY)
{
fpi_device_get_verify_data (dev, &matching);
if (!fp_print_equal (matching, new_scan))
matching = NULL;
}
else
{
GPtrArray *templates = NULL;
guint matching_index;
fpi_device_get_identify_data (dev, &templates);
for (int i = 0; i < templates->len; i++)
{
if (fp_print_equal (g_ptr_array_index (templates, i), new_scan))
{
matching = g_ptr_array_index (templates, i);
break;
}
}
}
if (g_ptr_array_find_with_equal_func (templates, new_scan,
(GEqualFunc) fp_print_equal,
&matching_index))
matching = g_ptr_array_index (templates, matching_index);
}
}
@@ -1609,11 +1600,11 @@ fp_verify_get_tpl_info_cb (FpiDeviceMafpmoc *self,
mafp_sensor_control (self, 0x8C, 0x00, mafp_scl_ctl_cb, NULL, 0);
return;
}
fpi_ssm_jump_to_state (self->task_ssm, MAPF_VERIFY_EXIT);
fpi_ssm_jump_to_state (self->task_ssm, MAPF_IDENTIFY_EXIT);
}
static void
fp_verify_search_step_cb (FpiDeviceMafpmoc *self,
fp_identify_search_step_cb (FpiDeviceMafpmoc *self,
mafp_cmd_response_t *resp,
GError *error)
{
@@ -1630,23 +1621,20 @@ fp_verify_search_step_cb (FpiDeviceMafpmoc *self,
if (resp->result == MAFP_SUCCESS)
{
fp_dbg ("identify ok, search_id: %d", self->search_id);
fpi_ssm_jump_to_state (self->task_ssm, MAPF_VERIFY_GET_TEMPLATE_INFO);
fpi_ssm_jump_to_state (self->task_ssm, MAPF_IDENTIFY_GET_TEMPLATE_INFO);
}
else
{
fp_dbg ("identify fail");
if (fpi_device_get_current_action (dev) == FPI_DEVICE_ACTION_IDENTIFY)
{
fpi_device_get_identify_data (dev, &prints);
self->enroll_identify_index++;
if (self->enroll_identify_index < prints->len)
{
fpi_ssm_jump_to_state (self->task_ssm, MAPF_VERIFY_SEARCH_STEP);
fpi_ssm_jump_to_state (self->task_ssm, MAPF_IDENTIFY_SEARCH_STEP);
return;
}
}
self->search_id = G_MAXUINT16;
fpi_ssm_jump_to_state (self->task_ssm, MAPF_VERIFY_GET_TEMPLATE_INFO);
fpi_ssm_jump_to_state (self->task_ssm, MAPF_IDENTIFY_GET_TEMPLATE_INFO);
}
}
@@ -1673,7 +1661,7 @@ mafp_get_startup_result_cb (FpiUsbTransfer *transfer,
{
self->search_id = transfer->buffer[2] * 256 + transfer->buffer[1];
usleep (1000 * 1000);
fpi_ssm_jump_to_state (transfer->ssm, MAPF_VERIFY_GET_TEMPLATE_INFO);
fpi_ssm_jump_to_state (transfer->ssm, MAPF_IDENTIFY_GET_TEMPLATE_INFO);
return;
}
}
@@ -1681,7 +1669,7 @@ mafp_get_startup_result_cb (FpiUsbTransfer *transfer,
}
static void
fp_verify_int_check_cb (FpiDeviceMafpmoc *self,
fp_identify_int_check_cb (FpiDeviceMafpmoc *self,
mafp_cmd_response_t *resp,
GError *error)
{
@@ -1694,7 +1682,7 @@ fp_verify_int_check_cb (FpiDeviceMafpmoc *self,
}
static void
fp_verify_int_detect_cb (FpiDeviceMafpmoc *self,
fp_identify_int_detect_cb (FpiDeviceMafpmoc *self,
mafp_cmd_response_t *resp,
GError *error)
{
@@ -1707,7 +1695,7 @@ fp_verify_int_detect_cb (FpiDeviceMafpmoc *self,
}
static void
fp_verify_int_refresh_cb (FpiDeviceMafpmoc *self,
fp_identify_int_refresh_cb (FpiDeviceMafpmoc *self,
mafp_cmd_response_t *resp,
GError *error)
{
@@ -1717,11 +1705,11 @@ fp_verify_int_refresh_cb (FpiDeviceMafpmoc *self,
return;
}
self->capture_cnt = 0;
fpi_ssm_jump_to_state (self->task_ssm, MAPF_VERIFY_GET_IMAGE);
fpi_ssm_jump_to_state (self->task_ssm, MAPF_IDENTIFY_GET_IMAGE);
}
static void
fp_verify_enable_int_cb (FpiUsbTransfer *transfer,
fp_identify_enable_int_cb (FpiUsbTransfer *transfer,
FpDevice *device,
gpointer user_data,
GError *error)
@@ -1735,7 +1723,7 @@ fp_verify_enable_int_cb (FpiUsbTransfer *transfer,
}
static void
fp_verify_disable_int_cb (FpiUsbTransfer *transfer,
fp_identify_disable_int_cb (FpiUsbTransfer *transfer,
FpDevice *device,
gpointer user_data,
GError *error)
@@ -1745,11 +1733,11 @@ fp_verify_disable_int_cb (FpiUsbTransfer *transfer,
fpi_ssm_mark_failed (transfer->ssm, g_steal_pointer (&error));
return;
}
fpi_ssm_jump_to_state (transfer->ssm, MAPF_VERIFY_GET_IMAGE);
fpi_ssm_jump_to_state (transfer->ssm, MAPF_IDENTIFY_GET_IMAGE);
}
static void
fp_verify_wait_int_cb (FpiUsbTransfer *transfer,
fp_identify_wait_int_cb (FpiUsbTransfer *transfer,
FpDevice *device,
gpointer user_data,
GError *error)
@@ -1761,7 +1749,7 @@ fp_verify_wait_int_cb (FpiUsbTransfer *transfer,
fp_dbg ("code %d", error->code);
if (error->code == G_USB_DEVICE_ERROR_TIMED_OUT)
{
fpi_ssm_jump_to_state (self->task_ssm, MAPF_VERIFY_GET_IMAGE);
fpi_ssm_jump_to_state (self->task_ssm, MAPF_IDENTIFY_GET_IMAGE);
g_clear_error (&error);
return;
}
@@ -1783,7 +1771,7 @@ fp_verify_wait_int_cb (FpiUsbTransfer *transfer,
}
static void
fp_verify_wait_int (FpiDeviceMafpmoc *self)
fp_identify_wait_int (FpiDeviceMafpmoc *self)
{
fp_dbg ("wait interrupt");
FpiUsbTransfer *transfer = fpi_usb_transfer_new (FP_DEVICE (self));
@@ -1792,12 +1780,12 @@ fp_verify_wait_int (FpiDeviceMafpmoc *self)
fpi_usb_transfer_submit (transfer,
30 * 60 * 1000,
fpi_device_get_cancellable (FP_DEVICE (self)),
fp_verify_wait_int_cb,
fp_identify_wait_int_cb,
NULL);
}
static void
fp_verify_sm_run_state (FpiSsm *ssm, FpDevice *device)
fp_identify_sm_run_state (FpiSsm *ssm, FpDevice *device)
{
FpiDeviceMafpmoc *self = FPI_DEVICE_MAFPMOC (device);
uint8_t para[PACKAGE_DATA_SIZE_MAX] = { 0 };
@@ -1806,110 +1794,97 @@ fp_verify_sm_run_state (FpiSsm *ssm, FpDevice *device)
switch(fpi_ssm_get_cur_state (ssm))
{
case MAPF_VERIFY_PWR_BTN_SHIELD_ON:
case MAPF_IDENTIFY_PWR_BTN_SHIELD_ON:
mafp_pwr_btn_shield_on (self, 1);
break;
case MAPF_VERIFY_TEMPLATE_TABLE:
case MAPF_IDENTIFY_TEMPLATE_TABLE:
para[0] = 0; /* page no. */
mafp_sensor_cmd (self, MOC_CMD_GET_TEMPLATE_TABLE, (const uint8_t *) &para, 1, fp_verify_tpl_table_cb);
mafp_sensor_cmd (self, MOC_CMD_GET_TEMPLATE_TABLE, (const uint8_t *) &para, 1, fp_identify_tpl_table_cb);
break;
case MAPF_VERIFY_GET_STARTUP_RESULT:
case MAPF_IDENTIFY_GET_STARTUP_RESULT:
mafp_sensor_control (self, 0x8D, 0x00, mafp_get_startup_result_cb, NULL, 0);
break;
case MAPF_VERIFY_GET_IMAGE:
mafp_sensor_cmd (self, MOC_CMD_GET_IMAGE, NULL, 0, fp_verify_get_image_cb);
case MAPF_IDENTIFY_GET_IMAGE:
mafp_sensor_cmd (self, MOC_CMD_GET_IMAGE, NULL, 0, fp_identify_get_image_cb);
break;
case MAPF_VERIFY_CHECK_INT_PARA:
case MAPF_IDENTIFY_CHECK_INT_PARA:
para[0] = MAFP_SLEEP_INT_CHECK;
mafp_sensor_cmd (self, MOC_CMD_SLEEP, para, 1, fp_verify_int_check_cb);
mafp_sensor_cmd (self, MOC_CMD_SLEEP, para, 1, fp_identify_int_check_cb);
break;
case MAPF_VERIFY_DETECT_MODE:
case MAPF_IDENTIFY_DETECT_MODE:
para[0] = MAFP_SLEEP_INT_WAIT;
mafp_sensor_cmd (self, MOC_CMD_SLEEP, para, 1, fp_verify_int_detect_cb);
mafp_sensor_cmd (self, MOC_CMD_SLEEP, para, 1, fp_identify_int_detect_cb);
break;
case MAPF_VERIFY_ENABLE_INT:
mafp_sensor_control (self, 0x89, 1, fp_verify_enable_int_cb, NULL, 0);
case MAPF_IDENTIFY_ENABLE_INT:
mafp_sensor_control (self, 0x89, 1, fp_identify_enable_int_cb, NULL, 0);
break;
case MAPF_VERIFY_WAIT_INT:
fp_verify_wait_int (self);
case MAPF_IDENTIFY_WAIT_INT:
fp_identify_wait_int (self);
break;
case MAPF_VERIFY_DISBALE_INT:
mafp_sensor_control (self, 0x89, 0, fp_verify_disable_int_cb, NULL, 0);
case MAPF_IDENTIFY_DISBALE_INT:
mafp_sensor_control (self, 0x89, 0, fp_identify_disable_int_cb, NULL, 0);
break;
case MAPF_VERIFY_REFRESH_INT_PARA:
case MAPF_IDENTIFY_REFRESH_INT_PARA:
fp_dbg ("refresh param");
para[0] = MAFP_SLEEP_INT_REFRESH;
mafp_sensor_cmd (self, MOC_CMD_SLEEP, para, 1, fp_verify_int_refresh_cb);
mafp_sensor_cmd (self, MOC_CMD_SLEEP, para, 1, fp_identify_int_refresh_cb);
break;
case MAPF_VERIFY_GENERATE_FEATURE:
case MAPF_IDENTIFY_GENERATE_FEATURE:
para[0] = 1; /* buffer id */
mafp_sensor_cmd (self, MOC_CMD_GEN_FEATURE, (const uint8_t *) &para, 1, fp_verify_gen_feature_cb);
mafp_sensor_cmd (self, MOC_CMD_GEN_FEATURE, (const uint8_t *) &para, 1, fp_identify_gen_feature_cb);
break;
case MAPF_VERIFY_SEARCH_STEP:
if (fpi_device_get_current_action (device) == FPI_DEVICE_ACTION_VERIFY)
{
fpi_device_get_verify_data (device, &print);
if (!print)
{
self->search_id = G_MAXUINT16;
fpi_ssm_jump_to_state (self->task_ssm, MAPF_VERIFY_GET_TEMPLATE_INFO);
break;
}
}
else
{
case MAPF_IDENTIFY_SEARCH_STEP:
fpi_device_get_identify_data (device, &prints);
if (!prints || prints->len == 0)
{
self->search_id = G_MAXUINT16;
fpi_ssm_jump_to_state (self->task_ssm, MAPF_VERIFY_GET_TEMPLATE_INFO);
fpi_ssm_jump_to_state (self->task_ssm, MAPF_IDENTIFY_GET_TEMPLATE_INFO);
break;
}
print = g_ptr_array_index (prints, self->enroll_identify_index);
}
mafp_template_t tpl = mafp_template_from_print (print);
self->search_id = tpl.id;
para[0] = (tpl.id >> 8) & 0xff;
para[1] = tpl.id & 0xff;
mafp_sensor_cmd (self, MOC_CMD_MATCH_WITHFID, (const uint8_t *) &para, 2, fp_verify_search_step_cb);
mafp_sensor_cmd (self, MOC_CMD_MATCH_WITHFID, (const uint8_t *) &para, 2, fp_identify_search_step_cb);
break;
case MAPF_VERIFY_GET_TEMPLATE_INFO:
case MAPF_IDENTIFY_GET_TEMPLATE_INFO:
if (self->search_id == G_MAXUINT16)
{
mafp_cmd_response_t resp;
resp.result = 1;
fp_verify_get_tpl_info_cb (self, &resp, NULL);
fp_identify_get_tpl_info_cb (self, &resp, NULL);
}
else
{
para[0] = (self->search_id >> 8) & 0xff; /* fp id high */
para[1] = self->search_id & 0xff; /* fp id low */
mafp_sensor_cmd (self, MOC_CMD_GET_TEMPLATE_INFO, (const uint8_t *) &para, 2, fp_verify_get_tpl_info_cb);
mafp_sensor_cmd (self, MOC_CMD_GET_TEMPLATE_INFO, (const uint8_t *) &para, 2, fp_identify_get_tpl_info_cb);
}
break;
case MAPF_VERIFY_EXIT:
case MAPF_IDENTIFY_EXIT:
mafp_pwr_btn_shield_on (self, 0);
break;
}
}
static void
fp_verify_ssm_done (FpiSsm *ssm, FpDevice *dev, GError *error)
fp_identify_ssm_done (FpiSsm *ssm, FpDevice *dev, GError *error)
{
fp_dbg ("verify completed");
fp_dbg ("identify completed");
FpiDeviceMafpmoc *self = FPI_DEVICE_MAFPMOC (dev);
g_autoptr(FpPrint) new_print = g_steal_pointer (&self->identify_new_print);
FpPrint *match_print = g_steal_pointer (&self->identify_match_print);
@@ -1918,9 +1893,6 @@ fp_verify_ssm_done (FpiSsm *ssm, FpDevice *dev, GError *error)
if (error && error->domain == FP_DEVICE_RETRY)
{
if (fpi_device_get_current_action (dev) == FPI_DEVICE_ACTION_VERIFY)
fpi_device_verify_report (dev, FPI_MATCH_ERROR, NULL, g_steal_pointer (&error));
else
fpi_device_identify_report (dev, NULL, NULL, g_steal_pointer (&error));
return;
@@ -1932,20 +1904,11 @@ fp_verify_ssm_done (FpiSsm *ssm, FpDevice *dev, GError *error)
return;
}
if (fpi_device_get_current_action (dev) == FPI_DEVICE_ACTION_VERIFY)
{
fpi_device_verify_report (dev, match_print ? FPI_MATCH_SUCCESS : FPI_MATCH_FAIL,
g_steal_pointer (&new_print), NULL);
fpi_device_verify_complete (dev, NULL);
}
else
{
fpi_device_identify_report (dev, match_print,
self->enroll_dupl_del_state ?
g_steal_pointer (&new_print) : NULL,
NULL);
fpi_device_identify_complete (dev, NULL);
}
}
static void
@@ -2460,7 +2423,7 @@ mafp_enroll (FpDevice *device)
}
static void
mafp_verify_identify (FpDevice *device)
mafp_identify (FpDevice *device)
{
FpiDeviceMafpmoc *self = FPI_DEVICE_MAFPMOC (device);
@@ -2471,14 +2434,14 @@ mafp_verify_identify (FpDevice *device)
self->identify_match_print = NULL;
g_clear_object (&self->identify_new_print);
self->task_ssm = fpi_ssm_new_full (device, fp_verify_sm_run_state,
MAPF_VERIFY_STATES,
MAPF_VERIFY_EXIT,
"verify");
self->task_ssm = fpi_ssm_new_full (device, fp_identify_sm_run_state,
MAPF_IDENTIFY_STATES,
MAPF_IDENTIFY_EXIT,
"identify");
if (!PRINT_SSM_DEBUG)
fpi_ssm_silence_debug (self->task_ssm);
fpi_ssm_start (self->task_ssm, fp_verify_ssm_done);
fpi_ssm_start (self->task_ssm, fp_identify_ssm_done);
}
static void
@@ -2579,8 +2542,7 @@ fpi_device_mafpmoc_class_init (FpiDeviceMafpmocClass *klass)
dev_class->probe = mafp_probe;
dev_class->enroll = mafp_enroll;
dev_class->cancel = mafp_cancel;
dev_class->verify = mafp_verify_identify;
dev_class->identify = mafp_verify_identify;
dev_class->identify = mafp_identify;
dev_class->delete = mafp_template_delete;
dev_class->clear_storage = mafp_template_delete_all;
dev_class->list = mafp_template_list;
+16 -16
View File
@@ -138,22 +138,22 @@ typedef enum {
} MapfEnrollState;
typedef enum {
MAPF_VERIFY_PWR_BTN_SHIELD_ON = 0,
MAPF_VERIFY_TEMPLATE_TABLE,
MAPF_VERIFY_GET_STARTUP_RESULT,
MAPF_VERIFY_GET_IMAGE,
MAPF_VERIFY_CHECK_INT_PARA,
MAPF_VERIFY_DETECT_MODE,
MAPF_VERIFY_ENABLE_INT,
MAPF_VERIFY_WAIT_INT,
MAPF_VERIFY_DISBALE_INT,
MAPF_VERIFY_REFRESH_INT_PARA,
MAPF_VERIFY_GENERATE_FEATURE,
MAPF_VERIFY_SEARCH_STEP, //match assigned id
MAPF_VERIFY_GET_TEMPLATE_INFO,
MAPF_VERIFY_EXIT,
MAPF_VERIFY_STATES,
} MapfVerifyState;
MAPF_IDENTIFY_PWR_BTN_SHIELD_ON = 0,
MAPF_IDENTIFY_TEMPLATE_TABLE,
MAPF_IDENTIFY_GET_STARTUP_RESULT,
MAPF_IDENTIFY_GET_IMAGE,
MAPF_IDENTIFY_CHECK_INT_PARA,
MAPF_IDENTIFY_DETECT_MODE,
MAPF_IDENTIFY_ENABLE_INT,
MAPF_IDENTIFY_WAIT_INT,
MAPF_IDENTIFY_DISBALE_INT,
MAPF_IDENTIFY_REFRESH_INT_PARA,
MAPF_IDENTIFY_GENERATE_FEATURE,
MAPF_IDENTIFY_SEARCH_STEP, //match assigned id
MAPF_IDENTIFY_GET_TEMPLATE_INFO,
MAPF_IDENTIFY_EXIT,
MAPF_IDENTIFY_STATES,
} MapfIdentifyState;
typedef enum {
MAPF_LIST_TEMPLATE_TABLE = 0,