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

Commit bd26e652 authored by Robert Carr's avatar Robert Carr
Browse files

Fix pointer capture

Pointer capture was working by sitting in the
Java layer of setInputWindows which is no longer called.
We simply provide an alternative solution and call it.

Bug: 80101428
Bug: 113136004
Bug: 111440400
Change-Id: I581a140ec80ed0c8675030132b50e4ad1087f129
parent b600bc29
Loading
Loading
Loading
Loading
+12 −15
Original line number Diff line number Diff line
@@ -1443,25 +1443,10 @@ public class InputManagerService extends IInputManager.Stub
        }
    }

    public void setInputWindows(InputWindowHandle[] windowHandles, int displayId) {
        nativeSetInputWindows(mPtr, windowHandles, displayId);
    }

    public void setFocusedApplication(int displayId, InputApplicationHandle application) {
        nativeSetFocusedApplication(mPtr, displayId, application);
    }

    public void setFocusedWindow(InputWindowHandle focusedWindowHandle) {
        final IWindow newFocusedWindow =
            focusedWindowHandle != null ? focusedWindowHandle.clientWindow : null;
        if (mFocusedWindow != newFocusedWindow) {
            if (mFocusedWindowHasCapture) {
                setPointerCapture(false);
            }
            mFocusedWindow = newFocusedWindow;
        }
    }

    public void setFocusedDisplay(int displayId) {
        nativeSetFocusedDisplay(mPtr, displayId);
    }
@@ -1799,6 +1784,18 @@ public class InputManagerService extends IInputManager.Stub
        mWindowManagerCallbacks.notifyInputChannelBroken(token);
    }

    // Native callback
    private void notifyFocusChanged(IBinder token) {
        if (mFocusedWindow != token) {
            if (mFocusedWindowHasCapture) {
                setPointerCapture(false);
            }
            if (token instanceof IWindow) {
                mFocusedWindow = (IWindow) token;
            }
        }
    }

    // Native callback.
    private long notifyANR(IBinder token, String reason) {
        return mWindowManagerCallbacks.notifyANR(
+1 −3
Original line number Diff line number Diff line
@@ -189,9 +189,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent> {
                mService.mH.sendMessage(msg);
            }
        });
        final WindowState topFocusedWindow = getTopFocusedDisplayContent().mCurrentFocus;
        mService.mInputManager.setFocusedWindow(
                topFocusedWindow != null ? topFocusedWindow.mInputWindowHandle : null);

        return changed;
    }

+21 −0
Original line number Diff line number Diff line
@@ -86,6 +86,7 @@ static struct {
    jmethodID notifySwitch;
    jmethodID notifyInputChannelBroken;
    jmethodID notifyANR;
    jmethodID notifyFocusChanged;
    jmethodID filterInputEvent;
    jmethodID interceptKeyBeforeQueueing;
    jmethodID interceptMotionBeforeQueueingNonInteractive;
@@ -240,6 +241,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 bool filterInputEvent(const InputEvent* inputEvent, uint32_t policyFlags);
    virtual void getDispatcherConfiguration(InputDispatcherConfiguration* outConfig);
    virtual void interceptKeyBeforeQueueing(const KeyEvent* keyEvent, uint32_t& policyFlags);
@@ -681,6 +683,22 @@ void NativeInputManager::notifyInputChannelBroken(const sp<IBinder>& token) {
    }
}

void NativeInputManager::notifyFocusChanged(const sp<IBinder>& token) {
#if DEBUG_INPUT_DISPATCHER_POLICY
    ALOGD("notifyFocusChanged");
#endif
    ATRACE_CALL();

    JNIEnv* env = jniEnv();

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

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

    GET_METHOD_ID(gServiceClassInfo.notifyANR, clazz,
            "notifyANR",
            "(Landroid/os/IBinder;Ljava/lang/String;)J");