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

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

Merge "Add support for remote views backed auto-fill UI"

parents 2c2c3eea 00c771dc
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -36246,9 +36246,10 @@ package android.service.autofill {
  }
  public static final class Dataset.Builder {
    ctor public Dataset.Builder(java.lang.CharSequence);
    ctor public Dataset.Builder();
    method public android.service.autofill.Dataset build();
    method public android.service.autofill.Dataset.Builder setAuthentication(android.content.IntentSender);
    method public android.service.autofill.Dataset.Builder setPresentation(android.widget.RemoteViews);
    method public android.service.autofill.Dataset.Builder setValue(android.view.autofill.AutoFillId, android.view.autofill.AutoFillValue);
  }
@@ -36270,6 +36271,7 @@ package android.service.autofill {
    method public android.service.autofill.FillResponse build();
    method public android.service.autofill.FillResponse.Builder setAuthentication(android.content.IntentSender);
    method public android.service.autofill.FillResponse.Builder setExtras(android.os.Bundle);
    method public android.service.autofill.FillResponse.Builder setPresentation(android.widget.RemoteViews);
  }
  public final class SaveCallback {
@@ -51236,7 +51238,7 @@ package dalvik.system {
    method public static dalvik.system.DexFile loadDex(java.lang.String, java.lang.String, int) throws java.io.IOException;
  }
  public final class InMemoryDexClassLoader extends java.lang.ClassLoader {
  public final class InMemoryDexClassLoader extends dalvik.system.BaseDexClassLoader {
    ctor public InMemoryDexClassLoader(java.nio.ByteBuffer, java.lang.ClassLoader);
  }
+4 −2
Original line number Diff line number Diff line
@@ -39326,9 +39326,10 @@ package android.service.autofill {
  }
  public static final class Dataset.Builder {
    ctor public Dataset.Builder(java.lang.CharSequence);
    ctor public Dataset.Builder();
    method public android.service.autofill.Dataset build();
    method public android.service.autofill.Dataset.Builder setAuthentication(android.content.IntentSender);
    method public android.service.autofill.Dataset.Builder setPresentation(android.widget.RemoteViews);
    method public android.service.autofill.Dataset.Builder setValue(android.view.autofill.AutoFillId, android.view.autofill.AutoFillValue);
  }
@@ -39350,6 +39351,7 @@ package android.service.autofill {
    method public android.service.autofill.FillResponse build();
    method public android.service.autofill.FillResponse.Builder setAuthentication(android.content.IntentSender);
    method public android.service.autofill.FillResponse.Builder setExtras(android.os.Bundle);
    method public android.service.autofill.FillResponse.Builder setPresentation(android.widget.RemoteViews);
  }
  public final class SaveCallback {
@@ -55105,7 +55107,7 @@ package dalvik.system {
    method public static dalvik.system.DexFile loadDex(java.lang.String, java.lang.String, int) throws java.io.IOException;
  }
  public final class InMemoryDexClassLoader extends java.lang.ClassLoader {
  public final class InMemoryDexClassLoader extends dalvik.system.BaseDexClassLoader {
    ctor public InMemoryDexClassLoader(java.nio.ByteBuffer, java.lang.ClassLoader);
  }
+4 −2
Original line number Diff line number Diff line
@@ -36385,9 +36385,10 @@ package android.service.autofill {
  }
  public static final class Dataset.Builder {
    ctor public Dataset.Builder(java.lang.CharSequence);
    ctor public Dataset.Builder();
    method public android.service.autofill.Dataset build();
    method public android.service.autofill.Dataset.Builder setAuthentication(android.content.IntentSender);
    method public android.service.autofill.Dataset.Builder setPresentation(android.widget.RemoteViews);
    method public android.service.autofill.Dataset.Builder setValue(android.view.autofill.AutoFillId, android.view.autofill.AutoFillValue);
  }
@@ -36409,6 +36410,7 @@ package android.service.autofill {
    method public android.service.autofill.FillResponse build();
    method public android.service.autofill.FillResponse.Builder setAuthentication(android.content.IntentSender);
    method public android.service.autofill.FillResponse.Builder setExtras(android.os.Bundle);
    method public android.service.autofill.FillResponse.Builder setPresentation(android.widget.RemoteViews);
  }
  public final class SaveCallback {
@@ -51615,7 +51617,7 @@ package dalvik.system {
    method public static dalvik.system.DexFile loadDex(java.lang.String, java.lang.String, int) throws java.io.IOException;
  }
  public final class InMemoryDexClassLoader extends java.lang.ClassLoader {
  public final class InMemoryDexClassLoader extends dalvik.system.BaseDexClassLoader {
    ctor public InMemoryDexClassLoader(java.nio.ByteBuffer, java.lang.ClassLoader);
  }
+2 −1
Original line number Diff line number Diff line
@@ -7039,7 +7039,8 @@ public class Activity extends ContextThemeWrapper
                }
            }
        } else if (who.startsWith(AUTO_FILL_AUTH_WHO_PREFIX)) {
            getSystemService(AutoFillManager.class).onAuthenticationResult(data);
            Intent resultData = (resultCode == Activity.RESULT_OK) ? data : null;
            getSystemService(AutoFillManager.class).onAuthenticationResult(resultData);
        } else {
            Fragment frag = mFragments.findFragmentByWho(who);
            if (frag != null) {
+42 −30
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ import android.os.Parcel;
import android.os.Parcelable;
import android.view.autofill.AutoFillId;
import android.view.autofill.AutoFillValue;

import android.widget.RemoteViews;
import com.android.internal.util.Preconditions;

import java.util.ArrayList;
@@ -36,32 +36,27 @@ import java.util.ArrayList;
 * <p>It contains:
 *
 * <ol>
 *   <li>A name used to identify the dataset in the UI.
 *   <li>A list of id/value pairs for the fields that can be auto-filled.
 *   <li>A list of savable ids in addition to the ones with a provided value.
 *   <li>A list of values for input fields.
 *   <li>A presentation view to visualize.
 *   <li>An optional intent to authenticate.
 * </ol>
 *
 * @see android.service.autofill.FillResponse for examples.
 */
public final class Dataset implements Parcelable {

    private final CharSequence mName;
    private final ArrayList<AutoFillId> mFieldIds;
    private final ArrayList<AutoFillValue> mFieldValues;
    private final RemoteViews mPresentation;
    private final IntentSender mAuthentication;

    private Dataset(Builder builder) {
        mName = builder.mName;
        mFieldIds = builder.mFieldIds;
        mFieldValues = builder.mFieldValues;
        mPresentation = builder.mPresentation;
        mAuthentication = builder.mAuthentication;
    }

    /** @hide */
    public @NonNull CharSequence getName() {
        return mName;
    }

    /** @hide */
    public @Nullable ArrayList<AutoFillId> getFieldIds() {
        return mFieldIds;
@@ -72,6 +67,11 @@ public final class Dataset implements Parcelable {
        return mFieldValues;
    }

    /** @hide */
    public @Nullable RemoteViews getPresentation() {
        return mPresentation;
    }

    /** @hide */
    public @Nullable IntentSender getAuthentication() {
        return mAuthentication;
@@ -86,11 +86,12 @@ public final class Dataset implements Parcelable {
    public String toString() {
        if (!DEBUG) return super.toString();

        final StringBuilder builder = new StringBuilder("Dataset [name=").append(mName)
        return new StringBuilder("Dataset [")
                .append(", fieldIds=").append(mFieldIds)
                .append(", fieldValues=").append(mFieldValues)
                .append(", hasAuthentication=").append(mAuthentication != null);
        return builder.append(']').toString();
                .append(", hasPresentation=").append(mPresentation != null)
                .append(", hasAuthentication=").append(mAuthentication != null)
                .append(']').toString();
    }

    /**
@@ -98,21 +99,22 @@ public final class Dataset implements Parcelable {
     * one value for a field or set an authentication intent.
     */
    public static final class Builder {
        private CharSequence mName;
        private ArrayList<AutoFillId> mFieldIds;
        private ArrayList<AutoFillValue> mFieldValues;
        private RemoteViews mPresentation;
        private IntentSender mAuthentication;
        private boolean mDestroyed;

        /**
         * Creates a new builder.
         * Sets the presentation used to visualize this dataset.
         *
         * @param presentation The presentation view.
         *
         * @param name Name used to identify the dataset in the UI. Typically it's the same value as
         * the first field in the dataset (like username or email address) or a user-provided name
         * (like "My Work Address").
         * @return This builder.
         */
        public Builder(@NonNull CharSequence name) {
            mName = Preconditions.checkStringNotEmpty(name, "name cannot be empty or null");
        public @NonNull Builder setPresentation(@Nullable RemoteViews presentation) {
            mPresentation = presentation;
            return this;
        }

        /**
@@ -121,7 +123,7 @@ public final class Dataset implements Parcelable {
         * <p>This method is called when you need to provide an authentication
         * UI for the data set. For example, when a data set contains credit card information
         * (such as number, expiration date, and verification code), you can display UI
         * asking for the verification code to before filing in the data). Even if the
         * asking for the verification code before filing in the data. Even if the
         * data set is completely populated the system will launch the specified authentication
         * intent and will need your approval to fill it in. Since the data set is "locked"
         * until the user authenticates it, typically this data set name is masked
@@ -138,7 +140,7 @@ public final class Dataset implements Parcelable {
         * android.app.Activity#RESULT_OK} and provide the fully populated {@link Dataset
         * dataset} by setting it to the {@link
         * android.view.autofill.AutoFillManager#EXTRA_AUTHENTICATION_RESULT} extra. For example,
         * if you provided an credit card information without the CVV for the data set in the
         * if you provided credit card information without the CVV for the data set in the
         * {@link FillResponse response} then the returned data set should contain the
         * CVV entry.</p>
         *
@@ -147,6 +149,7 @@ public final class Dataset implements Parcelable {
         * platform needs to fill in the authentication arguments.</p>
         *
         * @param authentication Intent to an activity with your authentication flow.
         * @return This builder.
         *
         * @see android.app.PendingIntent
         */
@@ -162,6 +165,7 @@ public final class Dataset implements Parcelable {
         * @param id id returned by {@link
         *         android.app.assist.AssistStructure.ViewNode#getAutoFillId()}.
         * @param value value to be auto filled.
         * @return This builder.
         */
        public @NonNull Builder setValue(@NonNull AutoFillId id, @NonNull AutoFillValue value) {
            throwIfDestroyed();
@@ -184,14 +188,21 @@ public final class Dataset implements Parcelable {

        /**
         * Creates a new {@link Dataset} instance. You should not interact
         * with this builder once this method is called.
         * with this builder once this method is called. It is required
         * that you specified at least one field. Also it is mandatory to
         * provide a presentation view to visualize the data set in the UI.
         *
         * @return The built dataset.
         */
        public @NonNull Dataset build() {
            throwIfDestroyed();
            mDestroyed = true;
            if (mFieldIds == null && mAuthentication == null) {
            if (mFieldIds == null) {
                throw new IllegalArgumentException(
                        "at least one value or an authentication must be set");
                        "at least one value must be set");
            }
            if (mPresentation == null) {
                throw new IllegalArgumentException("presentation must be set");
            }
            return new Dataset(this);
        }
@@ -214,9 +225,9 @@ public final class Dataset implements Parcelable {

    @Override
    public void writeToParcel(Parcel parcel, int flags) {
        parcel.writeCharSequence(mName);
        parcel.writeTypedArrayList(mFieldIds, 0);
        parcel.writeTypedArrayList(mFieldValues, 0);
        parcel.writeTypedArrayList(mFieldIds, flags);
        parcel.writeTypedArrayList(mFieldValues, flags);
        parcel.writeParcelable(mPresentation, flags);
        parcel.writeParcelable(mAuthentication, flags);
    }

@@ -226,7 +237,7 @@ public final class Dataset implements Parcelable {
            // Always go through the builder to ensure the data ingested by
            // the system obeys the contract of the builder to avoid attacks
            // using specially crafted parcels.
            final Builder builder = new Builder(parcel.readCharSequence());
            final Builder builder = new Builder();
            final ArrayList<AutoFillId> ids = parcel.readTypedArrayList(null);
            final ArrayList<AutoFillValue> values = parcel.readTypedArrayList(null);
            final int idCount = (ids != null) ? ids.size() : 0;
@@ -236,6 +247,7 @@ public final class Dataset implements Parcelable {
                AutoFillValue value = (valueCount > i) ? values.get(i) : null;
                builder.setValue(id, value);
            }
            builder.setPresentation(parcel.readParcelable(null));
            builder.setAuthentication(parcel.readParcelable(null));
            return builder.build();
        }
Loading