Skip to content

Commit 9ea6343

Browse files
sganovAndroid (Google) Code Review
authored andcommitted
Merge "The active window for accessibility purposes can be miscomputed." into jb-mr1-dev
2 parents fa5bc08 + 6ae8a24 commit 9ea6343

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)