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

Commit c219bc39 authored by Louis Chang's avatar Louis Chang
Browse files

Prevents exceptions while putting stacks to sleep

Stacks could be removed while pausing the activities which
the belonging process was gone.

Bug: 120450988
Test: existing tests pass
Change-Id: I452a0bc922ab8e7d2347d7baa075ea08da117c50
parent 298c49e4
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -1419,6 +1419,13 @@ class RootActivityContainer extends ConfigurationContainer
        for (int displayNdx = mActivityDisplays.size() - 1; displayNdx >= 0; --displayNdx) {
            final ActivityDisplay display = mActivityDisplays.get(displayNdx);
            for (int stackNdx = display.getChildCount() - 1; stackNdx >= 0; --stackNdx) {
                // Stacks and activities could be removed while putting activities to sleep if
                // the app process was gone. This prevents us getting exception by accessing an
                // invalid stack index.
                if (stackNdx >= display.getChildCount()) {
                    continue;
                }

                final ActivityStack stack = display.getChildAt(stackNdx);
                if (allowDelay) {
                    allSleep &= stack.goToSleepIfPossible(shuttingDown);