Skip to content

Commit 385d9f2

Browse files
committed
Cannot click on the last touch explored auto-completion item.
1. When typing into an auto completion edit field a list of completions pops up and if the user touch explores the list and tries to double tap to select the touched completion the latter is not selected. The auto completion is a popup that does not take input focus and is overlaid on top of the window that has input focus. The touch explorer was clicking on the location of the accessibility focus if the last touch explored location is within the bounds of the active window. In this case this was the window with the edit text into which the user is typing. The check performed by the touch explorer was missing the case when the last touch explored location was within the bounds of the active window but it actually was deloverd to another overlaid window. Now we are poking on the accessibility focus location if the last explored location is within the active window and was delivered to it. bug:6629535 Change-Id: Ie66d5bb81ab021f2bb0414339b7de26d96826191
1 parent 8678347 commit 385d9f2

File tree

2 files changed

+30
-14
lines changed

2 files changed

+30
-14
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -588,6 +588,10 @@ void getActiveWindowBounds(Rect outBounds) {
588588
}
589589
}
590590

591+
int getActiveWindowId() {
592+
return mSecurityPolicy.mActiveWindowId;
593+
}
594+
591595
private Service getQueryBridge() {
592596
if (mQueryBridge == null) {
593597
AccessibilityServiceInfo info = new AccessibilityServiceInfo();

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

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -190,6 +190,9 @@ public class TouchExplorer {
190190
// The long pressing pointer Y if coordinate remapping is needed.
191191
private int mLongPressingPointerDeltaY;
192192

193+
// The id of the last touch explored window.
194+
private int mLastTouchedWindowId;
195+
193196
/**
194197
* Creates a new instance.
195198
*
@@ -305,6 +308,11 @@ public void onAccessibilityEvent(AccessibilityEvent event) {
305308
mInjectedPointerTracker.mLastInjectedHoverEvent.recycle();
306309
mInjectedPointerTracker.mLastInjectedHoverEvent = null;
307310
}
311+
mLastTouchedWindowId = -1;
312+
} break;
313+
case AccessibilityEvent.TYPE_VIEW_HOVER_ENTER:
314+
case AccessibilityEvent.TYPE_VIEW_HOVER_EXIT: {
315+
mLastTouchedWindowId = event.getWindowId();
308316
} break;
309317
}
310318
}
@@ -1078,13 +1086,15 @@ public void onDoubleTap(MotionEvent secondTapUp, int policyFlags) {
10781086
clickLocationX = (int) lastExploreEvent.getX(lastExplorePointerIndex);
10791087
clickLocationY = (int) lastExploreEvent.getY(lastExplorePointerIndex);
10801088
Rect activeWindowBounds = mTempRect;
1081-
mAms.getActiveWindowBounds(activeWindowBounds);
1082-
if (activeWindowBounds.contains(clickLocationX, clickLocationY)) {
1083-
Rect focusBounds = mTempRect;
1084-
if (mAms.getAccessibilityFocusBoundsInActiveWindow(focusBounds)) {
1085-
if (!focusBounds.contains(clickLocationX, clickLocationY)) {
1086-
clickLocationX = focusBounds.centerX();
1087-
clickLocationY = focusBounds.centerY();
1089+
if (mLastTouchedWindowId == mAms.getActiveWindowId()) {
1090+
mAms.getActiveWindowBounds(activeWindowBounds);
1091+
if (activeWindowBounds.contains(clickLocationX, clickLocationY)) {
1092+
Rect focusBounds = mTempRect;
1093+
if (mAms.getAccessibilityFocusBoundsInActiveWindow(focusBounds)) {
1094+
if (!focusBounds.contains(clickLocationX, clickLocationY)) {
1095+
clickLocationX = focusBounds.centerX();
1096+
clickLocationY = focusBounds.centerY();
1097+
}
10881098
}
10891099
}
10901100
}
@@ -1308,13 +1318,15 @@ public void run() {
13081318
clickLocationX = (int) lastExploreEvent.getX(lastExplorePointerIndex);
13091319
clickLocationY = (int) lastExploreEvent.getY(lastExplorePointerIndex);
13101320
Rect activeWindowBounds = mTempRect;
1311-
mAms.getActiveWindowBounds(activeWindowBounds);
1312-
if (activeWindowBounds.contains(clickLocationX, clickLocationY)) {
1313-
Rect focusBounds = mTempRect;
1314-
if (mAms.getAccessibilityFocusBoundsInActiveWindow(focusBounds)) {
1315-
if (!focusBounds.contains(clickLocationX, clickLocationY)) {
1316-
clickLocationX = focusBounds.centerX();
1317-
clickLocationY = focusBounds.centerY();
1321+
if (mLastTouchedWindowId == mAms.getActiveWindowId()) {
1322+
mAms.getActiveWindowBounds(activeWindowBounds);
1323+
if (activeWindowBounds.contains(clickLocationX, clickLocationY)) {
1324+
Rect focusBounds = mTempRect;
1325+
if (mAms.getAccessibilityFocusBoundsInActiveWindow(focusBounds)) {
1326+
if (!focusBounds.contains(clickLocationX, clickLocationY)) {
1327+
clickLocationX = focusBounds.centerX();
1328+
clickLocationY = focusBounds.centerY();
1329+
}
13181330
}
13191331
}
13201332
}

0 commit comments

Comments
 (0)