From d51d212c798a8bd0798409742433852e7850c730 Mon Sep 17 00:00:00 2001 From: Adam He Date: Mon, 6 Jan 2020 13:44:41 -0800 Subject: [PATCH] Add SystemApis to TestApi in Dataset. Bug: 146453536 Test: atest android.autofillservice.cts.DatasetTest Change-Id: I42b2ccf4e3c388a672888051c09e608e9f9847cf --- api/test-current.txt | 5 +++++ .../java/android/service/autofill/Dataset.java | 18 +++++++++++++----- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/api/test-current.txt b/api/test-current.txt index 1c1d79473734f..03398e23a3e5d 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -2706,6 +2706,11 @@ package android.service.autofill { method @Nullable public android.util.SparseArray getActions(); } + public static final class Dataset.Builder { + ctor public Dataset.Builder(@NonNull android.service.autofill.InlinePresentation); + method @NonNull public android.service.autofill.Dataset.Builder setInlinePresentation(@NonNull android.view.autofill.AutofillId, @Nullable android.view.autofill.AutofillValue, @Nullable java.util.regex.Pattern, @NonNull android.service.autofill.InlinePresentation); + } + public final class DateTransformation extends android.service.autofill.InternalTransformation implements android.os.Parcelable android.service.autofill.Transformation { method public void apply(@NonNull android.service.autofill.ValueFinder, @NonNull android.widget.RemoteViews, int) throws java.lang.Exception; } diff --git a/core/java/android/service/autofill/Dataset.java b/core/java/android/service/autofill/Dataset.java index d827b30f27b6b..262d9896df87b 100644 --- a/core/java/android/service/autofill/Dataset.java +++ b/core/java/android/service/autofill/Dataset.java @@ -21,6 +21,7 @@ import static android.view.autofill.Helper.sDebug; import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.SystemApi; +import android.annotation.TestApi; import android.content.IntentSender; import android.os.Parcel; import android.os.Parcelable; @@ -238,6 +239,7 @@ public final class Dataset implements Parcelable { public Builder(@NonNull RemoteViews presentation, @NonNull InlinePresentation inlinePresentation) { Preconditions.checkNotNull(presentation, "presentation must be non-null"); + Preconditions.checkNotNull(inlinePresentation, "inlinePresentation must be non-null"); mPresentation = presentation; mInlinePresentation = inlinePresentation; } @@ -248,7 +250,8 @@ public final class Dataset implements Parcelable { * @param presentation The presentation used to visualize this dataset. */ public Builder(@NonNull RemoteViews presentation) { - this(presentation, null); + Preconditions.checkNotNull(presentation, "presentation must be non-null"); + mPresentation = presentation; } /** @@ -262,7 +265,9 @@ public final class Dataset implements Parcelable { * @hide */ @SystemApi + @TestApi public Builder(@NonNull InlinePresentation inlinePresentation) { + Preconditions.checkNotNull(inlinePresentation, "inlinePresentation must be non-null"); mInlinePresentation = inlinePresentation; } @@ -576,6 +581,7 @@ public final class Dataset implements Parcelable { * @hide */ @SystemApi + @TestApi public @NonNull Builder setInlinePresentation(@NonNull AutofillId id, @Nullable AutofillValue value, @Nullable Pattern filter, @NonNull InlinePresentation inlinePresentation) { @@ -672,11 +678,13 @@ public final class Dataset implements Parcelable { // using specially crafted parcels. final RemoteViews presentation = parcel.readParcelable(null); final InlinePresentation inlinePresentation = parcel.readParcelable(null); - final Builder builder = presentation == null - ? new Builder(inlinePresentation) - : inlinePresentation == null + final Builder builder = presentation != null + ? inlinePresentation == null ? new Builder(presentation) - : new Builder(presentation, inlinePresentation); + : new Builder(presentation, inlinePresentation) + : inlinePresentation == null + ? new Builder() + : new Builder(inlinePresentation); final ArrayList ids = parcel.createTypedArrayList(AutofillId.CREATOR); final ArrayList values =