From 91dae475de3d00bf6b364e2ce87829f0cb5f0a3f Mon Sep 17 00:00:00 2001 From: Feng Cao Date: Fri, 12 Jun 2020 15:47:49 -0700 Subject: [PATCH] Fix a bug where we didn't call IME before calling augmented autofill * For inline autofill, we always need to get an IME callback before calling the augmented autofill service. This is because although autofill keeps a list of undestroyed sessions, the IME side always discards the old callback for autofill when a new one is created. So in case of switching back to an existing autofill session, we need to make sure we ask the IME to return a new callback. * we current have the check which missed a case where we are re-entering an existing autofill session, but the standard autofill was returning null the previous time, so it goes to trigger augmented autofill directly. In this case, we need to call IME onCreateInlineSuggestionsRequest to get a callback before calling the augmented autofill. We didn't, and this patch fixes it. Test: atest android.autofillservice.cts.inline Test: manual Bug: 158877106 Change-Id: Ie15cf0763ae49a204ad09c2eaac798890388622e --- .../autofill/java/com/android/server/autofill/Session.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java index a9a0ab69f6335..995fd266fb3b4 100644 --- a/services/autofill/java/com/android/server/autofill/Session.java +++ b/services/autofill/java/com/android/server/autofill/Session.java @@ -3208,16 +3208,19 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState }; // When the inline suggestion render service is available and the view is focused, there - // are 2 cases when augmented autofill should ask IME for inline suggestion request, + // are 3 cases when augmented autofill should ask IME for inline suggestion request, // because standard autofill flow didn't: // 1. the field is augmented autofill only (when standard autofill provider is None or // when it returns null response) // 2. standard autofill provider doesn't support inline suggestion + // 3. we re-entered the autofill session and standard autofill was not re-triggered, this is + // recognized by seeing mExpiredResponse == true final RemoteInlineSuggestionRenderService remoteRenderService = mService.getRemoteInlineSuggestionRenderServiceLocked(); if (remoteRenderService != null && (mForAugmentedAutofillOnly - || !isInlineSuggestionsEnabledByAutofillProviderLocked()) + || !isInlineSuggestionsEnabledByAutofillProviderLocked() + || mExpiredResponse) && isViewFocusedLocked(flags)) { if (sDebug) Slog.d(TAG, "Create inline request for augmented autofill"); remoteRenderService.getInlineSuggestionsRendererInfo(new RemoteCallback(