diff options
| author | Dake Gu <dake@google.com> | 2018-02-08 12:09:30 -0800 |
|---|---|---|
| committer | Dake Gu <dake@google.com> | 2018-02-21 13:56:39 -0800 |
| commit | 6a20a194dd965c66d620d6e6dd0abbabd9ca6360 (patch) | |
| tree | fdaebd969792d8094007059dab1b06bd93dc25e0 /core/java/android/view/ViewRootImpl.java | |
| parent | 961b465ac469d9f596e8bd1d6a3bba10a63ba2d8 (diff) | |
autofill: pass keyevent from fillui to app
Since autofill window was made to have window focus, app lost the
ability to accept physical keyboard typing. User can no longer
type on physical keyboard to filter autofill result.
This CL dispatches unhandled keyevent(e.g. A/B/C) from autofill
window to app ViewRootImpl in a similar way InputMethodService
dispatches keyevent to app's ViewRoot.
The unhandled key is sent to app window's ViewRootImpl
PreImeStage so that the keystroke could be translated to CJK by IME.
This CL does not affect fullscreen autofill window for TV where app
window is fully covered: user has to close fullscreen autofill window
first.
Bug: 72951156
Test: atest CtsAutoFillServiceTestCases:LoginActivityTest
Change-Id: I8e50cfdfe8d5691d2b248d85f924c38488ca30f4
Diffstat (limited to 'core/java/android/view/ViewRootImpl.java')
| -rw-r--r-- | core/java/android/view/ViewRootImpl.java | 22 |
1 files changed, 21 insertions, 1 deletions
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 810864eaac3c..01d9265cc92c 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -3925,6 +3925,7 @@ public final class ViewRootImpl implements ViewParent, private final static int MSG_DISPATCH_APP_VISIBILITY = 8; private final static int MSG_DISPATCH_GET_NEW_SURFACE = 9; private final static int MSG_DISPATCH_KEY_FROM_IME = 11; + private final static int MSG_DISPATCH_KEY_FROM_AUTOFILL = 12; private final static int MSG_CHECK_FOCUS = 13; private final static int MSG_CLOSE_SYSTEM_DIALOGS = 14; private final static int MSG_DISPATCH_DRAG_EVENT = 15; @@ -3966,6 +3967,8 @@ public final class ViewRootImpl implements ViewParent, return "MSG_DISPATCH_GET_NEW_SURFACE"; case MSG_DISPATCH_KEY_FROM_IME: return "MSG_DISPATCH_KEY_FROM_IME"; + case MSG_DISPATCH_KEY_FROM_AUTOFILL: + return "MSG_DISPATCH_KEY_FROM_AUTOFILL"; case MSG_CHECK_FOCUS: return "MSG_CHECK_FOCUS"; case MSG_CLOSE_SYSTEM_DIALOGS: @@ -4143,6 +4146,15 @@ public final class ViewRootImpl implements ViewParent, } enqueueInputEvent(event, null, QueuedInputEvent.FLAG_DELIVER_POST_IME, true); } break; + case MSG_DISPATCH_KEY_FROM_AUTOFILL: { + if (LOCAL_LOGV) { + Log.v(TAG, "Dispatching key " + msg.obj + " from Autofill to " + mView); + } + KeyEvent event = (KeyEvent) msg.obj; + // send InputEvent to pre IME, set FLAG_FROM_AUTOFILL so the InputEvent + // wont be dropped as app window is not focus. + enqueueInputEvent(event, null, QueuedInputEvent.FLAG_FROM_AUTOFILL, true); + } break; case MSG_CHECK_FOCUS: { InputMethodManager imm = InputMethodManager.peekInstance(); if (imm != null) { @@ -4433,7 +4445,8 @@ public final class ViewRootImpl implements ViewParent, Slog.w(mTag, "Dropping event due to root view being removed: " + q.mEvent); return true; } else if ((!mAttachInfo.mHasWindowFocus - && !q.mEvent.isFromSource(InputDevice.SOURCE_CLASS_POINTER)) || mStopped + && !q.mEvent.isFromSource(InputDevice.SOURCE_CLASS_POINTER) + && (q.mFlags & QueuedInputEvent.FLAG_FROM_AUTOFILL) == 0) || mStopped || (mIsAmbientMode && !q.mEvent.isFromSource(InputDevice.SOURCE_CLASS_BUTTON)) || (mPausedForTransition && !isBack(q.mEvent))) { // This is a focus event and the window doesn't currently have input focus or @@ -6805,6 +6818,7 @@ public final class ViewRootImpl implements ViewParent, public static final int FLAG_FINISHED_HANDLED = 1 << 3; public static final int FLAG_RESYNTHESIZED = 1 << 4; public static final int FLAG_UNHANDLED = 1 << 5; + public static final int FLAG_FROM_AUTOFILL = 1 << 6; public QueuedInputEvent mNext; @@ -7262,6 +7276,12 @@ public final class ViewRootImpl implements ViewParent, mHandler.sendMessage(msg); } + public void dispatchKeyFromAutofill(KeyEvent event) { + Message msg = mHandler.obtainMessage(MSG_DISPATCH_KEY_FROM_AUTOFILL, event); + msg.setAsynchronous(true); + mHandler.sendMessage(msg); + } + /** * Reinject unhandled {@link InputEvent}s in order to synthesize fallbacks events. * |
