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

Commit 1c501ebf authored by Felipe Leme's avatar Felipe Leme
Browse files

Added getClientState() to FillEvent; deprecated it on FillEventHistory.

Test: cts-tradefed run commandAndExit cts-dev -m CtsAutoFillServiceTestCases

Fixes: 62830277

Change-Id: Ib99a342c931f4fd44fc8aced1faef0b75588f63d
parent 75d4dc33
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -37074,13 +37074,14 @@ package android.service.autofill {
  public final class FillEventHistory implements android.os.Parcelable {
    method public int describeContents();
    method public android.os.Bundle getClientState();
    method public deprecated android.os.Bundle getClientState();
    method public java.util.List<android.service.autofill.FillEventHistory.Event> getEvents();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.service.autofill.FillEventHistory> CREATOR;
  }
  public static final class FillEventHistory.Event {
    method public android.os.Bundle getClientState();
    method public java.lang.String getDatasetId();
    method public int getType();
    field public static final int TYPE_AUTHENTICATION_SELECTED = 2; // 0x2
+2 −1
Original line number Diff line number Diff line
@@ -40165,13 +40165,14 @@ package android.service.autofill {
  public final class FillEventHistory implements android.os.Parcelable {
    method public int describeContents();
    method public android.os.Bundle getClientState();
    method public deprecated android.os.Bundle getClientState();
    method public java.util.List<android.service.autofill.FillEventHistory.Event> getEvents();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.service.autofill.FillEventHistory> CREATOR;
  }
  public static final class FillEventHistory.Event {
    method public android.os.Bundle getClientState();
    method public java.lang.String getDatasetId();
    method public int getType();
    field public static final int TYPE_AUTHENTICATION_SELECTED = 2; // 0x2
+2 −1
Original line number Diff line number Diff line
@@ -37272,13 +37272,14 @@ package android.service.autofill {
  public final class FillEventHistory implements android.os.Parcelable {
    method public int describeContents();
    method public android.os.Bundle getClientState();
    method public deprecated android.os.Bundle getClientState();
    method public java.util.List<android.service.autofill.FillEventHistory.Event> getEvents();
    method public void writeToParcel(android.os.Parcel, int);
    field public static final android.os.Parcelable.Creator<android.service.autofill.FillEventHistory> CREATOR;
  }
  public static final class FillEventHistory.Event {
    method public android.os.Bundle getClientState();
    method public java.lang.String getDatasetId();
    method public int getType();
    field public static final int TYPE_AUTHENTICATION_SELECTED = 2; // 0x2
+23 −4
Original line number Diff line number Diff line
@@ -81,10 +81,13 @@ public final class FillEventHistory implements Parcelable {
    /**
     * Returns the client state set in the previous {@link FillResponse}.
     *
     * <p><b>NOTE: </b>the state is associated with the app that was autofilled in the previous
     * <p><b>Note: </b>the state is associated with the app that was autofilled in the previous
     * {@link AutofillService#onFillRequest(FillRequest, android.os.CancellationSignal, FillCallback)}
     * , which is not necessary the same app being autofilled now.
     *
     * @deprecated use {@link #getEvents()} then {@link Event#getClientState()} instead.
     */
    @Deprecated
    @Nullable public Bundle getClientState() {
        return mClientState;
    }
@@ -126,7 +129,6 @@ public final class FillEventHistory implements Parcelable {
    @Override
    public void writeToParcel(Parcel dest, int flags) {
        dest.writeBundle(mClientState);

        if (mEvents == null) {
            dest.writeInt(0);
        } else {
@@ -137,6 +139,7 @@ public final class FillEventHistory implements Parcelable {
                Event event = mEvents.get(i);
                dest.writeInt(event.getType());
                dest.writeString(event.getDatasetId());
                dest.writeBundle(event.getClientState());
            }
        }
    }
@@ -177,6 +180,7 @@ public final class FillEventHistory implements Parcelable {

        @EventIds private final int mEventType;
        @Nullable private final String mDatasetId;
        @Nullable private final Bundle mClientState;

        /**
         * Returns the type of the event.
@@ -196,19 +200,33 @@ public final class FillEventHistory implements Parcelable {
            return mDatasetId;
        }

        /**
         * Returns the client state from the {@link FillResponse} used to generate this event.
         *
         * <p><b>Note: </b>the state is associated with the app that was autofilled in the previous
         * {@link
         * AutofillService#onFillRequest(FillRequest, android.os.CancellationSignal, FillCallback)},
         * which is not necessary the same app being autofilled now.
         */
        @Nullable public Bundle getClientState() {
            return mClientState;
        }

        /**
         * Creates a new event.
         *
         * @param eventType The type of the event
         * @param datasetId The dataset the event was on, or {@code null} if the event was on the
         *                  whole response.
         * @param clientState The client state associated with the event.
         *
         * @hide
         */
        public Event(int eventType, String datasetId) {
        public Event(int eventType, @Nullable String datasetId, @Nullable Bundle clientState) {
            mEventType = Preconditions.checkArgumentInRange(eventType, 0, TYPE_SAVE_SHOWN,
                    "eventType");
            mDatasetId = datasetId;
            mClientState = clientState;
        }
    }

@@ -220,7 +238,8 @@ public final class FillEventHistory implements Parcelable {

                    int numEvents = parcel.readInt();
                    for (int i = 0; i < numEvents; i++) {
                        selection.addEvent(new Event(parcel.readInt(), parcel.readString()));
                        selection.addEvent(new Event(parcel.readInt(), parcel.readString(),
                                parcel.readBundle()));
                    }

                    return selection;
+13 −8
Original line number Diff line number Diff line
@@ -522,10 +522,11 @@ final class AutofillManagerServiceImpl {
    /**
     * Updates the last fill selection when an authentication was selected.
     */
    void setAuthenticationSelected(int sessionId) {
    void setAuthenticationSelected(int sessionId, @Nullable Bundle clientState) {
        synchronized (mLock) {
            if (isValidEventLocked("setAuthenticationSelected()", sessionId)) {
                mEventHistory.addEvent(new Event(Event.TYPE_AUTHENTICATION_SELECTED, null));
                mEventHistory
                        .addEvent(new Event(Event.TYPE_AUTHENTICATION_SELECTED, null, clientState));
            }
        }
    }
@@ -533,11 +534,13 @@ final class AutofillManagerServiceImpl {
    /**
     * Updates the last fill selection when an dataset authentication was selected.
     */
    void setDatasetAuthenticationSelected(@Nullable String selectedDataset, int sessionId) {
    void setDatasetAuthenticationSelected(@Nullable String selectedDataset, int sessionId,
            @Nullable Bundle clientState) {
        synchronized (mLock) {
            if (isValidEventLocked("setDatasetAuthenticationSelected()", sessionId)) {
                mEventHistory.addEvent(
                        new Event(Event.TYPE_DATASET_AUTHENTICATION_SELECTED, selectedDataset));
                        new Event(Event.TYPE_DATASET_AUTHENTICATION_SELECTED, selectedDataset,
                                clientState));
            }
        }
    }
@@ -545,10 +548,10 @@ final class AutofillManagerServiceImpl {
    /**
     * Updates the last fill selection when an save Ui is shown.
     */
    void setSaveShown(int sessionId) {
    void setSaveShown(int sessionId, @Nullable Bundle clientState) {
        synchronized (mLock) {
            if (isValidEventLocked("setSaveShown()", sessionId)) {
                mEventHistory.addEvent(new Event(Event.TYPE_SAVE_SHOWN, null));
                mEventHistory.addEvent(new Event(Event.TYPE_SAVE_SHOWN, null, clientState));
            }
        }
    }
@@ -556,10 +559,12 @@ final class AutofillManagerServiceImpl {
    /**
     * Updates the last fill response when a dataset was selected.
     */
    void setDatasetSelected(@Nullable String selectedDataset, int sessionId) {
    void setDatasetSelected(@Nullable String selectedDataset, int sessionId,
            @Nullable Bundle clientState) {
        synchronized (mLock) {
            if (isValidEventLocked("setDatasetSelected()", sessionId)) {
                mEventHistory.addEvent(new Event(Event.TYPE_DATASET_SELECTED, selectedDataset));
                mEventHistory.addEvent(
                        new Event(Event.TYPE_DATASET_SELECTED, selectedDataset, clientState));
            }
        }
    }
Loading