[DO NOT MERGE] Eliminate duplicate layers in A11yService#getWindows()
Fixes: 73904014
Test: using TestBack, ensure the attached bug is fixed
Change-Id: I097ca47563420d658cea083a3b6f8d5e7d02991c
(cherry picked from commit 8f0124190ac0386a9429724b5fdf8f491b8cad05)
diff --git a/services/core/java/com/android/server/wm/AccessibilityController.java b/services/core/java/com/android/server/wm/AccessibilityController.java
index c31cdec..641a1ba 100644
--- a/services/core/java/com/android/server/wm/AccessibilityController.java
+++ b/services/core/java/com/android/server/wm/AccessibilityController.java
@@ -1096,10 +1096,7 @@
// Add windows of certain types not covered by modal windows.
if (isReportedWindowType(windowState.mAttrs.type)) {
// Add the window to the ones to be reported.
- WindowInfo window = obtainPopulatedWindowInfo(windowState, boundsInScreen);
- window.layer = addedWindows.size();
- addedWindows.add(window.token);
- windows.add(window);
+ addPopulatedWindowInfo(windowState, boundsInScreen, windows, addedWindows);
if (windowState.isFocused()) {
focusedWindowAdded = true;
}
@@ -1150,10 +1147,8 @@
computeWindowBoundsInScreen(windowState, boundsInScreen);
// Add the window to the ones to be reported.
- WindowInfo window = obtainPopulatedWindowInfo(windowState,
- boundsInScreen);
- addedWindows.add(window.token);
- windows.add(window);
+ addPopulatedWindowInfo(
+ windowState, boundsInScreen, windows, addedWindows);
break;
}
}
@@ -1244,11 +1239,14 @@
(int) windowFrame.right, (int) windowFrame.bottom);
}
- private static WindowInfo obtainPopulatedWindowInfo(
- WindowState windowState, Rect boundsInScreen) {
+ private static void addPopulatedWindowInfo(
+ WindowState windowState, Rect boundsInScreen,
+ List<WindowInfo> out, Set<IBinder> tokenOut) {
final WindowInfo window = windowState.getWindowInfo();
window.boundsInScreen.set(boundsInScreen);
- return window;
+ window.layer = tokenOut.size();
+ out.add(window);
+ tokenOut.add(window.token);
}
private void cacheWindows(List<WindowInfo> windows) {