synaptics: Add clear_storage() and remove list()

This commit is contained in:
Vincent Huang 2021-03-15 16:18:15 +08:00 committed by Benjamin Berg
parent 77e95aa545
commit 8a04578847
4 changed files with 59 additions and 114 deletions

View file

@ -468,6 +468,7 @@ typedef union
bmkt_del_all_users_resp_t del_all_users_resp; bmkt_del_all_users_resp_t del_all_users_resp;
bmkt_enroll_templates_resp_t enroll_templates_resp; bmkt_enroll_templates_resp_t enroll_templates_resp;
bmkt_del_user_resp_t del_user_resp; bmkt_del_user_resp_t del_user_resp;
bmkt_del_all_users_resp_t del_all_user_resp;
bmkt_enrolled_fingers_resp_t enrolled_fingers_resp; bmkt_enrolled_fingers_resp_t enrolled_fingers_resp;
} bmkt_response_data_t; } bmkt_response_data_t;

View file

@ -485,100 +485,6 @@ create_print (FpiDeviceSynaptics *self,
return print; return print;
} }
static void
list_msg_cb (FpiDeviceSynaptics *self,
bmkt_response_t *resp,
GError *error)
{
bmkt_enroll_templates_resp_t *get_enroll_templates_resp;
if (error)
{
g_clear_pointer (&self->list_result, g_ptr_array_unref);
fpi_device_list_complete (FP_DEVICE (self), NULL, error);
return;
}
get_enroll_templates_resp = &resp->response.enroll_templates_resp;
switch (resp->response_id)
{
case BMKT_RSP_QUERY_FAIL:
if (resp->result == BMKT_FP_DATABASE_EMPTY)
{
fp_info ("Database is empty");
fpi_device_list_complete (FP_DEVICE (self),
g_steal_pointer (&self->list_result),
NULL);
}
else
{
fp_info ("Failed to query enrolled users: %d", resp->result);
g_clear_pointer (&self->list_result, g_ptr_array_unref);
fpi_device_list_complete (FP_DEVICE (self),
NULL,
fpi_device_error_new_msg (FP_DEVICE_ERROR_GENERAL,
"Failed to query enrolled users: %d",
resp->result));
}
break;
case BMKT_RSP_QUERY_RESPONSE_COMPLETE:
fp_info ("Query complete!");
fpi_device_list_complete (FP_DEVICE (self),
g_steal_pointer (&self->list_result),
NULL);
break;
case BMKT_RSP_TEMPLATE_RECORDS_REPORT:
for (int n = 0; n < BMKT_MAX_NUM_TEMPLATES_INTERNAL_FLASH; n++)
{
FpPrint *print;
if (get_enroll_templates_resp->templates[n].user_id_len == 0)
continue;
fp_info ("![query %d of %d] template %d: status=0x%x, userId=%s, fingerId=%d",
get_enroll_templates_resp->query_sequence,
get_enroll_templates_resp->total_query_messages,
n,
get_enroll_templates_resp->templates[n].template_status,
get_enroll_templates_resp->templates[n].user_id,
get_enroll_templates_resp->templates[n].finger_id);
print = create_print (self,
get_enroll_templates_resp->templates[n].user_id,
get_enroll_templates_resp->templates[n].finger_id);
g_ptr_array_add (self->list_result, g_object_ref_sink (print));
}
synaptics_sensor_cmd (self,
self->cmd_seq_num,
BMKT_CMD_GET_NEXT_QUERY_RESPONSE,
NULL,
0,
NULL);
break;
}
}
static void
list (FpDevice *device)
{
FpiDeviceSynaptics *self = FPI_DEVICE_SYNAPTICS (device);
G_DEBUG_HERE ();
self->list_result = g_ptr_array_new_with_free_func (g_object_unref);
synaptics_sensor_cmd (self, 0, BMKT_CMD_GET_TEMPLATE_RECORDS, NULL, 0, list_msg_cb);
}
static void static void
verify_complete_after_finger_removal (FpiDeviceSynaptics *self) verify_complete_after_finger_removal (FpiDeviceSynaptics *self)
{ {
@ -1133,6 +1039,54 @@ delete_print (FpDevice *device)
synaptics_sensor_cmd (self, 0, BMKT_CMD_DEL_USER_FP, payload, user_id_len + 1, delete_msg_cb); synaptics_sensor_cmd (self, 0, BMKT_CMD_DEL_USER_FP, payload, user_id_len + 1, delete_msg_cb);
} }
static void
clear_storage_msg_cb (FpiDeviceSynaptics *self,
bmkt_response_t *resp,
GError *error)
{
FpDevice *device = FP_DEVICE (self);
bmkt_del_all_users_resp_t *del_all_user_resp;
if (error)
{
fpi_device_clear_storage_complete (device, error);
return;
}
del_all_user_resp = &resp->response.del_all_user_resp;
switch (resp->response_id)
{
case BMKT_RSP_DELETE_PROGRESS:
fp_info ("Deleting All Enrolled Users is %d%% complete",
del_all_user_resp->progress);
break;
case BMKT_RSP_DEL_FULL_DB_FAIL:
if (resp->result == BMKT_FP_DATABASE_EMPTY)
fpi_device_clear_storage_complete (device, NULL);
else
fpi_device_clear_storage_complete (device,
fpi_device_error_new (FP_DEVICE_ERROR_GENERAL));
break;
case BMKT_RSP_DEL_FULL_DB_OK:
fp_info ("Successfully deleted all enrolled user");
fpi_device_clear_storage_complete (device, NULL);
break;
}
}
static void
clear_storage (FpDevice *device)
{
FpiDeviceSynaptics *self = FPI_DEVICE_SYNAPTICS (device);
g_debug ("clear all prints in database");
synaptics_sensor_cmd (self, 0, BMKT_CMD_DEL_FULL_DB, NULL, 0, clear_storage_msg_cb);
return;
}
static void static void
prob_msg_cb (FpiDeviceSynaptics *self, prob_msg_cb (FpiDeviceSynaptics *self,
bmkt_response_t *resp, bmkt_response_t *resp,
@ -1403,8 +1357,8 @@ fpi_device_synaptics_class_init (FpiDeviceSynapticsClass *klass)
dev_class->identify = identify; dev_class->identify = identify;
dev_class->enroll = enroll; dev_class->enroll = enroll;
dev_class->delete = delete_print; dev_class->delete = delete_print;
dev_class->clear_storage = clear_storage;
dev_class->cancel = cancel; dev_class->cancel = cancel;
dev_class->list = list;
fpi_device_class_auto_initialize_features (dev_class); fpi_device_class_auto_initialize_features (dev_class);
} }

