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

Commit ee6786f6 authored by Evan Rosky's avatar Evan Rosky Committed by Android (Google) Code Review
Browse files

Merge "moveTaskToBack also moves ActivityStack to back"

parents f137f895 9c44817e
Loading
Loading
Loading
Loading
+37 −2
Original line number Diff line number Diff line
@@ -871,6 +871,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;
@@ -2591,6 +2614,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);
@@ -2611,6 +2637,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();
@@ -4380,8 +4416,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);
    }