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

Commit 6bfee7cc authored by Jim Miller's avatar Jim Miller Committed by Android (Google) Code Review
Browse files

Merge "Fix fingerprint crypto operations."

parents 0a54f77b 7f7eb474
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -9,11 +9,13 @@ LOCAL_SRC_FILES := \
    service.cpp \

LOCAL_SHARED_LIBRARIES := \
    libbinder \
    liblog \
    libhidlbase \
    libhidltransport \
    libhardware \
    libhwbinder \
    libkeystore_binder \
    libutils \
    android.hardware.biometrics.fingerprint@2.1 \

+23 −0
Original line number Diff line number Diff line
@@ -15,6 +15,12 @@
 */
#define LOG_TAG "android.hardware.biometrics.fingerprint@2.1-service"

// For communication with Keystore binder interface
#include <binder/IServiceManager.h>
#include <keystore/IKeystoreService.h>
#include <keystore/keystore.h> // for error codes
#include <hardware/hw_auth_token.h>

#include <hardware/hardware.h>
#include <hardware/fingerprint.h>
#include "BiometricsFingerprint.h"
@@ -235,6 +241,23 @@ IBiometricsFingerprint* BiometricsFingerprint::getInstance() {
    return new BiometricsFingerprint(fp_device);
}

void BiometricsFingerprint::notifyKeystore(const uint8_t *auth_token, const size_t auth_token_length) {
    if (auth_token != nullptr && auth_token_length > 0) {
        // TODO: cache service?
        sp<IServiceManager> sm = android::defaultServiceManager();
        sp<IBinder> binder = sm->getService(String16("android.security.keystore"));
        sp<IKeystoreService> service = interface_cast<IKeystoreService>(binder);
        if (service != nullptr) {
            status_t ret = service->addAuthToken(auth_token, auth_token_length);
            if (ret != ResponseCode::NO_ERROR) {
                ALOGE("Falure sending auth token to KeyStore: %d", ret);
            }
        } else {
            ALOGE("Unable to communicate with KeyStore");
        }
    }
}

} // namespace implementation
}  // namespace V2_1
}  // namespace fingerprint
+6 −0
Original line number Diff line number Diff line
@@ -95,6 +95,11 @@ public:
                    msg->data.removed.remaining_templates);
                break;
            case FINGERPRINT_AUTHENTICATED:
                if (msg->data.authenticated.finger.fid != 0) {
                    const uint8_t* hat =
                            reinterpret_cast<const uint8_t *>(&msg->data.authenticated.hat);
                    notifyKeystore(hat, sizeof(msg->data.authenticated.hat));
                }
                mClientCallback->onAuthenticated(devId,
                    msg->data.authenticated.finger.fid,
                    msg->data.authenticated.finger.gid);
@@ -109,6 +114,7 @@ public:
    }
private:
    Return<RequestStatus> ErrorFilter(int32_t error);
    static void notifyKeystore(const uint8_t *auth_token, const size_t auth_token_length);
    static FingerprintError VendorErrorFilter(int32_t error,
            int32_t* vendorCode);
    static FingerprintAcquiredInfo VendorAcquiredFilter(int32_t error,