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

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

Get candidate stack for launch if possible

An activity stack was created while starting an activity in split-screen
mode. Since the activity did not landed on the stack eventually, the empty
stack leaks after activity launched.

We should get target stack from the candidate task in the first place
if possible.

Also make sure empty stack is removed.

Bug: 142345211
Test: atest ActivityLifecycleSplitScreenTests
Change-Id: I366a5690b26c4c564cf43f9057408f543a76a7fd
parent 9f2efe98
Loading
Loading
Loading
Loading
+6 −3
Original line number Diff line number Diff line
@@ -2324,9 +2324,9 @@ class ActivityStarter {
                    intentActivity.setTaskToAffiliateWith(mSourceRecord.getTaskRecord());
                }

                final ActivityStack launchStack = getLaunchStack(
                        mStartActivity, mLaunchFlags, mStartActivity.getTaskRecord(), mOptions);
                final TaskRecord intentTask = intentActivity.getTaskRecord();
                final ActivityStack launchStack =
                        getLaunchStack(mStartActivity, mLaunchFlags, intentTask, mOptions);
                if (launchStack == null || launchStack == mTargetStack) {
                    // We only want to move to the front, if we aren't going to launch on a
                    // different stack. If we launch on a different stack, we will put the
@@ -2370,9 +2370,12 @@ class ActivityStarter {
                            REPARENT_MOVE_STACK_TO_FRONT, ANIMATE, DEFER_RESUME,
                            "reparentingHome");
                    mMovedToFront = true;
                } else if (launchStack.topTask() == null) {
                }

                if (launchStack.topTask() == null) {
                    // The task does not need to be reparented to the launch stack. Remove the
                    // launch stack if there is no activity in it.
                    Slog.w(TAG, "Removing an empty stack: " + launchStack);
                    launchStack.remove();
                }

+6 −2
Original line number Diff line number Diff line
@@ -1780,9 +1780,13 @@ class RootActivityContainer extends ConfigurationContainer
        // If {@code r} is already in target display and its task is the same as the candidate task,
        // the intention should be getting a launch stack for the reusable activity, so we can use
        // the existing stack.
        if (r.getDisplayId() == displayId && r.getTaskRecord() == candidateTask) {
        if (candidateTask != null
                && (r.getTaskRecord() == null || r.getTaskRecord() == candidateTask)) {
            final int attachedDisplayId = r.getDisplayId();
            if (attachedDisplayId == INVALID_DISPLAY || attachedDisplayId == displayId) {
                return candidateTask.getStack();
            }
        }

        int windowingMode;
        if (launchParams != null) {