Using windowId from A11yWindowInfo instead

AccessibilityManagerService#getWindowBounds would return null if
using the windowId comes from the embedded hierarchy, and
EventDispatch#computeClickLocation will return CLICK_LOCATION_NONE
and can't perform long-click action. The fix try to use
AccessibilityWindowInfo's windowId to get correct window token to
get window bounds.

Bug: 161857059
Test: a11y CTS & unit tests
Change-Id: I5a978177352e973f06a856826a43910a9b655b29
This commit is contained in:
lucychang
2020-10-07 12:34:19 +08:00
committed by Lucy Chang
parent 168d7918b8
commit 12e1ea6a42

View File

@@ -941,10 +941,19 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
if (resolvedUserId != mCurrentUserId) {
return null;
}
if (mA11yWindowManager.findA11yWindowInfoByIdLocked(windowId) == null) {
final AccessibilityWindowInfo accessibilityWindowInfo = mA11yWindowManager
.findA11yWindowInfoByIdLocked(windowId);
if (accessibilityWindowInfo == null) {
return null;
}
return mA11yWindowManager.getWindowTokenForUserAndWindowIdLocked(userId, windowId);
// We use AccessibilityWindowInfo#getId instead of windowId. When the windowId comes
// from an embedded hierarchy, the system can't find correct window token because
// embedded hierarchy doesn't have windowInfo. Calling
// AccessibilityWindowManager#findA11yWindowInfoByIdLocked can look for its parent's
// windowInfo, so it is safer to use AccessibilityWindowInfo#getId
// to get window token to find real window.
return mA11yWindowManager.getWindowTokenForUserAndWindowIdLocked(userId,
accessibilityWindowInfo.getId());
}
}