Skip to content

Commit 6ae8a24

Browse files
committed
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
1 parent 2514456 commit 6ae8a24

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

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

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,10 @@ int getActiveWindowId() {
643643
return mSecurityPolicy.mActiveWindowId;
644644
}
645645

646+
void onTouchInteractionStart() {
647+
mSecurityPolicy.onTouchInteractionStart();
648+
}
649+
646650
void onTouchInteractionEnd() {
647651
mSecurityPolicy.onTouchInteractionEnd();
648652
}
@@ -2138,6 +2142,7 @@ final class SecurityPolicy {
21382142
| AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUS_CLEARED;
21392143

21402144
private int mActiveWindowId;
2145+
private boolean mTouchInteractionInProgress;
21412146

21422147
private boolean canDispatchAccessibilityEvent(AccessibilityEvent event) {
21432148
final int eventType = event.getEventType();
@@ -2185,12 +2190,21 @@ public void updateActiveWindow(int windowId, int eventType) {
21852190
}
21862191
} break;
21872192
case AccessibilityEvent.TYPE_VIEW_HOVER_ENTER: {
2188-
mActiveWindowId = windowId;
2193+
// Do not allow delayed hover events to confuse us
2194+
// which the active window is.
2195+
if (mTouchInteractionInProgress) {
2196+
mActiveWindowId = windowId;
2197+
}
21892198
} break;
21902199
}
21912200
}
21922201

2202+
public void onTouchInteractionStart() {
2203+
mTouchInteractionInProgress = true;
2204+
}
2205+
21932206
public void onTouchInteractionEnd() {
2207+
mTouchInteractionInProgress = false;
21942208
// We want to set the active window to be current immediately
21952209
// after the user has stopped touching the screen since if the
21962210
// user types with the IME he should get a feedback for the

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -398,6 +398,7 @@ private void handleMotionEventStateTouchExploring(MotionEvent event, MotionEvent
398398

399399
switch (event.getActionMasked()) {
400400
case MotionEvent.ACTION_DOWN:
401+
mAms.onTouchInteractionStart();
401402
// Pre-feed the motion events to the gesture detector since we
402403
// have a distance slop before getting into gesture detection
403404
// mode and not using the points within this slop significantly

0 commit comments

Comments
 (0)