Loading services/core/java/com/android/server/wm/DisplayAreaOrganizerController.java +2 −2 Original line number Diff line number Diff line Loading @@ -366,10 +366,10 @@ public class DisplayAreaOrganizerController extends IDisplayAreaOrganizerControl taskDisplayArea.setOrganizer(null); mService.mRootWindowContainer.mTaskSupervisor.beginDeferResume(); // TaskDisplayArea#remove() move the stacks to the default TaskDisplayArea. // TaskDisplayArea#remove() moves the stacks to the default TaskDisplayArea. Task lastReparentedRootTask; try { lastReparentedRootTask = taskDisplayArea.remove(); lastReparentedRootTask = taskDisplayArea.prepareForRemoval(); } finally { mService.mRootWindowContainer.mTaskSupervisor.endDeferResume(); } Loading services/core/java/com/android/server/wm/DisplayContent.java +7 −4 Original line number Diff line number Diff line Loading @@ -3265,7 +3265,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp mWmService.mDisplayWindowSettings.setShouldShowSystemDecorsLocked(this, shouldShow); if (!shouldShow) { clearAllTasksOnDisplay(null); clearAllTasksOnDisplay(null /* clearTasksCallback */, false /* isRemovingDisplay */); } } Loading Loading @@ -6471,12 +6471,15 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp return mRemoving; } void clearAllTasksOnDisplay(@Nullable Runnable clearTasksCallback) { private void clearAllTasksOnDisplay(@Nullable Runnable clearTasksCallback, boolean isRemovingDisplay) { Task lastReparentedRootTask; mRootWindowContainer.mTaskSupervisor.beginDeferResume(); try { lastReparentedRootTask = reduceOnAllTaskDisplayAreas((taskDisplayArea, rootTask) -> { final Task lastReparentedRootTaskFromArea = taskDisplayArea.remove(); final Task lastReparentedRootTaskFromArea = isRemovingDisplay ? taskDisplayArea.prepareForRemoval() : taskDisplayArea.setShouldKeepNoTask(true); if (lastReparentedRootTaskFromArea != null) { return lastReparentedRootTaskFromArea; } Loading Loading @@ -6506,7 +6509,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp if (mContentRecorder != null) { mContentRecorder.stopRecording(); } }); }, true /* isRemovingDisplay */); releaseSelfIfNeeded(); mDisplayPolicy.release(); Loading services/core/java/com/android/server/wm/RootWindowContainer.java +2 −2 Original line number Diff line number Diff line Loading @@ -1407,8 +1407,8 @@ class RootWindowContainer extends WindowContainer<DisplayContent> // When display content mode management flag is enabled, the task display area is marked as // removed when switching from extended display to mirroring display. We need to restart the // task display area before starting the home. if (enableDisplayContentModeManagement() && taskDisplayArea.isRemoved()) { taskDisplayArea.restart(); if (enableDisplayContentModeManagement() && taskDisplayArea.shouldKeepNoTask()) { taskDisplayArea.setShouldKeepNoTask(false); } Intent homeIntent = null; Loading services/core/java/com/android/server/wm/TaskDisplayArea.java +33 −9 Original line number Diff line number Diff line Loading @@ -154,6 +154,14 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> { */ private boolean mRemoved; /** * Whether the TaskDisplayArea has root tasks. * If {@code true}, the TaskDisplayArea cannot have a new task. * * TODO(b/394466501): Prevent a Task being added to the TaskDisplayArea that shouldKeepNoTask. */ private boolean mShouldKeepNoTask; /** * The id of a leaf task that most recently being moved to front. */ Loading Loading @@ -1787,6 +1795,10 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> { return mRemoved; } boolean shouldKeepNoTask() { return mShouldKeepNoTask; } @Override boolean canCreateRemoteAnimationTarget() { // In the legacy transition system, promoting animation target from TaskFragment to Loading @@ -1812,12 +1824,31 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> { } } @Nullable Task prepareForRemoval() { mShouldKeepNoTask = true; final Task lastReparentedTask = removeAllTasks(); mRemoved = true; return lastReparentedTask; } @Nullable Task setShouldKeepNoTask(boolean shouldKeepNoTask) { if (mShouldKeepNoTask == shouldKeepNoTask) { return null; } mShouldKeepNoTask = shouldKeepNoTask; return shouldKeepNoTask ? removeAllTasks() : null; } /** * Removes the root tasks in the node applying the content removal node from the display. * * @return last reparented root task, or {@code null} if the root tasks had to be destroyed. */ Task remove() { @Nullable private Task removeAllTasks() { final TaskDisplayArea toDisplayArea = getReparentToTaskDisplayArea(getFocusedRootTask()); mPreferredTopFocusableRootTask = null; // TODO(b/153090332): Allow setting content removal mode per task display area Loading @@ -1835,7 +1866,7 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> { for (int i = 0; i < numRootTasks; i++) { final WindowContainer child = mChildren.get(i); if (child.asTaskDisplayArea() != null) { lastReparentedRootTask = child.asTaskDisplayArea().remove(); lastReparentedRootTask = child.asTaskDisplayArea().removeAllTasks(); continue; } final Task task = mChildren.get(i).asTask(); Loading Loading @@ -1882,16 +1913,9 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> { lastReparentedRootTask.getRootTask().moveToFront("display-removed"); } mRemoved = true; return lastReparentedRootTask; } // TODO(b/385263090): Remove this method void restart() { mRemoved = false; } /** * Returns the {@link TaskDisplayArea} to which root tasks should be reparented. * Loading services/tests/wmtests/src/com/android/server/wm/DisplayAreaOrganizerTest.java +4 −2 Original line number Diff line number Diff line Loading @@ -223,9 +223,10 @@ public class DisplayAreaOrganizerTest extends WindowTestsBase { mOrganizerController.deleteTaskDisplayArea(newTda.mRemoteToken.toWindowContainerToken()); verify(newTda).remove(); verify(newTda).prepareForRemoval(); verify(newTda).removeImmediately(); assertThat(newTda.mOrganizer).isNull(); assertThat(newTda.shouldKeepNoTask()).isTrue(); assertThat(newTda.isRemoved()).isTrue(); final TaskDisplayArea curTda = mDisplayContent.getItemFromDisplayAreas( Loading @@ -248,9 +249,10 @@ public class DisplayAreaOrganizerTest extends WindowTestsBase { mOrganizerController.unregisterOrganizer(organizer); verify(newTda).remove(); verify(newTda).prepareForRemoval(); verify(newTda).removeImmediately(); assertThat(newTda.mOrganizer).isNull(); assertThat(newTda.shouldKeepNoTask()).isTrue(); assertThat(newTda.isRemoved()).isTrue(); final TaskDisplayArea curTda = mDisplayContent.getItemFromDisplayAreas( Loading Loading
services/core/java/com/android/server/wm/DisplayAreaOrganizerController.java +2 −2 Original line number Diff line number Diff line Loading @@ -366,10 +366,10 @@ public class DisplayAreaOrganizerController extends IDisplayAreaOrganizerControl taskDisplayArea.setOrganizer(null); mService.mRootWindowContainer.mTaskSupervisor.beginDeferResume(); // TaskDisplayArea#remove() move the stacks to the default TaskDisplayArea. // TaskDisplayArea#remove() moves the stacks to the default TaskDisplayArea. Task lastReparentedRootTask; try { lastReparentedRootTask = taskDisplayArea.remove(); lastReparentedRootTask = taskDisplayArea.prepareForRemoval(); } finally { mService.mRootWindowContainer.mTaskSupervisor.endDeferResume(); } Loading
services/core/java/com/android/server/wm/DisplayContent.java +7 −4 Original line number Diff line number Diff line Loading @@ -3265,7 +3265,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp mWmService.mDisplayWindowSettings.setShouldShowSystemDecorsLocked(this, shouldShow); if (!shouldShow) { clearAllTasksOnDisplay(null); clearAllTasksOnDisplay(null /* clearTasksCallback */, false /* isRemovingDisplay */); } } Loading Loading @@ -6471,12 +6471,15 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp return mRemoving; } void clearAllTasksOnDisplay(@Nullable Runnable clearTasksCallback) { private void clearAllTasksOnDisplay(@Nullable Runnable clearTasksCallback, boolean isRemovingDisplay) { Task lastReparentedRootTask; mRootWindowContainer.mTaskSupervisor.beginDeferResume(); try { lastReparentedRootTask = reduceOnAllTaskDisplayAreas((taskDisplayArea, rootTask) -> { final Task lastReparentedRootTaskFromArea = taskDisplayArea.remove(); final Task lastReparentedRootTaskFromArea = isRemovingDisplay ? taskDisplayArea.prepareForRemoval() : taskDisplayArea.setShouldKeepNoTask(true); if (lastReparentedRootTaskFromArea != null) { return lastReparentedRootTaskFromArea; } Loading Loading @@ -6506,7 +6509,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp if (mContentRecorder != null) { mContentRecorder.stopRecording(); } }); }, true /* isRemovingDisplay */); releaseSelfIfNeeded(); mDisplayPolicy.release(); Loading
services/core/java/com/android/server/wm/RootWindowContainer.java +2 −2 Original line number Diff line number Diff line Loading @@ -1407,8 +1407,8 @@ class RootWindowContainer extends WindowContainer<DisplayContent> // When display content mode management flag is enabled, the task display area is marked as // removed when switching from extended display to mirroring display. We need to restart the // task display area before starting the home. if (enableDisplayContentModeManagement() && taskDisplayArea.isRemoved()) { taskDisplayArea.restart(); if (enableDisplayContentModeManagement() && taskDisplayArea.shouldKeepNoTask()) { taskDisplayArea.setShouldKeepNoTask(false); } Intent homeIntent = null; Loading
services/core/java/com/android/server/wm/TaskDisplayArea.java +33 −9 Original line number Diff line number Diff line Loading @@ -154,6 +154,14 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> { */ private boolean mRemoved; /** * Whether the TaskDisplayArea has root tasks. * If {@code true}, the TaskDisplayArea cannot have a new task. * * TODO(b/394466501): Prevent a Task being added to the TaskDisplayArea that shouldKeepNoTask. */ private boolean mShouldKeepNoTask; /** * The id of a leaf task that most recently being moved to front. */ Loading Loading @@ -1787,6 +1795,10 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> { return mRemoved; } boolean shouldKeepNoTask() { return mShouldKeepNoTask; } @Override boolean canCreateRemoteAnimationTarget() { // In the legacy transition system, promoting animation target from TaskFragment to Loading @@ -1812,12 +1824,31 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> { } } @Nullable Task prepareForRemoval() { mShouldKeepNoTask = true; final Task lastReparentedTask = removeAllTasks(); mRemoved = true; return lastReparentedTask; } @Nullable Task setShouldKeepNoTask(boolean shouldKeepNoTask) { if (mShouldKeepNoTask == shouldKeepNoTask) { return null; } mShouldKeepNoTask = shouldKeepNoTask; return shouldKeepNoTask ? removeAllTasks() : null; } /** * Removes the root tasks in the node applying the content removal node from the display. * * @return last reparented root task, or {@code null} if the root tasks had to be destroyed. */ Task remove() { @Nullable private Task removeAllTasks() { final TaskDisplayArea toDisplayArea = getReparentToTaskDisplayArea(getFocusedRootTask()); mPreferredTopFocusableRootTask = null; // TODO(b/153090332): Allow setting content removal mode per task display area Loading @@ -1835,7 +1866,7 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> { for (int i = 0; i < numRootTasks; i++) { final WindowContainer child = mChildren.get(i); if (child.asTaskDisplayArea() != null) { lastReparentedRootTask = child.asTaskDisplayArea().remove(); lastReparentedRootTask = child.asTaskDisplayArea().removeAllTasks(); continue; } final Task task = mChildren.get(i).asTask(); Loading Loading @@ -1882,16 +1913,9 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> { lastReparentedRootTask.getRootTask().moveToFront("display-removed"); } mRemoved = true; return lastReparentedRootTask; } // TODO(b/385263090): Remove this method void restart() { mRemoved = false; } /** * Returns the {@link TaskDisplayArea} to which root tasks should be reparented. * Loading
services/tests/wmtests/src/com/android/server/wm/DisplayAreaOrganizerTest.java +4 −2 Original line number Diff line number Diff line Loading @@ -223,9 +223,10 @@ public class DisplayAreaOrganizerTest extends WindowTestsBase { mOrganizerController.deleteTaskDisplayArea(newTda.mRemoteToken.toWindowContainerToken()); verify(newTda).remove(); verify(newTda).prepareForRemoval(); verify(newTda).removeImmediately(); assertThat(newTda.mOrganizer).isNull(); assertThat(newTda.shouldKeepNoTask()).isTrue(); assertThat(newTda.isRemoved()).isTrue(); final TaskDisplayArea curTda = mDisplayContent.getItemFromDisplayAreas( Loading @@ -248,9 +249,10 @@ public class DisplayAreaOrganizerTest extends WindowTestsBase { mOrganizerController.unregisterOrganizer(organizer); verify(newTda).remove(); verify(newTda).prepareForRemoval(); verify(newTda).removeImmediately(); assertThat(newTda.mOrganizer).isNull(); assertThat(newTda.shouldKeepNoTask()).isTrue(); assertThat(newTda.isRemoved()).isTrue(); final TaskDisplayArea curTda = mDisplayContent.getItemFromDisplayAreas( Loading