Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 53afac01 authored by Sasha Levitskiy's avatar Sasha Levitskiy
Browse files

Fingerprint: Use integral types for remove()



Bug 21282699

Change-Id: I8fdb2112f3f930f080571da6a6b908f5f0581bdd
Signed-off-by: default avatarSasha Levitskiy <sanek@google.com>
parent 4d7f052a
Loading
Loading
Loading
Loading
+26 −29
Original line number Diff line number Diff line
@@ -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<IFingerprintDaemonCallback> 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<uint8_t *>(&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<const uint8_t *>(&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() {
+2 −2
Original line number Diff line number Diff line
@@ -48,8 +48,8 @@ class FingerprintDaemonProxy : public BnFingerprintDaemon {
        FingerprintDaemonProxy();
        virtual ~FingerprintDaemonProxy();
        void binderDied(const wp<IBinder>& 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;
+1 −1
Original line number Diff line number Diff line
@@ -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);
};

// ----------------------------------------------------------------------------