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

Commit ccce5c9e authored by Eugene Susla's avatar Eugene Susla
Browse files

Preserve order of a11y events

Test: cts-tradefed run singleCommand cts -d --module CtsAccessibilityServiceTestCases
cts-tradefed run singleCommand cts -d --module CtsAccessibilityTestCases
cts-tradefed run singleCommand cts -d --module CtsUiAutomationTestCases
Change-Id: I6a9230473f79148a3da9808d67d9e0c80abc8384
parent b69b789b
Loading
Loading
Loading
Loading
+14 −2
Original line number Diff line number Diff line
@@ -7061,6 +7061,14 @@ public final class ViewRootImpl implements ViewParent,
        if (mView == null || mStopped || mPausedForTransition) {
            return false;
        }

        // Immediately flush pending content changed event (if any) to preserve event order
        if (event.getEventType() != AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED
                && mSendWindowContentChangedAccessibilityEvent != null
                && mSendWindowContentChangedAccessibilityEvent.mSource != null) {
            mSendWindowContentChangedAccessibilityEvent.removeCallbacksAndRun();
        }

        // Intercept accessibility focus events fired by virtual nodes to keep
        // track of accessibility focus position in such nodes.
        final int eventType = event.getEventType();
@@ -7893,11 +7901,15 @@ public final class ViewRootImpl implements ViewParent,
            final long minEventIntevalMillis =
                    ViewConfiguration.getSendRecurringAccessibilityEventsInterval();
            if (timeSinceLastMillis >= minEventIntevalMillis) {
                mSource.removeCallbacks(this);
                run();
                removeCallbacksAndRun();
            } else {
                mSource.postDelayed(this, minEventIntevalMillis - timeSinceLastMillis);
            }
        }

        public void removeCallbacksAndRun() {
            mSource.removeCallbacks(this);
            run();
        }
    }
}