From cd60dd84b0afd1e3b6d6911a92f8cefc5dc1828e Mon Sep 17 00:00:00 2001 From: Jesse Chan Date: Sun, 5 Feb 2017 18:53:42 +0800 Subject: [PATCH] fingerprint: bauth: convert % completed to remaining * Samsung uses fingerprint enrollment % completed while AOSP uses fingerprint sample remaining. * This patch converts this data to AOSP-friendly one via (x = 100 - x). Change-Id: I27034cb148e0f33f7d3efae9c75123715452f178 Signed-off-by: Jesse Chan --- fingerprint/bauth/fingerprint.c | 21 ++++++++++++++++++++- 1 file changed, 20 insertions(+), 1 deletion(-) diff --git a/fingerprint/bauth/fingerprint.c b/fingerprint/bauth/fingerprint.c index 55a56b80..6e5ed90e 100644 --- a/fingerprint/bauth/fingerprint.c +++ b/fingerprint/bauth/fingerprint.c @@ -43,6 +43,8 @@ typedef struct { bauth_server_handle_t* bauth_handle; +static fingerprint_notify_t original_notify; + static int load_bauth_server(void) { bauth_handle = (bauth_server_handle_t *)malloc(sizeof(bauth_server_handle_t)); @@ -71,6 +73,22 @@ no_memory: return -ENOMEM; } +static void hal_notify_convert(const fingerprint_msg_t *msg) +{ + fingerprint_msg_t *new_msg = (fingerprint_msg_t *)msg; + + switch (msg->type) { + case FINGERPRINT_TEMPLATE_ENROLLING: + new_msg->data.enroll.samples_remaining = 100 - msg->data.enroll.samples_remaining; + break; + + default: + break; + } + + return original_notify(new_msg); +} + static int fingerprint_close(hw_device_t *dev) { bauth_handle->ss_fingerprint_close(); @@ -128,7 +146,8 @@ static int set_notify_callback(struct fingerprint_device *dev, fingerprint_notif { /* Decorate with locks */ dev->notify = notify; - return bauth_handle->ss_set_notify_callback(notify); + original_notify = notify; + return bauth_handle->ss_set_notify_callback(hal_notify_convert); } static int fingerprint_open(const hw_module_t* module, const char *id, hw_device_t** device)