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 <jc@linux.com>
diff --git a/fingerprint/bauth/fingerprint.c b/fingerprint/bauth/fingerprint.c
index 55a56b8..6e5ed90 100644
--- a/fingerprint/bauth/fingerprint.c
+++ b/fingerprint/bauth/fingerprint.c
@@ -43,6 +43,8 @@
 
 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 @@
     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 @@
 {
     /* 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)