diff options
author | Jeff Brown <jeffbrown@google.com> | 2010-08-11 17:26:16 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2010-08-11 17:26:16 -0700 |
commit | 4e14159a046da30bafa3d7c25108babbb7e441ee (patch) | |
tree | c7343fff89e5295f887bdf3fc1154dc839778190 /core/java/android | |
parent | 5744cd6ac8308b18d32938ee19ad3c8bb8b0fad5 (diff) | |
parent | bb65ae020f802bae3e80dd8e05845fee5d6bc2cb (diff) | |
download | frameworks_base-4e14159a046da30bafa3d7c25108babbb7e441ee.zip frameworks_base-4e14159a046da30bafa3d7c25108babbb7e441ee.tar.gz frameworks_base-4e14159a046da30bafa3d7c25108babbb7e441ee.tar.bz2 |
am bb65ae02: Merge "Fix ViewRoot bug attempting to finish synthetic KeyEvents." into gingerbread
Merge commit 'bb65ae020f802bae3e80dd8e05845fee5d6bc2cb' into gingerbread-plus-aosp
* commit 'bb65ae020f802bae3e80dd8e05845fee5d6bc2cb':
Fix ViewRoot bug attempting to finish synthetic KeyEvents.
Diffstat (limited to 'core/java/android')
-rw-r--r-- | core/java/android/view/ViewRoot.java | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/core/java/android/view/ViewRoot.java b/core/java/android/view/ViewRoot.java index 7ce04cf..57c9055 100644 --- a/core/java/android/view/ViewRoot.java +++ b/core/java/android/view/ViewRoot.java @@ -52,7 +52,6 @@ import android.Manifest; import android.media.AudioManager; import java.lang.ref.WeakReference; -import java.io.FileDescriptor; import java.io.IOException; import java.io.OutputStream; import java.util.ArrayList; @@ -1869,7 +1868,7 @@ public final class ViewRoot extends Handler implements ViewParent, if (LOCAL_LOGV) Log.v( TAG, "Dispatching key " + msg.obj + " to " + mView); - deliverKeyEvent((KeyEvent)msg.obj, true); + deliverKeyEvent((KeyEvent)msg.obj, msg.arg1 != 0); break; case DISPATCH_POINTER: { MotionEvent event = (MotionEvent) msg.obj; @@ -2021,9 +2020,14 @@ public final class ViewRoot extends Handler implements ViewParent, } private void finishKeyEvent(KeyEvent event) { + if (LOCAL_LOGV) Log.v(TAG, "Telling window manager key is finished"); + if (mFinishedCallback != null) { mFinishedCallback.run(); mFinishedCallback = null; + } else { + Slog.w(TAG, "Attempted to tell the input queue that the current key event " + + "is finished but there is no key event actually in progress."); } } @@ -2483,8 +2487,6 @@ public final class ViewRoot extends Handler implements ViewParent, ? mView.dispatchKeyEventPreIme(event) : true; if (handled) { if (sendDone) { - if (LOCAL_LOGV) Log.v( - TAG, "Telling window manager key is finished"); finishKeyEvent(event); } return; @@ -2516,8 +2518,6 @@ public final class ViewRoot extends Handler implements ViewParent, deliverKeyEventToViewHierarchy(event, sendDone); return; } else if (sendDone) { - if (LOCAL_LOGV) Log.v( - TAG, "Telling window manager key is finished"); finishKeyEvent(event); } else { Log.w(TAG, "handleFinishedEvent(seq=" + seq @@ -2591,8 +2591,6 @@ public final class ViewRoot extends Handler implements ViewParent, } finally { if (sendDone) { - if (LOCAL_LOGV) Log.v( - TAG, "Telling window manager key is finished"); finishKeyEvent(event); } // Let the exception fall through -- the looper will catch @@ -2776,9 +2774,14 @@ public final class ViewRoot extends Handler implements ViewParent, private final InputHandler mInputHandler = new InputHandler() { public void handleKey(KeyEvent event, Runnable finishedCallback) { + if (mFinishedCallback != null) { + Slog.w(TAG, "Received a new key event from the input queue but there is " + + "already an unfinished key event in progress."); + } + mFinishedCallback = finishedCallback; - dispatchKey(event); + dispatchKey(event, true); } public void handleMotion(MotionEvent event, Runnable finishedCallback) { @@ -2789,9 +2792,13 @@ public final class ViewRoot extends Handler implements ViewParent, }; public void dispatchKey(KeyEvent event) { - if (event.getAction() == KeyEvent.ACTION_DOWN) { - //noinspection ConstantConditions - if (false && event.getKeyCode() == KeyEvent.KEYCODE_CAMERA) { + dispatchKey(event, false); + } + + private void dispatchKey(KeyEvent event, boolean sendDone) { + //noinspection ConstantConditions + if (false && event.getAction() == KeyEvent.ACTION_DOWN) { + if (event.getKeyCode() == KeyEvent.KEYCODE_CAMERA) { if (Config.LOGD) Log.d("keydisp", "==================================================="); if (Config.LOGD) Log.d("keydisp", "Focused view Hierarchy is:"); @@ -2804,6 +2811,7 @@ public final class ViewRoot extends Handler implements ViewParent, Message msg = obtainMessage(DISPATCH_KEY); msg.obj = event; + msg.arg1 = sendDone ? 1 : 0; if (LOCAL_LOGV) Log.v( TAG, "sending key " + event + " to " + mView); |