Skip to content

Commit 58fd9f8

Browse files
committed
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
1 parent 26884df commit 58fd9f8

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

services/java/com/android/server/accessibility/AccessibilityManagerService.java

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)