mirror of
https://gitlab.freedesktop.org/libfprint/libfprint.git
synced 2026-06-11 02:28:05 +00:00
372 lines
144 KiB
Diff
372 lines
144 KiB
Diff
From: Benjamin Berg <bberg@redhat.com>
|
||
Date: Mon, 13 Jun 2022 16:05:18 +0200
|
||
Subject: goodix: Reset device if storage listing fails
|
||
|
||
When opening the device, query the stored prints. This should usually
|
||
always succeed (and it should be fast). If it fails, then we are very
|
||
likely dealing with a corrupted template storage on the device. In that
|
||
case, emit the command to clear the storage in order to reset the device
|
||
and get it back into a usable state.
|
||
---
|
||
libfprint/drivers/goodixmoc/goodix.c | 65 +++++++++++++++++++++++++++++++++++
|
||
libfprint/drivers/goodixmoc/goodix.h | 2 ++
|
||
tests/goodixmoc/custom.pcapng | Bin 61764 -> 73120 bytes
|
||
tests/goodixmoc/custom.py | 3 ++
|
||
tests/goodixmoc/device | 57 +++++++++++++++---------------
|
||
5 files changed, 99 insertions(+), 28 deletions(-)
|
||
|
||
diff --git a/libfprint/drivers/goodixmoc/goodix.c b/libfprint/drivers/goodixmoc/goodix.c
|
||
index 4eeb721..ab84130 100644
|
||
--- a/libfprint/drivers/goodixmoc/goodix.c
|
||
+++ b/libfprint/drivers/goodixmoc/goodix.c
|
||
@@ -1041,6 +1041,47 @@ fp_init_config_cb (FpiDeviceGoodixMoc *self,
|
||
fpi_ssm_next_state (self->task_ssm);
|
||
}
|
||
|
||
+static void
|
||
+fp_init_cb_reset_or_complete (FpiDeviceGoodixMoc *self,
|
||
+ gxfp_cmd_response_t *resp,
|
||
+ GError *error)
|
||
+{
|
||
+ if (error)
|
||
+ {
|
||
+ fp_warn ("Template storage appears to have been corrupted! Error was: %s", error->message);
|
||
+ fp_warn ("A known reason for this to happen is a firmware bug triggered by another storage area being initialized.");
|
||
+ fpi_ssm_jump_to_state (self->task_ssm, FP_INIT_RESET_DEVICE);
|
||
+ }
|
||
+ else
|
||
+ {
|
||
+ fpi_ssm_mark_completed (self->task_ssm);
|
||
+ }
|
||
+}
|
||
+
|
||
+static void
|
||
+fp_init_reset_device_cb (FpiDeviceGoodixMoc *self,
|
||
+ gxfp_cmd_response_t *resp,
|
||
+ GError *error)
|
||
+{
|
||
+ if (error)
|
||
+ {
|
||
+ fp_warn ("Reset failed: %s", error->message);
|
||
+ fpi_ssm_mark_failed (self->task_ssm, error);
|
||
+ return;
|
||
+ }
|
||
+ if ((resp->result >= GX_FAILED) && (resp->result != GX_ERROR_FINGER_ID_NOEXIST))
|
||
+ {
|
||
+ fp_warn ("Reset failed, device reported: 0x%x", resp->result);
|
||
+ fpi_ssm_mark_failed (self->task_ssm,
|
||
+ fpi_device_error_new_msg (FP_DEVICE_ERROR_GENERAL,
|
||
+ "Failed clear storage, result: 0x%x",
|
||
+ resp->result));
|
||
+ return;
|
||
+ }
|
||
+
|
||
+ fp_warn ("Reset completed");
|
||
+ fpi_ssm_mark_completed (self->task_ssm);
|
||
+}
|
||
|
||
static void
|
||
fp_init_sm_run_state (FpiSsm *ssm, FpDevice *device)
|
||
@@ -1065,6 +1106,30 @@ fp_init_sm_run_state (FpiSsm *ssm, FpDevice *device)
|
||
sizeof (gxfp_sensor_cfg_t),
|
||
fp_init_config_cb);
|
||
break;
|
||
+
|
||
+ case FP_INIT_TEMPLATE_LIST:
|
||
+ /* List prints to check whether the template DB was corrupted.
|
||
+ * As of 2022-06-13 there is a known firmware issue that can cause the
|
||
+ * stored templates for Linux to be corrupted when the Windows storage
|
||
+ * area is initialized.
|
||
+ * In that case, we'll get a protocol failure trying to retrieve the
|
||
+ * list of prints.
|
||
+ */
|
||
+ goodix_sensor_cmd (self, MOC_CMD0_GETFINGERLIST, MOC_CMD1_DEFAULT,
|
||
+ FALSE,
|
||
+ (const guint8 *) &dummy,
|
||
+ 1,
|
||
+ fp_init_cb_reset_or_complete);
|
||
+ break;
|
||
+
|
||
+ case FP_INIT_RESET_DEVICE:
|
||
+ fp_warn ("Resetting device storage, you will need to enroll all prints again!");
|
||
+ goodix_sensor_cmd (self, MOC_CMD0_DELETETEMPLATE, MOC_CMD1_DELETE_ALL,
|
||
+ FALSE,
|
||
+ NULL,
|
||
+ 0,
|
||
+ fp_init_reset_device_cb);
|
||
+ break;
|
||
}
|
||
|
||
|
||
diff --git a/libfprint/drivers/goodixmoc/goodix.h b/libfprint/drivers/goodixmoc/goodix.h
|
||
index 23e142a..56b2d17 100644
|
||
--- a/libfprint/drivers/goodixmoc/goodix.h
|
||
+++ b/libfprint/drivers/goodixmoc/goodix.h
|
||
@@ -35,6 +35,8 @@ typedef enum {
|
||
typedef enum {
|
||
FP_INIT_VERSION = 0,
|
||
FP_INIT_CONFIG,
|
||
+ FP_INIT_TEMPLATE_LIST,
|
||
+ FP_INIT_RESET_DEVICE,
|
||
FP_INIT_NUM_STATES,
|
||
} FpInitState;
|
||
|
||
diff --git a/tests/goodixmoc/custom.pcapng b/tests/goodixmoc/custom.pcapng
|
||
index eb58d86..b5e2d89 100644
|
||
--- a/tests/goodixmoc/custom.pcapng
|
||
+++ b/tests/goodixmoc/custom.pcapng
|
||
@@ -1,43 +1,25 @@
|
||
|
||
|
||
|
||
-¸ |