From 4924e209a3287b234d24e9124332f112a673190c Mon Sep 17 00:00:00 2001 From: Nikita Dubrovsky Date: Tue, 13 Oct 2020 09:22:14 -0700 Subject: [PATCH 1/2] Removed duplicate javadocs from OnReceiveContentCallback.Payload fields The fields are documented on the public getters and on the Builder, so removed the duplicate javadocs from the private fields. Bug: 152068298 Test: m -j Change-Id: Id45cee9003a4b754f09c52d1afcd1d8572e464df --- .../view/OnReceiveContentCallback.java | 30 ++----------------- 1 file changed, 2 insertions(+), 28 deletions(-) diff --git a/core/java/android/view/OnReceiveContentCallback.java b/core/java/android/view/OnReceiveContentCallback.java index 73bcb93d39d0d..1256554d2d3a2 100644 --- a/core/java/android/view/OnReceiveContentCallback.java +++ b/core/java/android/view/OnReceiveContentCallback.java @@ -217,37 +217,11 @@ public interface OnReceiveContentCallback { return String.valueOf(flags); } - /** - * The data to be inserted. - */ @NonNull private final ClipData mClip; - - /** - * The source of the operation. See {@code SOURCE_} constants. - */ private final @Source int mSource; - - /** - * Optional flags that control the insertion behavior. See {@code FLAG_} constants. - */ private final @Flags int mFlags; - - /** - * Optional http/https URI for the content that may be provided by the IME. This is only - * populated if the source is {@link #SOURCE_INPUT_METHOD} and if a non-empty - * {@link android.view.inputmethod.InputContentInfo#getLinkUri linkUri} was passed by the - * IME. - */ - @Nullable - private final Uri mLinkUri; - - /** - * Optional additional metadata. If the source is {@link #SOURCE_INPUT_METHOD}, this will - * include the {@link android.view.inputmethod.InputConnection#commitContent opts} passed by - * the IME. - */ - @Nullable - private final Bundle mExtras; + @Nullable private final Uri mLinkUri; + @Nullable private final Bundle mExtras; private Payload(Builder b) { this.mClip = Objects.requireNonNull(b.mClip); From 835e120747e5d468e16f6ca5bf395031f97388da Mon Sep 17 00:00:00 2001 From: Nikita Dubrovsky Date: Tue, 13 Oct 2020 09:35:44 -0700 Subject: [PATCH 2/2] Add SOURCE_APP to OnReceiveContentCallback.Payload Bug: 170191676 Bug: 152068298 Test: Will update CTS tests in a separate CL once all API council feedback is addressed Change-Id: I6e6f160020042ad19c4a7a8ae6fd0f090b301837 --- api/current.txt | 11 +++++---- .../view/OnReceiveContentCallback.java | 24 ++++++++++++------- non-updatable-api/current.txt | 11 +++++---- 3 files changed, 28 insertions(+), 18 deletions(-) diff --git a/api/current.txt b/api/current.txt index 94e90a75f644d..405a7880d5758 100644 --- a/api/current.txt +++ b/api/current.txt @@ -53709,11 +53709,12 @@ package android.view { method @Nullable public android.net.Uri getLinkUri(); method public int getSource(); field public static final int FLAG_CONVERT_TO_PLAIN_TEXT = 1; // 0x1 - field public static final int SOURCE_AUTOFILL = 3; // 0x3 - field public static final int SOURCE_CLIPBOARD = 0; // 0x0 - field public static final int SOURCE_DRAG_AND_DROP = 2; // 0x2 - field public static final int SOURCE_INPUT_METHOD = 1; // 0x1 - field public static final int SOURCE_PROCESS_TEXT = 4; // 0x4 + field public static final int SOURCE_APP = 0; // 0x0 + field public static final int SOURCE_AUTOFILL = 4; // 0x4 + field public static final int SOURCE_CLIPBOARD = 1; // 0x1 + field public static final int SOURCE_DRAG_AND_DROP = 3; // 0x3 + field public static final int SOURCE_INPUT_METHOD = 2; // 0x2 + field public static final int SOURCE_PROCESS_TEXT = 5; // 0x5 } public static final class OnReceiveContentCallback.Payload.Builder { diff --git a/core/java/android/view/OnReceiveContentCallback.java b/core/java/android/view/OnReceiveContentCallback.java index 1256554d2d3a2..a217ff642ab77 100644 --- a/core/java/android/view/OnReceiveContentCallback.java +++ b/core/java/android/view/OnReceiveContentCallback.java @@ -134,46 +134,52 @@ public interface OnReceiveContentCallback { final class Payload { /** - * Specifies the UI through which content is being inserted. + * Specifies the UI through which content is being inserted. Future versions of Android may + * support additional values. * * @hide */ - @IntDef(prefix = {"SOURCE_"}, value = {SOURCE_CLIPBOARD, SOURCE_INPUT_METHOD, + @IntDef(prefix = {"SOURCE_"}, value = {SOURCE_APP, SOURCE_CLIPBOARD, SOURCE_INPUT_METHOD, SOURCE_DRAG_AND_DROP, SOURCE_AUTOFILL, SOURCE_PROCESS_TEXT}) @Retention(RetentionPolicy.SOURCE) public @interface Source {} + /** + * Specifies that the operation was triggered by the app that contains the target view. + */ + public static final int SOURCE_APP = 0; + /** * Specifies that the operation was triggered by a paste from the clipboard (e.g. "Paste" or * "Paste as plain text" action in the insertion/selection menu). */ - public static final int SOURCE_CLIPBOARD = 0; + public static final int SOURCE_CLIPBOARD = 1; /** * Specifies that the operation was triggered from the soft keyboard (also known as input * method editor or IME). See https://developer.android.com/guide/topics/text/image-keyboard * for more info. */ - public static final int SOURCE_INPUT_METHOD = 1; + public static final int SOURCE_INPUT_METHOD = 2; /** * Specifies that the operation was triggered by the drag/drop framework. See * https://developer.android.com/guide/topics/ui/drag-drop for more info. */ - public static final int SOURCE_DRAG_AND_DROP = 2; + public static final int SOURCE_DRAG_AND_DROP = 3; /** * Specifies that the operation was triggered by the autofill framework. See * https://developer.android.com/guide/topics/text/autofill for more info. */ - public static final int SOURCE_AUTOFILL = 3; + public static final int SOURCE_AUTOFILL = 4; /** * Specifies that the operation was triggered by a result from a * {@link android.content.Intent#ACTION_PROCESS_TEXT PROCESS_TEXT} action in the selection * menu. */ - public static final int SOURCE_PROCESS_TEXT = 4; + public static final int SOURCE_PROCESS_TEXT = 5; /** * Returns the symbolic name of the given source. @@ -182,6 +188,7 @@ public interface OnReceiveContentCallback { */ static String sourceToString(@Source int source) { switch (source) { + case SOURCE_APP: return "SOURCE_APP"; case SOURCE_CLIPBOARD: return "SOURCE_CLIPBOARD"; case SOURCE_INPUT_METHOD: return "SOURCE_INPUT_METHOD"; case SOURCE_DRAG_AND_DROP: return "SOURCE_DRAG_AND_DROP"; @@ -252,7 +259,8 @@ public interface OnReceiveContentCallback { } /** - * The source of the operation. See {@code SOURCE_} constants. + * The source of the operation. See {@code SOURCE_} constants. Future versions of Android + * may pass additional values. */ public @Source int getSource() { return mSource; diff --git a/non-updatable-api/current.txt b/non-updatable-api/current.txt index 983f20aad2e3a..f017eb79b215b 100644 --- a/non-updatable-api/current.txt +++ b/non-updatable-api/current.txt @@ -51838,11 +51838,12 @@ package android.view { method @Nullable public android.net.Uri getLinkUri(); method public int getSource(); field public static final int FLAG_CONVERT_TO_PLAIN_TEXT = 1; // 0x1 - field public static final int SOURCE_AUTOFILL = 3; // 0x3 - field public static final int SOURCE_CLIPBOARD = 0; // 0x0 - field public static final int SOURCE_DRAG_AND_DROP = 2; // 0x2 - field public static final int SOURCE_INPUT_METHOD = 1; // 0x1 - field public static final int SOURCE_PROCESS_TEXT = 4; // 0x4 + field public static final int SOURCE_APP = 0; // 0x0 + field public static final int SOURCE_AUTOFILL = 4; // 0x4 + field public static final int SOURCE_CLIPBOARD = 1; // 0x1 + field public static final int SOURCE_DRAG_AND_DROP = 3; // 0x3 + field public static final int SOURCE_INPUT_METHOD = 2; // 0x2 + field public static final int SOURCE_PROCESS_TEXT = 5; // 0x5 } public static final class OnReceiveContentCallback.Payload.Builder {