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

Commit d0c14f3a authored by Issei Suzuki's avatar Issei Suzuki
Browse files

Hold off on destroying an activity until the resumed one is visible.

After ag/9754495, the visibility related flags in ActivityRecord are
already updated before the code reaches to completeFinishing(), so
we use activity status instead.

With this change, an activity in PAUSED state won't be destroyed
immediately but is put into the stopping list even if the next
top activity is already visible.

Bug: 145186882
Bug: 80414790
Test: atest ActivityLifeCycleTests ActivityLifecycleTopResumedStateTests
Change-Id: I61a9aa382d39797e835a1a5f64d64765372bf3bf
parent 7a21c313
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -2624,14 +2624,13 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
        // TODO(b/137329632): find the next activity directly underneath this one, not just anywhere
        final ActivityRecord next = getDisplay().topRunningActivity(
                true /* considerKeyguardState */);
        final boolean isVisible = mVisibleRequested || nowVisible;
        // isNextNotYetVisible is to check if the next activity is invisible, or it has been
        // requested to be invisible but its windows haven't reported as invisible.  If so, it
        // implied that the current finishing activity should be added into stopping list rather
        // than destroy immediately.
        final boolean isNextNotYetVisible = next != null
                && (!next.nowVisible || !next.mVisibleRequested);
        if (isVisible && isNextNotYetVisible) {
        if ((mVisibleRequested || isState(PAUSED)) && isNextNotYetVisible) {
            // Add this activity to the list of stopping activities. It will be processed and
            // destroyed when the next activity reports idle.
            addToStopping(false /* scheduleIdle */, false /* idleDelayed */,
+1 −1
Original line number Diff line number Diff line
@@ -902,7 +902,7 @@ public class ActivityRecordTests extends ActivityTestsBase {
        topActivity.mVisibleRequested = false;
        topActivity.nowVisible = false;
        topActivity.finishing = true;
        topActivity.setState(PAUSED, "true");
        topActivity.setState(STOPPED, "true");
        // Mark the bottom activity as not visible, so that we would wait for it before removing
        // the top one.
        mActivity.mVisibleRequested = false;