diff options
author | Feng Cao <fengcao@google.com> | 2020-06-12 15:47:49 -0700 |
---|---|---|
committer | Feng Cao <fengcao@google.com> | 2020-06-16 19:42:22 +0000 |
commit | 14de0026850b3993037f52583a207edfedab487c (patch) | |
tree | 4b3f4c406a7fb2e92a319088778083d26c276bb6 /services/autofill/java | |
parent | 556fe0b9e5c26ddb3181f4d55de4ac309d86c542 (diff) |
Fix input method switch handling in autofill
* this reverts ag/11592765 since it causes a regression for b/145949573
in the following case:
1. user taps on a field for which autofill returns null and augmented
autofill is triggered
2. user goes home, which sets the mExpiredResponse to true
3. user comes back to the app, now tapping on the input field over
and over, each tap will trigger a new augmented autofill request
* the fix is to revert the above patch, and then handle the input
method switch for augmented autofill case by setting the current
view to null, and also setting the augmented autofill id to null,
such that the entire autofill flow will be executed again.
* note that this patch changes one behavior - in case regular autofill
returns null and augmented autofill is triggered, switching input
method and tap on the field again, it will trigger regular autofill
again (before this patch, it will only trigger augmented autofill)
Test: relevant cts tests
Test: manual testing that on the chat app, switching input method
and then tap on the field again triggers a new request
Bug: 150483555
Bug: 157412832
Change-Id: I0868ff62047f66402885f9821f7981ca4596f76b
Diffstat (limited to 'services/autofill/java')
-rw-r--r-- | services/autofill/java/com/android/server/autofill/Session.java | 21 |
1 files changed, 15 insertions, 6 deletions
diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java index c7490b3b991c..fa449ad29e53 100644 --- a/services/autofill/java/com/android/server/autofill/Session.java +++ b/services/autofill/java/com/android/server/autofill/Session.java @@ -313,18 +313,28 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState private final AssistDataReceiverImpl mAssistReceiver = new AssistDataReceiverImpl(); void onSwitchInputMethodLocked() { + // One caveat is that for the case where the focus is on a field for which regular autofill + // returns null, and augmented autofill is triggered, and then the user switches the input + // method. Tapping on the field again will not trigger a new augmented autofill request. + // This may be fixed by adding more checks such as whether mCurrentViewId is null. if (mExpiredResponse) { return; } - - if (shouldExpireResponseOnInputMethodSwitch()) { + if (shouldResetSessionStateOnInputMethodSwitch()) { // Set the old response expired, so the next action (ACTION_VIEW_ENTERED) can trigger // a new fill request. mExpiredResponse = true; + // Clear the augmented autofillable ids so augmented autofill will trigger again. + mAugmentedAutofillableIds = null; + // In case the field is augmented autofill only, we clear the current view id, so that + // we won't skip view entered due to same view entered, for the augmented autofill. + if (mForAugmentedAutofillOnly) { + mCurrentViewId = null; + } } } - private boolean shouldExpireResponseOnInputMethodSwitch() { + private boolean shouldResetSessionStateOnInputMethodSwitch() { // One of below cases will need a new fill request to update the inline spec for the new // input method. // 1. The autofill provider supports inline suggestion and the render service is available. @@ -2588,15 +2598,14 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState id)) { // Regular autofill handled the view and returned null response, but it // triggered augmented autofill - if (!isSameViewEntered || mExpiredResponse) { + if (!isSameViewEntered) { if (sDebug) Slog.d(TAG, "trigger augmented autofill."); triggerAugmentedAutofillLocked(flags); } else { if (sDebug) Slog.d(TAG, "skip augmented autofill for same view."); } return; - } else if (mForAugmentedAutofillOnly && isSameViewEntered - && !mExpiredResponse) { + } else if (mForAugmentedAutofillOnly && isSameViewEntered) { // Regular autofill is disabled. if (sDebug) Slog.d(TAG, "skip augmented autofill for same view."); return; |