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

Commit 01315b10 authored by Ahaan Ugale's avatar Ahaan Ugale
Browse files

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
parent fb12492d
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -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;
    }
+4 −1
Original line number Diff line number Diff line
@@ -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) {