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

Commit c8bad940 authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

Make TaskStack have type TaskRecord children (62/n)

TaskRecord now extends Task and changing TaskStack to have type
TaskRecord children will make the Stack level merging easier.

Bug: 80414790
Test: Existing tests pass
Change-Id: Ia300624b1534eff620d1dec0533d449a122ede4d
parent 8577a05d
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -237,7 +237,8 @@ class Task extends WindowContainer<ActivityRecord> implements ConfigurationConta
            prevStack.moveHomeStackToFrontIfNeeded(wasTopFocusedStack, prevStackDisplay, reason);
        }

        stack.positionChildAt(position, this, moveParents);
        // TODO(task-merge): Remove cast.
        stack.positionChildAt(position, (TaskRecord) this, moveParents);

        // If we are moving from the fullscreen stack to the pinned stack then we want to preserve
        // our insets so that there will not be a jump in the area covered by system decorations.
@@ -247,7 +248,8 @@ class Task extends WindowContainer<ActivityRecord> implements ConfigurationConta

    /** @see ActivityTaskManagerService#positionTaskInStack(int, int, int). */
    void positionAt(int position) {
        getTaskStack().positionChildAt(position, this, false /* includingParents */);
        // TODO(task-merge): Remove cast.
        getTaskStack().positionChildAt(position, (TaskRecord) this, false /* includingParents */);
    }

    void setSendingToBottom(boolean toBottom) {
+11 −13
Original line number Diff line number Diff line
@@ -84,7 +84,7 @@ import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;

public class TaskStack extends WindowContainer<Task> implements
public class TaskStack extends WindowContainer<TaskRecord> implements
        BoundsAnimationTarget, ConfigurationContainerListener {
    /** Minimum size of an adjusted stack bounds relative to original stack bounds. Used to
     * restrict IME adjustment so that a min portion of top stack remains visible.*/
@@ -488,19 +488,18 @@ public class TaskStack extends WindowContainer<Task> implements
     * @param position Target position to add the task to.
     * @param showForAllUsers Whether to show the task regardless of the current user.
     */
    void addChild(Task task, int position, boolean showForAllUsers, boolean moveParents) {
    void addChild(TaskRecord task, int position, boolean showForAllUsers, boolean moveParents) {
        // Add child task.
        addChild(task, null);

        // Move child to a proper position, as some restriction for position might apply.
        position = positionChildAt(
                position, task, moveParents /* includingParents */, showForAllUsers);
        // TODO(task-merge): Remove cast.
        mActivityStack.onChildAdded((TaskRecord) task, position);
        mActivityStack.onChildAdded(task, position);
    }

    @Override
    void addChild(Task task, int position) {
    void addChild(TaskRecord task, int position) {
        addChild(task, position, task.showForAllUsers(), false /* includingParents */);
    }

@@ -518,7 +517,7 @@ public class TaskStack extends WindowContainer<Task> implements
        getDisplayContent().layoutAndAssignWindowLayersIfNeeded();
    }

    void positionChildAtTop(Task child, boolean includingParents) {
    void positionChildAtTop(TaskRecord child, boolean includingParents) {
        if (child == null) {
            // TODO: Fix the call-points that cause this to happen.
            return;
@@ -533,7 +532,7 @@ public class TaskStack extends WindowContainer<Task> implements
        displayContent.layoutAndAssignWindowLayersIfNeeded();
    }

    void positionChildAtBottom(Task child, boolean includingParents) {
    void positionChildAtBottom(TaskRecord child, boolean includingParents) {
        if (child == null) {
            // TODO: Fix the call-points that cause this to happen.
            return;
@@ -548,7 +547,7 @@ public class TaskStack extends WindowContainer<Task> implements
    }

    @Override
    void positionChildAt(int position, Task child, boolean includingParents) {
    void positionChildAt(int position, TaskRecord child, boolean includingParents) {
        positionChildAt(position, child, includingParents, child.showForAllUsers());
    }

@@ -557,7 +556,7 @@ public class TaskStack extends WindowContainer<Task> implements
     * {@link TaskStack#addChild(Task, int, boolean showForAllUsers, boolean)}, as it can receive
     * showForAllUsers param from {@link ActivityRecord} instead of {@link Task#showForAllUsers()}.
     */
    int positionChildAt(int position, Task child, boolean includingParents,
    int positionChildAt(int position, TaskRecord child, boolean includingParents,
            boolean showForAllUsers) {
        final int targetPosition = findPositionForTask(child, position, showForAllUsers);
        super.positionChildAt(targetPosition, child, includingParents);
@@ -664,7 +663,7 @@ public class TaskStack extends WindowContainer<Task> implements
     * @param task The Task to delete.
     */
    @Override
    void removeChild(Task task) {
    void removeChild(TaskRecord task) {
        if (!mChildren.contains(task)) {
            // Not really in this stack anymore...
            return;
@@ -673,8 +672,7 @@ public class TaskStack extends WindowContainer<Task> implements

        super.removeChild(task);

        // TODO(task-merge): Remove cast.
        mActivityStack.onChildRemoved((TaskRecord) task, mDisplayContent);
        mActivityStack.onChildRemoved(task, mDisplayContent);
    }

    @Override
@@ -960,7 +958,7 @@ public class TaskStack extends WindowContainer<Task> implements
        super.switchUser();
        int top = mChildren.size();
        for (int taskNdx = 0; taskNdx < top; ++taskNdx) {
            Task task = mChildren.get(taskNdx);
            TaskRecord task = mChildren.get(taskNdx);
            if (mWmService.isCurrentProfileLocked(task.mUserId) || task.showForAllUsers()) {
                mChildren.remove(taskNdx);
                mChildren.add(task);
+1 −1
Original line number Diff line number Diff line
@@ -121,7 +121,7 @@ public class TaskStackContainersTests extends WindowTestsBase {
                false /* includingParents */);

        // Move the task of {@code mDisplayContent} to top.
        stack.positionChildAt(WindowContainer.POSITION_TOP, task, true /* includingParents */);
        stack.positionChildAt(WindowContainer.POSITION_TOP, (TaskRecord) task, true /* includingParents */);
        final int indexOfDisplayWithPinnedStack = mWm.mRoot.mChildren.indexOf(mDisplayContent);

        assertEquals("The testing DisplayContent should be moved to top with task",
+2 −2
Original line number Diff line number Diff line
@@ -58,12 +58,12 @@ public class TaskStackTests extends WindowTestsBase {
        final Task task2 = createTaskInStack(stack, 1 /* userId */);

        // Current user task should be moved to top.
        stack.positionChildAt(WindowContainer.POSITION_TOP, task1, false /* includingParents */);
        stack.positionChildAt(WindowContainer.POSITION_TOP, (TaskRecord) task1, false /* includingParents */);
        assertEquals(stack.mChildren.get(0), task2);
        assertEquals(stack.mChildren.get(1), task1);

        // Non-current user won't be moved to top.
        stack.positionChildAt(WindowContainer.POSITION_TOP, task2, false /* includingParents */);
        stack.positionChildAt(WindowContainer.POSITION_TOP, (TaskRecord) task2, false /* includingParents */);
        assertEquals(stack.mChildren.get(0), task2);
        assertEquals(stack.mChildren.get(1), task1);
    }