summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Dianne Hackborn <hackbod@google.com> 2012-09-12 17:04:41 -0700
committer Android (Google) Code Review <android-gerrit@google.com> 2012-09-12 17:04:42 -0700
commit3c78702db58af95b71b87c356f8fb0f95f3b70a7 (patch)
tree2f71b7b488e24bcfe39f4a365a0abb747101e075
parent39de2b0e1941c143d5b882a468e36929d978a35f (diff)
parent8d5e6f8d4a2bd39c6656cbac4f963d2527d707bf (diff)
Merge "Maybe fix issue #7146119: exception in FragmentManager" into jb-mr1-dev
-rw-r--r--core/java/android/view/ViewRootImpl.java23
1 files changed, 23 insertions, 0 deletions
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index 3006b5d5687c..e1312c19283a 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -3612,8 +3612,31 @@ public final class ViewRootImpl implements ViewParent,
finishInputEvent(q, true);
} else {
if (q.mEvent instanceof KeyEvent) {
+ KeyEvent event = (KeyEvent)q.mEvent;
+ if (event.getAction() != KeyEvent.ACTION_UP) {
+ // If the window doesn't currently have input focus, then drop
+ // this event. This could be an event that came back from the
+ // IME dispatch but the window has lost focus in the meantime.
+ if (!mAttachInfo.mHasWindowFocus) {
+ Slog.w(TAG, "Dropping event due to no window focus: " + event);
+ finishInputEvent(q, true);
+ return;
+ }
+ }
deliverKeyEventPostIme(q);
} else {
+ MotionEvent event = (MotionEvent)q.mEvent;
+ if (event.getAction() != MotionEvent.ACTION_CANCEL
+ && event.getAction() != MotionEvent.ACTION_UP) {
+ // If the window doesn't currently have input focus, then drop
+ // this event. This could be an event that came back from the
+ // IME dispatch but the window has lost focus in the meantime.
+ if (!mAttachInfo.mHasWindowFocus) {
+ Slog.w(TAG, "Dropping event due to no window focus: " + event);
+ finishInputEvent(q, true);
+ return;
+ }
+ }
final int source = q.mEvent.getSource();
if ((source & InputDevice.SOURCE_CLASS_TRACKBALL) != 0) {
deliverTrackballEventPostIme(q);