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

Commit 74828103 authored by Tony Mak's avatar Tony Mak
Browse files

Remove remaining deepCopy() usages in TextClassifier

Did a grep to ensure no more deepCopy() in textclassifier folder.

BUG: 129901152

Test: atest cts/tests/tests/view/src/android/view/textclassifier/cts/

Change-Id: Ia1e6f3ad1664a0b57495d94d2cf5aa8945965862
parent f67cd9bb
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -266,7 +266,7 @@ public final class ConversationAction implements Parcelable {
                    mAction,
                    mTextReply,
                    mScore,
                    mExtras == null ? Bundle.EMPTY : mExtras.deepCopy());
                    mExtras == null ? Bundle.EMPTY : mExtras);
        }
    }
}
+1 −1
Original line number Diff line number Diff line
@@ -275,7 +275,7 @@ public final class ConversationActions implements Parcelable {
                        mAuthor,
                        mReferenceTime,
                        mText == null ? null : new SpannedString(mText),
                        mExtras == null ? new Bundle() : mExtras.deepCopy());
                        mExtras == null ? Bundle.EMPTY : mExtras);
            }
        }
    }
+2 −2
Original line number Diff line number Diff line
@@ -521,7 +521,7 @@ public final class TextClassification implements Parcelable {
        }

        private Bundle buildExtras(EntityConfidence entityConfidence) {
            final Bundle extras = mExtras == null ? new Bundle() : mExtras.deepCopy();
            final Bundle extras = mExtras == null ? new Bundle() : mExtras;
            if (mActionIntents.stream().anyMatch(Objects::nonNull)) {
                ExtrasUtils.putActionsIntents(extras, mActionIntents);
            }
@@ -713,7 +713,7 @@ public final class TextClassification implements Parcelable {
            public Request build() {
                return new Request(new SpannedString(mText), mStartIndex, mEndIndex,
                        mDefaultLocales, mReferenceTime,
                        mExtras == null ? Bundle.EMPTY : mExtras.deepCopy());
                        mExtras == null ? Bundle.EMPTY : mExtras);
            }
        }

+6 −10
Original line number Diff line number Diff line
@@ -113,12 +113,11 @@ public final class TextLanguage implements Parcelable {
     * Returns a bundle containing non-structured extra information about this result. What is
     * returned in the extras is specific to the {@link TextClassifier} implementation.
     *
     * <p><b>NOTE: </b>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.
     * <p><b>NOTE: </b>Do not modify this bundle.
     */
    @NonNull
    public Bundle getExtras() {
        return mBundle.deepCopy();
        return mBundle;
    }

    @Override
@@ -199,7 +198,7 @@ public final class TextLanguage implements Parcelable {
         */
        @NonNull
        public TextLanguage build() {
            mBundle = mBundle == null ? new Bundle() : mBundle.deepCopy();
            mBundle = mBundle == null ? Bundle.EMPTY : mBundle;
            return new TextLanguage(
                    mId,
                    new EntityConfidence(mEntityConfidenceMap),
@@ -263,13 +262,11 @@ public final class TextLanguage implements Parcelable {
        /**
         * Returns a bundle containing non-structured extra information about this request.
         *
         * <p><b>NOTE: </b>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.
         * <p><b>NOTE: </b>Do not modify this bundle.
         */
        @NonNull
        public Bundle getExtras() {
            return mExtra.deepCopy();
            return mExtra;
        }

        @Override
@@ -327,8 +324,7 @@ public final class TextLanguage implements Parcelable {
             */
            @NonNull
            public Request build() {
                mBundle = mBundle == null ? new Bundle() : mBundle.deepCopy();
                return new Request(mText.toString(), mBundle);
                return new Request(mText.toString(), mBundle == null ? Bundle.EMPTY : mBundle);
            }
        }
    }
+2 −2
Original line number Diff line number Diff line
@@ -493,7 +493,7 @@ public final class TextLinks implements Parcelable {
                return new Request(
                        mText, mDefaultLocales, mEntityConfig,
                        mLegacyFallback,
                        mExtras == null ? Bundle.EMPTY : mExtras.deepCopy());
                        mExtras == null ? Bundle.EMPTY : mExtras);
            }
        }

@@ -702,7 +702,7 @@ public final class TextLinks implements Parcelable {
        @NonNull
        public TextLinks build() {
            return new TextLinks(mFullText, mLinks,
                    mExtras == null ? Bundle.EMPTY : mExtras.deepCopy());
                    mExtras == null ? Bundle.EMPTY : mExtras);
        }
    }
}
Loading