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

Commit 5dcb275c authored by Chong Zhang's avatar Chong Zhang
Browse files

Restore recent task to freeform space when resizing

bug: 22984782
Change-Id: I95b7b7b4871865102a279e529f068479e9b5df34
parent dda53bf0
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -404,6 +404,12 @@ public class ActivityManager {
     */
    public static final int COMPAT_MODE_TOGGLE = 2;

    /**
     * Invalid stack ID.
     * @hide
     */
    public static final int INVALID_STACK_ID = -1;

    /**
     * First static stack ID.
     * @hide
+14 −5
Original line number Diff line number Diff line
@@ -562,7 +562,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
            return task;
        }

        if (!restoreRecentTaskLocked(task)) {
        if (!restoreRecentTaskLocked(task, INVALID_STACK_ID)) {
            if (DEBUG_RECENTS) Slog.w(TAG_RECENTS,
                    "Couldn't restore task id=" + id + " found in recents");
            return null;
@@ -2956,7 +2956,7 @@ public final class ActivityStackSupervisor implements DisplayListener {
            task.mBounds = task.mLastNonFullscreenBounds = new Rect(bounds);
            if (task.stack != null && task.stack.mStackId != FREEFORM_WORKSPACE_STACK_ID) {
                // re-restore the task so it can have the proper stack association.
                restoreRecentTaskLocked(task);
                restoreRecentTaskLocked(task, FREEFORM_WORKSPACE_STACK_ID);
            }
            return;
        }
@@ -3021,9 +3021,18 @@ public final class ActivityStackSupervisor implements DisplayListener {
        return mNextFreeStackId;
    }

    private boolean restoreRecentTaskLocked(TaskRecord task) {
        final int stackId =
                mLeanbackOnlyDevice ? mHomeStack.mStackId : task.getLaunchStackId(mFocusedStack);
    /**
     * Restores a recent task to a stack
     * @param task The recent task to be restored.
     * @param stackId The stack to restore the task to (default launch stack will be used
     *                if stackId is invalid).
     * @return true if the task has been restored successfully.
     */
    private boolean restoreRecentTaskLocked(TaskRecord task, int stackId) {
        if (stackId == INVALID_STACK_ID) {
            stackId = mLeanbackOnlyDevice ?
                    mHomeStack.mStackId : task.getLaunchStackId(mFocusedStack);
        }
        if (task.stack != null) {
            // Task has already been restored once. See if we need to do anything more
            if (task.stack.mStackId == stackId) {