Tell system server whether the app handled input events.
Refactored ViewRoot, NativeActivity and related classes to tell the
dispatcher whether an input event was actually handled by the application.
This will be used to move more of the global default key processing
into the system server instead of the application.
Change-Id: If06b98b6f45c543e5ac5b1eae2b3baf9371fba28
diff --git a/services/java/com/android/server/WindowManagerService.java b/services/java/com/android/server/WindowManagerService.java
index c74a27c..1c92da9 100644
--- a/services/java/com/android/server/WindowManagerService.java
+++ b/services/java/com/android/server/WindowManagerService.java
@@ -824,13 +824,15 @@
DragState mDragState = null;
private final InputHandler mDragInputHandler = new BaseInputHandler() {
@Override
- public void handleMotion(MotionEvent event, Runnable finishedCallback) {
- boolean endDrag = false;
- final float newX = event.getRawX();
- final float newY = event.getRawY();
-
+ public void handleMotion(MotionEvent event, InputQueue.FinishedCallback finishedCallback) {
+ boolean handled = false;
try {
- if (mDragState != null) {
+ if ((event.getSource() & InputDevice.SOURCE_CLASS_POINTER) != 0
+ && mDragState != null) {
+ boolean endDrag = false;
+ final float newX = event.getRawX();
+ final float newY = event.getRawY();
+
switch (event.getAction()) {
case MotionEvent.ACTION_DOWN: {
if (DEBUG_DRAG) {
@@ -866,11 +868,13 @@
mDragState.endDragLw();
}
}
+
+ handled = true;
}
} catch (Exception e) {
Slog.e(TAG, "Exception caught by drag handleMotion", e);
} finally {
- finishedCallback.run();
+ finishedCallback.finished(handled);
}
}
};
@@ -5781,6 +5785,16 @@
keyCode, scanCode, metaState, repeatCount, policyFlags);
}
+ /* Provides an opportunity for the window manager policy to process a key that
+ * the application did not handle. */
+ public boolean dispatchUnhandledKey(InputChannel focus,
+ int action, int flags, int keyCode, int scanCode, int metaState, int repeatCount,
+ int policyFlags) {
+ WindowState windowState = getWindowStateForInputChannel(focus);
+ return mPolicy.dispatchUnhandledKey(windowState, action, flags,
+ keyCode, scanCode, metaState, repeatCount, policyFlags);
+ }
+
/* Called when the current input focus changes.
* Layer assignment is assumed to be complete by the time this is called.
*/