diff options
| author | Dake Gu <dake@google.com> | 2018-02-26 12:25:14 -0800 |
|---|---|---|
| committer | Dake Gu <dake@google.com> | 2018-02-28 16:10:07 -0800 |
| commit | b0fa378f9d390d27ab2a2f83eb6fa16f2b5cbb97 (patch) | |
| tree | 43413817e97fb7f86dfdc4bc6b3515e0cb2a84ed /core/java/android/view/ViewRootImpl.java | |
| parent | bf6edacac900e4f889dde292474e0e3fecb8d689 (diff) | |
autofill: touch on IME should not close autofill
ag/3434666 causes a regression:
Before ag/3434666, autofill gets touch event after IME, autofill
close itself if it gets ACTION_OUTSIDE touch event.
But after ag/3434666, autofill intercepts touch events before IME, if
user touches within IME, autofill still gets ACTION_OUTSIDE event,
and close itself unexpectedly.
The fix moves the closing code to ViewRootImpl.EarlyPostImeStage
around the same place closing tooltip.
If user taps outside autofill window, we will force to close window,
even last autofillid that requestShowUi does not match.
Bug: 73796497
Test: atest CtsAutoFillServiceTestCases
Test: Added LoginActivityTest.testAutofillTapOutside
Test: manually tested using IME and sample app
TODO: need a fake IME service to dispatch given key upon touch.
Change-Id: I10fc0d29dc30d29a48b2118264ec1c4375062deb
Diffstat (limited to 'core/java/android/view/ViewRootImpl.java')
| -rw-r--r-- | core/java/android/view/ViewRootImpl.java | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java index 01d9265cc92c..62755669affd 100644 --- a/core/java/android/view/ViewRootImpl.java +++ b/core/java/android/view/ViewRootImpl.java @@ -95,6 +95,7 @@ import android.view.accessibility.IAccessibilityInteractionConnection; import android.view.accessibility.IAccessibilityInteractionConnectionCallback; import android.view.animation.AccelerateDecelerateInterpolator; import android.view.animation.Interpolator; +import android.view.autofill.AutofillManager; import android.view.inputmethod.InputMethodManager; import android.widget.Scroller; @@ -4781,6 +4782,21 @@ public final class ViewRootImpl implements ViewParent, ensureTouchMode(event.isFromSource(InputDevice.SOURCE_TOUCHSCREEN)); } + if (action == MotionEvent.ACTION_DOWN && mView instanceof ViewGroup) { + // Upon motion event within app window, close autofill ui. + ViewGroup decorView = (ViewGroup) mView; + if (decorView.getChildCount() > 0) { + // We cannot use decorView's Context for querying AutofillManager: DecorView's + // context is based on Application Context, it would allocate a different + // AutofillManager instance. + AutofillManager afm = (AutofillManager) decorView.getChildAt(0).getContext() + .getSystemService(Context.AUTOFILL_MANAGER_SERVICE); + if (afm != null) { + afm.requestHideFillUi(); + } + } + } + if (action == MotionEvent.ACTION_DOWN && mAttachInfo.mTooltipHost != null) { mAttachInfo.mTooltipHost.hideTooltip(); } |
