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

Commit 9c44817e authored by Evan Rosky's avatar Evan Rosky
Browse files

moveTaskToBack also moves ActivityStack to back

Bug: 67931573
Bug: 68952157
Test: manually tested with apps launching chrome. CTS
      ActivityManagerAppConfigurationTests#testTaskMoveToBackOrientation
      now passes again.
Change-Id: Ibe73e1d6accd5fd1f09d193305b1d9697ee19d97
parent 181799bc
Loading
Loading
Loading
Loading
+37 −2
Original line number Diff line number Diff line
@@ -870,6 +870,29 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
        }
    }

    /**
     * @param reason The reason for moving the stack to the back.
     * @param task If non-null, the task will be moved to the bottom of the stack.
     **/
    void moveToBack(String reason, TaskRecord task) {
        if (!isAttached()) {
            return;
        }

        getDisplay().positionChildAtBottom(this);
        mStackSupervisor.setFocusStackUnchecked(reason, getDisplay().getTopStack());
        if (task != null) {
            insertTaskAtBottom(task);
            return;
        } else {
            task = bottomTask();
            if (task != null) {
                mWindowContainerController.positionChildAtBottom(
                        task.getWindowContainerController(), true /* includingParents */);
            }
        }
    }

    boolean isFocusable() {
        if (getWindowConfiguration().canReceiveKeys()) {
            return true;
@@ -2581,6 +2604,9 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
        if (position >= mTaskHistory.size()) {
            insertTaskAtTop(task, null);
            return;
        } else if (position <= 0) {
            insertTaskAtBottom(task);
            return;
        }
        position = getAdjustedPositionForTask(task, position, null /* starting */);
        mTaskHistory.remove(task);
@@ -2601,6 +2627,16 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
                true /* includingParents */);
    }

    private void insertTaskAtBottom(TaskRecord task) {
        // Unlike insertTaskAtPosition, this will also position parents of the windowcontroller.
        mTaskHistory.remove(task);
        final int position = getAdjustedPositionForTask(task, 0, null);
        mTaskHistory.add(position, task);
        updateTaskMovement(task, true);
        mWindowContainerController.positionChildAtBottom(task.getWindowContainerController(),
                true /* includingParents */);
    }

    final void startActivityLocked(ActivityRecord r, ActivityRecord focusedTopActivity,
            boolean newTask, boolean keepCurTransition, ActivityOptions options) {
        TaskRecord rTask = r.getTask();
@@ -4370,8 +4406,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
        updateTaskMovement(tr, false);

        mWindowManager.prepareAppTransition(TRANSIT_TASK_TO_BACK, false);
        mWindowContainerController.positionChildAtBottom(tr.getWindowContainerController(),
                true /* includingParents */);
        moveToBack("moveTaskToBackLocked", tr);

        if (inPinnedWindowingMode()) {
            mStackSupervisor.removeStack(this);
+8 −0
Original line number Diff line number Diff line
@@ -603,6 +603,14 @@ public class TaskStack extends WindowContainer<Task> implements DimLayer.DimLaye
        } else {
            maxPosition = computeMaxPosition(maxPosition);
        }

        // preserve POSITION_BOTTOM/POSITION_TOP positions if they are still valid.
        if (targetPosition == POSITION_BOTTOM && minPosition == 0) {
            return POSITION_BOTTOM;
        } else if (targetPosition == POSITION_TOP
                && maxPosition == (addingNew ? stackSize : stackSize - 1)) {
            return POSITION_TOP;
        }
        // Reset position based on minimum/maximum possible positions.
        return Math.min(Math.max(targetPosition, minPosition), maxPosition);
    }