From 5a8d8275267c88718d5dba87e428c76034e81994 Mon Sep 17 00:00:00 2001 From: Tony Mak Date: Mon, 8 Apr 2019 15:46:13 +0100 Subject: [PATCH] Do not deep copy bundle in getExtras() Test: atest cts/tests/tests/view/src/android/view/textclassifier/cts/* BUG: 129901152 Change-Id: Icc55b81acabfad317622de4d664d573646f49914 --- .../view/textclassifier/ConversationAction.java | 6 ++---- .../view/textclassifier/ConversationActions.java | 6 ++---- .../view/textclassifier/TextClassification.java | 12 ++++-------- core/java/android/view/textclassifier/TextLinks.java | 12 ++++-------- .../android/view/textclassifier/TextSelection.java | 12 ++++-------- 5 files changed, 16 insertions(+), 32 deletions(-) diff --git a/core/java/android/view/textclassifier/ConversationAction.java b/core/java/android/view/textclassifier/ConversationAction.java index f2d878a8bf54f..b8cb7bed8712a 100644 --- a/core/java/android/view/textclassifier/ConversationAction.java +++ b/core/java/android/view/textclassifier/ConversationAction.java @@ -200,13 +200,11 @@ public final class ConversationAction implements Parcelable { /** * Returns the extended data related to this conversation action. * - *

NOTE: Each call to this method returns a new bundle copy so clients should - * prefer to hold a reference to the returned bundle rather than frequently calling this - * method. + *

NOTE: Do not modify this bundle. */ @NonNull public Bundle getExtras() { - return mExtras.deepCopy(); + return mExtras; } /** Builder class to construct {@link ConversationAction}. */ diff --git a/core/java/android/view/textclassifier/ConversationActions.java b/core/java/android/view/textclassifier/ConversationActions.java index dc7521296e9f1..eddc672dc87f0 100644 --- a/core/java/android/view/textclassifier/ConversationActions.java +++ b/core/java/android/view/textclassifier/ConversationActions.java @@ -214,13 +214,11 @@ public final class ConversationActions implements Parcelable { /** * Returns the extended data related to this conversation action. * - *

NOTE: Each call to this method returns a new bundle copy so clients should - * prefer to hold a reference to the returned bundle rather than frequently calling this - * method. + *

NOTE: Do not modify this bundle. */ @NonNull public Bundle getExtras() { - return mExtras.deepCopy(); + return mExtras; } /** Builder class to construct a {@link Message} */ diff --git a/core/java/android/view/textclassifier/TextClassification.java b/core/java/android/view/textclassifier/TextClassification.java index 9ede8fbd176e3..4c4cb55cd3a02 100644 --- a/core/java/android/view/textclassifier/TextClassification.java +++ b/core/java/android/view/textclassifier/TextClassification.java @@ -265,13 +265,11 @@ public final class TextClassification implements Parcelable { /** * Returns the extended data. * - *

NOTE: Each call to this method returns a new bundle copy so clients should - * prefer to hold a reference to the returned bundle rather than frequently calling this - * method. + *

NOTE: Do not modify this bundle. */ @NonNull public Bundle getExtras() { - return mExtras.deepCopy(); + return mExtras; } @Override @@ -635,13 +633,11 @@ public final class TextClassification implements Parcelable { /** * Returns the extended data. * - *

NOTE: Each call to this method returns a new bundle copy so clients should - * prefer to hold a reference to the returned bundle rather than frequently calling this - * method. + *

NOTE: Do not modify this bundle. */ @NonNull public Bundle getExtras() { - return mExtras.deepCopy(); + return mExtras; } /** diff --git a/core/java/android/view/textclassifier/TextLinks.java b/core/java/android/view/textclassifier/TextLinks.java index cde27a08fc798..c815f63b17084 100644 --- a/core/java/android/view/textclassifier/TextLinks.java +++ b/core/java/android/view/textclassifier/TextLinks.java @@ -125,13 +125,11 @@ public final class TextLinks implements Parcelable { /** * Returns the extended data. * - *

NOTE: Each call to this method returns a new bundle copy so clients should - * prefer to hold a reference to the returned bundle rather than frequently calling this - * method. + *

NOTE: Do not modify this bundle. */ @NonNull public Bundle getExtras() { - return mExtras.deepCopy(); + return mExtras; } /** @@ -413,13 +411,11 @@ public final class TextLinks implements Parcelable { /** * Returns the extended data. * - *

NOTE: Each call to this method returns a new bundle copy so clients should - * prefer to hold a reference to the returned bundle rather than frequently calling this - * method. + *

NOTE: Do not modify this bundle. */ @NonNull public Bundle getExtras() { - return mExtras.deepCopy(); + return mExtras; } /** diff --git a/core/java/android/view/textclassifier/TextSelection.java b/core/java/android/view/textclassifier/TextSelection.java index 52989397e4730..e378e65aa29e6 100644 --- a/core/java/android/view/textclassifier/TextSelection.java +++ b/core/java/android/view/textclassifier/TextSelection.java @@ -112,13 +112,11 @@ public final class TextSelection implements Parcelable { /** * Returns the extended data. * - *

NOTE: Each call to this method returns a new bundle copy so clients should - * prefer to hold a reference to the returned bundle rather than frequently calling this - * method. + *

NOTE: Do not modify this bundle. */ @NonNull public Bundle getExtras() { - return mExtras.deepCopy(); + return mExtras; } @Override @@ -296,13 +294,11 @@ public final class TextSelection implements Parcelable { /** * Returns the extended data. * - *

NOTE: Each call to this method returns a new bundle copy so clients should - * prefer to hold a reference to the returned bundle rather than frequently calling this - * method. + *

NOTE: Do not modify this bundle. */ @NonNull public Bundle getExtras() { - return mExtras.deepCopy(); + return mExtras; } /**