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

Commit 4258dfea authored by Yunfan Chen's avatar Yunfan Chen Committed by Android (Google) Code Review
Browse files

Merge "Remove TaskWindowContainerController & TaskWindowContainerListener (44/n)"

parents b45334bd 0e7aff96
Loading
Loading
Loading
Loading
+5 −8
Original line number Original line Diff line number Diff line
@@ -1035,8 +1035,6 @@ final class ActivityRecord extends ConfigurationContainer {


        inHistory = true;
        inHistory = true;


        final TaskWindowContainerController taskController = task.getWindowContainerController();

        // TODO(b/36505427): Maybe this call should be moved inside updateOverrideConfiguration()
        // TODO(b/36505427): Maybe this call should be moved inside updateOverrideConfiguration()
        task.updateOverrideConfigurationFromLaunchBounds();
        task.updateOverrideConfigurationFromLaunchBounds();
        // Make sure override configuration is up-to-date before using to create window controller.
        // Make sure override configuration is up-to-date before using to create window controller.
@@ -1048,10 +1046,9 @@ final class ActivityRecord extends ConfigurationContainer {
            // TODO: Should this throw an exception instead?
            // TODO: Should this throw an exception instead?
            Slog.w(TAG, "Attempted to add existing app token: " + appToken);
            Slog.w(TAG, "Attempted to add existing app token: " + appToken);
        } else {
        } else {
            final Task container = taskController.mContainer;
            final Task container = task.getTask();
            if (container == null) {
            if (container == null) {
                throw new IllegalArgumentException("AppWindowContainerController: invalid "
                throw new IllegalArgumentException("createAppWindowToken: invalid task =" + task);
                        + " controller=" + taskController);
            }
            }
            mAppWindowToken = createAppWindow(mAtmService.mWindowManager, appToken,
            mAppWindowToken = createAppWindow(mAtmService.mWindowManager, appToken,
                    task.voiceSession != null, container.getDisplayContent(),
                    task.voiceSession != null, container.getDisplayContent(),
@@ -1062,7 +1059,7 @@ final class ActivityRecord extends ConfigurationContainer {
                    mLaunchTaskBehind, isAlwaysFocusable());
                    mLaunchTaskBehind, isAlwaysFocusable());
            if (DEBUG_TOKEN_MOVEMENT || DEBUG_ADD_REMOVE) {
            if (DEBUG_TOKEN_MOVEMENT || DEBUG_ADD_REMOVE) {
                Slog.v(TAG, "addAppToken: "
                Slog.v(TAG, "addAppToken: "
                        + mAppWindowToken + " controller=" + taskController + " at "
                        + mAppWindowToken + " task=" + container + " at "
                        + Integer.MAX_VALUE);
                        + Integer.MAX_VALUE);
            }
            }
            container.addChild(mAppWindowToken, Integer.MAX_VALUE /* add on top */);
            container.addChild(mAppWindowToken, Integer.MAX_VALUE /* add on top */);
@@ -1148,7 +1145,7 @@ final class ActivityRecord extends ConfigurationContainer {
                    + " r=" + this + " (" + prevTask.getStackId() + ")");
                    + " r=" + this + " (" + prevTask.getStackId() + ")");
        }
        }


        mAppWindowToken.reparent(newTask.getWindowContainerController(), position);
        mAppWindowToken.reparent(newTask.getTask(), position);


        // Reparenting prevents informing the parent stack of activity removal in the case that
        // Reparenting prevents informing the parent stack of activity removal in the case that
        // the new stack has the same parent. we must manually signal here if this is not the case.
        // the new stack has the same parent. we must manually signal here if this is not the case.
