From 58fd9f8d6ad6bf1975e834f1a69e68673db9a452 Mon Sep 17 00:00:00 2001 From: Svetoslav Ganov Date: Wed, 3 Oct 2012 18:10:27 -0700 Subject: [PATCH] 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 --- .../AccessibilityManagerService.java | 27 ++++++++++++++++--- 1 file changed, 24 insertions(+), 3 deletions(-) diff --git a/services/java/com/android/server/accessibility/AccessibilityManagerService.java b/services/java/com/android/server/accessibility/AccessibilityManagerService.java index d23e5714804ba..5e9e223dacb87 100644 --- a/services/java/com/android/server/accessibility/AccessibilityManagerService.java +++ b/services/java/com/android/server/accessibility/AccessibilityManagerService.java @@ -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) {