From 53afac018d0c53fdfac68e874c432211fd6ba25a Mon Sep 17 00:00:00 2001 From: Sasha Levitskiy Date: Tue, 9 Jun 2015 16:47:09 -0700 Subject: [PATCH] Fingerprint: Use integral types for remove() Bug 21282699 Change-Id: I8fdb2112f3f930f080571da6a6b908f5f0581bdd Signed-off-by: Sasha Levitskiy --- fingerprintd/FingerprintDaemonProxy.cpp | 55 ++++++++++++------------- fingerprintd/FingerprintDaemonProxy.h | 4 +- fingerprintd/IFingerprintDaemon.h | 2 +- 3 files changed, 29 insertions(+), 32 deletions(-) diff --git a/fingerprintd/FingerprintDaemonProxy.cpp b/fingerprintd/FingerprintDaemonProxy.cpp index a8a4024ea..a55f30a2d 100644 --- a/fingerprintd/FingerprintDaemonProxy.cpp +++ b/fingerprintd/FingerprintDaemonProxy.cpp @@ -41,7 +41,7 @@ FingerprintDaemonProxy::~FingerprintDaemonProxy() { closeHal(); } -void FingerprintDaemonProxy::hal_notify_callback(fingerprint_msg_t msg) { +void FingerprintDaemonProxy::hal_notify_callback(const fingerprint_msg_t *msg) { FingerprintDaemonProxy* instance = FingerprintDaemonProxy::getInstance(); const sp callback = instance->mCallback; if (callback == NULL) { @@ -49,52 +49,52 @@ void FingerprintDaemonProxy::hal_notify_callback(fingerprint_msg_t msg) { return; } const int64_t device = (int64_t) instance->mDevice; - switch (msg.type) { + switch (msg->type) { case FINGERPRINT_ERROR: - ALOGD("onError(%d)", msg.data.error); - callback->onError(device, msg.data.error); + ALOGD("onError(%d)", msg->data.error); + callback->onError(device, msg->data.error); break; case FINGERPRINT_ACQUIRED: - ALOGD("onAcquired(%d)", msg.data.acquired.acquired_info); - callback->onAcquired(device, msg.data.acquired.acquired_info); + ALOGD("onAcquired(%d)", msg->data.acquired.acquired_info); + callback->onAcquired(device, msg->data.acquired.acquired_info); break; case FINGERPRINT_AUTHENTICATED: ALOGD("onAuthenticated(fid=%d, gid=%d)", - msg.data.authenticated.finger.fid, - msg.data.authenticated.finger.gid); - if (msg.data.authenticated.finger.fid != 0) { - uint8_t* hat = reinterpret_cast(&msg.data.authenticated.hat); - instance->notifyKeystore(hat, sizeof(msg.data.authenticated.hat)); + msg->data.authenticated.finger.fid, + msg->data.authenticated.finger.gid); + if (msg->data.authenticated.finger.fid != 0) { + const uint8_t* hat = reinterpret_cast(&msg->data.authenticated.hat); + instance->notifyKeystore(hat, sizeof(msg->data.authenticated.hat)); } callback->onAuthenticated(device, - msg.data.authenticated.finger.fid, - msg.data.authenticated.finger.gid); + msg->data.authenticated.finger.fid, + msg->data.authenticated.finger.gid); break; case FINGERPRINT_TEMPLATE_ENROLLING: ALOGD("onEnrollResult(fid=%d, gid=%d, rem=%d)", - msg.data.enroll.finger.fid, - msg.data.enroll.finger.gid, - msg.data.enroll.samples_remaining); + msg->data.enroll.finger.fid, + msg->data.enroll.finger.gid, + msg->data.enroll.samples_remaining); callback->onEnrollResult(device, - msg.data.enroll.finger.fid, - msg.data.enroll.finger.gid, - msg.data.enroll.samples_remaining); + msg->data.enroll.finger.fid, + msg->data.enroll.finger.gid, + msg->data.enroll.samples_remaining); break; case FINGERPRINT_TEMPLATE_REMOVED: ALOGD("onRemove(fid=%d, gid=%d)", - msg.data.removed.finger.fid, - msg.data.removed.finger.gid); + msg->data.removed.finger.fid, + msg->data.removed.finger.gid); callback->onRemoved(device, - msg.data.removed.finger.fid, - msg.data.removed.finger.gid); + msg->data.removed.finger.fid, + msg->data.removed.finger.gid); break; default: - ALOGE("invalid msg: %d", msg.type); + ALOGE("invalid msg type: %d", msg->type); return; } } -void FingerprintDaemonProxy::notifyKeystore(uint8_t *auth_token, size_t auth_token_length) { +void FingerprintDaemonProxy::notifyKeystore(const uint8_t *auth_token, const size_t auth_token_length) { if (auth_token != NULL && auth_token_length > 0) { // TODO: cache service? sp < IServiceManager > sm = defaultServiceManager(); @@ -151,10 +151,7 @@ int32_t FingerprintDaemonProxy::stopAuthentication() { int32_t FingerprintDaemonProxy::remove(int32_t fingerId, int32_t groupId) { ALOG(LOG_VERBOSE, LOG_TAG, "remove(fid=%d, gid=%d)\n", fingerId, groupId); - fingerprint_finger_id_t finger; - finger.fid = fingerId; - finger.gid = groupId; - return mDevice->remove(mDevice, finger); + return mDevice->remove(mDevice, groupId, fingerId); } uint64_t FingerprintDaemonProxy::getAuthenticatorId() { diff --git a/fingerprintd/FingerprintDaemonProxy.h b/fingerprintd/FingerprintDaemonProxy.h index 95c926bda..50d30efd1 100644 --- a/fingerprintd/FingerprintDaemonProxy.h +++ b/fingerprintd/FingerprintDaemonProxy.h @@ -48,8 +48,8 @@ class FingerprintDaemonProxy : public BnFingerprintDaemon { FingerprintDaemonProxy(); virtual ~FingerprintDaemonProxy(); void binderDied(const wp& who); - void notifyKeystore(uint8_t *auth_token, size_t auth_token_length); - static void hal_notify_callback(fingerprint_msg_t msg); + void notifyKeystore(const uint8_t *auth_token, const size_t auth_token_length); + static void hal_notify_callback(const fingerprint_msg_t *msg); static FingerprintDaemonProxy* sInstance; fingerprint_module_t const* mModule; diff --git a/fingerprintd/IFingerprintDaemon.h b/fingerprintd/IFingerprintDaemon.h index fe3f64b93..08cb00857 100644 --- a/fingerprintd/IFingerprintDaemon.h +++ b/fingerprintd/IFingerprintDaemon.h @@ -65,7 +65,7 @@ class IFingerprintDaemon : public IInterface, public IBinder::DeathRecipient { // DECLARE_META_INTERFACE - C++ client interface not needed static const android::String16 descriptor; - static void hal_notify_callback(fingerprint_msg_t msg); + static void hal_notify_callback(const fingerprint_msg_t *msg); }; // ----------------------------------------------------------------------------