samsung: hidl: correct USES_PERCENTAGE_SAMPLES behaviour as previously it did nothing
authorDanny Wood <danwood76@gmail.com>
Mon, 23 Dec 2019 11:37:10 +0000 (11:37 +0000)
committerJan Altensen <info@stricted.net>
Tue, 10 Mar 2020 14:41:21 +0000 (15:41 +0100)
This fixes fingerprint on the SM-A510F and possibly other older Samsung devices when using the new
HIDL implementation

Change-Id: Ie8883d3d628e924a9b181b08681388cd05e5f325

hidl/fingerprint/BiometricsFingerprint.cpp

index e8db272df1f7fece46addb3b93c18b1508259748..bb27999b85b9fe89e344fd00ebb58a1c1e72b72c 100644 (file)
@@ -288,19 +288,17 @@ void BiometricsFingerprint::notify(const fingerprint_msg_t* msg) {
             }
         } break;
         case FINGERPRINT_TEMPLATE_ENROLLING:
+#ifdef USES_PERCENTAGE_SAMPLES
+            const_cast<fingerprint_msg_t*>(msg)->data.enroll.samples_remaining =
+                100 - msg->data.enroll.samples_remaining;
+#endif
             LOG(DEBUG) << "onEnrollResult(fid=" << msg->data.enroll.finger.fid
                        << ", gid=" << msg->data.enroll.finger.gid
                        << ", rem=" << msg->data.enroll.samples_remaining << ")";
-            if (thisPtr->mClientCallback
+            if (!thisPtr->mClientCallback
                     ->onEnrollResult(devId, msg->data.enroll.finger.fid,
                                      msg->data.enroll.finger.gid, msg->data.enroll.samples_remaining)
                     .isOk()) {
-#ifdef USES_PERCENTAGE_SAMPLES
-                fingerprint_msg_t* newMsg = (fingerprint_msg_t*)msg;
-                newMsg->data.enroll.samples_remaining = 100 - msg->data.enroll.samples_remaining;
-                msg = newMsg;
-#endif
-            } else {
                 LOG(ERROR) << "failed to invoke fingerprint onEnrollResult callback";
             }
             break;