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

Commit 4e558e8d authored by Android Build Merger (Role)'s avatar Android Build Merger (Role) Committed by Android (Google) Code Review
Browse files

Merge "Merge "Changed local refs in JNI to ScopedLocalRef" into qt-dev am:...

Merge "Merge "Changed local refs in JNI to ScopedLocalRef" into qt-dev am: e32ae7e3" into qt-dev-plus-aosp
parents 6084f24b 447b8302
Loading
Loading
Loading
Loading
+17 −17
Original line number Original line Diff line number Diff line
@@ -724,19 +724,18 @@ nsecs_t NativeInputManager::notifyANR(const sp<InputApplicationHandle>& inputApp


    JNIEnv* env = jniEnv();
    JNIEnv* env = jniEnv();


    jobject tokenObj = javaObjectForIBinder(env, token);
    ScopedLocalRef<jobject> tokenObj(env, javaObjectForIBinder(env, token));
    jstring reasonObj = env->NewStringUTF(reason.c_str());
    ScopedLocalRef<jstring> reasonObj(env, env->NewStringUTF(reason.c_str()));


    jlong newTimeout = env->CallLongMethod(mServiceObj,
    jlong newTimeout = env->CallLongMethod(mServiceObj,
                gServiceClassInfo.notifyANR, tokenObj,
                gServiceClassInfo.notifyANR, tokenObj.get(),
                reasonObj);
                reasonObj.get());
    if (checkAndClearExceptionFromCallback(env, "notifyANR")) {
    if (checkAndClearExceptionFromCallback(env, "notifyANR")) {
        newTimeout = 0; // abort dispatch
        newTimeout = 0; // abort dispatch
    } else {
    } else {
        assert(newTimeout >= 0);
        assert(newTimeout >= 0);
    }
    }


    env->DeleteLocalRef(reasonObj);
    return newTimeout;
    return newTimeout;
}
}


@@ -748,10 +747,10 @@ void NativeInputManager::notifyInputChannelBroken(const sp<IBinder>& token) {


    JNIEnv* env = jniEnv();
    JNIEnv* env = jniEnv();


    jobject tokenObj = javaObjectForIBinder(env, token);
    ScopedLocalRef<jobject> tokenObj(env, javaObjectForIBinder(env, token));
    if (tokenObj) {
    if (tokenObj.get()) {
        env->CallVoidMethod(mServiceObj, gServiceClassInfo.notifyInputChannelBroken,
        env->CallVoidMethod(mServiceObj, gServiceClassInfo.notifyInputChannelBroken,
                tokenObj);
                tokenObj.get());
        checkAndClearExceptionFromCallback(env, "notifyInputChannelBroken");
        checkAndClearExceptionFromCallback(env, "notifyInputChannelBroken");
    }
    }
}
}
@@ -765,10 +764,10 @@ void NativeInputManager::notifyFocusChanged(const sp<IBinder>& oldToken,


    JNIEnv* env = jniEnv();
    JNIEnv* env = jniEnv();


    jobject oldTokenObj = javaObjectForIBinder(env, oldToken);
    ScopedLocalRef<jobject> oldTokenObj(env, javaObjectForIBinder(env, oldToken));
    jobject newTokenObj = javaObjectForIBinder(env, newToken);
    ScopedLocalRef<jobject> newTokenObj(env, javaObjectForIBinder(env, newToken));
    env->CallVoidMethod(mServiceObj, gServiceClassInfo.notifyFocusChanged,
    env->CallVoidMethod(mServiceObj, gServiceClassInfo.notifyFocusChanged,
            oldTokenObj, newTokenObj);
            oldTokenObj.get(), newTokenObj.get());
    checkAndClearExceptionFromCallback(env, "notifyFocusChanged");
    checkAndClearExceptionFromCallback(env, "notifyFocusChanged");
}
}


@@ -1141,13 +1140,13 @@ nsecs_t NativeInputManager::interceptKeyBeforeDispatching(
        JNIEnv* env = jniEnv();
        JNIEnv* env = jniEnv();


        // Token may be null
        // Token may be null
        jobject tokenObj = javaObjectForIBinder(env, token);
        ScopedLocalRef<jobject> tokenObj(env, javaObjectForIBinder(env, token));


        jobject keyEventObj = android_view_KeyEvent_fromNative(env, keyEvent);
        jobject keyEventObj = android_view_KeyEvent_fromNative(env, keyEvent);
        if (keyEventObj) {
        if (keyEventObj) {
            jlong delayMillis = env->CallLongMethod(mServiceObj,
            jlong delayMillis = env->CallLongMethod(mServiceObj,
                    gServiceClassInfo.interceptKeyBeforeDispatching,
                    gServiceClassInfo.interceptKeyBeforeDispatching,
                    tokenObj, keyEventObj, policyFlags);
                    tokenObj.get(), keyEventObj, policyFlags);
            bool error = checkAndClearExceptionFromCallback(env, "interceptKeyBeforeDispatching");
            bool error = checkAndClearExceptionFromCallback(env, "interceptKeyBeforeDispatching");
            android_view_KeyEvent_recycle(env, keyEventObj);
            android_view_KeyEvent_recycle(env, keyEventObj);
            env->DeleteLocalRef(keyEventObj);
            env->DeleteLocalRef(keyEventObj);
@@ -1175,12 +1174,12 @@ bool NativeInputManager::dispatchUnhandledKey(const sp<IBinder>& token,
        JNIEnv* env = jniEnv();
        JNIEnv* env = jniEnv();


        // Note: tokenObj may be null.
        // Note: tokenObj may be null.
        jobject tokenObj = javaObjectForIBinder(env, token);
        ScopedLocalRef<jobject> tokenObj(env, javaObjectForIBinder(env, token));
        jobject keyEventObj = android_view_KeyEvent_fromNative(env, keyEvent);
        jobject keyEventObj = android_view_KeyEvent_fromNative(env, keyEvent);
        if (keyEventObj) {
        if (keyEventObj) {
            jobject fallbackKeyEventObj = env->CallObjectMethod(mServiceObj,
            jobject fallbackKeyEventObj = env->CallObjectMethod(mServiceObj,
                    gServiceClassInfo.dispatchUnhandledKey,
                    gServiceClassInfo.dispatchUnhandledKey,
                    tokenObj, keyEventObj, policyFlags);
                    tokenObj.get(), keyEventObj, policyFlags);
            if (checkAndClearExceptionFromCallback(env, "dispatchUnhandledKey")) {
            if (checkAndClearExceptionFromCallback(env, "dispatchUnhandledKey")) {
                fallbackKeyEventObj = nullptr;
                fallbackKeyEventObj = nullptr;
            }
            }
@@ -1225,8 +1224,9 @@ void NativeInputManager::onPointerDownOutsideFocus(const sp<IBinder>& touchedTok
    ATRACE_CALL();
    ATRACE_CALL();
    JNIEnv* env = jniEnv();
    JNIEnv* env = jniEnv();


    jobject touchedTokenObj = javaObjectForIBinder(env, touchedToken);
    ScopedLocalRef<jobject> touchedTokenObj(env, javaObjectForIBinder(env, touchedToken));
    env->CallVoidMethod(mServiceObj, gServiceClassInfo.onPointerDownOutsideFocus, touchedTokenObj);
    env->CallVoidMethod(mServiceObj, gServiceClassInfo.onPointerDownOutsideFocus,
            touchedTokenObj.get());
    checkAndClearExceptionFromCallback(env, "onPointerDownOutsideFocus");
    checkAndClearExceptionFromCallback(env, "onPointerDownOutsideFocus");
}
}