Merge "[content-capture] remove span support, fix leaks" into udc-dev
This commit is contained in:
@@ -46,8 +46,6 @@ import android.os.IBinder.DeathRecipient;
|
||||
import android.os.RemoteException;
|
||||
import android.text.Selection;
|
||||
import android.text.Spannable;
|
||||
import android.text.SpannableString;
|
||||
import android.text.Spanned;
|
||||
import android.text.TextUtils;
|
||||
import android.util.LocalLog;
|
||||
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
|
||||
// a copy of its content so that its value will not be changed by subsequent updates
|
||||
// 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 composingEnd;
|
||||
@@ -761,16 +762,6 @@ public final class MainContentCaptureSession extends ContentCaptureSession {
|
||||
.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 void notifyViewInsetsChanged(int sessionId, @NonNull Insets viewInsets) {
|
||||
mHandler.post(() -> sendEvent(new ContentCaptureEvent(sessionId, TYPE_VIEW_INSETS_CHANGED)
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user