@@ -2134,9 +2134,30 @@ final class SecurityPolicy {
21342134 private int mActiveWindowId ;
21352135
21362136 private boolean canDispatchAccessibilityEvent (AccessibilityEvent event ) {
2137- // Send window changed event only for the retrieval allowing window.
2138- return (event .getEventType () != AccessibilityEvent .TYPE_WINDOW_CONTENT_CHANGED
2139- || event .getWindowId () == mActiveWindowId );
2137+ final int eventType = event .getEventType ();
2138+ switch (eventType ) {
2139+ // All events that are for changes in a global window
2140+ // state should *always* be dispatched.
2141+ case AccessibilityEvent .TYPE_WINDOW_STATE_CHANGED :
2142+ case AccessibilityEvent .TYPE_NOTIFICATION_STATE_CHANGED :
2143+ // All events generated by the user touching the
2144+ // screen should *always* be dispatched.
2145+ case AccessibilityEvent .TYPE_TOUCH_EXPLORATION_GESTURE_START :
2146+ case AccessibilityEvent .TYPE_TOUCH_EXPLORATION_GESTURE_END :
2147+ case AccessibilityEvent .TYPE_GESTURE_DETECTION_START :
2148+ case AccessibilityEvent .TYPE_GESTURE_DETECTION_END :
2149+ case AccessibilityEvent .TYPE_TOUCH_INTERACTION_START :
2150+ case AccessibilityEvent .TYPE_TOUCH_INTERACTION_END :
2151+ // These will change the active window, so dispatch.
2152+ case AccessibilityEvent .TYPE_VIEW_HOVER_ENTER :
2153+ case AccessibilityEvent .TYPE_VIEW_HOVER_EXIT : {
2154+ return true ;
2155+ }
2156+ // All events for changes in window content should be
2157+ // dispatched *only* if this window is the active one.
2158+ default :
2159+ return event .getWindowId () == mActiveWindowId ;
2160+ }
21402161 }
21412162
21422163 public void updateEventSourceLocked (AccessibilityEvent event ) {
0 commit comments