From 8e2731bfeffeba32345f8b14d70dae3b8ba17353 Mon Sep 17 00:00:00 2001 From: Petr Cermak Date: Fri, 16 Mar 2018 10:23:00 +0000 Subject: [PATCH] Annotate RemoteInput#SOURCE_* with @IntDef This patch addresses a request from the API Council (http://b/74409378). It defines a new RemoteInput.Source annotation for RemoteInput source constants. Bug: 74409378 Test: atest RemoteInputTest Change-Id: I78a006b6a600ea0c0603b2591d1a29596074a44e --- core/java/android/app/RemoteInput.java | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/core/java/android/app/RemoteInput.java b/core/java/android/app/RemoteInput.java index b7100e6f4d87..6feb38e9d791 100644 --- a/core/java/android/app/RemoteInput.java +++ b/core/java/android/app/RemoteInput.java @@ -16,6 +16,7 @@ package android.app; +import android.annotation.IntDef; import android.content.ClipData; import android.content.ClipDescription; import android.content.Intent; @@ -25,6 +26,8 @@ import android.os.Parcel; import android.os.Parcelable; import android.util.ArraySet; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; import java.util.HashMap; import java.util.Map; import java.util.Set; @@ -74,9 +77,14 @@ public final class RemoteInput implements Parcelable { private static final String EXTRA_DATA_TYPE_RESULTS_DATA = "android.remoteinput.dataTypeResultsData"; - /** Extra added to a clip data intent object identifying the source of the results. */ + /** Extra added to a clip data intent object identifying the {@link Source} of the results. */ private static final String EXTRA_RESULTS_SOURCE = "android.remoteinput.resultsSource"; + /** @hide */ + @IntDef(prefix = {"SOURCE_"}, value = {SOURCE_FREE_FORM_INPUT, SOURCE_CHOICE}) + @Retention(RetentionPolicy.SOURCE) + public @interface Source {} + /** The user manually entered the data. */ public static final int SOURCE_FREE_FORM_INPUT = 0; @@ -437,10 +445,9 @@ public final class RemoteInput implements Parcelable { * * @param intent The intent to add remote input source to. The {@link ClipData} * field of the intent will be modified to contain the source. - * field of the intent will be modified to contain the source. * @param source The source of the results. */ - public static void setResultsSource(Intent intent, int source) { + public static void setResultsSource(Intent intent, @Source int source) { Intent clipDataIntent = getClipDataIntentFromIntent(intent); if (clipDataIntent == null) { clipDataIntent = new Intent(); // First time we've added a result. @@ -460,6 +467,7 @@ public final class RemoteInput implements Parcelable { * @return The source of the results. If no source was set, {@link #SOURCE_FREE_FORM_INPUT} will * be returned. */ + @Source public static int getResultsSource(Intent intent) { Intent clipDataIntent = getClipDataIntentFromIntent(intent); if (clipDataIntent == null) { -- 2.11.0