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

Commit 58fd9f8d authored by Svetoslav Ganov's avatar Svetoslav Ganov
Browse files

Events for window's content change should be dispatched only for the active window.

1. Accessibility events for changes in the content of a given window, such as
   click, focus, etc. are dispatched to clients only if they come from the
   active window.

   Events for changes in the state of a window, such as window got input focus
   or a notification appeared, are always dispatched. The notification events
   do not contain source, so a client cannot introspect the notification area
   (unless the user explicitly touches it which generates hove events). The
   events for a window getting input focus change the active window so they
   have to be dispatched.

   Events that are a result of the user touching the screen, such as hover
   enter, first tocuh, etc. should always be dispatched.

bug:7282006

Change-Id: I96b79189f8571285175d9660a22394cc84f39559
parent 26884df7
Loading
Loading
Loading
Loading
+24 −3
Original line number Diff line number Diff line
@@ -2134,9 +2134,30 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub {
        private int mActiveWindowId;

        private boolean canDispatchAccessibilityEvent(AccessibilityEvent event) {
            // Send window changed event only for the retrieval allowing window.
            return (event.getEventType() != AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED
                    || event.getWindowId() == mActiveWindowId);
            final int eventType = event.getEventType();
            switch (eventType) {
                // All events that are for changes in a global window
                // state should *always* be dispatched.
                case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED:
                case AccessibilityEvent.TYPE_NOTIFICATION_STATE_CHANGED:
                // All events generated by the user touching the
                // screen should *always* be dispatched.
                case AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_START:
                case AccessibilityEvent.TYPE_TOUCH_EXPLORATION_GESTURE_END:
                case AccessibilityEvent.TYPE_GESTURE_DETECTION_START:
                case AccessibilityEvent.TYPE_GESTURE_DETECTION_END:
                case AccessibilityEvent.TYPE_TOUCH_INTERACTION_START:
                case AccessibilityEvent.TYPE_TOUCH_INTERACTION_END:
                // These will change the active window, so dispatch.
                case AccessibilityEvent.TYPE_VIEW_HOVER_ENTER:
                case AccessibilityEvent.TYPE_VIEW_HOVER_EXIT: {
                    return true;
                }
                // All events for changes in window content should be
                // dispatched *only* if this window is the active one.
                default:
                    return event.getWindowId() == mActiveWindowId;
            }
        }

        public void updateEventSourceLocked(AccessibilityEvent event) {