Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5d6243e4 authored by Feng Cao's avatar Feng Cao
Browse files

Fix a bug to not complete the augmented autofill request when fill window is shown

* The bug was introduced in ag/11784240 causing the existing CTS test to
  fail: android.autofillservice.cts.augmented.AugmentedLoginActivityTest
  #testCancellationSignalCalled_retriggerAugmentedAutofill
* Basically when the dropdown fill window is displayed, we should not mark
  the augmented autofill request as complete

Test: atest android.autofillservice.cts.augmented
Test: atest android.autofillservice.cts.inline
Bug: 158864213
Bug: 158038231

Change-Id: Ifb75189c1ba3183c99516bfb9a7053524f4bbddc
parent f3e7dfe1
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -564,9 +564,9 @@ public abstract class AugmentedAutofillService extends Service {
        }

        void reportResult(@Nullable List<Dataset> 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);
            }
+11 −10
Original line number Diff line number Diff line
@@ -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<Dataset> 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<Dataset> 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).
+3 −1
Original line number Diff line number Diff line
@@ -30,7 +30,9 @@ import java.util.List;
 */
interface IFillCallback {
    void onCancellable(in ICancellationSignal cancellation);
    void onSuccess(in @nullable List<Dataset> inlineSuggestionsData, in @nullable Bundle clientState);
    void onSuccess(in @nullable List<Dataset> inlineSuggestionsData,
     in @nullable Bundle clientState,
     boolean showingFillWindow);
    boolean isCompleted();
    void cancel();
}
+4 −2
Original line number Diff line number Diff line
@@ -167,15 +167,17 @@ final class RemoteAugmentedAutofillService
                            new IFillCallback.Stub() {
                                @Override
                                public void onSuccess(@Nullable List<Dataset> inlineSuggestionsData,
                                        @Nullable Bundle clientState) {
                                        @Nullable Bundle clientState, boolean showingFillWindow) {
                                    mCallbacks.resetLastResponse();
                                    maybeRequestShowInlineSuggestions(sessionId,
                                            inlineSuggestionsRequest, inlineSuggestionsData,
                                            clientState, focusedId, focusedValue,
                                            inlineSuggestionsCallback,
                                            client, onErrorCallback, remoteRenderService);
                                    if (!showingFillWindow) {
                                        requestAutofill.complete(null);
                                    }
                                }

                                @Override
                                public boolean isCompleted() {