View file

@ -164,14 +164,10 @@ USBDEVFS_REAPURBNDELAY 0 3 1 0 0 37 37 0 A7FE03512000014650312D30303030303030302
USBDEVFS_REAPURBNDELAY 0 3 1 0 0 1 1 0 A8 USBDEVFS_REAPURBNDELAY 0 3 1 0 0 1 1 0 A8
USBDEVFS_REAPURBNDELAY 0 3 129 0 0 266 7 0 0000FE00910101 USBDEVFS_REAPURBNDELAY 0 3 129 0 0 266 7 0 0000FE00910101
USBDEVFS_REAPURBNDELAY 0 1 131 0 0 7 7 0 06000000000100 USBDEVFS_REAPURBNDELAY 0 1 131 0 0 7 7 0 06000000000100
USBDEVFS_REAPURBNDELAY 0 3 1 0 0 5 5 0 A7FE047100 USBDEVFS_REAPURBNDELAY 0 3 1 0 0 35 35 0 A7FE04651E4650312D30303030303030302D302D30303030303030302D6E6F626F6479
USBDEVFS_REAPURBNDELAY 0 3 129 0 0 266 41 0 0000FE04752301012007014650312D30303030303030302D302D30303030303030302D6E6F626F6479 USBDEVFS_REAPURBNDELAY 0 3 129 0 0 266 6 0 0000FE046600
USBDEVFS_REAPURBNDELAY 0 3 1 0 0 5 5 0 A7FE047200
USBDEVFS_REAPURBNDELAY 0 3 129 0 0 266 6 0 0000FE047600
USBDEVFS_REAPURBNDELAY 0 3 1 0 0 35 35 0 A7FE05651E4650312D30303030303030302D302D30303030303030302D6E6F626F6479
USBDEVFS_REAPURBNDELAY 0 3 129 0 0 266 6 0 0000FE056600
USBDEVFS_REAPURBNDELAY 0 1 131 0 0 7 7 0 06000000000000 USBDEVFS_REAPURBNDELAY 0 1 131 0 0 7 7 0 06000000000000
USBDEVFS_REAPURBNDELAY 0 3 129 0 0 266 6 0 0000FE056000 USBDEVFS_REAPURBNDELAY 0 3 129 0 0 266 6 0 0000FE046000
USBDEVFS_REAPURBNDELAY 0 1 131 0 0 7 7 0 06000000000100 USBDEVFS_REAPURBNDELAY 0 1 131 0 0 7 7 0 06000000000100
USBDEVFS_REAPURBNDELAY 0 3 1 0 0 1 1 0 A8 USBDEVFS_REAPURBNDELAY 0 3 1 0 0 1 1 0 A8
USBDEVFS_REAPURBNDELAY 0 3 129 0 0 266 7 0 0000FE00910101 USBDEVFS_REAPURBNDELAY 0 3 129 0 0 266 7 0 0000FE00910101
@ -180,9 +176,9 @@ USBDEVFS_REAPURBNDELAY 0 3 1 0 0 35 35 0 A7FE05651E4650312D30303030303030302D302
USBDEVFS_REAPURBNDELAY 0 3 129 0 0 266 7 0 0000FE00910100 USBDEVFS_REAPURBNDELAY 0 3 129 0 0 266 7 0 0000FE00910100
USBDEVFS_REAPURBNDELAY 0 1 131 0 0 7 7 0 05000000000100 USBDEVFS_REAPURBNDELAY 0 1 131 0 0 7 7 0 05000000000100
USBDEVFS_REAPURBNDELAY 0 3 1 0 0 1 1 0 A8 USBDEVFS_REAPURBNDELAY 0 3 1 0 0 1 1 0 A8
USBDEVFS_REAPURBNDELAY 0 3 129 0 0 266 39 0 0000FE0568214F2B014650312D30303030303030302D302D30303030303030302D6E6F626F6479 USBDEVFS_REAPURBNDELAY 0 3 129 0 0 266 39 0 0000FE0468214F2B014650312D30303030303030302D302D30303030303030302D6E6F626F6479
USBDEVFS_REAPURBNDELAY 0 3 1 0 0 36 36 0 A7FE06811F014650312D30303030303030302D302D30303030303030302D6E6F626F6479 USBDEVFS_REAPURBNDELAY 0 3 1 0 0 36 36 0 A7FE05811F014650312D30303030303030302D302D30303030303030302D6E6F626F6479
USBDEVFS_REAPURBNDELAY 0 3 129 0 0 266 37 0 0000FE06831F014650312D30303030303030302D302D30303030303030302D6E6F626F6479 USBDEVFS_REAPURBNDELAY 0 3 129 0 0 266 37 0 0000FE05831F014650312D30303030303030302D302D30303030303030302D6E6F626F6479
USBDEVFS_REAPURBNDELAY 0 3 1 0 0 5 5 0 A7FE07A100 USBDEVFS_REAPURBNDELAY 0 3 1 0 0 5 5 0 A7FE06A100
USBDEVFS_REAPURBNDELAY 0 3 129 0 0 266 6 0 0000FE07A200 USBDEVFS_REAPURBNDELAY 0 3 129 0 0 266 6 0 0000FE06A200

