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

Commit 793442c5 authored by Riddle Hsu's avatar Riddle Hsu Committed by Wale Ogunwale
Browse files

Fix index out of bounds of display removal

When removing a display, if it contains an activity in the active
transition, the display will be marked as removed and the activity
will be marked as exiting. Then when the animation is done, the
removal of the activity will continue while checking the deferred
removal from display. Once the activity is removed, because it is
the last activity and the display was marked as removed, all of its
parents will also be removed.

Bug: 143873959
Test: atest ActivityViewTest#testStartActivity
Change-Id: Iebee5b24fcb6b525c325d5aee2442b992ac6a35f
parent 3ae41e41
Loading
Loading
Loading
Loading
+13 −1
Original line number Diff line number Diff line
@@ -2409,7 +2409,19 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo
    /** Returns true if a removal action is still being deferred. */
    @Override
    boolean checkCompleteDeferredRemoval() {
        final boolean stillDeferringRemoval = super.checkCompleteDeferredRemoval();
        boolean stillDeferringRemoval = false;

        for (int i = getChildCount() - 1; i >= 0; --i) {
            final DisplayChildWindowContainer child = getChildAt(i);
            stillDeferringRemoval |= child.checkCompleteDeferredRemoval();
            if (getChildCount() == 0) {
                // If this display is pending to be removed because it contains an activity with
                // {@link ActivityRecord#mIsExiting} is true, this display may be removed when
                // completing the removal of the last activity from
                // {@link ActivityRecord#checkCompleteDeferredRemoval}.
                return false;
            }
        }

        if (!stillDeferringRemoval && mDeferredRemoval) {
            removeImmediately();