Skip to content

Commit 8678347

Browse files
committed
Cannot interact with dialogs when IME is up and on not touch explored popups.
1. If the last touch explored location is within the active window we used to click on exact location if it is within the accessibility focus otherwise in the accessibility focus center. If the last touch explored location is not within the active window we used to just click there. This breaks in the case were one has touch explored at a given place in the current window and now a dialog opens *not* covering the touch explored location. If one uses swipes to move accessibility focus i.e. to traverse the dialog without touching it one cannot activate anything because the touch explorer is using the last touch explored location that is outside of the active window e.g the dialog. The solution is to clear the last touch explored location when a window opens or accessibility focus moves. If the last touch explored location is null we are clicking in the accessibility focus location. bug:6620911 2. There is a bug in the window manager that does not notify a window that its location has changed (bug:6623031). This breaks accessibility interaction with dialogs that have input because when the IME is up the dialog is moved but not notified. Now the accessibility layer gets incorrect location for the accessibility focus and the window bounds. The soluion is when the accessibility manager service calls into the remove thress to obtain some accessibility node infos it passes the window left and top which it gets from the window manager. These values are used to update the attach info window left and top so all accessibility node infos emitted from that window had correct bounds in screen coordinates. bug:6620796 Change-Id: I18914f2095c55cfc826acf5277bd94b776bda0c8
1 parent fefd489 commit 8678347

File tree

9 files changed

+347
-123
lines changed

9 files changed

+347
-123
lines changed

core/java/android/view/AccessibilityInteractionController.java

Lines changed: 101 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -138,18 +138,26 @@ private boolean isShown(View view) {
138138
}
139139

