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

Commit 17572896 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Log FillEventHistory for the inline augmented autofill requests"

parents a07e0252 949525b2
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -10107,6 +10107,7 @@ package android.service.autofill.augmented {
    ctor public AugmentedAutofillService();
    method protected final void dump(java.io.FileDescriptor, java.io.PrintWriter, String[]);
    method protected void dump(@NonNull java.io.PrintWriter, @NonNull String[]);
    method @Nullable public final android.service.autofill.FillEventHistory getFillEventHistory();
    method public void onConnected();
    method public void onDisconnected();
    method public void onFillRequest(@NonNull android.service.autofill.augmented.FillRequest, @NonNull android.os.CancellationSignal, @NonNull android.service.autofill.augmented.FillController, @NonNull android.service.autofill.augmented.FillCallback);
@@ -10136,6 +10137,7 @@ package android.service.autofill.augmented {
  public static final class FillResponse.Builder {
    ctor public FillResponse.Builder();
    method @NonNull public android.service.autofill.augmented.FillResponse build();
    method @NonNull public android.service.autofill.augmented.FillResponse.Builder setClientState(@Nullable android.os.Bundle);
    method @NonNull public android.service.autofill.augmented.FillResponse.Builder setFillWindow(@Nullable android.service.autofill.augmented.FillWindow);
    method @NonNull public android.service.autofill.augmented.FillResponse.Builder setInlineSuggestions(@Nullable java.util.List<android.service.autofill.Dataset>);
  }
+2 −0
Original line number Diff line number Diff line
@@ -3104,6 +3104,7 @@ package android.service.autofill.augmented {
    ctor public AugmentedAutofillService();
    method protected final void dump(java.io.FileDescriptor, java.io.PrintWriter, String[]);
    method protected void dump(@NonNull java.io.PrintWriter, @NonNull String[]);
    method @Nullable public final android.service.autofill.FillEventHistory getFillEventHistory();
    method public void onConnected();
    method public void onDisconnected();
    method public void onFillRequest(@NonNull android.service.autofill.augmented.FillRequest, @NonNull android.os.CancellationSignal, @NonNull android.service.autofill.augmented.FillController, @NonNull android.service.autofill.augmented.FillCallback);
@@ -3133,6 +3134,7 @@ package android.service.autofill.augmented {
  public static final class FillResponse.Builder {
    ctor public FillResponse.Builder();
    method @NonNull public android.service.autofill.augmented.FillResponse build();
    method @NonNull public android.service.autofill.augmented.FillResponse.Builder setClientState(@Nullable android.os.Bundle);
    method @NonNull public android.service.autofill.augmented.FillResponse.Builder setFillWindow(@Nullable android.service.autofill.augmented.FillWindow);
    method @NonNull public android.service.autofill.augmented.FillResponse.Builder setInlineSuggestions(@Nullable java.util.List<android.service.autofill.Dataset>);
  }
+32 −3
Original line number Diff line number Diff line
@@ -31,6 +31,7 @@ import android.content.ComponentName;
import android.content.Intent;
import android.graphics.Rect;
import android.os.Build;
import android.os.Bundle;
import android.os.CancellationSignal;
import android.os.Handler;
import android.os.IBinder;
@@ -39,6 +40,7 @@ import android.os.Looper;
import android.os.RemoteException;
import android.os.SystemClock;
import android.service.autofill.Dataset;
import android.service.autofill.FillEventHistory;
import android.service.autofill.augmented.PresentationParams.SystemPopupPresentationParams;
import android.util.Log;
import android.util.Pair;
@@ -319,6 +321,31 @@ public abstract class AugmentedAutofillService extends Service {
        pw.print(getClass().getName()); pw.println(": nothing to dump");
    }

    /**
     * Gets the inline augmented autofill events that happened after the last
     * {@link #onFillRequest(FillRequest, CancellationSignal, FillController, FillCallback)} call.
     *
     * <p>The history is not persisted over reboots, and it's cleared every time the service
     * replies to a
     * {@link #onFillRequest(FillRequest, CancellationSignal, FillController, FillCallback)}
     * by calling {@link FillCallback#onSuccess(FillResponse)}. Hence, the service should call
     * {@link #getFillEventHistory() before finishing the {@link FillCallback}.
     *
     * <p>Also note that the events from the dropdown suggestion UI is not stored in the history
     * since the service owns the UI.
     *
     * @return The history or {@code null} if there are no events.
     */
    @Nullable public final FillEventHistory getFillEventHistory() {
        final AutofillManager afm = getSystemService(AutofillManager.class);

        if (afm == null) {
            return null;
        } else {
            return afm.getFillEventHistory();
        }
    }

    /** @hide */
    static final class AutofillProxy {

@@ -487,9 +514,10 @@ public abstract class AugmentedAutofillService extends Service {
            }
        }

        public void onInlineSuggestionsDataReady(@NonNull List<Dataset> inlineSuggestionsData) {
        public void onInlineSuggestionsDataReady(@NonNull List<Dataset> inlineSuggestionsData,
                @Nullable Bundle clientState) {
            try {
                mCallback.onSuccess(inlineSuggestionsData.toArray(new Dataset[]{}));
                mCallback.onSuccess(inlineSuggestionsData.toArray(new Dataset[]{}), clientState);
            } catch (RemoteException e) {
                Log.e(TAG, "Error calling back with the inline suggestions data: " + e);
            }
@@ -511,7 +539,8 @@ public abstract class AugmentedAutofillService extends Service {
                        }
                    }
                    try {
                        mCallback.onSuccess(/* mInlineSuggestionsData= */null);
                        mCallback.onSuccess(/* inlineSuggestionsData= */null, /* clientState=*/
                                null);
                    } catch (RemoteException e) {
                        Log.e(TAG, "Error reporting success: " + e);
                    }
+1 −1
Original line number Diff line number Diff line
@@ -60,7 +60,7 @@ public final class FillCallback {

        List<Dataset> inlineSuggestions = response.getInlineSuggestions();
        if (inlineSuggestions != null && !inlineSuggestions.isEmpty()) {
            mProxy.onInlineSuggestionsDataReady(inlineSuggestions);
            mProxy.onInlineSuggestionsDataReady(inlineSuggestions, response.getClientState());
            return;
        }

+50 −6
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.annotation.TestApi;
import android.os.Bundle;
import android.service.autofill.Dataset;

import com.android.internal.util.DataClass;
@@ -50,6 +51,13 @@ public final class FillResponse {
    @DataClass.PluralOf("inlineSuggestion")
    private @Nullable List<Dataset> mInlineSuggestions;

    /**
     * The client state that {@link AugmentedAutofillService} implementation can put anything in to
     * identify the request and the response when calling
     * {@link AugmentedAutofillService#getFillEventHistory()}.
     */
    private @Nullable Bundle mClientState;

    private static FillWindow defaultFillWindow() {
        return null;
    }
@@ -58,6 +66,10 @@ public final class FillResponse {
        return null;
    }

    private static Bundle defaultClientState() {
        return null;
    }


    /** @hide */
    abstract static class BaseBuilder {
@@ -82,9 +94,11 @@ public final class FillResponse {
    @DataClass.Generated.Member
    /* package-private */ FillResponse(
            @Nullable FillWindow fillWindow,
            @Nullable List<Dataset> inlineSuggestions) {
            @Nullable List<Dataset> inlineSuggestions,
            @Nullable Bundle clientState) {
        this.mFillWindow = fillWindow;
        this.mInlineSuggestions = inlineSuggestions;
        this.mClientState = clientState;

        // onConstructed(); // You can define this method to get a callback
    }
@@ -110,6 +124,18 @@ public final class FillResponse {
        return mInlineSuggestions;
    }

    /**
     * The client state that {@link AugmentedAutofillService} implementation can put anything in to
     * identify the request and the response when calling
     * {@link AugmentedAutofillService#getFillEventHistory()}.
     *
     * @hide
     */
    @DataClass.Generated.Member
    public @Nullable Bundle getClientState() {
        return mClientState;
    }

    /**
     * A builder for {@link FillResponse}
     */
@@ -119,6 +145,7 @@ public final class FillResponse {

        private @Nullable FillWindow mFillWindow;
        private @Nullable List<Dataset> mInlineSuggestions;
        private @Nullable Bundle mClientState;

        private long mBuilderFieldsSet = 0L;

@@ -157,10 +184,23 @@ public final class FillResponse {
            return this;
        }

        /**
         * The client state that {@link AugmentedAutofillService} implementation can put anything in to
         * identify the request and the response when calling
         * {@link AugmentedAutofillService#getFillEventHistory()}.
         */
        @DataClass.Generated.Member
        public @NonNull Builder setClientState(@Nullable Bundle value) {
            checkNotUsed();
            mBuilderFieldsSet |= 0x4;
            mClientState = value;
            return this;
        }

        /** Builds the instance. This builder should not be touched after calling this! */
        public @NonNull FillResponse build() {
            checkNotUsed();
            mBuilderFieldsSet |= 0x4; // Mark builder used
            mBuilderFieldsSet |= 0x8; // Mark builder used

            if ((mBuilderFieldsSet & 0x1) == 0) {
                mFillWindow = defaultFillWindow();
@@ -168,14 +208,18 @@ public final class FillResponse {
            if ((mBuilderFieldsSet & 0x2) == 0) {
                mInlineSuggestions = defaultInlineSuggestions();
            }
            if ((mBuilderFieldsSet & 0x4) == 0) {
                mClientState = defaultClientState();
            }
            FillResponse o = new FillResponse(
                    mFillWindow,
                    mInlineSuggestions);
                    mInlineSuggestions,
                    mClientState);
            return o;
        }

        private void checkNotUsed() {
            if ((mBuilderFieldsSet & 0x4) != 0) {
            if ((mBuilderFieldsSet & 0x8) != 0) {
                throw new IllegalStateException(
                        "This Builder should not be reused. Use a new Builder instance instead");
            }
@@ -183,10 +227,10 @@ public final class FillResponse {
    }

    @DataClass.Generated(
            time = 1577476012370L,
            time = 1580335256422L,
            codegenVersion = "1.0.14",
            sourceFile = "frameworks/base/core/java/android/service/autofill/augmented/FillResponse.java",
            inputSignatures = "private @android.annotation.Nullable android.service.autofill.augmented.FillWindow mFillWindow\nprivate @com.android.internal.util.DataClass.PluralOf(\"inlineSuggestion\") @android.annotation.Nullable java.util.List<android.service.autofill.Dataset> mInlineSuggestions\nprivate static  android.service.autofill.augmented.FillWindow defaultFillWindow()\nprivate static  java.util.List<android.service.autofill.Dataset> defaultInlineSuggestions()\nclass FillResponse extends java.lang.Object implements []\n@com.android.internal.util.DataClass(genBuilder=true, genHiddenGetters=true)\nabstract  android.service.autofill.augmented.FillResponse.Builder addInlineSuggestion(android.service.autofill.Dataset)\nclass BaseBuilder extends java.lang.Object implements []")
            inputSignatures = "private @android.annotation.Nullable android.service.autofill.augmented.FillWindow mFillWindow\nprivate @com.android.internal.util.DataClass.PluralOf(\"inlineSuggestion\") @android.annotation.Nullable java.util.List<android.service.autofill.Dataset> mInlineSuggestions\nprivate @android.annotation.Nullable android.os.Bundle mClientState\nprivate static  android.service.autofill.augmented.FillWindow defaultFillWindow()\nprivate static  java.util.List<android.service.autofill.Dataset> defaultInlineSuggestions()\nprivate static  android.os.Bundle defaultClientState()\nclass FillResponse extends java.lang.Object implements []\n@com.android.internal.util.DataClass(genBuilder=true, genHiddenGetters=true)\nabstract  android.service.autofill.augmented.FillResponse.Builder addInlineSuggestion(android.service.autofill.Dataset)\nclass BaseBuilder extends java.lang.Object implements []")
    @Deprecated
    private void __metadata() {}

Loading