diff options
6 files changed, 21 insertions, 18 deletions
diff --git a/services/core/java/com/android/server/input/InputManagerService.java b/services/core/java/com/android/server/input/InputManagerService.java index 24e23003d12b..087c52573118 100644 --- a/services/core/java/com/android/server/input/InputManagerService.java +++ b/services/core/java/com/android/server/input/InputManagerService.java @@ -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. diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java index 3000a1c5c043..5b13d3fead90 100644 --- a/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -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")) { diff --git a/services/core/java/com/android/server/policy/WindowManagerPolicy.java b/services/core/java/com/android/server/policy/WindowManagerPolicy.java index 03a7bd3b68b3..3016b39a7e6b 100644 --- a/services/core/java/com/android/server/policy/WindowManagerPolicy.java +++ b/services/core/java/com/android/server/policy/WindowManagerPolicy.java @@ -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. diff --git a/services/core/java/com/android/server/wm/InputManagerCallback.java b/services/core/java/com/android/server/wm/InputManagerCallback.java index 8cf471394c63..a84ebd95cf1c 100644 --- a/services/core/java/com/android/server/wm/InputManagerCallback.java +++ b/services/core/java/com/android/server/wm/InputManagerCallback.java @@ -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); } /** diff --git a/services/core/jni/com_android_server_input_InputManagerService.cpp b/services/core/jni/com_android_server_input_InputManagerService.cpp index 0dd0564ae034..9ba0a2aae02c 100644 --- a/services/core/jni/com_android_server_input_InputManagerService.cpp +++ b/services/core/jni/com_android_server_input_InputManagerService.cpp @@ -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", diff --git a/services/tests/wmtests/src/com/android/server/wm/TestWindowManagerPolicy.java b/services/tests/wmtests/src/com/android/server/wm/TestWindowManagerPolicy.java index bd111ada8550..52e2d8abc2d5 100644 --- a/services/tests/wmtests/src/com/android/server/wm/TestWindowManagerPolicy.java +++ b/services/tests/wmtests/src/com/android/server/wm/TestWindowManagerPolicy.java @@ -89,8 +89,8 @@ class TestWindowManagerPolicy implements WindowManagerPolicy { } @Override - public int interceptMotionBeforeQueueingNonInteractive(int displayId, long whenNanos, - int policyFlags) { + public int interceptMotionBeforeQueueingNonInteractive(int displayId, int source, int action, + long whenNanos, int policyFlags) { return 0; } |