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

Commit 4a5d4e51 authored by TYM Tsai's avatar TYM Tsai
Browse files

Add API for creating AutofillId with virtual child id

App needs to create AutofillId for virtual views for client suggestion.
That requires new API otherwise client can not have any id with virtual
view id when request a response from client.

Bug: 261024705
Test: atest android.autofillservice.cts.unittests.AutofillIdTest
Change-Id: Ic78a548b414a47239c222192d2d29063341d6c35
parent 7b57978a
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -53203,6 +53203,7 @@ package android.view.animation {
package android.view.autofill {
  public final class AutofillId implements android.os.Parcelable {
    method @NonNull public static android.view.autofill.AutofillId create(@NonNull android.view.View, int);
    method public int describeContents();
    method public void writeToParcel(android.os.Parcel, int);
    field @NonNull public static final android.os.Parcelable.Creator<android.view.autofill.AutofillId> CREATOR;
+19 −0
Original line number Diff line number Diff line
@@ -22,6 +22,8 @@ import android.os.Parcel;
import android.os.Parcelable;
import android.view.View;

import java.util.Objects;

/**
 * A unique identifier for an autofill node inside an {@link android.app.Activity}.
 */
@@ -76,6 +78,23 @@ public final class AutofillId implements Parcelable {
    @NonNull
    public static final AutofillId NO_AUTOFILL_ID = new AutofillId(0);

    /**
     * Creates an {@link AutofillId} with the virtual id.
     *
     * This method is used by a {@link View} that contains the virtual view hierarchy. Use this
     * method to create the {@link AutofillId} for each virtual view.
     *
     * @param host the view hosting the virtual view hierarchy which is used to show autofill
     *            suggestions.
     * @param virtualId id identifying the virtual view inside the host view.
     * @return an {@link AutofillId} for the virtual view
     */
    @NonNull
    public static AutofillId create(@NonNull View host, int virtualId) {
        Objects.requireNonNull(host);
        return new AutofillId(host.getAutofillId(), virtualId);
    }

    /** @hide */
    @NonNull
    @TestApi