Skip to content

Commit f772cba

Browse files
committed
Accessibility active window not updated on time.
1. The active window is the one the user is touching or the one that has input focus. It has to be made current immediately after the user has stopped touching the screen because if the user types with the IME he should get a feedback for the letter typed in the text view which is in the input focused window. Note that we always deliver hover accessibility events (they are a result of user touching the screen) so change of the active window before all hover accessibility events from the touched window are delivered is fine. bug:7296890 Change-Id: I1ae87c8419e2f19bd8eb68de084c7117c66894bc
1 parent 7ef38ea commit f772cba

File tree

2 files changed

+22
-5
lines changed

2 files changed

+22
-5
lines changed

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

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

646+
void onTouchInteractionEnd() {
647+
mSecurityPolicy.onTouchInteractionEnd();
648+
}
649+
646650
private void switchUser(int userId) {
647651
synchronized (mLock) {
648652
// The user switched so we do not need to restore the current user
@@ -2178,16 +2182,24 @@ public void updateActiveWindow(int windowId, int eventType) {
21782182
mActiveWindowId = windowId;
21792183
}
21802184
} break;
2181-
case AccessibilityEvent.TYPE_VIEW_HOVER_ENTER:
2182-
case AccessibilityEvent.TYPE_VIEW_HOVER_EXIT: {
2185+
case AccessibilityEvent.TYPE_VIEW_HOVER_ENTER: {
21832186
mActiveWindowId = windowId;
21842187
} break;
2185-
case AccessibilityEvent.TYPE_TOUCH_INTERACTION_END: {
2186-
mActiveWindowId = getFocusedWindowId();
2187-
} break;
21882188
}
21892189
}
21902190

2191+
public void onTouchInteractionEnd() {
2192+
// We want to set the active window to be current immediately
2193+
// after the user has stopped touching the screen since if the
2194+
// user types with the IME he should get a feedback for the
2195+
// letter typed in the text view which is in the input focused
2196+
// window. Note that we always deliver hover accessibility events
2197+
// (they are a result of user touching the screen) so change of
2198+
// the active window before all hover accessibility events from
2199+
// the touched window are delivered is fine.
2200+
mActiveWindowId = getFocusedWindowId();
2201+
}
2202+
21912203
public int getRetrievalAllowingWindowLocked() {
21922204
return mActiveWindowId;
21932205
}

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

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -304,6 +304,7 @@ private void clear(MotionEvent event, int policyFlags) {
304304
mNext.clear();
305305
}
306306
mTouchExplorationInProgress = false;
307+
mAms.onTouchInteractionEnd();
307308
}
308309

309310
@Override
@@ -615,6 +616,7 @@ private void handleMotionEventStateTouchExploring(MotionEvent event, MotionEvent
615616
}
616617
} break;
617618
case MotionEvent.ACTION_UP:
619+
mAms.onTouchInteractionEnd();
618620
// We know that we do not need the pre-fed gesture points are not
619621
// needed anymore since the last pointer just went up.
620622
mStrokeBuffer.clear();
@@ -737,6 +739,7 @@ private void handleMotionEventStateDragging(MotionEvent event, int policyFlags)
737739
}
738740
} break;
739741
case MotionEvent.ACTION_UP: {
742+
mAms.onTouchInteractionEnd();
740743
// Announce the end of a new touch interaction.
741744
sendAccessibilityEvent(
742745
AccessibilityEvent.TYPE_TOUCH_INTERACTION_END);
@@ -782,6 +785,7 @@ private void handleMotionEventStateDelegating(MotionEvent event, int policyFlags
782785
AccessibilityEvent.TYPE_TOUCH_INTERACTION_END);
783786
//$FALL-THROUGH$
784787
case MotionEvent.ACTION_POINTER_UP: {
788+
mAms.onTouchInteractionEnd();
785789
mLongPressingPointerId = -1;
786790
mLongPressingPointerDeltaX = 0;
787791
mLongPressingPointerDeltaY = 0;
@@ -819,6 +823,7 @@ private void handleMotionEventGestureDetecting(MotionEvent event, int policyFlag
819823
}
820824
} break;
821825
case MotionEvent.ACTION_UP: {
826+
mAms.onTouchInteractionEnd();
822827
// Announce the end of gesture recognition.
823828
sendAccessibilityEvent(
824829
AccessibilityEvent.TYPE_GESTURE_DETECTION_END);

0 commit comments

Comments
 (0)