ContentCapture: Don't ignore events with changed composing/selection span
Currently, if the view has a TEXT_CHANGED event in the buffer with the same text, the new event is ignored, even if the Composing or Selection span is changed. Bug: 184311217 Test: manual - move cursor quickly and check flushed event Test: atest android.contentcaptureservice.cts.LoginActivityTest Change-Id: I4de28576b138225f4e64ed93bcb0b9dd3ed0095c
This commit is contained in:
@@ -285,6 +285,15 @@ public final class ContentCaptureEvent implements Parcelable {
|
||||
return this;
|
||||
}
|
||||
|
||||
boolean hasSameComposingSpan(@NonNull ContentCaptureEvent other) {
|
||||
return mComposingStart == other.mComposingStart && mComposingEnd == other.mComposingEnd;
|
||||
}
|
||||
|
||||
boolean hasSameSelectionSpan(@NonNull ContentCaptureEvent other) {
|
||||
return mSelectionStartIndex == other.mSelectionStartIndex
|
||||
&& mSelectionEndIndex == other.mSelectionEndIndex;
|
||||
}
|
||||
|
||||
private int getComposingStart() {
|
||||
return mComposingStart;
|
||||
}
|
||||
|
||||
@@ -362,7 +362,10 @@ public final class MainContentCaptureSession extends ContentCaptureSession {
|
||||
final CharSequence lastText = lastEvent.getText();
|
||||
final boolean bothNonEmpty = !TextUtils.isEmpty(lastText)
|
||||
&& !TextUtils.isEmpty(text);
|
||||
boolean equalContent = TextUtils.equals(lastText, text);
|
||||
boolean equalContent =
|
||||
TextUtils.equals(lastText, text)
|
||||
&& lastEvent.hasSameComposingSpan(event)
|
||||
&& lastEvent.hasSameSelectionSpan(event);
|
||||
if (equalContent) {
|
||||
addEvent = false;
|
||||
} else if (bothNonEmpty) {
|
||||
|
||||
Reference in New Issue
Block a user