@@ -2774,7 +2771,7 @@ final class ActivityRecord extends ConfigurationContainer {
            final boolean hasResizeChange = hasResizeChange(changes & ~info.getRealConfigChanged());
            final boolean hasResizeChange = hasResizeChange(changes & ~info.getRealConfigChanged());
            if (hasResizeChange) {
            if (hasResizeChange) {
                final boolean isDragResizing =
                final boolean isDragResizing =
                        getTaskRecord().getWindowContainerController().isDragResizing();
                        getTaskRecord().getTask().isDragResizing();
                mRelaunchReason = isDragResizing ? RELAUNCH_REASON_FREE_RESIZE
                mRelaunchReason = isDragResizing ? RELAUNCH_REASON_FREE_RESIZE
                        : RELAUNCH_REASON_WINDOWING_MODE_RESIZE;
                        : RELAUNCH_REASON_WINDOWING_MODE_RESIZE;
            } else {
            } else {
+4 −4
Original line number Original line Diff line number Diff line
@@ -911,7 +911,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
    }
    }


    void positionChildWindowContainerAtTop(TaskRecord child) {
    void positionChildWindowContainerAtTop(TaskRecord child) {
        mWindowContainerController.positionChildAtTop(child.getWindowContainerController(),
        mWindowContainerController.positionChildAtTop(child.getTask(),
                true /* includingParents */);
                true /* includingParents */);
    }
    }


@@ -921,7 +921,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
        // task to bottom, the next focusable stack on the same display should be focused.
        // task to bottom, the next focusable stack on the same display should be focused.
        final ActivityStack nextFocusableStack = getDisplay().getNextFocusableStack(
        final ActivityStack nextFocusableStack = getDisplay().getNextFocusableStack(
                child.getStack(), true /* ignoreCurrent */);
                child.getStack(), true /* ignoreCurrent */);
        mWindowContainerController.positionChildAtBottom(child.getWindowContainerController(),
        mWindowContainerController.positionChildAtBottom(child.getTask(),
                nextFocusableStack == null /* includingParents */);
                nextFocusableStack == null /* includingParents */);
    }
    }


@@ -2984,7 +2984,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
        position = getAdjustedPositionForTask(task, position, null /* starting */);
        position = getAdjustedPositionForTask(task, position, null /* starting */);
        mTaskHistory.remove(task);
        mTaskHistory.remove(task);
        mTaskHistory.add(position, task);
        mTaskHistory.add(position, task);
        mWindowContainerController.positionChildAt(task.getWindowContainerController(), position);
        mWindowContainerController.positionChildAt(task.getTask(), position);
        updateTaskMovement(task, true);
        updateTaskMovement(task, true);
    }
    }


@@ -5349,7 +5349,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
                && !matchParentBounds() && task.isResizeable() && !isLockscreenShown) {
                && !matchParentBounds() && task.isResizeable() && !isLockscreenShown) {
            task.updateOverrideConfiguration(getRequestedOverrideBounds());
            task.updateOverrideConfiguration(getRequestedOverrideBounds());
        }
        }
        task.createWindowContainer(toTop, (info.flags & FLAG_SHOW_FOR_ALL_USERS) != 0);
        task.createTask(toTop, (info.flags & FLAG_SHOW_FOR_ALL_USERS) != 0);
        return task;
        return task;
    }
    }


