From 6ae8a24fc045bc7970f2843fa9baf06aff15e22d Mon Sep 17 00:00:00 2001 From: Svetoslav Ganov Date: Wed, 10 Oct 2012 13:09:00 -0700 Subject: [PATCH] The active window for accessibility purposes can be miscomputed. 1. The active window is the one that the user touches or the one that has input focus. We recognize the user touching a window by the received accessibility hover events and the user not touching the screen by a call from the touch explorer. It is possible that the user touches window that does not have input focus and as soon as he lifts finger the active one will become the window that has input focus but now we get he hover accessibility events from the touched window which incorrectly changes the active window to be the touched one. Note that at this point the user is not touching the screen. bug:7298484 Change-Id: Ife035a798a6e68133f9220eeeabdfcd35a431b56 --- .../AccessibilityManagerService.java | 16 +++++++++++++++- .../server/accessibility/TouchExplorer.java | 1 + 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/services/java/com/android/server/accessibility/AccessibilityManagerService.java b/services/java/com/android/server/accessibility/AccessibilityManagerService.java index 3d77b3a9f4679..7c482f58f80b6 100644 --- a/services/java/com/android/server/accessibility/AccessibilityManagerService.java +++ b/services/java/com/android/server/accessibility/AccessibilityManagerService.java @@ -643,6 +643,10 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub { return mSecurityPolicy.mActiveWindowId; } + void onTouchInteractionStart() { + mSecurityPolicy.onTouchInteractionStart(); + } + void onTouchInteractionEnd() { mSecurityPolicy.onTouchInteractionEnd(); } @@ -2138,6 +2142,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub { | AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED; private int mActiveWindowId; + private boolean mTouchInteractionInProgress; private boolean canDispatchAccessibilityEvent(AccessibilityEvent event) { final int eventType = event.getEventType(); @@ -2185,12 +2190,21 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub { } } break; case AccessibilityEvent.TYPE_VIEW_HOVER_ENTER: { - mActiveWindowId = windowId; + // Do not allow delayed hover events to confuse us + // which the active window is. + if (mTouchInteractionInProgress) { + mActiveWindowId = windowId; + } } break; } } + public void onTouchInteractionStart() { + mTouchInteractionInProgress = true; + } + public void onTouchInteractionEnd() { + mTouchInteractionInProgress = false; // We want to set the active window to be current immediately // after the user has stopped touching the screen since if the // user types with the IME he should get a feedback for the diff --git a/services/java/com/android/server/accessibility/TouchExplorer.java b/services/java/com/android/server/accessibility/TouchExplorer.java index 26887767028a1..dcf873508f3f0 100644 --- a/services/java/com/android/server/accessibility/TouchExplorer.java +++ b/services/java/com/android/server/accessibility/TouchExplorer.java @@ -398,6 +398,7 @@ class TouchExplorer implements EventStreamTransformation { switch (event.getActionMasked()) { case MotionEvent.ACTION_DOWN: + mAms.onTouchInteractionStart(); // Pre-feed the motion events to the gesture detector since we // have a distance slop before getting into gesture detection // mode and not using the points within this slop significantly