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

Commit 935e5029 authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

Set right bounds/configuration for task when positioned in stack.

When AMS.positionTaskInStack API is called we need to make sure
the task has the right bounds and configuration if it is moving
to a different stack.

Bug: 25501082
Change-Id: I2a80aa08a4ee52d860502ab16b6cdb432c954084
parent 208ff92d
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -4606,14 +4606,20 @@ final class ActivityStack {
                voiceInteractor);
        // add the task to stack first, mTaskPositioner might need the stack association
        addTask(task, toTop, false);
        if (mTaskPositioner != null) {
            mTaskPositioner.updateDefaultBounds(task, mTaskHistory, info.layout);
        } else if (mBounds != null && task.mResizeable) {
        if (!layoutTaskInStack(task, info.layout) && mBounds != null && task.mResizeable) {
            task.updateOverrideConfiguration(mBounds);
        }
        return task;
    }

    boolean layoutTaskInStack(TaskRecord task, ActivityInfo.Layout layout) {
        if (mTaskPositioner == null) {
            return false;
        }
        mTaskPositioner.updateDefaultBounds(task, mTaskHistory, layout);
        return true;
    }

    ArrayList<TaskRecord> getAllTasks() {
        return new ArrayList<>(mTaskHistory);
    }
+6 −3
Original line number Diff line number Diff line
@@ -3420,9 +3420,12 @@ public final class ActivityStackSupervisor implements DisplayListener {
            Slog.w(TAG, "positionTaskInStackLocked: no task for id=" + taskId);
            return;
        }
        ActivityStack stack =
                getStack(stackId, CREATE_IF_NEEDED, !ON_TOP);
        mWindowManager.positionTaskInStack(taskId, stackId, position);
        final ActivityStack stack = getStack(stackId, CREATE_IF_NEEDED, !ON_TOP);

        task.updateOverrideConfigurationForStack(stack);

        mWindowManager.positionTaskInStack(
                taskId, stackId, position, task.mBounds, task.mOverrideConfig);
        final boolean stackChanged = task.stack != null && task.stack != stack;
        if (stackChanged) {
            task.stack.removeTask(task, "moveTaskToStack", MOVING);
+25 −0
Original line number Diff line number Diff line
@@ -1234,6 +1234,31 @@ final class TaskRecord {
        return !mOverrideConfig.equals(oldConfig) ? mOverrideConfig : null;
    }

    /** Updates the task's bounds and override configuration to match what is expected for the
     * input stack. */
    void updateOverrideConfigurationForStack(ActivityStack inStack) {
        if (stack != null && stack == inStack) {
            return;
        }

        if (inStack.mStackId == FREEFORM_WORKSPACE_STACK_ID) {
            if (!mResizeable) {
                throw new IllegalArgumentException("Can not position non-resizeable task="
                        + this + " in stack=" + inStack);
            }
            if (mBounds != null) {
                return;
            }
            if (mLastNonFullscreenBounds != null) {
                updateOverrideConfiguration(mLastNonFullscreenBounds);
            } else {
                inStack.layoutTaskInStack(this, null);
            }
        } else {
            updateOverrideConfiguration(inStack.mBounds);
        }
    }

    /**
     * Returns the correct stack to use based on task type and currently set bounds,
     * regardless of the focused stack and current stack association of the task.
+2 −1
Original line number Diff line number Diff line
@@ -135,7 +135,7 @@ class Task implements DimLayer.DimLayerUser {
        stack.addTask(this, toTop);
    }

    void positionTaskInStack(TaskStack stack, int position) {
    void positionTaskInStack(TaskStack stack, int position, Rect bounds, Configuration config) {
        if (mStack != null && stack != mStack) {
            if (DEBUG_STACK) Slog.i(TAG, "positionTaskInStack: removing taskId=" + mTaskId
                    + " from stack=" + mStack);
@@ -143,6 +143,7 @@ class Task implements DimLayer.DimLayerUser {
            mStack.removeTask(this);
        }
        stack.positionTask(this, position, showForAllUsers());
        setBounds(bounds, config);
    }

    boolean removeAppToken(AppWindowToken wtoken) {
+3 −2
Original line number Diff line number Diff line
@@ -4795,7 +4795,8 @@ public class WindowManagerService extends IWindowManager.Stub
        }
    }

    public void positionTaskInStack(int taskId, int stackId, int position) {
    public void positionTaskInStack(int taskId, int stackId, int position, Rect bounds,
            Configuration config) {
        synchronized (mWindowMap) {
            if (DEBUG_STACK) Slog.i(TAG, "positionTaskInStack: positioning taskId=" + taskId
                    + " in stackId=" + stackId + " at " + position);
@@ -4811,7 +4812,7 @@ public class WindowManagerService extends IWindowManager.Stub
                        "positionTaskInStack: could not find stackId=" + stackId);
                return;
            }
            task.positionTaskInStack(stack, position);
            task.positionTaskInStack(stack, position, bounds, config);
            final DisplayContent displayContent = stack.getDisplayContent();
            displayContent.layoutNeeded = true;
            mWindowPlacerLocked.performSurfacePlacement();