+1 −1
Original line number Original line Diff line number Diff line
@@ -1868,7 +1868,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks {


        stack.addTask(task, onTop, "restoreRecentTask");
        stack.addTask(task, onTop, "restoreRecentTask");
        // TODO: move call for creation here and other place into Stack.addTask()
        // TODO: move call for creation here and other place into Stack.addTask()
        task.createWindowContainer(onTop, true /* showForAllUsers */);
        task.createTask(onTop, true /* showForAllUsers */);
        if (DEBUG_RECENTS) Slog.v(TAG_RECENTS,
        if (DEBUG_RECENTS) Slog.v(TAG_RECENTS,
                "Added restored task=" + task + " to stack=" + stack);
                "Added restored task=" + task + " to stack=" + stack);
        final ArrayList<ActivityRecord> activities = task.mActivities;
        final ArrayList<ActivityRecord> activities = task.mActivities;
+4 −10
Original line number Original line Diff line number Diff line
@@ -1175,21 +1175,14 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
        }
        }
    }
    }


    void reparent(TaskWindowContainerController taskController, int position) {
    void reparent(Task task, int position) {
        if (DEBUG_ADD_REMOVE) {
        if (DEBUG_ADD_REMOVE) {
            Slog.i(TAG_WM, "reparent: moving app token=" + this
            Slog.i(TAG_WM, "reparent: moving app token=" + this
                    + " to task=" + taskController + " at " + position);
                    + " to task=" + task.mTaskId + " at " + position);
        }
        }
        final Task task = taskController.mContainer;
        if (task == null) {
        if (task == null) {
            throw new IllegalArgumentException("reparent: could not find task="
            throw new IllegalArgumentException("reparent: could not find task");
                    + taskController);
        }
        reparent(task, position);
        getDisplayContent().layoutAndAssignWindowLayersIfNeeded();
        }
        }

    void reparent(Task task, int position) {
        final Task currentTask = getTask();
        final Task currentTask = getTask();
        if (task == currentTask) {
        if (task == currentTask) {
            throw new IllegalArgumentException(
            throw new IllegalArgumentException(
@@ -1220,6 +1213,7 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
            onDisplayChanged(displayContent);
            onDisplayChanged(displayContent);
            prevDisplayContent.setLayoutNeeded();
            prevDisplayContent.setLayoutNeeded();
        }
        }
        getDisplayContent().layoutAndAssignWindowLayersIfNeeded();
    }
    }


    @Override
    @Override
+137 −171
Original line number Original line Diff line number Diff line
@@ -67,7 +67,6 @@ public class StackWindowController
        mStackId = stackId;
        mStackId = stackId;
        mHandler = new H(new WeakReference<>(this), service.mH.getLooper());
        mHandler = new H(new WeakReference<>(this), service.mH.getLooper());


        synchronized (mGlobalLock) {
        final DisplayContent dc = mRoot.getDisplayContent(displayId);
        final DisplayContent dc = mRoot.getDisplayContent(displayId);
        if (dc == null) {
        if (dc == null) {
            throw new IllegalArgumentException("Trying to add stackId=" + stackId
            throw new IllegalArgumentException("Trying to add stackId=" + stackId
@@ -77,20 +76,16 @@ public class StackWindowController
        dc.createStack(stackId, onTop, this);
        dc.createStack(stackId, onTop, this);
        getRawBounds(outBounds);
        getRawBounds(outBounds);
    }
    }
    }


    @Override
    @Override
    public void removeContainer() {
    public void removeContainer() {
        synchronized (mGlobalLock) {
        if (mContainer != null) {
        if (mContainer != null) {
            mContainer.removeIfPossible();
            mContainer.removeIfPossible();
            super.removeContainer();
            super.removeContainer();
        }
        }
    }
    }
    }


    public void reparent(int displayId, Rect outStackBounds, boolean onTop) {
    void reparent(int displayId, Rect outStackBounds, boolean onTop) {
        synchronized (mGlobalLock) {
        if (mContainer == null) {
        if (mContainer == null) {
            throw new IllegalArgumentException("Trying to move unknown stackId=" + mStackId
            throw new IllegalArgumentException("Trying to move unknown stackId=" + mStackId
                    + " to displayId=" + displayId);
                    + " to displayId=" + displayId);
@@ -105,70 +100,55 @@ public class StackWindowController
        targetDc.moveStackToDisplay(mContainer, onTop);
        targetDc.moveStackToDisplay(mContainer, onTop);
        getRawBounds(outStackBounds);
        getRawBounds(outStackBounds);
    }
    }
    }


    public void positionChildAt(TaskWindowContainerController child, int position) {
    void positionChildAt(Task child, int position) {
        synchronized (mGlobalLock) {
        if (DEBUG_STACK) {
            if (DEBUG_STACK) Slog.i(TAG_WM, "positionChildAt: positioning task=" + child
            Slog.i(TAG_WM, "positionChildAt: positioning task=" + child + " at " + position);
                    + " at " + position);
        }
            if (child.mContainer == null) {
        if (child == null) {
                if (DEBUG_STACK) Slog.i(TAG_WM,
            if (DEBUG_STACK) {
                        "positionChildAt: could not find task=" + this);
                Slog.i(TAG_WM, "positionChildAt: could not find task=" + this);
            }
            return;
            return;
        }
        }
        if (mContainer == null) {
        if (mContainer == null) {
                if (DEBUG_STACK) Slog.i(TAG_WM,
            if (DEBUG_STACK) {
                        "positionChildAt: could not find stack for task=" + mContainer);
                Slog.i(TAG_WM, "positionChildAt: could not find stack for task=" + mContainer);
            }
            return;
            return;
        }
        }
            child.mContainer.positionAt(position);
        child.positionAt(position);
        mContainer.getDisplayContent().layoutAndAssignWindowLayersIfNeeded();
        mContainer.getDisplayContent().layoutAndAssignWindowLayersIfNeeded();
    }
    }
    }


    public void positionChildAtTop(TaskWindowContainerController child, boolean includingParents) {
    void positionChildAtTop(Task child, boolean includingParents) {
        if (child == null) {
        if (child == null) {
            // TODO: Fix the call-points that cause this to happen.
            // TODO: Fix the call-points that cause this to happen.
            return;
            return;
        }
        }


        synchronized (mGlobalLock) {
        mContainer.positionChildAt(POSITION_TOP, child, includingParents);
            final Task childTask = child.mContainer;
            if (childTask == null) {
                Slog.e(TAG_WM, "positionChildAtTop: task=" + child + " not found");
                return;
            }
            mContainer.positionChildAt(POSITION_TOP, childTask, includingParents);


        final DisplayContent displayContent = mContainer.getDisplayContent();
        final DisplayContent displayContent = mContainer.getDisplayContent();
        if (displayContent.mAppTransition.isTransitionSet()) {
        if (displayContent.mAppTransition.isTransitionSet()) {
                childTask.setSendingToBottom(false);
            child.setSendingToBottom(false);
        }
        }
        displayContent.layoutAndAssignWindowLayersIfNeeded();
        displayContent.layoutAndAssignWindowLayersIfNeeded();
    }
    }
    }


    public void positionChildAtBottom(TaskWindowContainerController child,
    void positionChildAtBottom(Task child, boolean includingParents) {
            boolean includingParents) {
        if (child == null) {
        if (child == null) {
            // TODO: Fix the call-points that cause this to happen.
            // TODO: Fix the call-points that cause this to happen.
            return;
            return;
        }
        }


        synchronized (mGlobalLock) {
        mContainer.positionChildAt(POSITION_BOTTOM, child, includingParents);
            final Task childTask = child.mContainer;
            if (childTask == null) {
                Slog.e(TAG_WM, "positionChildAtBottom: task=" + child + " not found");
                return;
            }
            mContainer.positionChildAt(POSITION_BOTTOM, childTask, includingParents);


        if (mContainer.getDisplayContent().mAppTransition.isTransitionSet()) {
        if (mContainer.getDisplayContent().mAppTransition.isTransitionSet()) {
                childTask.setSendingToBottom(true);
            child.setSendingToBottom(true);
        }
        }
        mContainer.getDisplayContent().layoutAndAssignWindowLayersIfNeeded();
        mContainer.getDisplayContent().layoutAndAssignWindowLayersIfNeeded();
    }
    }
    }


    /**
    /**
     * Re-sizes a stack and its containing tasks.
     * Re-sizes a stack and its containing tasks.
@@ -179,7 +159,6 @@ public class StackWindowController
     */
     */
    public void resize(Rect bounds, SparseArray<Rect> taskBounds,
    public void resize(Rect bounds, SparseArray<Rect> taskBounds,
            SparseArray<Rect> taskTempInsetBounds) {
            SparseArray<Rect> taskTempInsetBounds) {
        synchronized (mGlobalLock) {
        if (mContainer == null) {
        if (mContainer == null) {
            throw new IllegalArgumentException("resizeStack: stack " + this + " not found.");
            throw new IllegalArgumentException("resizeStack: stack " + this + " not found.");
        }
        }
@@ -191,13 +170,10 @@ public class StackWindowController
            mService.mWindowPlacerLocked.performSurfacePlacement();
            mService.mWindowPlacerLocked.performSurfacePlacement();
        }
        }
    }
    }
    }


    public void onPipAnimationEndResize() {
    public void onPipAnimationEndResize() {
        synchronized (mService.mGlobalLock) {
        mContainer.onPipAnimationEndResize();
        mContainer.onPipAnimationEndResize();
    }
    }
    }


    /**
    /**
     * @see TaskStack.getStackDockedModeBoundsLocked(ConfigurationContainer, Rect, Rect, Rect)
     * @see TaskStack.getStackDockedModeBoundsLocked(ConfigurationContainer, Rect, Rect, Rect)
@@ -205,7 +181,6 @@ public class StackWindowController
    public void getStackDockedModeBounds(Configuration parentConfig, Rect dockedBounds,
    public void getStackDockedModeBounds(Configuration parentConfig, Rect dockedBounds,
            Rect currentTempTaskBounds,
            Rect currentTempTaskBounds,
            Rect outStackBounds, Rect outTempTaskBounds) {
            Rect outStackBounds, Rect outTempTaskBounds) {
        synchronized (mGlobalLock) {
        if (mContainer != null) {
        if (mContainer != null) {
            mContainer.getStackDockedModeBoundsLocked(parentConfig, dockedBounds,
            mContainer.getStackDockedModeBoundsLocked(parentConfig, dockedBounds,
                    currentTempTaskBounds, outStackBounds, outTempTaskBounds);
                    currentTempTaskBounds, outStackBounds, outTempTaskBounds);
@@ -214,37 +189,30 @@ public class StackWindowController
        outStackBounds.setEmpty();
        outStackBounds.setEmpty();
        outTempTaskBounds.setEmpty();
        outTempTaskBounds.setEmpty();
    }
    }
    }


    public void prepareFreezingTaskBounds() {
    public void prepareFreezingTaskBounds() {
        synchronized (mGlobalLock) {
        if (mContainer == null) {
        if (mContainer == null) {
            throw new IllegalArgumentException("prepareFreezingTaskBounds: stack " + this
            throw new IllegalArgumentException("prepareFreezingTaskBounds: stack " + this
                    + " not found.");
                    + " not found.");
        }
        }
        mContainer.prepareFreezingTaskBounds();
        mContainer.prepareFreezingTaskBounds();
    }
    }
    }


    public void getRawBounds(Rect outBounds) {
    public void getRawBounds(Rect outBounds) {
        synchronized (mGlobalLock) {
        if (mContainer.matchParentBounds()) {
        if (mContainer.matchParentBounds()) {
            outBounds.setEmpty();
            outBounds.setEmpty();
        } else {
        } else {
            mContainer.getRawBounds(outBounds);
            mContainer.getRawBounds(outBounds);
        }
        }
    }
    }
    }


    public void getBounds(Rect outBounds) {
    public void getBounds(Rect outBounds) {
        synchronized (mGlobalLock) {
        if (mContainer != null) {
        if (mContainer != null) {
            mContainer.getBounds(outBounds);
            mContainer.getBounds(outBounds);
            return;
            return;
        }
        }
        outBounds.setEmpty();
        outBounds.setEmpty();
    }
    }
    }


    /**
    /**
     * Adjusts the screen size in dp's for the {@param config} for the given params. The provided
     * Adjusts the screen size in dp's for the {@param config} for the given params. The provided
@@ -256,7 +224,6 @@ public class StackWindowController
            Rect nonDecorBounds, Rect stableBounds, boolean overrideWidth,
            Rect nonDecorBounds, Rect stableBounds, boolean overrideWidth,
            boolean overrideHeight, float density, Configuration config,
            boolean overrideHeight, float density, Configuration config,
            Configuration parentConfig, int windowingMode) {
            Configuration parentConfig, int windowingMode) {
        synchronized (mGlobalLock) {
        final TaskStack stack = mContainer;
        final TaskStack stack = mContainer;
        final DisplayContent displayContent = stack.getDisplayContent();
        final DisplayContent displayContent = stack.getDisplayContent();
        final DisplayInfo di = displayContent.getDisplayInfo();
        final DisplayInfo di = displayContent.getDisplayInfo();
@@ -323,7 +290,6 @@ public class StackWindowController
        config.smallestScreenWidthDp = getSmallestWidthForTaskBounds(
        config.smallestScreenWidthDp = getSmallestWidthForTaskBounds(
                bounds, density, windowingMode);
                bounds, density, windowingMode);
    }
    }
    }


    /**
    /**
     * Intersects the specified {@code inOutBounds} with the display frame that excludes the stable
     * Intersects the specified {@code inOutBounds} with the display frame that excludes the stable
Loading