From 62cc7dec3f5a586aec44f3037357cbaced4d6426 Mon Sep 17 00:00:00 2001 From: Feng Cao Date: Wed, 24 Jun 2020 20:02:40 -0700 Subject: [PATCH] Clear inline suggestions before onStartInput instead of before onFinishInput * In case where there are multiple input fields in a single WebView, switching focuses between input fields doesn't trigger an onFinishInput from the previous field. But it always triggers an onStartInput in the new field. So it's safer to clear the suggestions onStartInput Test: atest android.autofillservice.cts.inline Test: atest CtsInputMethodTestCases Bug: 159479887 Bug: 157515522 Change-Id: Ie380db855fbc93600635790ef5adc1031d6f0787 --- .../inputmethodservice/InlineSuggestionSessionController.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/java/android/inputmethodservice/InlineSuggestionSessionController.java b/core/java/android/inputmethodservice/InlineSuggestionSessionController.java index 8c0dd2a9bf59d..071c096ee2f01 100644 --- a/core/java/android/inputmethodservice/InlineSuggestionSessionController.java +++ b/core/java/android/inputmethodservice/InlineSuggestionSessionController.java @@ -134,6 +134,7 @@ class InlineSuggestionSessionController { mImeClientFieldId = imeFieldId; if (mSession != null) { + mSession.consumeInlineSuggestionsResponse(InlineSuggestionSession.EMPTY_RESPONSE); // Initiates the callback to Autofill if there is a pending matching session. // Otherwise updates the session with the Ime status. if (!mSession.isCallbackInvoked() && match(mSession.getRequestInfo())) { @@ -213,7 +214,6 @@ class InlineSuggestionSessionController { mImeInputViewStarted = false; mImeInputStarted = false; if (mSession != null && mSession.shouldSendImeStatus()) { - mSession.consumeInlineSuggestionsResponse(InlineSuggestionSession.EMPTY_RESPONSE); try { mSession.getRequestCallback().onInputMethodFinishInput(); } catch (RemoteException e) {