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

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

Merge "Fill-provider can control the negative button label and listener"

parents 5a66e72a 33d06fca
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -36535,6 +36535,7 @@ package android.service.autofill {
    method public android.service.autofill.SaveInfo.Builder addSavableIds(android.view.autofill.AutoFillId...);
    method public android.service.autofill.SaveInfo.Builder addSavableIds(android.view.autofill.AutoFillId...);
    method public android.service.autofill.SaveInfo build();
    method public android.service.autofill.SaveInfo build();
    method public android.service.autofill.SaveInfo.Builder setDescription(java.lang.CharSequence);
    method public android.service.autofill.SaveInfo.Builder setDescription(java.lang.CharSequence);
    method public android.service.autofill.SaveInfo.Builder setNegativeAction(java.lang.CharSequence, android.content.IntentSender);
  }
  }
}
}
+1 −0
Original line number Original line Diff line number Diff line
@@ -39458,6 +39458,7 @@ package android.service.autofill {
    method public android.service.autofill.SaveInfo.Builder addSavableIds(android.view.autofill.AutoFillId...);
    method public android.service.autofill.SaveInfo.Builder addSavableIds(android.view.autofill.AutoFillId...);
    method public android.service.autofill.SaveInfo build();
    method public android.service.autofill.SaveInfo build();
    method public android.service.autofill.SaveInfo.Builder setDescription(java.lang.CharSequence);
    method public android.service.autofill.SaveInfo.Builder setDescription(java.lang.CharSequence);
    method public android.service.autofill.SaveInfo.Builder setNegativeAction(java.lang.CharSequence, android.content.IntentSender);
  }
  }
}
}
+1 −0
Original line number Original line Diff line number Diff line
@@ -36674,6 +36674,7 @@ package android.service.autofill {
    method public android.service.autofill.SaveInfo.Builder addSavableIds(android.view.autofill.AutoFillId...);
    method public android.service.autofill.SaveInfo.Builder addSavableIds(android.view.autofill.AutoFillId...);
    method public android.service.autofill.SaveInfo build();
    method public android.service.autofill.SaveInfo build();
    method public android.service.autofill.SaveInfo.Builder setDescription(java.lang.CharSequence);
    method public android.service.autofill.SaveInfo.Builder setDescription(java.lang.CharSequence);
    method public android.service.autofill.SaveInfo.Builder setNegativeAction(java.lang.CharSequence, android.content.IntentSender);
  }
  }
}
}
+3 −3
Original line number Original line Diff line number Diff line
@@ -171,7 +171,7 @@ public final class FillResponse implements Parcelable {


        if (false) {
        if (false) {
            // TODO(b/33197203, 35727295): this is how mSaveInfo will be set once we don't support
            // TODO(b/33197203, 35727295): this is how mSaveInfo will be set once we don't support
            // FillResponse.setSavableIds()
            // FillResponse.addSavableIds()
            mSaveInfo = builder.mSaveInfo;
            mSaveInfo = builder.mSaveInfo;
            if (mSaveInfo != null) {
            if (mSaveInfo != null) {
                mSaveInfo.addSavableIds(mDatasets);
                mSaveInfo.addSavableIds(mDatasets);
@@ -181,11 +181,11 @@ public final class FillResponse implements Parcelable {
                }
                }
            }
            }
        } else {
        } else {
            // Temporary workaround to support FillResponse.setSavableIds()
            // Temporary workaround to support FillResponse.addSavableIds()
            SaveInfo saveInfo = builder.mSaveInfoBuilder != null ? builder.mSaveInfoBuilder.build()
            SaveInfo saveInfo = builder.mSaveInfoBuilder != null ? builder.mSaveInfoBuilder.build()
                    : builder.mSaveInfo;
                    : builder.mSaveInfo;


            // Handle the the case where service didn't call setSavableIds() because it would
            // Handle the the case where service didn't call addSavableIds() because it would
            // contain just the ids from the datasets.
            // contain just the ids from the datasets.
            if (saveInfo == null && mDatasets != null) {
            if (saveInfo == null && mDatasets != null) {
                saveInfo = new SaveInfo.Builder(SaveInfo.SAVE_DATA_TYPE_GENERIC).build();
                saveInfo = new SaveInfo.Builder(SaveInfo.SAVE_DATA_TYPE_GENERIC).build();
+56 −0
Original line number Original line Diff line number Diff line
@@ -21,6 +21,7 @@ import static android.view.autofill.Helper.DEBUG;
import android.annotation.IntDef;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.Nullable;
import android.content.IntentSender;
import android.os.Bundle;
import android.os.Bundle;
import android.os.Parcel;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.Parcelable;
@@ -72,6 +73,8 @@ public final class SaveInfo implements Parcelable {
    public static final int SAVE_DATA_TYPE_CREDIT_CARD = 3;
    public static final int SAVE_DATA_TYPE_CREDIT_CARD = 3;


    private final @SaveDataType int mType;
    private final @SaveDataType int mType;
    private CharSequence mNegativeActionTitle;
    private IntentSender mNegativeActionListener;
    private ArraySet<AutoFillId> mSavableIds;
    private ArraySet<AutoFillId> mSavableIds;
    private final CharSequence mDescription;
    private final CharSequence mDescription;


@@ -88,10 +91,22 @@ public final class SaveInfo implements Parcelable {


    private SaveInfo(Builder builder) {
    private SaveInfo(Builder builder) {
        mType = builder.mType;
        mType = builder.mType;
        mNegativeActionTitle = builder.mNegativeActionTitle;
        mNegativeActionListener = builder.mNegativeActionListener;
        mSavableIds = builder.mSavableIds;
        mSavableIds = builder.mSavableIds;
        mDescription = builder.mDescription;
        mDescription = builder.mDescription;
    }
    }


    /** @hide */
    public @Nullable CharSequence getNegativeActionTitle() {
        return mNegativeActionTitle;
    }

    /** @hide */
    public @Nullable IntentSender getNegativeActionListener() {
        return mNegativeActionListener;
    }

    /** @hide */
    /** @hide */
    public @Nullable ArraySet<AutoFillId> getSavableIds() {
    public @Nullable ArraySet<AutoFillId> getSavableIds() {
        return mSavableIds;
        return mSavableIds;
@@ -132,6 +147,8 @@ public final class SaveInfo implements Parcelable {
    public static final class Builder {
    public static final class Builder {


        private final @SaveDataType int mType;
        private final @SaveDataType int mType;
        private CharSequence mNegativeActionTitle;
        private IntentSender mNegativeActionListener;
        private ArraySet<AutoFillId> mSavableIds;
        private ArraySet<AutoFillId> mSavableIds;
        private CharSequence mDescription;
        private CharSequence mDescription;
        private boolean mDestroyed;
        private boolean mDestroyed;
@@ -194,6 +211,42 @@ public final class SaveInfo implements Parcelable {
            return this;
            return this;
        }
        }


        /**
         * Sets the title and listener for the negative save action.
         *
         * <p>This allows a fill-provider to customize the text and be
         * notified when the user selects the negative action in the save
         * UI. Note that selecting the negative action regardless of its text
         * and listener being customized would dismiss the save UI and if a
         * custom listener intent is provided then this intent will be
         * started.</p>
         *
         * <p>This customization could be useful for providing additional
         * semantics to the negative action. For example, a fill-provider
         * can use this mechanism to add a "Disable" function or a "More info"
         * function, etc. Note that the save action is exclusively controlled
         * by the platform to ensure user consent is collected to release
         * data from the filled app to the fill-provider.</p>
         *
         * @param title The action title.
         * @param listener The action listener.
         * @return This builder.
         *
         * @throws IllegalArgumentException If the title and the listener
         *     are not both either null or non-null.
         */
        public @NonNull Builder setNegativeAction(@Nullable CharSequence title,
                @Nullable IntentSender listener) {
            throwIfDestroyed();
            if (title == null ^ listener == null) {
                throw new IllegalArgumentException("title and listener"
                        + " must be both non-null or null");
            }
            mNegativeActionTitle = title;
            mNegativeActionListener = listener;
            return this;
        }

        /**
        /**
         * Builds a new {@link SaveInfo} instance.
         * Builds a new {@link SaveInfo} instance.
         */
         */
@@ -235,6 +288,8 @@ public final class SaveInfo implements Parcelable {
    @Override
    @Override
    public void writeToParcel(Parcel parcel, int flags) {
    public void writeToParcel(Parcel parcel, int flags) {
        parcel.writeInt(mType);
        parcel.writeInt(mType);
        parcel.writeCharSequence(mNegativeActionTitle);
        parcel.writeParcelable(mNegativeActionListener, flags);
        parcel.writeTypedArraySet(mSavableIds, flags);
        parcel.writeTypedArraySet(mSavableIds, flags);
        parcel.writeCharSequence(mDescription);
        parcel.writeCharSequence(mDescription);
    }
    }
@@ -246,6 +301,7 @@ public final class SaveInfo implements Parcelable {
            // the system obeys the contract of the builder to avoid attacks
            // the system obeys the contract of the builder to avoid attacks
            // using specially crafted parcels.
            // using specially crafted parcels.
            final Builder builder = new Builder(parcel.readInt());
            final Builder builder = new Builder(parcel.readInt());
            builder.setNegativeAction(parcel.readCharSequence(), parcel.readParcelable(null));
            final ArraySet<AutoFillId> savableIds = parcel.readTypedArraySet(null);
            final ArraySet<AutoFillId> savableIds = parcel.readTypedArraySet(null);
            final int savableIdsCount = (savableIds != null) ? savableIds.size() : 0;
            final int savableIdsCount = (savableIds != null) ? savableIds.size() : 0;
            for (int i = 0; i < savableIdsCount; i++) {
            for (int i = 0; i < savableIdsCount; i++) {
Loading