Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 66b42a61 authored by Hiroki Sato's avatar Hiroki Sato Committed by Android (Google) Code Review
Browse files

Merge "Fix correctly recycle AccessibilityWindow in A11yController" into main

parents 3d66fa7d 74088ce8
Loading
Loading
Loading
Loading
+5 −15
Original line number Diff line number Diff line
@@ -1540,16 +1540,12 @@ final class AccessibilityController {

        private static final boolean DEBUG = false;

        private final List<AccessibilityWindow> mTempA11yWindows = new ArrayList<>();

        private final Set<IBinder> mTempBinderSet = new ArraySet<>();

        private final Point mTempPoint = new Point();

        private final Region mTempRegion = new Region();

        private final Region mTempRegion1 = new Region();

        private final Region mTempRegion2 = new Region();

        private final WindowManagerService mService;
@@ -1617,7 +1613,8 @@ final class AccessibilityController {
                Slog.i(LOG_TAG, "computeChangedWindows()");
            }

            List<WindowInfo> windows = new ArrayList<>();
            final List<WindowInfo> windows = new ArrayList<>();
            final List<AccessibilityWindow> visibleWindows = new ArrayList<>();
            final int topFocusedDisplayId;
            IBinder topFocusedWindowToken = null;

@@ -1652,7 +1649,6 @@ final class AccessibilityController {
                Region unaccountedSpace = mTempRegion;
                unaccountedSpace.set(0, 0, screenWidth, screenHeight);

                final List<AccessibilityWindow> visibleWindows = mTempA11yWindows;
                mA11yWindowsPopulator.populateVisibleWindowsOnScreenLocked(
                        mDisplayId, visibleWindows);
                Set<IBinder> addedWindows = mTempBinderSet;
@@ -1709,7 +1705,6 @@ final class AccessibilityController {
                    }
                }

                visibleWindows.clear();
                addedWindows.clear();

                // Gets the top focused display Id and window token for supporting multi-display.
@@ -1720,7 +1715,9 @@ final class AccessibilityController {
                    topFocusedWindowToken, windows);

            // Recycle the windows as we do not need them.
            clearAndRecycleWindows(windows);
            for (final AccessibilityWindowsPopulator.AccessibilityWindow window : visibleWindows) {
                window.getWindowInfo().recycle();
            }
            mInitialized = true;
        }

@@ -1802,13 +1799,6 @@ final class AccessibilityController {
            tokenOut.add(window.token);
        }

        private static void clearAndRecycleWindows(List<WindowInfo> windows) {
            final int windowCount = windows.size();
            for (int i = windowCount - 1; i >= 0; i--) {
                windows.remove(i).recycle();
            }
        }

        private static boolean isReportedWindowType(int windowType) {
            return (windowType != WindowManager.LayoutParams.TYPE_WALLPAPER
                    && windowType != WindowManager.LayoutParams.TYPE_BOOT_PROGRESS