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

Commit 80383beb authored by Felix Oghina's avatar Felix Oghina Committed by Android (Google) Code Review
Browse files

Merge "[content-capture] ensure memory-safe charsequences"

parents 2a5d05f1 50f5ce8b
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -740,7 +740,8 @@ public final class MainContentCaptureSession extends ContentCaptureSession {
        // Since the same CharSequence instance may be reused in the TextView, we need to make
        // a copy of its content so that its value will not be changed by subsequent updates
        // in the TextView.
        final CharSequence eventText = stringOrSpannedStringWithoutNoCopySpans(text);
        final CharSequence eventText =
                TextUtils.trimToParcelableSize(stringOrSpannedStringWithoutNoCopySpans(text));

        final int composingStart;
        final int composingEnd;
+10 −3
Original line number Diff line number Diff line
@@ -1052,14 +1052,21 @@ public final class ViewNode extends AssistStructure.ViewNode {
        }

        void writeToParcel(Parcel out, boolean simple) {
            TextUtils.writeToParcel(mText, out, 0);
            CharSequence text = TextUtils.trimToParcelableSize(mText);
            TextUtils.writeToParcel(text, out, 0);
            out.writeFloat(mTextSize);
            out.writeInt(mTextStyle);
            out.writeInt(mTextColor);
            if (!simple) {
                int selectionStart = text != null
                        ? Math.min(mTextSelectionStart, text.length())
                        : mTextSelectionStart;
                int selectionEnd = text != null
                        ? Math.min(mTextSelectionEnd, text.length())
                        : mTextSelectionEnd;
                out.writeInt(mTextBackgroundColor);
                out.writeInt(mTextSelectionStart);
                out.writeInt(mTextSelectionEnd);
                out.writeInt(selectionStart);
                out.writeInt(selectionEnd);
                out.writeIntArray(mLineCharOffsets);
                out.writeIntArray(mLineBaselines);
                out.writeString(mHint);
+2 −1
Original line number Diff line number Diff line
@@ -13601,7 +13601,8 @@ public class TextView extends View implements ViewTreeObserver.OnPreDrawListener
    @Nullable
    public AutofillValue getAutofillValue() {
        if (isTextEditable()) {
            final CharSequence text = TextUtils.trimToParcelableSize(getText());
            final CharSequence text =
                    TextUtils.trimToParcelableSize(TextUtils.trimNoCopySpans(getText()));
            return AutofillValue.forText(text);
        }
        return null;