summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Andres Morales <anmorales@google.com> 2015-04-13 12:40:11 -0700
committer Jim Miller <jaggies@google.com> 2015-04-14 23:52:08 +0000
commitaf0479d16d381c7569b81c450f9ba947207d82fc (patch)
tree5381fde6cfcd79c8ba5fe49c25fa652d84d254d7
parentf4f2693fc9c2118315aee3818ed97341e23dba0f (diff)
Add notify keystore method to FPS JNI
Change-Id: I0b29a9e4a15e9386586df98be419be9e0b0c8f7b
-rw-r--r--services/core/jni/Android.mk2
-rw-r--r--services/core/jni/com_android_server_fingerprint_FingerprintService.cpp30
2 files changed, 30 insertions, 2 deletions
diff --git a/services/core/jni/Android.mk b/services/core/jni/Android.mk
index 6448de2b1a2f..19ca2b46af14 100644
--- a/services/core/jni/Android.mk
+++ b/services/core/jni/Android.mk
@@ -37,6 +37,7 @@ LOCAL_C_INCLUDES += \
frameworks/native/services \
libcore/include \
libcore/include/libsuspend \
+ system/security/keystore/include \
$(call include-path-for, libhardware)/hardware \
$(call include-path-for, libhardware_legacy)/hardware_legacy \
@@ -48,6 +49,7 @@ LOCAL_SHARED_LIBRARIES += \
liblog \
libhardware \
libhardware_legacy \
+ libkeystore_binder \
libnativehelper \
libutils \
libui \
diff --git a/services/core/jni/com_android_server_fingerprint_FingerprintService.cpp b/services/core/jni/com_android_server_fingerprint_FingerprintService.cpp
index bd09bdf73f06..7503c5b57ec9 100644
--- a/services/core/jni/com_android_server_fingerprint_FingerprintService.cpp
+++ b/services/core/jni/com_android_server_fingerprint_FingerprintService.cpp
@@ -22,13 +22,19 @@
#include <android_runtime/AndroidRuntime.h>
#include <android_runtime/Log.h>
#include <android_os_MessageQueue.h>
+#include <binder/IServiceManager.h>
+#include <utils/String16.h>
+#include <utils/Looper.h>
+#include <keystore/IKeystoreService.h>
+
#include <hardware/hardware.h>
#include <hardware/fingerprint.h>
#include <hardware/hw_auth_token.h>
+
#include <utils/Log.h>
-#include <utils/Looper.h>
#include "core_jni_helpers.h"
+
namespace android {
static const uint16_t kVersion = HARDWARE_MODULE_API_VERSION(2, 0);
@@ -61,6 +67,22 @@ public:
}
};
+static void notifyKeystore(uint8_t *auth_token, size_t auth_token_length) {
+ if (auth_token != NULL && auth_token_length > 0) {
+ // TODO: cache service?
+ sp<IServiceManager> sm = defaultServiceManager();
+ sp<IBinder> binder = sm->getService(String16("android.security.keystore"));
+ sp<IKeystoreService> service = interface_cast<IKeystoreService>(binder);
+ if (service != NULL) {
+ if (service->addAuthToken(auth_token, auth_token_length) != NO_ERROR) {
+ ALOGE("Falure sending auth token to KeyStore");
+ }
+ } else {
+ ALOGE("Unable to communicate with KeyStore");
+ }
+ }
+}
+
// Called by the HAL to notify us of fingerprint events
static void hal_notify_callback(fingerprint_msg_t msg) {
uint32_t arg1 = 0;
@@ -76,7 +98,10 @@ static void hal_notify_callback(fingerprint_msg_t msg) {
case FINGERPRINT_AUTHENTICATED:
arg1 = msg.data.authenticated.finger.fid;
arg2 = msg.data.authenticated.finger.gid;
- // Jim, arg3 would be the hw_auth_token_t, please pass it the way you like.
+ if (arg1 != 0) {
+ notifyKeystore(&msg.data.authenticated.hat,
+ sizeof(msg.data.authenticated.hat));
+ }
break;
case FINGERPRINT_TEMPLATE_ENROLLING:
arg1 = msg.data.enroll.finger.fid;
@@ -198,6 +223,7 @@ static jint nativeCloseHal(JNIEnv* env, jobject clazz) {
// ----------------------------------------------------------------------------
+
// TODO: clean up void methods
static const JNINativeMethod g_methods[] = {
{ "nativeAuthenticate", "(JI)I", (void*)nativeAuthenticate },