From 7c978ecc8f9a254dcf54668445c1445926a4579b Mon Sep 17 00:00:00 2001 From: Feng Cao Date: Mon, 11 May 2020 18:00:21 -0700 Subject: [PATCH] Only clear inline suggestions when IMS.onInputFinish is called * Don't clear inline suggestions when receiving VIEW_EXIT from Autofill session * Don't clear inline suggestions when IME becomes invisible from IMS.onInputViewFinish(), instead only clear when IMS.onInputFinish() is called * Don't clear inline suggestions when launching an intent from inline action chip (be it authentication intent or regular action) Test: atest android.autofillservice.cts.inline Bug: 156099633 Change-Id: I8bebec3135410131e12c62e37b8a63a3702f7fac --- .../AutofillInlineSuggestionsRequestSession.java | 10 +++++----- .../java/com/android/server/autofill/Session.java | 8 ++++++-- .../server/autofill/ui/InlineSuggestionFactory.java | 2 -- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/services/autofill/java/com/android/server/autofill/AutofillInlineSuggestionsRequestSession.java b/services/autofill/java/com/android/server/autofill/AutofillInlineSuggestionsRequestSession.java index 0bf89936f2ce5..aee4afbdc3d26 100644 --- a/services/autofill/java/com/android/server/autofill/AutofillInlineSuggestionsRequestSession.java +++ b/services/autofill/java/com/android/server/autofill/AutofillInlineSuggestionsRequestSession.java @@ -212,12 +212,12 @@ final class AutofillInlineSuggestionsRequestSession { if (mDestroyed || mResponseCallback == null) { return; } - if (!mImeInputViewStarted && mPreviousResponseIsNotEmpty) { - // 1. if previous response is not empty, and IME just become invisible, then send - // empty response to make sure existing responses don't stick around on the IME. + if (!mImeInputStarted && mPreviousResponseIsNotEmpty) { + // 1. if previous response is not empty, and IME is just disconnected from the view, + // then send empty response to make sure existing responses don't stick around. // Although the inline suggestions should disappear when IME hides which removes them - // from the view hierarchy, but we still send an empty response to be extra safe. - + // from the view hierarchy, but we still send an empty response to indicate that the + // previous suggestions are invalid now. if (sVerbose) Slog.v(TAG, "Send empty inline response"); updateResponseToImeUncheckLocked(new InlineSuggestionsResponse(Collections.EMPTY_LIST)); mPreviousResponseIsNotEmpty = false; diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java index ff4e7bac6cae7..177453417787d 100644 --- a/services/autofill/java/com/android/server/autofill/Session.java +++ b/services/autofill/java/com/android/server/autofill/Session.java @@ -2573,7 +2573,6 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState if (sVerbose) Slog.v(TAG, "Exiting view " + id); mUi.hideFillUi(this); hideAugmentedAutofillLocked(viewState); - mInlineSessionController.hideInlineSuggestionsUiLocked(mCurrentViewId); mCurrentViewId = null; } break; @@ -2647,6 +2646,9 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState if (sVerbose) { Slog.v(TAG, "ignoring autofilled change on id " + id); } + // TODO(b/156099633): remove this once framework gets out of business of resending + // inline suggestions when IME visibility changes. + mInlineSessionController.hideInlineSuggestionsUiLocked(viewState.id); viewState.resetState(ViewState.STATE_CHANGED); return; } else if ((viewState.id.equals(this.mCurrentViewId)) @@ -3339,7 +3341,9 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState if (generateEvent) { mService.logDatasetSelected(dataset.getId(), id, mClientState); } - + if (mCurrentViewId != null) { + mInlineSessionController.hideInlineSuggestionsUiLocked(mCurrentViewId); + } autoFillApp(dataset); return; } diff --git a/services/autofill/java/com/android/server/autofill/ui/InlineSuggestionFactory.java b/services/autofill/java/com/android/server/autofill/ui/InlineSuggestionFactory.java index 089eeb2aa086a..8cc0de4733280 100644 --- a/services/autofill/java/com/android/server/autofill/ui/InlineSuggestionFactory.java +++ b/services/autofill/java/com/android/server/autofill/ui/InlineSuggestionFactory.java @@ -57,7 +57,6 @@ final class InlineSuggestionFactory { @NonNull AutoFillUI.AutoFillUiCallback client, @NonNull Runnable onErrorCallback, @Nullable RemoteInlineSuggestionRenderService remoteRenderService) { final BiConsumer onClickFactory = (dataset, datasetIndex) -> { - client.requestHideFillUi(autofillId); client.authenticate(response.getRequestId(), datasetIndex, response.getAuthentication(), response.getClientState(), /* authenticateInline= */ true); @@ -85,7 +84,6 @@ final class InlineSuggestionFactory { final Consumer intentSenderConsumer = (intentSender) -> client.startIntentSender(intentSender, new Intent()); final BiConsumer onClickFactory = (dataset, datasetIndex) -> { - client.requestHideFillUi(autofillId); client.fill(requestId, datasetIndex, dataset); };