summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDevyn Cairns <devyn.cairns@gmail.com>2021-11-05 07:27:56 -0700
committerBenjamin Berg <benjamin@sipsolutions.net>2022-02-11 18:08:53 +0000
commit356805168637666c758fbc2a2f436d6418c7e5f4 (patch)
tree7f33d04049149840ebb526edbad609bc9cd17fb2
parent9ce6ed4164399de36695349f95602e3bece33b7e (diff)
goodixmoc: support for clear_storage
The internal storage of this device can get messed up by other operating systems, so it's handy to be able to clear it. I'm not 100% sure whether the commands I've sent to the device are exactly what is supposed to be used (just a guess), but it did seem to work, and it even fixed another issue I had.
-rw-r--r--libfprint/drivers/goodixmoc/goodix.c40
-rwxr-xr-xtests/goodixmoc/custom.py2
2 files changed, 41 insertions, 1 deletions
diff --git a/libfprint/drivers/goodixmoc/goodix.c b/libfprint/drivers/goodixmoc/goodix.c
index 43f6325..4eeb721 100644
--- a/libfprint/drivers/goodixmoc/goodix.c
+++ b/libfprint/drivers/goodixmoc/goodix.c
@@ -1160,6 +1160,32 @@ fp_template_delete_cb (FpiDeviceGoodixMoc *self,
fp_info ("Successfully deleted enrolled user");
fpi_device_delete_complete (device, NULL);
}
+
+static void
+fp_template_delete_all_cb (FpiDeviceGoodixMoc *self,
+ gxfp_cmd_response_t *resp,
+ GError *error)
+{
+ FpDevice *device = FP_DEVICE (self);
+
+ if (error)
+ {
+ fpi_device_clear_storage_complete (device, error);
+ return;
+ }
+ if ((resp->result >= GX_FAILED) && (resp->result != GX_ERROR_FINGER_ID_NOEXIST))
+ {
+ fpi_device_clear_storage_complete (FP_DEVICE (self),
+ fpi_device_error_new_msg (FP_DEVICE_ERROR_GENERAL,
+ "Failed clear storage, result: 0x%x",
+ resp->result));
+ return;
+ }
+
+ fp_info ("Successfully cleared storage");
+ fpi_device_clear_storage_complete (device, NULL);
+}
+
/******************************************************************************
*
* fp_template_list Function
@@ -1484,6 +1510,19 @@ gx_fp_template_delete (FpDevice *device)
}
static void
+gx_fp_template_delete_all (FpDevice *device)
+{
+ FpiDeviceGoodixMoc *self = FPI_DEVICE_GOODIXMOC (device);
+
+ goodix_sensor_cmd (self, MOC_CMD0_DELETETEMPLATE, MOC_CMD1_DELETE_ALL,
+ false,
+ NULL,
+ 0,
+ fp_template_delete_all_cb);
+
+}
+
+static void
fpi_device_goodixmoc_init (FpiDeviceGoodixMoc *self)
{
@@ -1526,6 +1565,7 @@ fpi_device_goodixmoc_class_init (FpiDeviceGoodixMocClass *klass)
dev_class->probe = gx_fp_probe;
dev_class->enroll = gx_fp_enroll;
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;
diff --git a/tests/goodixmoc/custom.py b/tests/goodixmoc/custom.py
index 2fe6edd..1fb513a 100755
--- a/tests/goodixmoc/custom.py
+++ b/tests/goodixmoc/custom.py
@@ -21,7 +21,7 @@ assert d.has_feature(FPrint.DeviceFeature.DUPLICATES_CHECK)
assert d.has_feature(FPrint.DeviceFeature.STORAGE)
assert d.has_feature(FPrint.DeviceFeature.STORAGE_LIST)
assert d.has_feature(FPrint.DeviceFeature.STORAGE_DELETE)
-assert not d.has_feature(FPrint.DeviceFeature.STORAGE_CLEAR)
+assert d.has_feature(FPrint.DeviceFeature.STORAGE_CLEAR)
d.open_sync()