Merge "Refactor embedded window handling in AccessibilityWindowManager" into main
diff --git a/services/accessibility/java/com/android/server/accessibility/AccessibilityWindowManager.java b/services/accessibility/java/com/android/server/accessibility/AccessibilityWindowManager.java
index 78f07e4..a11cf8c 100644
--- a/services/accessibility/java/com/android/server/accessibility/AccessibilityWindowManager.java
+++ b/services/accessibility/java/com/android/server/accessibility/AccessibilityWindowManager.java
@@ -818,7 +818,7 @@
}
// Don't need to add the embedded hierarchy windows into the accessibility windows list.
- if (mHostEmbeddedMap.size() > 0 && isEmbeddedHierarchyWindowsLocked(windowId)) {
+ if (isEmbeddedHierarchyWindowsLocked(windowId)) {
return null;
}
final AccessibilityWindowInfo reportedWindow = AccessibilityWindowInfo.obtain();
@@ -866,21 +866,6 @@
return reportedWindow;
}
- private boolean isEmbeddedHierarchyWindowsLocked(int windowId) {
- final IBinder leashToken = mWindowIdMap.get(windowId);
- if (leashToken == null) {
- return false;
- }
-
- for (int i = 0; i < mHostEmbeddedMap.size(); i++) {
- if (mHostEmbeddedMap.keyAt(i).equals(leashToken)) {
- return true;
- }
- }
-
- return false;
- }
-
private int getTypeForWindowManagerWindowType(int windowType) {
switch (windowType) {
case WindowManager.LayoutParams.TYPE_APPLICATION:
@@ -1490,7 +1475,7 @@
* @return The windowId of the parent window, or self if no parent exists
*/
public int resolveParentWindowIdLocked(int windowId) {
- final IBinder token = getTokenLocked(windowId);
+ final IBinder token = getLeashTokenLocked(windowId);
if (token == null) {
return windowId;
}
@@ -2095,7 +2080,7 @@
* @param windowId The windowID.
* @return The token, or {@code NULL} if this windowID doesn't exist
*/
- IBinder getTokenLocked(int windowId) {
+ IBinder getLeashTokenLocked(int windowId) {
return mWindowIdMap.get(windowId);
}
@@ -2124,6 +2109,23 @@
}
/**
+ * Checks if the window is embedded into another window so that the window should be excluded
+ * from the exposed accessibility windows, and the node tree should be embedded in the host.
+ */
+ boolean isEmbeddedHierarchyWindowsLocked(int windowId) {
+ if (mHostEmbeddedMap.size() == 0) {
+ return false;
+ }
+
+ final IBinder leashToken = getLeashTokenLocked(windowId);
+ if (leashToken == null) {
+ return false;
+ }
+
+ return mHostEmbeddedMap.containsKey(leashToken);
+ }
+
+ /**
* Checks if the window belongs to a proxy display and if so clears the focused window id.
* @param focusClearedWindowId the cleared window id.
* @return true if an observer is proxy-ed and has cleared its focused window id.
diff --git a/services/tests/servicestests/src/com/android/server/accessibility/AccessibilityWindowManagerTest.java b/services/tests/servicestests/src/com/android/server/accessibility/AccessibilityWindowManagerTest.java
index 2dfabd0..b12d6da 100644
--- a/services/tests/servicestests/src/com/android/server/accessibility/AccessibilityWindowManagerTest.java
+++ b/services/tests/servicestests/src/com/android/server/accessibility/AccessibilityWindowManagerTest.java
@@ -893,13 +893,13 @@
@Test
public void getTokenLocked_windowIsRegistered_shouldReturnToken() {
- final IBinder token = mA11yWindowManager.getTokenLocked(HOST_WINDOW_ID);
+ final IBinder token = mA11yWindowManager.getLeashTokenLocked(HOST_WINDOW_ID);
assertEquals(token, mMockHostToken);
}
@Test
public void getTokenLocked_windowIsNotRegistered_shouldReturnNull() {
- final IBinder token = mA11yWindowManager.getTokenLocked(OTHER_WINDOW_ID);
+ final IBinder token = mA11yWindowManager.getLeashTokenLocked(OTHER_WINDOW_ID);
assertNull(token);
}