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

Commit 33fde7d0 authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

Fixed IndexOutOfBoundsException when removing child windows

The size of the list reduces when a child window is removed from the
list. So, we copy the window list and loop from the last entry to the
first when removing to avoid IndexOutOfBoundsException.

Bug: 27345523
Change-Id: I15986e418d29ee5035dc9d4c4f728ad33bfe6999
parent 10b6e077
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -101,6 +101,10 @@ import static com.android.server.wm.WindowManagerDebugConfig.TAG_WITH_CLASS_NAME
import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;

class WindowList extends ArrayList<WindowState> {
    WindowList() {}
    WindowList(WindowList windowList) {
        super(windowList);
    }
}

/**
+6 −3
Original line number Diff line number Diff line
@@ -434,9 +434,12 @@ class WindowStateAnimator {
                + " remove=" + mWin.mRemoveOnExit
                + " windowAnimating=" + isWindowAnimating());

        final int N = mWin.mChildWindows.size();
        for (int i=0; i<N; i++) {
            mWin.mChildWindows.get(i).mWinAnimator.finishExit();
        if (!mWin.mChildWindows.isEmpty()) {
            // Copying to a different list as multiple children can be removed.
            final WindowList childWindows = new WindowList(mWin.mChildWindows);
            for (int i = childWindows.size() - 1; i >= 0; i--) {
                childWindows.get(i).mWinAnimator.finishExit();
            }
        }

        if (mEnteringAnimation) {