Pass input source and action in interceptMotionBeforeQueueing
In a follow up change, the source and action will be passed to
a separate helper class that would handle input-based wake ups.
Bug: 317432315
Test: build passes
Change-Id: I0d52963bf44a23a4780f3e19d0aa233329dedf5b
diff --git a/services/core/java/com/android/server/input/InputManagerService.java b/services/core/java/com/android/server/input/InputManagerService.java
index 24e23003..087c525 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 @@
// 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 @@
* 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 3000a1c..5b13d3fe 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 @@
// 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 03a7bd3..3016b39 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 @@
* 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 8cf4713..a84ebd9 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 @@
/** {@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 0dd0564..9ba0a2a 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 @@
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 @@
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 @@
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 @@
"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 bd111ad..52e2d8a 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 @@
}
@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;
}