140140
public void findAccessibilityNodeInfoByAccessibilityIdClientThread(
141-
long accessibilityNodeId, int interactionId,
141+
long accessibilityNodeId, int windowLeft, int windowTop, int interactionId,
142142
IAccessibilityInteractionConnectionCallback callback, int flags, int interrogatingPid,
143143
long interrogatingTid) {
144144
Message message = mHandler.obtainMessage();
145145
message.what = PrivateHandler.MSG_FIND_ACCESSIBLITY_NODE_INFO_BY_ACCESSIBILITY_ID;
146146
message.arg1 = flags;
147+
147148
SomeArgs args = mPool.acquire();
148149
args.argi1 = AccessibilityNodeInfo.getAccessibilityViewId(accessibilityNodeId);
149150
args.argi2 = AccessibilityNodeInfo.getVirtualDescendantId(accessibilityNodeId);
150151
args.argi3 = interactionId;
151152
args.arg1 = callback;
153+
154+
SomeArgs moreArgs = mPool.acquire();
155+
moreArgs.argi1 = windowLeft;
156+
moreArgs.argi2 = windowTop;
157+
args.arg2 = moreArgs;
158+
152159
message.obj = args;
160+
153161
// If the interrogation is performed by the same thread as the main UI
154162
// thread in this process, set the message as a static reference so
155163
// after this call completes the same thread but in the interrogating
@@ -164,13 +172,21 @@ public void findAccessibilityNodeInfoByAccessibilityIdClientThread(
164172

165173
private void findAccessibilityNodeInfoByAccessibilityIdUiThread(Message message) {
166174
final int flags = message.arg1;
175+
167176
SomeArgs args = (SomeArgs) message.obj;
168177
final int accessibilityViewId = args.argi1;
169178
final int virtualDescendantId = args.argi2;
170179
final int interactionId = args.argi3;
171180
final IAccessibilityInteractionConnectionCallback callback =
172181
(IAccessibilityInteractionConnectionCallback) args.arg1;
182+
183+
SomeArgs moreArgs = (SomeArgs) args.arg2;
184+
mViewRootImpl.mAttachInfo.mActualWindowLeft = moreArgs.argi1;
185+
mViewRootImpl.mAttachInfo.mActualWindowTop = moreArgs.argi2;
186+
187+
mPool.release(moreArgs);
173188
mPool.release(args);
189+
174190
List<AccessibilityNodeInfo> infos = mTempAccessibilityNodeInfoList;
175191
infos.clear();
176192
try {
@@ -200,17 +216,26 @@ private void findAccessibilityNodeInfoByAccessibilityIdUiThread(Message message)
200216
}
201217

202218
public void findAccessibilityNodeInfoByViewIdClientThread(long accessibilityNodeId,
203-
int viewId, int interactionId, IAccessibilityInteractionConnectionCallback callback,
204-
int flags, int interrogatingPid, long interrogatingTid) {
219+
int viewId, int windowLeft, int windowTop, int interactionId,
220+
IAccessibilityInteractionConnectionCallback callback, int flags, int interrogatingPid,
221+
long interrogatingTid) {
205222
Message message = mHandler.obtainMessage();
206223
message.what = PrivateHandler.MSG_FIND_ACCESSIBLITY_NODE_INFO_BY_VIEW_ID;
207224
message.arg1 = flags;
208225
message.arg2 = AccessibilityNodeInfo.getAccessibilityViewId(accessibilityNodeId);
226+
209227
SomeArgs args = mPool.acquire();
210228
args.argi1 = viewId;
211229
args.argi2 = interactionId;
212230
args.arg1 = callback;
231+
232+
SomeArgs moreArgs = mPool.acquire();
233+
moreArgs.argi1 = windowLeft;
234+
moreArgs.argi2 = windowTop;
235+
args.arg2 = moreArgs;
236+
213237
message.obj = args;
238+
214239
// If the interrogation is performed by the same thread as the main UI
215240
// thread in this process, set the message as a static reference so
216241
// after this call completes the same thread but in the interrogating
@@ -226,12 +251,20 @@ public void findAccessibilityNodeInfoByViewIdClientThread(long accessibilityNode
226251
private void findAccessibilityNodeInfoByViewIdUiThread(Message message) {
227252
final int flags = message.arg1;
228253
final int accessibilityViewId = message.arg2;
254+
229255
SomeArgs args = (SomeArgs) message.obj;
230256
final int viewId = args.argi1;
231257
final int interactionId = args.argi2;
232258
final IAccessibilityInteractionConnectionCallback callback =
233259
(IAccessibilityInteractionConnectionCallback) args.arg1;
260+
261+
SomeArgs moreArgs = (SomeArgs) args.arg2;
262+
mViewRootImpl.mAttachInfo.mActualWindowLeft = moreArgs.argi1;
263+
mViewRootImpl.mAttachInfo.mActualWindowTop = moreArgs.argi2;
264+
265+
mPool.release(moreArgs);
234266
mPool.release(args);
267+
235268
AccessibilityNodeInfo info = null;
236269
try {
237270
if (mViewRootImpl.mView == null || mViewRootImpl.mAttachInfo == null) {
@@ -262,18 +295,27 @@ private void findAccessibilityNodeInfoByViewIdUiThread(Message message) {
262295
}
263296

264297
public void findAccessibilityNodeInfosByTextClientThread(long accessibilityNodeId,
265-
String text, int interactionId, IAccessibilityInteractionConnectionCallback callback,
266-
int flags, int interrogatingPid, long interrogatingTid) {
298+
String text, int windowLeft, int windowTop, int interactionId,
299+
IAccessibilityInteractionConnectionCallback callback, int flags,
300+
int interrogatingPid, long interrogatingTid) {
267301
Message message = mHandler.obtainMessage();
268302
message.what = PrivateHandler.MSG_FIND_ACCESSIBLITY_NODE_INFO_BY_TEXT;
269303
message.arg1 = flags;
304+
270305
SomeArgs args = mPool.acquire();
271306
args.arg1 = text;
272307
args.argi1 = AccessibilityNodeInfo.getAccessibilityViewId(accessibilityNodeId);
273308
args.argi2 = AccessibilityNodeInfo.getVirtualDescendantId(accessibilityNodeId);
274309
args.argi3 = interactionId;
275-
args.arg2 = callback;
310+
311+
SomeArgs moreArgs = mPool.acquire();
312+
moreArgs.arg1 = callback;
313+
moreArgs.argi1 = windowLeft;
314+
moreArgs.argi2 = windowTop;
315+
args.arg2 = moreArgs;
316+
276317
message.obj = args;
318+
277319
// If the interrogation is performed by the same thread as the main UI
278320
// thread in this process, set the message as a static reference so
279321
// after this call completes the same thread but in the interrogating
@@ -288,14 +330,22 @@ public void findAccessibilityNodeInfosByTextClientThread(long accessibilityNodeI
288330

289331
private void findAccessibilityNodeInfosByTextUiThread(Message message) {
290332
final int flags = message.arg1;
333+
291334
SomeArgs args = (SomeArgs) message.obj;
292335
final String text = (String) args.arg1;
293336
final int accessibilityViewId = args.argi1;
294337
final int virtualDescendantId = args.argi2;
295338
final int interactionId = args.argi3;
339+
340+
SomeArgs moreArgs = (SomeArgs) args.arg2;
296341
final IAccessibilityInteractionConnectionCallback callback =
297-
(IAccessibilityInteractionConnectionCallback) args.arg2;
342+
(IAccessibilityInteractionConnectionCallback) moreArgs.arg1;
343+
mViewRootImpl.mAttachInfo.mActualWindowLeft = moreArgs.argi1;
344+
mViewRootImpl.mAttachInfo.mActualWindowTop = moreArgs.argi2;
345+
346+
mPool.release(moreArgs);
298347
mPool.release(args);
348+
299349
List<AccessibilityNodeInfo> infos = null;
300350
try {
301351
if (mViewRootImpl.mView == null || mViewRootImpl.mAttachInfo == null) {
@@ -353,19 +403,27 @@ private void findAccessibilityNodeInfosByTextUiThread(Message message) {
353403
}
354404
}
355405

356-
public void findFocusClientThread(long accessibilityNodeId, int interactionId, int focusType,
357-
IAccessibilityInteractionConnectionCallback callback, int flags, int interogatingPid,
358-
long interrogatingTid) {
406+
public void findFocusClientThread(long accessibilityNodeId, int focusType, int windowLeft,
407+
int windowTop, int interactionId, IAccessibilityInteractionConnectionCallback callback,
408+
int flags, int interogatingPid, long interrogatingTid) {
359409
Message message = mHandler.obtainMessage();
360410
message.what = PrivateHandler.MSG_FIND_FOCUS;
361411
message.arg1 = flags;
362412
message.arg2 = focusType;
413+
363414
SomeArgs args = mPool.acquire();
364415
args.argi1 = interactionId;
365416
args.argi2 = AccessibilityNodeInfo.getAccessibilityViewId(accessibilityNodeId);
366417
args.argi3 = AccessibilityNodeInfo.getVirtualDescendantId(accessibilityNodeId);
367418
args.arg1 = callback;
419+
420+
SomeArgs moreArgs = mPool.acquire();
421+
moreArgs.argi1 = windowLeft;
422+
moreArgs.argi2 = windowTop;
423+
args.arg2 = moreArgs;
424+
368425
message.obj = args;
426+
369427
// If the interrogation is performed by the same thread as the main UI
370428
// thread in this process, set the message as a static reference so
371429
// after this call completes the same thread but in the interrogating
@@ -381,13 +439,21 @@ public void findFocusClientThread(long accessibilityNodeId, int interactionId, i
381439
private void findFocusUiThread(Message message) {
382440
final int flags = message.arg1;
383441
final int focusType = message.arg2;
442+
384443
SomeArgs args = (SomeArgs) message.obj;
385444
final int interactionId = args.argi1;
386445
final int accessibilityViewId = args.argi2;
387446
final int virtualDescendantId = args.argi3;
388447
final IAccessibilityInteractionConnectionCallback callback =
389448
(IAccessibilityInteractionConnectionCallback) args.arg1;
449+
450+
SomeArgs moreArgs = (SomeArgs) args.arg2;
451+
mViewRootImpl.mAttachInfo.mActualWindowLeft = moreArgs.argi1;
452+
mViewRootImpl.mAttachInfo.mActualWindowTop = moreArgs.argi2;
453+
454+
mPool.release(moreArgs);
390455
mPool.release(args);
456+
391457
AccessibilityNodeInfo focused = null;
392458
try {
393459
if (mViewRootImpl.mView == null || mViewRootImpl.mAttachInfo == null) {
@@ -440,19 +506,27 @@ private void findFocusUiThread(Message message) {
440506
}
441507
}
442508

443-
public void focusSearchClientThread(long accessibilityNodeId, int interactionId, int direction,
444-
IAccessibilityInteractionConnectionCallback callback, int flags, int interogatingPid,
445-
long interrogatingTid) {
509+
public void focusSearchClientThread(long accessibilityNodeId, int direction, int windowLeft,
510+
int windowTop, int interactionId, IAccessibilityInteractionConnectionCallback callback,
511+
int flags, int interogatingPid, long interrogatingTid) {
446512
Message message = mHandler.obtainMessage();
447513
message.what = PrivateHandler.MSG_FOCUS_SEARCH;
448514
message.arg1 = flags;
449515
message.arg2 = AccessibilityNodeInfo.getAccessibilityViewId(accessibilityNodeId);
516+
450517
SomeArgs args = mPool.acquire();
451518
args.argi1 = AccessibilityNodeInfo.getVirtualDescendantId(accessibilityNodeId);
452519
args.argi2 = direction;
453520
args.argi3 = interactionId;
454521
args.arg1 = callback;
522+
523+
SomeArgs moreArgs = mPool.acquire();
524+
moreArgs.argi1 = windowLeft;
525+
moreArgs.argi2 = windowTop;
526+
args.arg2 = moreArgs;
527+
455528
message.obj = args;
529+
456530
// If the interrogation is performed by the same thread as the main UI
457531
// thread in this process, set the message as a static reference so
458532
// after this call completes the same thread but in the interrogating
@@ -468,13 +542,21 @@ public void focusSearchClientThread(long accessibilityNodeId, int interactionId,
468542
private void focusSearchUiThread(Message message) {
469543
final int flags = message.arg1;
470544
final int accessibilityViewId = message.arg2;
545+
471546
SomeArgs args = (SomeArgs) message.obj;
472547
final int virtualDescendantId = args.argi1;
473548
final int direction = args.argi2;
474549
final int interactionId = args.argi3;
475550
final IAccessibilityInteractionConnectionCallback callback =
476551
(IAccessibilityInteractionConnectionCallback) args.arg1;
552+
553+
SomeArgs moreArgs = (SomeArgs) args.arg2;
554+
mViewRootImpl.mAttachInfo.mActualWindowLeft = moreArgs.argi1;
555+
mViewRootImpl.mAttachInfo.mActualWindowTop = moreArgs.argi2;
556+
557+
mPool.release(moreArgs);
477558
mPool.release(args);
559+
478560
AccessibilityNodeInfo next = null;
479561
try {
480562
if (mViewRootImpl.mView == null || mViewRootImpl.mAttachInfo == null) {
@@ -541,13 +623,16 @@ public void performAccessibilityActionClientThread(long accessibilityNodeId, int
541623
message.what = PrivateHandler.MSG_PERFORM_ACCESSIBILITY_ACTION;
542624
message.arg1 = flags;
543625
message.arg2 = AccessibilityNodeInfo.getAccessibilityViewId(accessibilityNodeId);
626+
544627
SomeArgs args = mPool.acquire();
545628
args.argi1 = AccessibilityNodeInfo.getVirtualDescendantId(accessibilityNodeId);
546629
args.argi2 = action;
547630
args.argi3 = interactionId;
548631
args.arg1 = callback;
549632
args.arg2 = arguments;
633+
550634
message.obj = args;
635+
551636
// If the interrogation is performed by the same thread as the main UI
552637
// thread in this process, set the message as a static reference so
553638
// after this call completes the same thread but in the interrogating
@@ -563,14 +648,17 @@ public void performAccessibilityActionClientThread(long accessibilityNodeId, int
563648
private void perfromAccessibilityActionUiThread(Message message) {
564649
final int flags = message.arg1;
565650
final int accessibilityViewId = message.arg2;
651+
566652
SomeArgs args = (SomeArgs) message.obj;
567653
final int virtualDescendantId = args.argi1;
568654
final int action = args.argi2;
569655
final int interactionId = args.argi3;
570656
final IAccessibilityInteractionConnectionCallback callback =
571657
(IAccessibilityInteractionConnectionCallback) args.arg1;
572658
Bundle arguments = (Bundle) args.arg2;
659+
573660
mPool.release(args);
661+
574662
boolean succeeded = false;
575663
try {
576664
if (mViewRootImpl.mView == null || mViewRootImpl.mAttachInfo == null) {

core/java/android/view/View.java

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3609,6 +3609,7 @@ public void onClick(View v) {
36093609
case R.styleable.View_importantForAccessibility:
36103610
setImportantForAccessibility(a.getInt(attr,
36113611
IMPORTANT_FOR_ACCESSIBILITY_DEFAULT));
3612+
break;
36123613
}
36133614
}
36143615

@@ -4901,6 +4902,30 @@ void onInitializeAccessibilityNodeInfoInternal(AccessibilityNodeInfo info) {
49014902
}
49024903
}
49034904

4905+
/**
4906+
* Returns the delta between the actual and last reported window left.
4907+
*
4908+
* @hide
4909+
*/
4910+
public int getActualAndReportedWindowLeftDelta() {
4911+
if (mAttachInfo != null) {
4912+
return mAttachInfo.mActualWindowLeft - mAttachInfo.mWindowLeft;
4913+
}
4914+
return 0;
4915+
}
4916+
4917+
/**
4918+
* Returns the delta between the actual and last reported window top.
4919+
*
4920+
* @hide
4921+
*/
4922+
public int getActualAndReportedWindowTopDelta() {
4923+
if (mAttachInfo != null) {
4924+
return mAttachInfo.mActualWindowTop - mAttachInfo.mWindowTop;
4925+
}
4926+
return 0;
4927+
}
4928+
49044929
/**
49054930
* Computes whether this view is visible to the user. Such a view is
49064931
* attached, visible, all its predecessors are visible, it is not clipped
@@ -17306,6 +17331,20 @@ public void setPooled(boolean isPooled) {
1730617331
*/
1730717332
int mWindowTop;
1730817333

17334+
/**
17335+
* Left actual position of this view's window.
17336+
*
17337+
* TODO: This is a workaround for 6623031. Remove when fixed.
17338+
*/
17339+
int mActualWindowLeft;
17340+
17341+
/**
17342+
* Actual top position of this view's window.
17343+
*
17344+
* TODO: This is a workaround for 6623031. Remove when fixed.
17345+
*/
17346+
int mActualWindowTop;
17347+
1730917348
/**
1731017349
* Indicates whether views need to use 32-bit drawing caches
1731117350
*/

0 commit comments

Comments
 (0)