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

Commit 094be7fb authored by Chavi Weingarten's avatar Chavi Weingarten Committed by Android (Google) Code Review
Browse files

Merge "Added last focused window to notifyFocusChanged callback (2/3)"

parents 56ac01eb 91089864
Loading
Loading
Loading
Loading
+3 −3
Original line number Diff line number Diff line
@@ -1760,14 +1760,14 @@ public class InputManagerService extends IInputManager.Stub
    }

    // Native callback
    private void notifyFocusChanged(IBinder token) {
        if (mFocusedWindow.asBinder() == token) {
    private void notifyFocusChanged(IBinder oldToken, IBinder newToken) {
        if (mFocusedWindow.asBinder() == newToken) {
            Log.w(TAG, "notifyFocusChanged called with unchanged mFocusedWindow=" + mFocusedWindow);
            return;
        }

        setPointerCapture(false);
        mFocusedWindow = IWindow.Stub.asInterface(token);
        mFocusedWindow = IWindow.Stub.asInterface(newToken);
    }

    // Native callback.
+9 −9
Original line number Diff line number Diff line
@@ -244,7 +244,7 @@ public:
            const sp<IBinder>& token,
            const std::string& reason);
    virtual void notifyInputChannelBroken(const sp<IBinder>& token);
    virtual void notifyFocusChanged(const sp<IBinder>& token);
    virtual void notifyFocusChanged(const sp<IBinder>& oldToken, const sp<IBinder>& newToken);
    virtual bool filterInputEvent(const InputEvent* inputEvent, uint32_t policyFlags);
    virtual void getDispatcherConfiguration(InputDispatcherConfiguration* outConfig);
    virtual void interceptKeyBeforeQueueing(const KeyEvent* keyEvent, uint32_t& policyFlags);
@@ -738,7 +738,8 @@ void NativeInputManager::notifyInputChannelBroken(const sp<IBinder>& token) {
    }
}

void NativeInputManager::notifyFocusChanged(const sp<IBinder>& token) {
void NativeInputManager::notifyFocusChanged(const sp<IBinder>& oldToken,
        const sp<IBinder>& newToken) {
#if DEBUG_INPUT_DISPATCHER_POLICY
    ALOGD("notifyFocusChanged");
#endif
@@ -746,13 +747,12 @@ void NativeInputManager::notifyFocusChanged(const sp<IBinder>& token) {

    JNIEnv* env = jniEnv();

    jobject tokenObj = javaObjectForIBinder(env, token);
    if (tokenObj) {
    jobject oldTokenObj = javaObjectForIBinder(env, oldToken);
    jobject newTokenObj = javaObjectForIBinder(env, newToken);
    env->CallVoidMethod(mServiceObj, gServiceClassInfo.notifyFocusChanged,
                tokenObj);
            oldTokenObj, newTokenObj);
    checkAndClearExceptionFromCallback(env, "notifyFocusChanged");
}
}

void NativeInputManager::getDispatcherConfiguration(InputDispatcherConfiguration* outConfig) {
    ATRACE_CALL();
@@ -1762,7 +1762,7 @@ int register_android_server_InputManager(JNIEnv* env) {
            "notifyInputChannelBroken", "(Landroid/os/IBinder;)V");
    
    GET_METHOD_ID(gServiceClassInfo.notifyFocusChanged, clazz,
            "notifyFocusChanged", "(Landroid/os/IBinder;)V");
            "notifyFocusChanged", "(Landroid/os/IBinder;Landroid/os/IBinder;)V");

    GET_METHOD_ID(gServiceClassInfo.notifyANR, clazz,
            "notifyANR",