View file

@ -19,9 +19,8 @@ assert d.has_feature(FPrint.DeviceFeature.IDENTIFY)
assert d.has_feature(FPrint.DeviceFeature.VERIFY) assert d.has_feature(FPrint.DeviceFeature.VERIFY)
assert not d.has_feature(FPrint.DeviceFeature.DUPLICATES_CHECK) assert not d.has_feature(FPrint.DeviceFeature.DUPLICATES_CHECK)
assert d.has_feature(FPrint.DeviceFeature.STORAGE) assert d.has_feature(FPrint.DeviceFeature.STORAGE)
assert d.has_feature(FPrint.DeviceFeature.STORAGE_LIST)
assert d.has_feature(FPrint.DeviceFeature.STORAGE_DELETE) 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() d.open_sync()
@ -38,11 +37,6 @@ p = d.enroll_sync(template, None, enroll_progress, None)
assert d.get_finger_status() == FPrint.FingerStatusFlags.NONE assert d.get_finger_status() == FPrint.FingerStatusFlags.NONE
print("enroll done") print("enroll done")
print("listing")
stored = d.list_prints_sync()
print("listing done")
assert len(stored) == 1
assert stored[0].equal(p)
print("verifying") print("verifying")
assert d.get_finger_status() == FPrint.FingerStatusFlags.NONE assert d.get_finger_status() == FPrint.FingerStatusFlags.NONE
verify_res, verify_print = d.verify_sync(p) verify_res, verify_print = d.verify_sync(p)