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

Commit 00e99e74 authored by Ahaan Ugale's avatar Ahaan Ugale Committed by Android (Google) Code Review
Browse files

Merge changes from topic "aff_bottom_sheet"

* changes:
  Add bottom sheet fill UI for Autofill
  Implement actions on client and service for bottom sheet
  Notify Autofill while activity started
  Adds APIs for Autofill bottom sheet UI
parents 0891d4b3 33571fb8
Loading
Loading
Loading
Loading
+48 −14
Original line number Diff line number Diff line
@@ -37928,21 +37928,23 @@ package android.service.autofill {
  }
  public static final class Dataset.Builder {
    ctor public Dataset.Builder(@NonNull android.widget.RemoteViews);
    ctor @Deprecated public Dataset.Builder(@NonNull android.widget.RemoteViews);
    ctor public Dataset.Builder(@NonNull android.service.autofill.Presentations);
    ctor public Dataset.Builder();
    method @NonNull public android.service.autofill.Dataset build();
    method @NonNull public android.service.autofill.Dataset.Builder setAuthentication(@Nullable android.content.IntentSender);
    method @NonNull public android.service.autofill.Dataset.Builder setField(@NonNull android.view.autofill.AutofillId, @Nullable android.service.autofill.Field);
    method @NonNull public android.service.autofill.Dataset.Builder setId(@Nullable String);
    method @NonNull public android.service.autofill.Dataset.Builder setInlinePresentation(@NonNull android.service.autofill.InlinePresentation);
    method @NonNull public android.service.autofill.Dataset.Builder setInlinePresentation(@NonNull android.service.autofill.InlinePresentation, @NonNull android.service.autofill.InlinePresentation);
    method @NonNull public android.service.autofill.Dataset.Builder setValue(@NonNull android.view.autofill.AutofillId, @Nullable android.view.autofill.AutofillValue);
    method @NonNull public android.service.autofill.Dataset.Builder setValue(@NonNull android.view.autofill.AutofillId, @Nullable android.view.autofill.AutofillValue, @NonNull android.widget.RemoteViews);
    method @NonNull public android.service.autofill.Dataset.Builder setValue(@NonNull android.view.autofill.AutofillId, @Nullable android.view.autofill.AutofillValue, @Nullable java.util.regex.Pattern);
    method @NonNull public android.service.autofill.Dataset.Builder setValue(@NonNull android.view.autofill.AutofillId, @Nullable android.view.autofill.AutofillValue, @Nullable java.util.regex.Pattern, @NonNull android.widget.RemoteViews);
    method @NonNull public android.service.autofill.Dataset.Builder setValue(@NonNull android.view.autofill.AutofillId, @Nullable android.view.autofill.AutofillValue, @NonNull android.widget.RemoteViews, @NonNull android.service.autofill.InlinePresentation);
    method @NonNull public android.service.autofill.Dataset.Builder setValue(@NonNull android.view.autofill.AutofillId, @Nullable android.view.autofill.AutofillValue, @NonNull android.widget.RemoteViews, @NonNull android.service.autofill.InlinePresentation, @NonNull android.service.autofill.InlinePresentation);
    method @NonNull public android.service.autofill.Dataset.Builder setValue(@NonNull android.view.autofill.AutofillId, @Nullable android.view.autofill.AutofillValue, @Nullable java.util.regex.Pattern, @NonNull android.widget.RemoteViews, @NonNull android.service.autofill.InlinePresentation);
    method @NonNull public android.service.autofill.Dataset.Builder setValue(@NonNull android.view.autofill.AutofillId, @Nullable android.view.autofill.AutofillValue, @Nullable java.util.regex.Pattern, @NonNull android.widget.RemoteViews, @NonNull android.service.autofill.InlinePresentation, @NonNull android.service.autofill.InlinePresentation);
    method @Deprecated @NonNull public android.service.autofill.Dataset.Builder setInlinePresentation(@NonNull android.service.autofill.InlinePresentation);
    method @Deprecated @NonNull public android.service.autofill.Dataset.Builder setInlinePresentation(@NonNull android.service.autofill.InlinePresentation, @NonNull android.service.autofill.InlinePresentation);
    method @Deprecated @NonNull public android.service.autofill.Dataset.Builder setValue(@NonNull android.view.autofill.AutofillId, @Nullable android.view.autofill.AutofillValue);
    method @Deprecated @NonNull public android.service.autofill.Dataset.Builder setValue(@NonNull android.view.autofill.AutofillId, @Nullable android.view.autofill.AutofillValue, @NonNull android.widget.RemoteViews);
    method @Deprecated @NonNull public android.service.autofill.Dataset.Builder setValue(@NonNull android.view.autofill.AutofillId, @Nullable android.view.autofill.AutofillValue, @Nullable java.util.regex.Pattern);
    method @Deprecated @NonNull public android.service.autofill.Dataset.Builder setValue(@NonNull android.view.autofill.AutofillId, @Nullable android.view.autofill.AutofillValue, @Nullable java.util.regex.Pattern, @NonNull android.widget.RemoteViews);
    method @Deprecated @NonNull public android.service.autofill.Dataset.Builder setValue(@NonNull android.view.autofill.AutofillId, @Nullable android.view.autofill.AutofillValue, @NonNull android.widget.RemoteViews, @NonNull android.service.autofill.InlinePresentation);
    method @Deprecated @NonNull public android.service.autofill.Dataset.Builder setValue(@NonNull android.view.autofill.AutofillId, @Nullable android.view.autofill.AutofillValue, @NonNull android.widget.RemoteViews, @NonNull android.service.autofill.InlinePresentation, @NonNull android.service.autofill.InlinePresentation);
    method @Deprecated @NonNull public android.service.autofill.Dataset.Builder setValue(@NonNull android.view.autofill.AutofillId, @Nullable android.view.autofill.AutofillValue, @Nullable java.util.regex.Pattern, @NonNull android.widget.RemoteViews, @NonNull android.service.autofill.InlinePresentation);
    method @Deprecated @NonNull public android.service.autofill.Dataset.Builder setValue(@NonNull android.view.autofill.AutofillId, @Nullable android.view.autofill.AutofillValue, @Nullable java.util.regex.Pattern, @NonNull android.widget.RemoteViews, @NonNull android.service.autofill.InlinePresentation, @NonNull android.service.autofill.InlinePresentation);
  }
  public final class DateTransformation implements android.os.Parcelable android.service.autofill.Transformation {
@@ -37959,6 +37961,19 @@ package android.service.autofill {
    field @NonNull public static final android.os.Parcelable.Creator<android.service.autofill.DateValueSanitizer> CREATOR;
  }
  public final class Field {
    method @Nullable public android.service.autofill.Presentations getPresentations();
    method @Nullable public android.view.autofill.AutofillValue getValue();
  }
  public static final class Field.Builder {
    ctor public Field.Builder();
    method @NonNull public android.service.autofill.Field build();
    method @NonNull public android.service.autofill.Field.Builder setFilter(@Nullable java.util.regex.Pattern);
    method @NonNull public android.service.autofill.Field.Builder setPresentations(@NonNull android.service.autofill.Presentations);
    method @NonNull public android.service.autofill.Field.Builder setValue(@NonNull android.view.autofill.AutofillValue);
  }
  public final class FieldClassification {
    method @NonNull public java.util.List<android.service.autofill.FieldClassification.Match> getMatches();
  }
@@ -38041,11 +38056,14 @@ package android.service.autofill {
    method @NonNull public android.service.autofill.FillResponse.Builder addDataset(@Nullable android.service.autofill.Dataset);
    method @NonNull public android.service.autofill.FillResponse build();
    method @NonNull public android.service.autofill.FillResponse.Builder disableAutofill(long);
    method @NonNull public android.service.autofill.FillResponse.Builder setAuthentication(@NonNull android.view.autofill.AutofillId[], @Nullable android.content.IntentSender, @Nullable android.widget.RemoteViews);
    method @NonNull public android.service.autofill.FillResponse.Builder setAuthentication(@NonNull android.view.autofill.AutofillId[], @Nullable android.content.IntentSender, @Nullable android.widget.RemoteViews, @Nullable android.service.autofill.InlinePresentation);
    method @NonNull public android.service.autofill.FillResponse.Builder setAuthentication(@NonNull android.view.autofill.AutofillId[], @Nullable android.content.IntentSender, @Nullable android.widget.RemoteViews, @Nullable android.service.autofill.InlinePresentation, @Nullable android.service.autofill.InlinePresentation);
    method @Deprecated @NonNull public android.service.autofill.FillResponse.Builder setAuthentication(@NonNull android.view.autofill.AutofillId[], @Nullable android.content.IntentSender, @Nullable android.widget.RemoteViews);
    method @Deprecated @NonNull public android.service.autofill.FillResponse.Builder setAuthentication(@NonNull android.view.autofill.AutofillId[], @Nullable android.content.IntentSender, @Nullable android.widget.RemoteViews, @Nullable android.service.autofill.InlinePresentation);
    method @Deprecated @NonNull public android.service.autofill.FillResponse.Builder setAuthentication(@NonNull android.view.autofill.AutofillId[], @Nullable android.content.IntentSender, @Nullable android.widget.RemoteViews, @Nullable android.service.autofill.InlinePresentation, @Nullable android.service.autofill.InlinePresentation);
    method @NonNull public android.service.autofill.FillResponse.Builder setAuthentication(@NonNull android.view.autofill.AutofillId[], @Nullable android.content.IntentSender, @Nullable android.service.autofill.Presentations);
    method @NonNull public android.service.autofill.FillResponse.Builder setClientState(@Nullable android.os.Bundle);
    method @NonNull public android.service.autofill.FillResponse.Builder setDialogHeader(@NonNull android.widget.RemoteViews);
    method @NonNull public android.service.autofill.FillResponse.Builder setFieldClassificationIds(@NonNull android.view.autofill.AutofillId...);
    method @NonNull public android.service.autofill.FillResponse.Builder setFillDialogTriggerIds(@NonNull android.view.autofill.AutofillId...);
    method @NonNull public android.service.autofill.FillResponse.Builder setFlags(int);
    method @NonNull public android.service.autofill.FillResponse.Builder setFooter(@NonNull android.widget.RemoteViews);
    method @NonNull public android.service.autofill.FillResponse.Builder setHeader(@NonNull android.widget.RemoteViews);
@@ -38090,6 +38108,22 @@ package android.service.autofill {
  public interface OnClickAction {
  }
  public final class Presentations {
    method @Nullable public android.widget.RemoteViews getDialogPresentation();
    method @Nullable public android.service.autofill.InlinePresentation getInlinePresentation();
    method @Nullable public android.service.autofill.InlinePresentation getInlineTooltipPresentation();
    method @Nullable public android.widget.RemoteViews getMenuPresentation();
  }
  public static final class Presentations.Builder {
    ctor public Presentations.Builder();
    method @NonNull public android.service.autofill.Presentations build();
    method @NonNull public android.service.autofill.Presentations.Builder setDialogPresentation(@NonNull android.widget.RemoteViews);
    method @NonNull public android.service.autofill.Presentations.Builder setInlinePresentation(@NonNull android.service.autofill.InlinePresentation);
    method @NonNull public android.service.autofill.Presentations.Builder setInlineTooltipPresentation(@NonNull android.service.autofill.InlinePresentation);
    method @NonNull public android.service.autofill.Presentations.Builder setMenuPresentation(@NonNull android.widget.RemoteViews);
  }
  public final class RegexValidator implements android.os.Parcelable android.service.autofill.Validator {
    ctor public RegexValidator(@NonNull android.view.autofill.AutofillId, @NonNull java.util.regex.Pattern);
    method public int describeContents();
+2 −2
Original line number Diff line number Diff line
@@ -10638,9 +10638,9 @@ package android.service.autofill {
  }
  public static final class Dataset.Builder {
    ctor public Dataset.Builder(@NonNull android.service.autofill.InlinePresentation);
    ctor @Deprecated public Dataset.Builder(@NonNull android.service.autofill.InlinePresentation);
    method @NonNull public android.service.autofill.Dataset.Builder setContent(@NonNull android.view.autofill.AutofillId, @Nullable android.content.ClipData);
    method @NonNull public android.service.autofill.Dataset.Builder setFieldInlinePresentation(@NonNull android.view.autofill.AutofillId, @Nullable android.view.autofill.AutofillValue, @Nullable java.util.regex.Pattern, @NonNull android.service.autofill.InlinePresentation);
    method @Deprecated @NonNull public android.service.autofill.Dataset.Builder setFieldInlinePresentation(@NonNull android.view.autofill.AutofillId, @Nullable android.view.autofill.AutofillValue, @Nullable java.util.regex.Pattern, @NonNull android.service.autofill.InlinePresentation);
  }
  public abstract class InlineSuggestionRenderService extends android.app.Service {
+212 −46

File changed.

Preview size limit exceeded, changes collapsed.

+165 −0
Original line number Diff line number Diff line
/*
 * Copyright (C) 2022 The Android Open Source Project
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package android.service.autofill;

import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SuppressLint;
import android.view.autofill.AutofillId;
import android.view.autofill.AutofillValue;

import com.android.internal.util.DataClass;

import java.util.regex.Pattern;

/**
 * This class is used to set all information of a field. Such as the
 * {@link AutofillId} of the field, the {@link AutofillValue} to be autofilled,
 * a <a href="#Filtering">explicit filter</a>, and presentations to be visualized,
 * etc.
 */
public final class Field {

    /**
     * The value to be autofilled. Pass {@code null} if you do not have the value
     * but the target view is a logical part of the dataset. For example, if the
     * dataset needs authentication and you have no access to the value.
     */
    private @Nullable AutofillValue mValue;

    /**
     * Regex used to determine if the dataset should be shown in the autofill UI;
     * when {@code null}, it disables filtering on that dataset (this is the recommended
     * approach when {@code value} is not {@code null} and field contains sensitive data
     * such as passwords).
     *
     * @see Dataset.DatasetFieldFilter
     * @hide
     */
    private @Nullable Dataset.DatasetFieldFilter mFilter;

    /**
     * The presentations used to visualize this field in Autofill UI.
     */
    private @Nullable Presentations mPresentations;


    /* package-private */ Field(
            @Nullable AutofillValue value,
            @Nullable Dataset.DatasetFieldFilter filter,
            @Nullable Presentations presentations) {
        this.mValue = value;
        this.mFilter = filter;
        this.mPresentations = presentations;
    }

    /**
     * The value to be autofilled. Pass {@code null} if you do not have the value
     * but the target view is a logical part of the dataset. For example, if the
     * dataset needs authentication and you have no access to the value.
     */
    @DataClass.Generated.Member
    public @Nullable AutofillValue getValue() {
        return mValue;
    }

    /**
     * Regex used to determine if the dataset should be shown in the autofill UI;
     * when {@code null}, it disables filtering on that dataset (this is the recommended
     * approach when {@code value} is not {@code null} and field contains sensitive data
     * such as passwords).
     *
     * @see Dataset.DatasetFieldFilter
     * @hide
     */
    public @Nullable Dataset.DatasetFieldFilter getFilter() {
        return mFilter;
    }

    /**
     * The presentations used to visualize this field in Autofill UI.
     */
    public @Nullable Presentations getPresentations() {
        return mPresentations;
    }

    /**
     * A builder for {@link Field}
     */
    public static final class Builder {

        private @Nullable AutofillValue mValue = null;
        private @Nullable Dataset.DatasetFieldFilter mFilter = null;
        private @Nullable Presentations mPresentations = null;
        private boolean mDestroyed = false;

        public Builder() {
        }

        /**
         * The value to be autofilled. Pass {@code null} if you do not have the value
         * but the target view is a logical part of the dataset. For example, if the
         * dataset needs authentication and you have no access to the value.
         */
        public @NonNull Builder setValue(@NonNull AutofillValue value) {
            checkNotUsed();
            mValue = value;
            return this;
        }

        /**
         * Regex used to determine if the dataset should be shown in the autofill UI;
         * when {@code null}, it disables filtering on that dataset (this is the recommended
         * approach when {@code value} is not {@code null} and field contains sensitive data
         * such as passwords).
         */
        @SuppressLint("MissingGetterMatchingBuilder")
        public @NonNull Builder setFilter(@Nullable Pattern value) {
            checkNotUsed();
            mFilter = new Dataset.DatasetFieldFilter(value);
            return this;
        }

        /**
         * The presentations used to visualize this field in Autofill UI.
         */
        public @NonNull Builder setPresentations(@NonNull Presentations value) {
            checkNotUsed();
            mPresentations = value;
            return this;
        }

        /** Builds the instance. This builder should not be touched after calling this! */
        public @NonNull Field build() {
            checkNotUsed();
            mDestroyed = true; // Mark builder used

            Field o = new Field(
                    mValue,
                    mFilter,
                    mPresentations);
            return o;
        }

        private void checkNotUsed() {
            if (mDestroyed) {
                throw new IllegalStateException(
                        "This Builder should not be reused. Use a new Builder instance instead");
            }
        }
    }
}
+20 −9
Original line number Diff line number Diff line
@@ -98,6 +98,12 @@ public final class FillRequest implements Parcelable {

    // The flag value 0x20 has been defined in AutofillManager.

    /**
     * Indicates the request is coming from the activity just started.
     * @hide
     */
    public static final @RequestFlags int FLAG_ACTIVITY_START = 0x40;

    /** @hide */
    public static final int INVALID_REQUEST_ID = Integer.MIN_VALUE;

@@ -160,13 +166,13 @@ public final class FillRequest implements Parcelable {



    // Code below generated by codegen v1.0.15.
    // Code below generated by codegen v1.0.23.
    //
    // DO NOT MODIFY!
    // CHECKSTYLE:OFF Generated code
    //
    // To regenerate run:
    // $ codegen $ANDROID_BUILD_TOP/frameworks/base/core/java/android/service/autofill/FillRequest.java
    // $ codegen $ANDROID_BUILD_TOP/./frameworks/base/core/java/android/service/autofill/FillRequest.java
    //
    // To exclude the generated code from IntelliJ auto-formatting enable (one-time):
    //   Settings > Editor > Code Style > Formatter Control
@@ -178,7 +184,8 @@ public final class FillRequest implements Parcelable {
        FLAG_MANUAL_REQUEST,
        FLAG_COMPATIBILITY_MODE_REQUEST,
        FLAG_PASSWORD_INPUT_TYPE,
        FLAG_VIEW_NOT_FOCUSED
        FLAG_VIEW_NOT_FOCUSED,
        FLAG_ACTIVITY_START
    })
    @Retention(RetentionPolicy.SOURCE)
    @DataClass.Generated.Member
@@ -202,6 +209,8 @@ public final class FillRequest implements Parcelable {
                    return "FLAG_PASSWORD_INPUT_TYPE";
            case FLAG_VIEW_NOT_FOCUSED:
                    return "FLAG_VIEW_NOT_FOCUSED";
            case FLAG_ACTIVITY_START:
                    return "FLAG_ACTIVITY_START";
            default: return Integer.toHexString(value);
        }
    }
@@ -264,7 +273,8 @@ public final class FillRequest implements Parcelable {
                FLAG_MANUAL_REQUEST
                        | FLAG_COMPATIBILITY_MODE_REQUEST
                        | FLAG_PASSWORD_INPUT_TYPE
                        | FLAG_VIEW_NOT_FOCUSED);
                        | FLAG_VIEW_NOT_FOCUSED
                        | FLAG_ACTIVITY_START);
        this.mInlineSuggestionsRequest = inlineSuggestionsRequest;

        onConstructed();
@@ -384,7 +394,7 @@ public final class FillRequest implements Parcelable {
        byte flg = in.readByte();
        int id = in.readInt();
        List<FillContext> fillContexts = new ArrayList<>();
        in.readParcelableList(fillContexts, FillContext.class.getClassLoader(), android.service.autofill.FillContext.class);
        in.readParcelableList(fillContexts, FillContext.class.getClassLoader());
        Bundle clientState = (flg & 0x4) == 0 ? null : in.readBundle();
        int flags = in.readInt();
        InlineSuggestionsRequest inlineSuggestionsRequest = (flg & 0x10) == 0 ? null : (InlineSuggestionsRequest) in.readTypedObject(InlineSuggestionsRequest.CREATOR);
@@ -401,7 +411,8 @@ public final class FillRequest implements Parcelable {
                FLAG_MANUAL_REQUEST
                        | FLAG_COMPATIBILITY_MODE_REQUEST
                        | FLAG_PASSWORD_INPUT_TYPE
                        | FLAG_VIEW_NOT_FOCUSED);
                        | FLAG_VIEW_NOT_FOCUSED
                        | FLAG_ACTIVITY_START);
        this.mInlineSuggestionsRequest = inlineSuggestionsRequest;

        onConstructed();
@@ -422,10 +433,10 @@ public final class FillRequest implements Parcelable {
    };

    @DataClass.Generated(
            time = 1589280816805L,
            codegenVersion = "1.0.15",
            time = 1643052544776L,
            codegenVersion = "1.0.23",
            sourceFile = "frameworks/base/core/java/android/service/autofill/FillRequest.java",
            inputSignatures = "public static final @android.service.autofill.FillRequest.RequestFlags int FLAG_MANUAL_REQUEST\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_COMPATIBILITY_MODE_REQUEST\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_PASSWORD_INPUT_TYPE\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_VIEW_NOT_FOCUSED\npublic static final  int INVALID_REQUEST_ID\nprivate final  int mId\nprivate final @android.annotation.NonNull java.util.List<android.service.autofill.FillContext> mFillContexts\nprivate final @android.annotation.Nullable android.os.Bundle mClientState\nprivate final @android.service.autofill.FillRequest.RequestFlags int mFlags\nprivate final @android.annotation.Nullable android.view.inputmethod.InlineSuggestionsRequest mInlineSuggestionsRequest\nprivate  void onConstructed()\nclass FillRequest extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genHiddenConstructor=true, genHiddenConstDefs=true)")
            inputSignatures = "public static final @android.service.autofill.FillRequest.RequestFlags int FLAG_MANUAL_REQUEST\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_COMPATIBILITY_MODE_REQUEST\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_PASSWORD_INPUT_TYPE\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_VIEW_NOT_FOCUSED\npublic static final @android.service.autofill.FillRequest.RequestFlags int FLAG_ACTIVITY_START\npublic static final  int INVALID_REQUEST_ID\nprivate final  int mId\nprivate final @android.annotation.NonNull java.util.List<android.service.autofill.FillContext> mFillContexts\nprivate final @android.annotation.Nullable android.os.Bundle mClientState\nprivate final @android.service.autofill.FillRequest.RequestFlags int mFlags\nprivate final @android.annotation.Nullable android.view.inputmethod.InlineSuggestionsRequest mInlineSuggestionsRequest\nprivate  void onConstructed()\nclass FillRequest extends java.lang.Object implements [android.os.Parcelable]\n@com.android.internal.util.DataClass(genToString=true, genHiddenConstructor=true, genHiddenConstDefs=true)")
    @Deprecated
    private void __metadata() {}

Loading