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

Commit 2fb8607d authored by Felix Oghina's avatar Felix Oghina Committed by Automerger Merge Worker
Browse files

Merge "[content-capture] remove span support, fix leaks" into udc-dev am:...

Merge "[content-capture] remove span support, fix leaks" into udc-dev am: 52774ac4 am: 03714878 am: d7afcb57

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/22931836



Change-Id: I98d1606825851c17492559b3f4ef025843c888ef
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents 7fd6e543 d7afcb57
Loading
Loading
Loading
Loading
+4 −13
Original line number Original line Diff line number Diff line
@@ -46,8 +46,6 @@ import android.os.IBinder.DeathRecipient;
import android.os.RemoteException;
import android.os.RemoteException;
import android.text.Selection;
import android.text.Selection;
import android.text.Spannable;
import android.text.Spannable;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
import android.text.TextUtils;
import android.util.LocalLog;
import android.util.LocalLog;
import android.util.Log;
import android.util.Log;
@@ -740,7 +738,10 @@ public final class MainContentCaptureSession extends ContentCaptureSession {
        // Since the same CharSequence instance may be reused in the TextView, we need to make
        // 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
        // a copy of its content so that its value will not be changed by subsequent updates
        // in the TextView.
        // in the TextView.
        final CharSequence eventText = stringOrSpannedStringWithoutNoCopySpans(text);
        CharSequence trimmed = TextUtils.trimToParcelableSize(text);
        final CharSequence eventText = trimmed != null && trimmed == text
                ? trimmed.toString()
                : trimmed;


        final int composingStart;
        final int composingStart;
        final int composingEnd;
        final int composingEnd;
@@ -761,16 +762,6 @@ public final class MainContentCaptureSession extends ContentCaptureSession {
                        .setSelectionIndex(startIndex, endIndex)));
                        .setSelectionIndex(startIndex, endIndex)));
    }
    }


    private CharSequence stringOrSpannedStringWithoutNoCopySpans(CharSequence source) {
        if (source == null) {
            return null;
        } else if (source instanceof Spanned) {
            return new SpannableString(source, /* ignoreNoCopySpan= */ true);
        } else {
            return source.toString();
        }
    }

    /** Public because is also used by ViewRootImpl */
    /** Public because is also used by ViewRootImpl */
    public void notifyViewInsetsChanged(int sessionId, @NonNull Insets viewInsets) {
    public void notifyViewInsetsChanged(int sessionId, @NonNull Insets viewInsets) {
        mHandler.post(() -> sendEvent(new ContentCaptureEvent(sessionId, TYPE_VIEW_INSETS_CHANGED)
        mHandler.post(() -> sendEvent(new ContentCaptureEvent(sessionId, TYPE_VIEW_INSETS_CHANGED)
+10 −3
Original line number Original line Diff line number Diff line
@@ -1052,14 +1052,21 @@ public final class ViewNode extends AssistStructure.ViewNode {
        }
        }


        void writeToParcel(Parcel out, boolean simple) {
        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.writeFloat(mTextSize);
            out.writeInt(mTextStyle);
            out.writeInt(mTextStyle);
            out.writeInt(mTextColor);
            out.writeInt(mTextColor);
            if (!simple) {
            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(mTextBackgroundColor);
                out.writeInt(mTextSelectionStart);
                out.writeInt(selectionStart);
                out.writeInt(mTextSelectionEnd);
                out.writeInt(selectionEnd);
                out.writeIntArray(mLineCharOffsets);
                out.writeIntArray(mLineCharOffsets);
                out.writeIntArray(mLineBaselines);
                out.writeIntArray(mLineBaselines);
                out.writeString(mHint);
                out.writeString(mHint);