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

Commit b55243ae authored by Yeabkal Wubshit's avatar Yeabkal Wubshit Committed by Android (Google) Code Review
Browse files

Merge "Pass input source and action in interceptMotionBeforeQueueing" into main

parents bea6edee 97f3b19c
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -2523,9 +2523,9 @@ public class InputManagerService extends IInputManager.Stub
    // Native callback.
    @SuppressWarnings("unused")
    private int interceptMotionBeforeQueueingNonInteractive(int displayId,
            long whenNanos, int policyFlags) {
            int source, int action, long whenNanos, int policyFlags) {
        return mWindowManagerCallbacks.interceptMotionBeforeQueueingNonInteractive(
                displayId, whenNanos, policyFlags);
                displayId, source, action, whenNanos, policyFlags);
    }

    // Native callback.
@@ -2901,8 +2901,8 @@ public class InputManagerService extends IInputManager.Stub
         * processing when the device is in a non-interactive state since these events are normally
         * dropped.
         */
        int interceptMotionBeforeQueueingNonInteractive(int displayId, long whenNanos,
                int policyFlags);
        int interceptMotionBeforeQueueingNonInteractive(int displayId, int source, int action,
                long whenNanos, int policyFlags);

        /**
         * This callback is invoked just before the key is about to be sent to an application.
+2 −2
Original line number Diff line number Diff line
@@ -5201,8 +5201,8 @@ public class PhoneWindowManager implements WindowManagerPolicy {
    // TODO(b/117479243): handle it in InputPolicy
    /** {@inheritDoc} */
    @Override
    public int interceptMotionBeforeQueueingNonInteractive(int displayId, long whenNanos,
            int policyFlags) {
    public int interceptMotionBeforeQueueingNonInteractive(int displayId, int source, int action,
            long whenNanos, int policyFlags) {
        if ((policyFlags & FLAG_WAKE) != 0) {
            if (wakeUp(whenNanos / 1000000, mAllowTheaterModeWakeFromMotion,
                    PowerManager.WAKE_REASON_WAKE_MOTION, "android.policy:MOTION")) {
+4 −2
Original line number Diff line number Diff line
@@ -706,12 +706,14 @@ public interface WindowManagerPolicy extends WindowManagerPolicyConstants {
     * Generally, it's best to keep as little as possible in the queue thread
     * because it's the most fragile.
     * @param displayId The display ID of the motion event.
     * @param source the {@link InputDevice} source that caused the motion.
     * @param action the {@link MotionEvent} action for the motion.
     * @param policyFlags The policy flags associated with the motion.
     *
     * @return Actions flags: may be {@link #ACTION_PASS_TO_USER}.
     */
    int interceptMotionBeforeQueueingNonInteractive(int displayId, long whenNanos,
            int policyFlags);
    int interceptMotionBeforeQueueingNonInteractive(int displayId, int source, int action,
            long whenNanos, int policyFlags);

    /**
     * Called from the input dispatcher thread before a key is dispatched to a window.
+3 −3
Original line number Diff line number Diff line
@@ -167,10 +167,10 @@ final class InputManagerCallback implements InputManagerService.WindowManagerCal

    /** {@inheritDoc} */
    @Override
    public int interceptMotionBeforeQueueingNonInteractive(int displayId, long whenNanos,
            int policyFlags) {
    public int interceptMotionBeforeQueueingNonInteractive(int displayId, int source, int action,
            long whenNanos, int policyFlags) {
        return mService.mPolicy.interceptMotionBeforeQueueingNonInteractive(
                displayId, whenNanos, policyFlags);
                displayId, source, action, whenNanos, policyFlags);
    }

    /**
+6 −5
Original line number Diff line number Diff line
@@ -358,8 +358,8 @@ public:
    void notifyVibratorState(int32_t deviceId, bool isOn) override;
    bool filterInputEvent(const InputEvent& inputEvent, uint32_t policyFlags) override;
    void interceptKeyBeforeQueueing(const KeyEvent& keyEvent, uint32_t& policyFlags) override;
    void interceptMotionBeforeQueueing(int32_t displayId, nsecs_t when,
                                       uint32_t& policyFlags) override;
    void interceptMotionBeforeQueueing(int32_t displayId, uint32_t source, int32_t action,
                                       nsecs_t when, uint32_t& policyFlags) override;
    nsecs_t interceptKeyBeforeDispatching(const sp<IBinder>& token, const KeyEvent& keyEvent,
                                          uint32_t policyFlags) override;
    std::optional<KeyEvent> dispatchUnhandledKey(const sp<IBinder>& token, const KeyEvent& keyEvent,
@@ -1496,7 +1496,8 @@ void NativeInputManager::interceptKeyBeforeQueueing(const KeyEvent& keyEvent,
    handleInterceptActions(wmActions, when, /*byref*/ policyFlags);
}

void NativeInputManager::interceptMotionBeforeQueueing(int32_t displayId, nsecs_t when,
void NativeInputManager::interceptMotionBeforeQueueing(int32_t displayId, uint32_t source,
                                                       int32_t action, nsecs_t when,
                                                       uint32_t& policyFlags) {
    ATRACE_CALL();
    // Policy:
@@ -1525,7 +1526,7 @@ void NativeInputManager::interceptMotionBeforeQueueing(int32_t displayId, nsecs_
    const jint wmActions =
            env->CallIntMethod(mServiceObj,
                               gServiceClassInfo.interceptMotionBeforeQueueingNonInteractive,
                               displayId, when, policyFlags);
                               displayId, source, action, when, policyFlags);
    if (checkAndClearExceptionFromCallback(env, "interceptMotionBeforeQueueingNonInteractive")) {
        return;
    }
@@ -2943,7 +2944,7 @@ int register_android_server_InputManager(JNIEnv* env) {
            "interceptKeyBeforeQueueing", "(Landroid/view/KeyEvent;I)I");

    GET_METHOD_ID(gServiceClassInfo.interceptMotionBeforeQueueingNonInteractive, clazz,
            "interceptMotionBeforeQueueingNonInteractive", "(IJI)I");
            "interceptMotionBeforeQueueingNonInteractive", "(IIIJI)I");

    GET_METHOD_ID(gServiceClassInfo.interceptKeyBeforeDispatching, clazz,
            "interceptKeyBeforeDispatching",
Loading