Skip to content

Commit 5d043ce

Browse files
committed
Active window not updated window not updated properly.
1. Accessibility allows querying only of the active window. The active window is the one that has input focus or the one the user is touching. Hence, if the user is touching a window that does not have input focus this window is the active one and as soon as the user stops touching it the active window becomes the one that has input focus. Currently the active window is not updated properly when the user lifts his finger. This leads to a scenario of traversal actions sent to the wrong window and the user being stuck. The reason is that the last touch explored event that is used to determine where to click is cleared when accessibility focus moves but this event is also used to determine when to send the hover exit and touch exploration gesture end events. The problem is that the last hover event is cleared before it is used for sending the right exit events, thus the event stream is inconsistent and the accessibility manager service relies on this stream to update the active window. Now we are keeping separate copies of the last touch event - one for clicking and one for determining the which events to inject to ensure consistent stream. bug:6666041 Change-Id: Ie9961e562a42ef8a9463afacfff2246adcb66303
1 parent 95068e5 commit 5d043ce

File tree

1 file changed

+21
-5
lines changed

1 file changed

+21
-5
lines changed

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

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -312,9 +312,9 @@ public void onAccessibilityEvent(AccessibilityEvent event) {
312312
switch (eventType) {
313313
case AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED:
314314
case AccessibilityEvent.TYPE_VIEW_ACCESSIBILITY_FOCUSED: {
315-
if (mInjectedPointerTracker.mLastInjectedHoverEvent != null) {
316-
mInjectedPointerTracker.mLastInjectedHoverEvent.recycle();
317-
mInjectedPointerTracker.mLastInjectedHoverEvent = null;
315+
if (mInjectedPointerTracker.mLastInjectedHoverEventForClick != null) {
316+
mInjectedPointerTracker.mLastInjectedHoverEventForClick.recycle();
317+
mInjectedPointerTracker.mLastInjectedHoverEventForClick = null;
318318
}
319319
mLastTouchedWindowId = -1;
320320
} break;
@@ -1077,7 +1077,8 @@ public void onDoubleTap(MotionEvent secondTapUp, int policyFlags) {
10771077
final int pointerId = secondTapUp.getPointerId(secondTapUp.getActionIndex());
10781078
final int pointerIndex = secondTapUp.findPointerIndex(pointerId);
10791079

1080-
MotionEvent lastExploreEvent = mInjectedPointerTracker.getLastInjectedHoverEvent();
1080+
MotionEvent lastExploreEvent =
1081+
mInjectedPointerTracker.getLastInjectedHoverEventForClick();
10811082
if (lastExploreEvent == null) {
10821083
// No last touch explored event but there is accessibility focus in
10831084
// the active window. We click in the middle of the focus bounds.
@@ -1328,7 +1329,8 @@ public void run() {
13281329
final int pointerId = mEvent.getPointerId(mEvent.getActionIndex());
13291330
final int pointerIndex = mEvent.findPointerIndex(pointerId);
13301331

1331-
MotionEvent lastExploreEvent = mInjectedPointerTracker.getLastInjectedHoverEvent();
1332+
MotionEvent lastExploreEvent =
1333+
mInjectedPointerTracker.getLastInjectedHoverEventForClick();
13321334
if (lastExploreEvent == null) {
13331335
// No last touch explored event but there is accessibility focus in
13341336
// the active window. We click in the middle of the focus bounds.
@@ -1482,6 +1484,9 @@ class InjectedPointerTracker {
14821484
// The last injected hover event.
14831485
private MotionEvent mLastInjectedHoverEvent;
14841486

1487+
// The last injected hover event used for performing clicks.
1488+
private MotionEvent mLastInjectedHoverEventForClick;
1489+
14851490
/**
14861491
* Processes an injected {@link MotionEvent} event.
14871492
*
@@ -1513,6 +1518,10 @@ public void onMotionEvent(MotionEvent event) {
15131518
mLastInjectedHoverEvent.recycle();
15141519
}
15151520
mLastInjectedHoverEvent = MotionEvent.obtain(event);
1521+
if (mLastInjectedHoverEventForClick != null) {
1522+
mLastInjectedHoverEventForClick.recycle();
1523+
}
1524+
mLastInjectedHoverEventForClick = MotionEvent.obtain(event);
15161525
} break;
15171526
}
15181527
if (DEBUG) {
@@ -1566,6 +1575,13 @@ public MotionEvent getLastInjectedHoverEvent() {
15661575
return mLastInjectedHoverEvent;
15671576
}
15681577

1578+
/**
1579+
* @return The the last injected hover event.
1580+
*/
1581+
public MotionEvent getLastInjectedHoverEventForClick() {
1582+
return mLastInjectedHoverEventForClick;
1583+
}
1584+
15691585
@Override
15701586
public String toString() {
15711587
StringBuilder builder = new StringBuilder();

0 commit comments

Comments
 (0)