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

Commit 0e160531 authored by Scott Mertz's avatar Scott Mertz Committed by Gerrit Code Review
Browse files

fingerprint: detach java vm in HAL callback

Change-Id: Icc33c52d43fc1be38aa0cd767671408f07d74d03
parent 76fb3805
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -88,9 +88,10 @@ static void hal_notify_callback(fingerprint_msg_t msg) {

	// TODO: fix gross hack to attach JNI to calling thread
    JNIEnv* env = AndroidRuntime::getJNIEnv();
    JavaVM* vm = NULL;
    if (env == NULL) {
        JavaVMAttachArgs args = {JNI_VERSION_1_4, NULL, NULL};
        JavaVM* vm = AndroidRuntime::getJavaVM();
        vm = AndroidRuntime::getJavaVM();
        int result = vm->AttachCurrentThread(&env, (void*) &args);
        if (result != JNI_OK) {
            ALOGE("Can't call JNI method: attach failed: %#x", result);
@@ -99,6 +100,9 @@ static void hal_notify_callback(fingerprint_msg_t msg) {
    }
    env->CallVoidMethod(gFingerprintServiceClassInfo.callbackObject,
            gFingerprintServiceClassInfo.notify, msg.type, arg1, arg2);
    if (vm != NULL) {
        vm->DetachCurrentThread();
    }
}

static void nativeInit(JNIEnv *env, jobject clazz, jobject callbackObj) {