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

Commit 074cdf2d authored by Louis Chang's avatar Louis Chang
Browse files

Remove ActivityStack#moveHomeStackToFrontIfNeeded

The method seems no longer necessary. The purpose of the original CL 04a0ea60
was to keep the home stack on top while allowing empty stacks existed, which
not making sense now.

And this additional code flow caused exceptions due to unexpected detached
stack access while updating focus in the middle of reparenting a task in
split-screen.


Bug: 145990447
Bug: 145972535
Test: atest ActivityLifecycleSplitScreenTests
Change-Id: I46b8b2044c851edb4e68616c8b7d38115af000e4
parent 97a17d56
Loading
Loading
Loading
Loading
+3 −16
Original line number Diff line number Diff line
@@ -3661,8 +3661,9 @@ class ActivityStack extends WindowContainer<WindowContainer> implements BoundsAn
        }

        final DisplayContent display = getDisplay();
        final boolean topFocused = mRootActivityContainer.isTopDisplayFocusedStack(this);
        if (DEBUG_TASK_MOVEMENT) Slog.d(TAG_WM, "removeChild: task=" + child);
        if (DEBUG_TASK_MOVEMENT) {
            Slog.d(TAG_WM, "removeChild: task=" + child + " reason=" + reason);
        }

        super.removeChild(child);

@@ -3678,8 +3679,6 @@ class ActivityStack extends WindowContainer<WindowContainer> implements BoundsAn
            // Stack is now empty...
          removeIfPossible();
        }

        moveHomeStackToFrontIfNeeded(topFocused, display, reason);
    }

    @Override
@@ -3687,18 +3686,6 @@ class ActivityStack extends WindowContainer<WindowContainer> implements BoundsAn
        removeChild(child, "removeChild");
    }

    void moveHomeStackToFrontIfNeeded(
            boolean wasTopFocusedStack, DisplayContent display, String reason) {
        if (!hasChild() && wasTopFocusedStack) {
            // We only need to adjust focused stack if this stack is in focus and we are not in the
            // process of moving the task to the top of the stack that will be focused.
            String myReason = reason + " leftTaskHistoryEmpty";
            if (!inMultiWindowMode() || adjustFocusToNextFocusableStack(myReason) == null) {
                display.moveHomeStackToFront(myReason);
            }
        }
    }

    Task createTask(int taskId, ActivityInfo info, Intent intent,
            IVoiceInteractionSession voiceSession, IVoiceInteractor voiceInteractor,
            boolean toTop) {
+1 −11
Original line number Diff line number Diff line
@@ -2182,22 +2182,12 @@ class Task extends WindowContainer<WindowContainer> {
    void reparent(ActivityStack stack, int position, boolean moveParents, String reason) {
        if (DEBUG_STACK) Slog.i(TAG, "reParentTask: removing taskId=" + mTaskId
                + " from stack=" + getTaskStack());
        EventLogTags.writeWmTaskRemoved(mTaskId, "reParentTask");

        final ActivityStack prevStack = getTaskStack();
        final boolean wasTopFocusedStack =
                mAtmService.mRootActivityContainer.isTopDisplayFocusedStack(prevStack);
        final DisplayContent prevStackDisplay = prevStack.getDisplay();
        EventLogTags.writeWmTaskRemoved(mTaskId, "reParentTask:" + reason);

        position = stack.findPositionForTask(this, position, showForAllUsers());

        reparent(stack, position);

        if (!moveParents) {
            // Only move home stack forward if we are not going to move the new parent forward.
            prevStack.moveHomeStackToFrontIfNeeded(wasTopFocusedStack, prevStackDisplay, reason);
        }

        stack.positionChildAt(position, this, moveParents);

        // If we are moving from the fullscreen stack to the pinned stack then we want to preserve