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

Commit a76876c4 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Updating moveTaskToBack to handle PiP activities"

parents 5fe6fbca 261c0f3c
Loading
Loading
Loading
Loading
+13 −7
Original line number Diff line number Diff line
@@ -10088,8 +10088,18 @@ public class ActivityManagerService extends IActivityManager.Stub
    }
    /**
     * Moves an activity, and all of the other activities within the same task, to the bottom
     * of the history stack.  The activity's order within the task is unchanged.
     * Attempts to move a task backwards in z-order (the order of activities within the task is
     * unchanged).
     *
     * There are several possible results of this call:
     * - if the task is locked, then we will show the lock toast
     * - if there is a task behind the provided task, then that task is made visible and resumed as
     *   this task is moved to the back
     * - otherwise, if there are no other tasks in the stack:
     *     - if this task is in the pinned stack, then we remove the stack completely, which will
     *       have the effect of moving the task to the top or bottom of the fullscreen stack
     *       (depending on whether it is visible)
     *     - otherwise, we simply return home and hide this task
     *
     * @param token A reference to the activity we wish to move
     * @param nonRoot If false then this only works if the activity is the root
@@ -10105,10 +10115,6 @@ public class ActivityManagerService extends IActivityManager.Stub
                int taskId = ActivityRecord.getTaskForActivityLocked(token, !nonRoot);
                final TaskRecord task = mStackSupervisor.anyTaskForIdLocked(taskId);
                if (task != null) {
                    if (mStackSupervisor.isLockedTask(task)) {
                        mStackSupervisor.showLockTaskToast();
                        return false;
                    }
                    return ActivityRecord.getStackLocked(token).moveTaskToBackLocked(taskId);
                }
            } finally {
@@ -10367,7 +10373,7 @@ public class ActivityManagerService extends IActivityManager.Stub
        synchronized (this) {
            if (!mSupportsPictureInPicture) {
                throw new IllegalStateException("moveTopActivityToPinnedStack:"
                        + "Device doesn't support picture-in-pciture mode");
                        + "Device doesn't support picture-in-picture mode");
            }
            long ident = Binder.clearCallingIdentity();
+23 −10
Original line number Diff line number Diff line
@@ -4351,9 +4351,13 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
            Slog.i(TAG, "moveTaskToBack: bad taskId=" + taskId);
            return false;
        }

        Slog.i(TAG, "moveTaskToBack: " + tr);
        mStackSupervisor.removeLockedTaskLocked(tr);

        // If the task is locked, then show the lock task toast
        if (mStackSupervisor.isLockedTask(tr)) {
            mStackSupervisor.showLockTaskToast();
            return false;
        }

        // If we have a watcher, preflight the move before committing to it.  First check
        // for *other* available tasks, but if none are available, then try again allowing the
@@ -4416,12 +4420,24 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
                prevIsHome = true;
            }
        }

        boolean requiresMove = mTaskHistory.indexOf(tr) != 0;
        if (requiresMove) {
            mTaskHistory.remove(tr);
            mTaskHistory.add(0, tr);
            updateTaskMovement(tr, false);

        // There is an assumption that moving a task to the back moves it behind the home activity.
        // We make sure here that some activity in the stack will launch home.
            mWindowManager.prepareAppTransition(TRANSIT_TASK_TO_BACK, false);
            mWindowContainerController.positionChildAtBottom(tr.getWindowContainerController());
        }

        if (mStackId == PINNED_STACK_ID) {
            mStackSupervisor.removeStackLocked(PINNED_STACK_ID);
            return true;
        }

        // Otherwise, there is an assumption that moving a task to the back moves it behind the
        // home activity. We make sure here that some activity in the stack will launch home.
        int numTasks = mTaskHistory.size();
        for (int taskNdx = numTasks - 1; taskNdx >= 1; --taskNdx) {
            final TaskRecord task = mTaskHistory.get(taskNdx);
@@ -4434,9 +4450,6 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
            }
        }

        mWindowManager.prepareAppTransition(TRANSIT_TASK_TO_BACK, false);
        mWindowContainerController.positionChildAtBottom(tr.getWindowContainerController());

        final TaskRecord task = mResumedActivity != null ? mResumedActivity.task : null;
        if (prevIsHome || (task == tr && canGoHome) || (numTasks <= 1 && isOnHomeDisplay())) {
            if (!mService.mBooting && !mService.mBooted) {