diff options
author | 2013-08-22 19:41:29 -0700 | |
---|---|---|
committer | 2013-08-22 20:07:08 -0700 | |
commit | 0b31d812abe152cee3208f59be45bc94d9b299d5 (patch) | |
tree | 3a7f45cce134243bc31ce6e9b728223fad1117c1 | |
parent | 7e458235ac2f2522bea07aa24423b39d1729d2e3 (diff) |
Drop touch events when no window was touched.
Prevent spurious ANRs in the case where an input event is simply
undeliverable because there is no window at the touched location.
Previously, we would assume that we were just waiting for an
application to start and become available to handle the event but
this assumption is no longer valid.
Monkeys in particular have a tendency to inject events outside
of the boundaries of the display which results in spurious ANRs.
So we should just reject them.
Bug: 9774124
Change-Id: I5c40ce4c942f0557593a229dc5253a0e0bdb8466
-rw-r--r-- | services/input/InputDispatcher.cpp | 16 | ||||
-rw-r--r-- | services/java/com/android/server/wm/InputMonitor.java | 7 |
2 files changed, 8 insertions, 15 deletions
diff --git a/services/input/InputDispatcher.cpp b/services/input/InputDispatcher.cpp index 32247e75e066..795ab4740a78 100644 --- a/services/input/InputDispatcher.cpp +++ b/services/input/InputDispatcher.cpp @@ -1275,21 +1275,7 @@ int32_t InputDispatcher::findTouchedWindowTargetsLocked(nsecs_t currentTime, // Try to assign the pointer to the first foreground window we find, if there is one. newTouchedWindowHandle = mTempTouchState.getFirstForegroundWindowHandle(); if (newTouchedWindowHandle == NULL) { - // There is no touched window. If this is an initial down event - // then wait for a window to appear that will handle the touch. This is - // to ensure that we report an ANR in the case where an application has started - // but not yet put up a window and the user is starting to get impatient. - if (maskedAction == AMOTION_EVENT_ACTION_DOWN - && mFocusedApplicationHandle != NULL) { - injectionResult = handleTargetsNotReadyLocked(currentTime, entry, - mFocusedApplicationHandle, NULL, nextWakeupTime, - "Waiting because there is no touchable window that can " - "handle the event but there is focused application that may " - "eventually add a new window when it finishes starting up."); - goto Unresponsive; - } - - ALOGI("Dropping event because there is no touched window."); + ALOGI("Dropping event because there is no touchable window at (%d, %d).", x, y); injectionResult = INPUT_EVENT_INJECTION_FAILED; goto Failed; } diff --git a/services/java/com/android/server/wm/InputMonitor.java b/services/java/com/android/server/wm/InputMonitor.java index d22178d10b7a..9620612ec7bc 100644 --- a/services/java/com/android/server/wm/InputMonitor.java +++ b/services/java/com/android/server/wm/InputMonitor.java @@ -312,6 +312,7 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks { } /* Notifies that the input device configuration has changed. */ + @Override public void notifyConfigurationChanged() { mService.sendNewConfiguration(); @@ -337,12 +338,14 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks { } /* Notifies that the lid switch changed state. */ + @Override public void notifyLidSwitchChanged(long whenNanos, boolean lidOpen) { mService.mPolicy.notifyLidSwitchChanged(whenNanos, lidOpen); } /* Provides an opportunity for the window manager policy to intercept early key * processing as soon as the key has been read from the device. */ + @Override public int interceptKeyBeforeQueueing( KeyEvent event, int policyFlags, boolean isScreenOn) { return mService.mPolicy.interceptKeyBeforeQueueing(event, policyFlags, isScreenOn); @@ -351,12 +354,14 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks { /* Provides an opportunity for the window manager policy to intercept early * motion event processing when the screen is off since these events are normally * dropped. */ + @Override public int interceptMotionBeforeQueueingWhenScreenOff(int policyFlags) { return mService.mPolicy.interceptMotionBeforeQueueingWhenScreenOff(policyFlags); } /* Provides an opportunity for the window manager policy to process a key before * ordinary dispatch. */ + @Override public long interceptKeyBeforeDispatching( InputWindowHandle focus, KeyEvent event, int policyFlags) { WindowState windowState = focus != null ? (WindowState) focus.windowState : null; @@ -365,6 +370,7 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks { /* Provides an opportunity for the window manager policy to process a key that * the application did not handle. */ + @Override public KeyEvent dispatchUnhandledKey( InputWindowHandle focus, KeyEvent event, int policyFlags) { WindowState windowState = focus != null ? (WindowState) focus.windowState : null; @@ -372,6 +378,7 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks { } /* Callback to get pointer layer. */ + @Override public int getPointerLayer() { return mService.mPolicy.windowTypeToLayerLw(WindowManager.LayoutParams.TYPE_POINTER) * WindowManagerService.TYPE_LAYER_MULTIPLIER |