diff --git a/core/java/android/service/autofill/augmented/AugmentedAutofillService.java b/core/java/android/service/autofill/augmented/AugmentedAutofillService.java index c2234bad3803b..95cc64ae8aab5 100644 --- a/core/java/android/service/autofill/augmented/AugmentedAutofillService.java +++ b/core/java/android/service/autofill/augmented/AugmentedAutofillService.java @@ -564,9 +564,9 @@ public abstract class AugmentedAutofillService extends Service { } void reportResult(@Nullable List inlineSuggestionsData, - @Nullable Bundle clientState) { + @Nullable Bundle clientState, boolean showingFillWindow) { try { - mCallback.onSuccess(inlineSuggestionsData, clientState); + mCallback.onSuccess(inlineSuggestionsData, clientState, showingFillWindow); } catch (RemoteException e) { Log.e(TAG, "Error calling back with the inline suggestions data: " + e); } diff --git a/core/java/android/service/autofill/augmented/FillCallback.java b/core/java/android/service/autofill/augmented/FillCallback.java index 8ba5c173890c6..fc3baf1c9836e 100644 --- a/core/java/android/service/autofill/augmented/FillCallback.java +++ b/core/java/android/service/autofill/augmented/FillCallback.java @@ -56,23 +56,24 @@ public final class FillCallback { if (response == null) { mProxy.logEvent(AutofillProxy.REPORT_EVENT_NO_RESPONSE); - mProxy.reportResult(/* inlineSuggestionsData */ null, /* clientState */ null); + mProxy.reportResult(/* inlineSuggestionsData */ null, /* clientState */ + null, /* showingFillWindow */ false); return; } - List inlineSuggestions = response.getInlineSuggestions(); - Bundle clientState = response.getClientState(); - // We need to report result regardless of whether inline suggestions are returned or not. - mProxy.reportResult(inlineSuggestions, clientState); + final List inlineSuggestions = response.getInlineSuggestions(); + final Bundle clientState = response.getClientState(); + final FillWindow fillWindow = response.getFillWindow(); + boolean showingFillWindow = false; if (inlineSuggestions != null && !inlineSuggestions.isEmpty()) { mProxy.logEvent(AutofillProxy.REPORT_EVENT_INLINE_RESPONSE); - return; - } - - final FillWindow fillWindow = response.getFillWindow(); - if (fillWindow != null) { + } else if (fillWindow != null) { fillWindow.show(); + showingFillWindow = true; } + // We need to report result regardless of whether inline suggestions are returned or not. + mProxy.reportResult(inlineSuggestions, clientState, showingFillWindow); + // TODO(b/123099468): must notify the server so it can update the session state to avoid // showing conflicting UIs (for example, if a new request is made to the main autofill // service and it now wants to show something). diff --git a/core/java/android/service/autofill/augmented/IFillCallback.aidl b/core/java/android/service/autofill/augmented/IFillCallback.aidl index 609e382e2b962..4dfdd4db27e53 100644 --- a/core/java/android/service/autofill/augmented/IFillCallback.aidl +++ b/core/java/android/service/autofill/augmented/IFillCallback.aidl @@ -30,7 +30,9 @@ import java.util.List; */ interface IFillCallback { void onCancellable(in ICancellationSignal cancellation); - void onSuccess(in @nullable List inlineSuggestionsData, in @nullable Bundle clientState); + void onSuccess(in @nullable List inlineSuggestionsData, + in @nullable Bundle clientState, + boolean showingFillWindow); boolean isCompleted(); void cancel(); } diff --git a/services/autofill/java/com/android/server/autofill/RemoteAugmentedAutofillService.java b/services/autofill/java/com/android/server/autofill/RemoteAugmentedAutofillService.java index 4e0970f1e40b2..11f9015388689 100644 --- a/services/autofill/java/com/android/server/autofill/RemoteAugmentedAutofillService.java +++ b/services/autofill/java/com/android/server/autofill/RemoteAugmentedAutofillService.java @@ -167,14 +167,16 @@ final class RemoteAugmentedAutofillService new IFillCallback.Stub() { @Override public void onSuccess(@Nullable List inlineSuggestionsData, - @Nullable Bundle clientState) { + @Nullable Bundle clientState, boolean showingFillWindow) { mCallbacks.resetLastResponse(); maybeRequestShowInlineSuggestions(sessionId, inlineSuggestionsRequest, inlineSuggestionsData, clientState, focusedId, focusedValue, inlineSuggestionsCallback, client, onErrorCallback, remoteRenderService); - requestAutofill.complete(null); + if (!showingFillWindow) { + requestAutofill.complete(null); + } } @Override