Loading services/core/java/com/android/server/wm/ActivityRecord.java +11 −1 Original line number Original line Diff line number Diff line Loading @@ -7411,7 +7411,17 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A */ */ boolean isResumedActivityOnDisplay() { boolean isResumedActivityOnDisplay() { final DisplayContent display = getDisplay(); final DisplayContent display = getDisplay(); return display != null && this == display.mTaskContainers.getResumedActivity(); if (display == null) { return false; } for (int tdaNdx = display.getTaskDisplayAreaCount() - 1; tdaNdx >= 0; --tdaNdx) { final TaskDisplayArea taskDisplayArea = display.getTaskDisplayAreaAt(tdaNdx); final ActivityRecord resumedActivity = taskDisplayArea.getFocusedActivity(); if (resumedActivity != null) { return resumedActivity == this; } } return false; } } Loading services/core/java/com/android/server/wm/ActivityStack.java +2 −2 Original line number Original line Diff line number Diff line Loading @@ -1119,8 +1119,8 @@ class ActivityStack extends Task { @Override @Override public boolean isAttached() { public boolean isAttached() { final DisplayContent display = getDisplay(); final TaskDisplayArea taskDisplayArea = getDisplayArea(); return display != null && !display.isRemoved(); return taskDisplayArea != null && !taskDisplayArea.isRemoved(); } } // TODO: Should each user have there own stacks? // TODO: Should each user have there own stacks? Loading services/core/java/com/android/server/wm/ActivityStackSupervisor.java +24 −23 Original line number Original line Diff line number Diff line Loading @@ -385,15 +385,15 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks { private final MoveTaskToFullscreenHelper mMoveTaskToFullscreenHelper = private final MoveTaskToFullscreenHelper mMoveTaskToFullscreenHelper = new MoveTaskToFullscreenHelper(); new MoveTaskToFullscreenHelper(); private class MoveTaskToFullscreenHelper { private class MoveTaskToFullscreenHelper { private DisplayContent mToDisplay; private TaskDisplayArea mToDisplayArea; private boolean mOnTop; private boolean mOnTop; private Task mTopTask; private Task mTopTask; private boolean mSchedulePictureInPictureModeChange; private boolean mSchedulePictureInPictureModeChange; void process(ActivityStack fromStack, DisplayContent toDisplay, boolean onTop, void process(ActivityStack fromStack, TaskDisplayArea toDisplayArea, boolean onTop, boolean schedulePictureInPictureModeChange) { boolean schedulePictureInPictureModeChange) { mSchedulePictureInPictureModeChange = schedulePictureInPictureModeChange; mSchedulePictureInPictureModeChange = schedulePictureInPictureModeChange; mToDisplay = toDisplay; mToDisplayArea = toDisplayArea; mOnTop = onTop; mOnTop = onTop; mTopTask = fromStack.getTopMostTask(); mTopTask = fromStack.getTopMostTask(); Loading @@ -401,7 +401,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks { MoveTaskToFullscreenHelper::processLeafTask, this, PooledLambda.__(Task.class)); MoveTaskToFullscreenHelper::processLeafTask, this, PooledLambda.__(Task.class)); fromStack.forAllLeafTasks(c, false /* traverseTopToBottom */); fromStack.forAllLeafTasks(c, false /* traverseTopToBottom */); c.recycle(); c.recycle(); mToDisplay = null; mToDisplayArea = null; mTopTask = null; mTopTask = null; } } Loading @@ -411,19 +411,18 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks { task.getActivityType())) { task.getActivityType())) { final ActivityStack stack = (ActivityStack) task; final ActivityStack stack = (ActivityStack) task; stack.setWindowingMode(WINDOWING_MODE_FULLSCREEN); stack.setWindowingMode(WINDOWING_MODE_FULLSCREEN); if (mToDisplay.getDisplayId() != stack.getDisplayId()) { if (mToDisplayArea.getDisplayId() != stack.getDisplayId()) { stack.reparent(mToDisplay.getDefaultTaskDisplayArea(), mOnTop); stack.reparent(mToDisplayArea, mOnTop); } else if (mOnTop) { } else if (mOnTop) { mToDisplay.mTaskContainers.positionStackAtTop(stack, mToDisplayArea.positionStackAtTop(stack, false /* includingParents */); false /* includingParents */); } else { } else { mToDisplay.mTaskContainers.positionStackAtBottom(stack); mToDisplayArea.positionStackAtBottom(stack); } } return; return; } } final ActivityStack toStack = mToDisplay.mTaskContainers.getOrCreateStack( final ActivityStack toStack = mToDisplayArea.getOrCreateStack(null, mTmpOptions, task, null, mTmpOptions, task, task.getActivityType(), mOnTop); task.getActivityType(), mOnTop); if (task == toStack) { if (task == toStack) { // The task was reused as the root task. // The task was reused as the root task. return; return; Loading Loading @@ -1418,7 +1417,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks { mRootWindowContainer.getLaunchStack(null, options, task, ON_TOP); mRootWindowContainer.getLaunchStack(null, options, task, ON_TOP); if (stack != currentStack) { if (stack != currentStack) { moveHomeStackToFrontIfNeeded(flags, stack.getDisplay(), reason); moveHomeStackToFrontIfNeeded(flags, stack.getDisplayArea(), reason); task.reparent(stack, ON_TOP, REPARENT_KEEP_STACK_AT_FRONT, !ANIMATE, DEFER_RESUME, task.reparent(stack, ON_TOP, REPARENT_KEEP_STACK_AT_FRONT, !ANIMATE, DEFER_RESUME, reason); reason); currentStack = stack; currentStack = stack; Loading @@ -1437,7 +1436,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks { } } if (!reparented) { if (!reparented) { moveHomeStackToFrontIfNeeded(flags, currentStack.getDisplay(), reason); moveHomeStackToFrontIfNeeded(flags, currentStack.getDisplayArea(), reason); } } final ActivityRecord r = task.getTopNonFinishingActivity(); final ActivityRecord r = task.getTopNonFinishingActivity(); Loading @@ -1451,15 +1450,16 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks { currentStack, forceNonResizeable); currentStack, forceNonResizeable); } } private void moveHomeStackToFrontIfNeeded(int flags, DisplayContent display, String reason) { private void moveHomeStackToFrontIfNeeded(int flags, TaskDisplayArea taskDisplayArea, final ActivityStack focusedStack = display.getFocusedStack(); String reason) { final ActivityStack focusedStack = taskDisplayArea.getFocusedStack(); if ((display.getWindowingMode() == WINDOWING_MODE_FULLSCREEN if ((taskDisplayArea.getWindowingMode() == WINDOWING_MODE_FULLSCREEN && (flags & ActivityManager.MOVE_TASK_WITH_HOME) != 0) && (flags & ActivityManager.MOVE_TASK_WITH_HOME) != 0) || (focusedStack != null && focusedStack.isActivityTypeRecents())) { || (focusedStack != null && focusedStack.isActivityTypeRecents())) { // We move home stack to front when we are on a fullscreen display and caller has // We move home stack to front when we are on a fullscreen display area and caller has // requested the home activity to move with it. Or the previous stack is recents. // requested the home activity to move with it. Or the previous stack is recents. display.mTaskContainers.moveHomeStackToFront(reason); taskDisplayArea.moveHomeStackToFront(reason); } } } } Loading Loading @@ -1511,15 +1511,15 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks { mService.deferWindowLayout(); mService.deferWindowLayout(); try { try { final int windowingMode = fromStack.getWindowingMode(); final int windowingMode = fromStack.getWindowingMode(); final DisplayContent toDisplay = final TaskDisplayArea toDisplayArea = mRootWindowContainer mRootWindowContainer.getDisplayContent(toDisplayId); .getDisplayContent(toDisplayId).getDefaultTaskDisplayArea(); if (windowingMode == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY) { if (windowingMode == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY) { // We are moving all tasks from the docked stack to the fullscreen stack, // We are moving all tasks from the docked stack to the fullscreen stack, // which is dismissing the docked stack, so resize all other stacks to // which is dismissing the docked stack, so resize all other stacks to // fullscreen here already so we don't end up with resize trashing. // fullscreen here already so we don't end up with resize trashing. for (int i = toDisplay.getStackCount() - 1; i >= 0; --i) { for (int i = toDisplayArea.getStackCount() - 1; i >= 0; --i) { final ActivityStack otherStack = toDisplay.getStackAt(i); final ActivityStack otherStack = toDisplayArea.getStackAt(i); if (!otherStack.inSplitScreenSecondaryWindowingMode()) { if (!otherStack.inSplitScreenSecondaryWindowingMode()) { continue; continue; } } Loading @@ -1535,7 +1535,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks { if (fromStack.hasChild()) { if (fromStack.hasChild()) { mTmpOptions.setLaunchWindowingMode(WINDOWING_MODE_FULLSCREEN); mTmpOptions.setLaunchWindowingMode(WINDOWING_MODE_FULLSCREEN); mMoveTaskToFullscreenHelper.process( mMoveTaskToFullscreenHelper.process( fromStack, toDisplay, onTop, schedulePictureInPictureModeChange); fromStack, toDisplayArea, onTop, schedulePictureInPictureModeChange); } } mRootWindowContainer.ensureActivitiesVisible(null, 0, PRESERVE_WINDOWS); mRootWindowContainer.ensureActivitiesVisible(null, 0, PRESERVE_WINDOWS); Loading @@ -1546,6 +1546,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks { } } void moveTasksToFullscreenStackLocked(ActivityStack fromStack, boolean onTop) { void moveTasksToFullscreenStackLocked(ActivityStack fromStack, boolean onTop) { // TODO(b/153089193): Support moving within the same task display area mWindowManager.inSurfaceTransaction(() -> mWindowManager.inSurfaceTransaction(() -> moveTasksToFullscreenStackInSurfaceTransaction(fromStack, DEFAULT_DISPLAY, onTop)); moveTasksToFullscreenStackInSurfaceTransaction(fromStack, DEFAULT_DISPLAY, onTop)); } } Loading services/core/java/com/android/server/wm/ActivityStartController.java +3 −2 Original line number Original line Diff line number Diff line Loading @@ -189,9 +189,10 @@ public class ActivityStartController { mSupervisor.beginDeferResume(); mSupervisor.beginDeferResume(); final ActivityStack homeStack; final ActivityStack homeStack; try { try { // TODO(multi-display-area): Support starting home in a task display area // Make sure home stack exist on display. // Make sure home stack exist on display. homeStack = display.mTaskContainers.getOrCreateStack(WINDOWING_MODE_FULLSCREEN, homeStack = display.getDefaultTaskDisplayArea().getOrCreateStack( ACTIVITY_TYPE_HOME, ON_TOP); WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_HOME, ON_TOP); } finally { } finally { mSupervisor.endDeferResume(); mSupervisor.endDeferResume(); } } Loading services/core/java/com/android/server/wm/DisplayContent.java +119 −80 Original line number Original line Diff line number Diff line Loading @@ -2060,20 +2060,53 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo * activity type. Null is no compatible stack on the display. * activity type. Null is no compatible stack on the display. */ */ ActivityStack getStack(int windowingMode, int activityType) { ActivityStack getStack(int windowingMode, int activityType) { return mTaskContainers.getStack(windowingMode, activityType); for (int tdaNdx = getTaskDisplayAreaCount() - 1; tdaNdx >= 0; --tdaNdx) { final ActivityStack stack = getTaskDisplayAreaAt(tdaNdx) .getStack(windowingMode, activityType); if (stack != null) { return stack; } } return null; } } protected int getStackCount() { protected int getTaskDisplayAreaCount() { return mTaskContainers.mChildren.size(); // TODO(multi-display-area): Report actual display area count return 1; } protected TaskDisplayArea getTaskDisplayAreaAt(int index) { // TODO(multi-display-area): Report actual display area values return mTaskContainers; } } protected ActivityStack getStackAt(int index) { ActivityStack getStack(int rootTaskId) { return mTaskContainers.mChildren.get(index); for (int tdaNdx = getTaskDisplayAreaCount() - 1; tdaNdx >= 0; --tdaNdx) { final ActivityStack stack = getTaskDisplayAreaAt(tdaNdx).getStack(rootTaskId); if (stack != null) { return stack; } } return null; } protected int getStackCount() { int totalStackCount = 0; for (int i = getTaskDisplayAreaCount() - 1; i >= 0; --i) { totalStackCount += getTaskDisplayAreaAt(i).getStackCount(); } return totalStackCount; } } @VisibleForTesting @VisibleForTesting ActivityStack getTopStack() { ActivityStack getTopStack() { return mTaskContainers.getTopStack(); for (int i = getTaskDisplayAreaCount() - 1; i >= 0; --i) { final ActivityStack stack = getTaskDisplayAreaAt(i).getTopStack(); if (stack != null) { return stack; } } return null; } } /** /** Loading Loading @@ -2449,7 +2482,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo final PooledConsumer c = PooledLambda.obtainConsumer( final PooledConsumer c = PooledLambda.obtainConsumer( DisplayContent::processTaskForTouchExcludeRegion, this, DisplayContent::processTaskForTouchExcludeRegion, this, PooledLambda.__(Task.class), focusedTask, delta); PooledLambda.__(Task.class), focusedTask, delta); mTaskContainers.forAllTasks(c); forAllTasks(c); c.recycle(); c.recycle(); // If we removed the focused task above, add it back and only leave its // If we removed the focused task above, add it back and only leave its Loading Loading @@ -2630,9 +2663,8 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo } } void prepareFreezingTaskBounds() { void prepareFreezingTaskBounds() { for (int stackNdx = mTaskContainers.getChildCount() - 1; stackNdx >= 0; --stackNdx) { for (int tdaNdx = getTaskDisplayAreaCount() - 1; tdaNdx >= 0; --tdaNdx) { final ActivityStack stack = mTaskContainers.getChildAt(stackNdx); getTaskDisplayAreaAt(tdaNdx).prepareFreezingTaskBounds(); stack.prepareFreezingTaskBounds(); } } } } Loading Loading @@ -2738,8 +2770,8 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo final ActivityStack focusedStack = getFocusedStack(); final ActivityStack focusedStack = getFocusedStack(); if (focusedStack != null) { if (focusedStack != null) { proto.write(FOCUSED_ROOT_TASK_ID, focusedStack.getRootTaskId()); proto.write(FOCUSED_ROOT_TASK_ID, focusedStack.getRootTaskId()); final ActivityRecord focusedActivity = focusedStack.getDisplay().mTaskContainers final ActivityRecord focusedActivity = focusedStack.getDisplayArea() .getResumedActivity(); .getFocusedActivity(); if (focusedActivity != null) { if (focusedActivity != null) { focusedActivity.writeIdentifierToProto(proto, RESUMED_ACTIVITY); focusedActivity.writeIdentifierToProto(proto, RESUMED_ACTIVITY); } } Loading Loading @@ -2797,13 +2829,6 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo if (mLastFocus != mCurrentFocus) { if (mLastFocus != mCurrentFocus) { pw.print(" mLastFocus="); pw.println(mLastFocus); pw.print(" mLastFocus="); pw.println(mLastFocus); } } if (mTaskContainers.mPreferredTopFocusableStack != null) { pw.println(prefix + "mPreferredTopFocusableStack=" + mTaskContainers.mPreferredTopFocusableStack); } if (mTaskContainers.mLastFocusedStack != null) { pw.println(prefix + "mLastFocusedStack=" + mTaskContainers.mLastFocusedStack); } if (mLosingFocus.size() > 0) { if (mLosingFocus.size() > 0) { pw.println(); pw.println(); pw.println(" Windows losing focus:"); pw.println(" Windows losing focus:"); Loading Loading @@ -2837,10 +2862,9 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo } } pw.println(); pw.println(); pw.println(prefix + "Application tokens in top down Z order:"); pw.println(prefix + "Task display areas in top down Z order:"); for (int stackNdx = mTaskContainers.getChildCount() - 1; stackNdx >= 0; --stackNdx) { for (int tdaNdx = getTaskDisplayAreaCount() - 1; tdaNdx >= 0; --tdaNdx) { final ActivityStack stack = mTaskContainers.getChildAt(stackNdx); getTaskDisplayAreaAt(tdaNdx).dump(pw, prefix + " ", dumpAll); stack.dump(pw, prefix + " ", dumpAll); } } pw.println(); pw.println(); Loading Loading @@ -4002,7 +4026,9 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo } } // Initialize state of exiting applications. // Initialize state of exiting applications. mTaskContainers.setExitingTokensHasVisible(hasVisible); for (int i = getTaskDisplayAreaCount() - 1; i >= 0; --i) { getTaskDisplayAreaAt(i).setExitingTokensHasVisible(hasVisible); } } } void removeExistingTokensIfPossible() { void removeExistingTokensIfPossible() { Loading @@ -4014,7 +4040,9 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo } } // Time to remove any exiting applications? // Time to remove any exiting applications? mTaskContainers.removeExistingAppTokensIfPossible(); for (int i = getTaskDisplayAreaCount() - 1; i >= 0; --i) { getTaskDisplayAreaAt(i).removeExistingAppTokensIfPossible(); } } } @Override @Override Loading Loading @@ -4475,7 +4503,9 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo } } void assignStackOrdering() { void assignStackOrdering() { mTaskContainers.assignStackOrdering(getPendingTransaction()); for (int i = getTaskDisplayAreaCount() - 1; i >= 0; --i) { getTaskDisplayAreaAt(i).assignStackOrdering(getPendingTransaction()); } } } /** /** Loading Loading @@ -5002,13 +5032,15 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo || windowingMode == WINDOWING_MODE_MULTI_WINDOW); || windowingMode == WINDOWING_MODE_MULTI_WINDOW); } } ActivityStack createStack(int windowingMode, int activityType, boolean onTop) { @Nullable return mTaskContainers.createStack(windowingMode, activityType, onTop, null /* info */, null /* intent */, false /* createdByOrganizer */); } ActivityStack getFocusedStack() { ActivityStack getFocusedStack() { return mTaskContainers.getFocusedStack(); for (int i = getTaskDisplayAreaCount() - 1; i >= 0; --i) { final ActivityStack stack = getTaskDisplayAreaAt(i).getFocusedStack(); if (stack != null) { return stack; } } return null; } } /** /** Loading @@ -5016,11 +5048,15 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo * ACTIVITY_TYPE_STANDARD or ACTIVITY_TYPE_UNDEFINED * ACTIVITY_TYPE_STANDARD or ACTIVITY_TYPE_UNDEFINED */ */ void removeStacksInWindowingModes(int... windowingModes) { void removeStacksInWindowingModes(int... windowingModes) { mTaskContainers.removeStacksInWindowingModes(windowingModes); for (int i = getTaskDisplayAreaCount() - 1; i >= 0; --i) { getTaskDisplayAreaAt(i).removeStacksInWindowingModes(windowingModes); } } } void removeStacksWithActivityTypes(int... activityTypes) { void removeStacksWithActivityTypes(int... activityTypes) { mTaskContainers.removeStacksWithActivityTypes(activityTypes); for (int i = getTaskDisplayAreaCount() - 1; i >= 0; --i) { getTaskDisplayAreaAt(i).removeStacksWithActivityTypes(activityTypes); } } } ActivityRecord topRunningActivity() { ActivityRecord topRunningActivity() { Loading @@ -5037,7 +5073,14 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo * @return The top running activity. {@code null} if none is available. * @return The top running activity. {@code null} if none is available. */ */ ActivityRecord topRunningActivity(boolean considerKeyguardState) { ActivityRecord topRunningActivity(boolean considerKeyguardState) { return mTaskContainers.topRunningActivity(considerKeyguardState); for (int i = getTaskDisplayAreaCount() - 1; i >= 0; --i) { final ActivityRecord activity = getTaskDisplayAreaAt(i) .topRunningActivity(considerKeyguardState); if (activity != null) { return activity; } } return null; } } boolean updateDisplayOverrideConfigurationLocked() { boolean updateDisplayOverrideConfigurationLocked() { Loading Loading @@ -5149,7 +5192,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo // The display may be about to rotate seamlessly, and the animation of closing apps may // The display may be about to rotate seamlessly, and the animation of closing apps may // still animate in old rotation. So make sure the outdated animation won't show on the // still animate in old rotation. So make sure the outdated animation won't show on the // rotated display. // rotated display. mTaskContainers.forAllActivities(a -> { forAllActivities(a -> { if (a.nowVisible && a != mFixedRotationLaunchingApp if (a.nowVisible && a != mFixedRotationLaunchingApp && a.getWindowConfiguration().getRotation() != newRotation) { && a.getWindowConfiguration().getRotation() != newRotation) { final WindowContainer<?> w = a.getAnimatingContainer(); final WindowContainer<?> w = a.getAnimatingContainer(); Loading Loading @@ -5210,40 +5253,17 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo void remove() { void remove() { mRemoving = true; mRemoving = true; final boolean destroyContentOnRemoval = shouldDestroyContentOnRemove(); ActivityStack lastReparentedStack = null; ActivityStack lastReparentedStack = null; mTaskContainers.mPreferredTopFocusableStack = null; // Stacks could be reparented from the removed display to other display. While // reparenting the last stack of the removed display, the remove display is ready to be // released (no more ActivityStack). But, we cannot release it at that moment or the // related WindowContainer will also be removed. So, we set display as removed after // reparenting stack finished. final TaskDisplayArea toTaskDisplayArea = mRootWindowContainer.getDefaultTaskDisplayArea(); mRootWindowContainer.mStackSupervisor.beginDeferResume(); mRootWindowContainer.mStackSupervisor.beginDeferResume(); try { try { int numStacks = getStackCount(); int numTaskContainers = getTaskDisplayAreaCount(); // Keep the order from bottom to top. for (int tdaNdx = 0; tdaNdx < numTaskContainers; tdaNdx++) { for (int stackNdx = 0; stackNdx < numStacks; stackNdx++) { final ActivityStack lastReparentedStackFromArea = getTaskDisplayAreaAt(tdaNdx) final ActivityStack stack = getStackAt(stackNdx); .remove(); // Always finish non-standard type stacks. if (lastReparentedStackFromArea != null) { if (destroyContentOnRemoval || !stack.isActivityTypeStandardOrUndefined()) { lastReparentedStack = lastReparentedStackFromArea; stack.finishAllActivitiesImmediately(); } } else { // If default display is in split-window mode, set windowing mode of the stack // to split-screen secondary. Otherwise, set the windowing mode to undefined by // default to let stack inherited the windowing mode from the new display. final int windowingMode = toTaskDisplayArea.isSplitScreenModeActivated() ? WINDOWING_MODE_SPLIT_SCREEN_SECONDARY : WINDOWING_MODE_UNDEFINED; stack.reparent(toTaskDisplayArea, true /* onTop */); stack.setWindowingMode(windowingMode); lastReparentedStack = stack; } // Stacks may be removed from this display. Ensure each stack will be processed and // the loop will end. stackNdx -= numStacks - getStackCount(); numStacks = getStackCount(); } } } finally { } finally { mRootWindowContainer.mStackSupervisor.endDeferResume(); mRootWindowContainer.mStackSupervisor.endDeferResume(); Loading @@ -5270,12 +5290,27 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo return; return; } } final ActivityStack stack = getStackCount() == 1 ? getStackAt(0) : null; // Check if all task display areas have only the empty home stacks left. if (stack != null && stack.isActivityTypeHome() && !stack.hasChild()) { boolean onlyEmptyHomeStacksLeft = true; // Release this display if an empty home stack is the only thing left. for (int tdaNdx = getTaskDisplayAreaCount() - 1; tdaNdx >= 0; --tdaNdx) { // Since it is the last stack, this display will be released along with the stack final TaskDisplayArea taskDisplayArea = getTaskDisplayAreaAt(tdaNdx); // removal. if (taskDisplayArea.getStackCount() != 1) { stack.removeIfPossible(); onlyEmptyHomeStacksLeft = false; break; } final ActivityStack stack = taskDisplayArea.getStackAt(0); if (!stack.isActivityTypeHome() || stack.hasChild()) { onlyEmptyHomeStacksLeft = false; break; } } if (onlyEmptyHomeStacksLeft) { // Release this display if only empty home stack(s) are left. This display will be // released along with the stack(s) removal. for (int tdaNdx = getTaskDisplayAreaCount() - 1; tdaNdx >= 0; --tdaNdx) { final ActivityStack s = getTaskDisplayAreaAt(tdaNdx).getStackAt(0); s.removeIfPossible(); } } else if (getTopStack() == null) { } else if (getTopStack() == null) { removeIfPossible(); removeIfPossible(); mRootWindowContainer.mStackSupervisor mRootWindowContainer.mStackSupervisor Loading Loading @@ -5334,10 +5369,9 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo void ensureActivitiesVisible(ActivityRecord starting, int configChanges, void ensureActivitiesVisible(ActivityRecord starting, int configChanges, boolean preserveWindows, boolean notifyClients) { boolean preserveWindows, boolean notifyClients) { for (int stackNdx = getStackCount() - 1; stackNdx >= 0; --stackNdx) { for (int i = getTaskDisplayAreaCount() - 1; i >= 0; --i) { final ActivityStack stack = getStackAt(stackNdx); getTaskDisplayAreaAt(i).ensureActivitiesVisible(starting, configChanges, stack.ensureActivitiesVisible(starting, configChanges, preserveWindows, preserveWindows, notifyClients); notifyClients); } } } } Loading @@ -5350,13 +5384,18 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo } } void setDisplayToSingleTaskInstance() { void setDisplayToSingleTaskInstance() { final int childCount = getStackCount(); final int taskDisplayAreaCount = getTaskDisplayAreaCount(); if (childCount > 1) { if (taskDisplayAreaCount > 1) { throw new IllegalArgumentException( "Display already has multiple task display areas. display=" + this); } final int stackCount = getDefaultTaskDisplayArea().getStackCount(); if (stackCount > 1) { throw new IllegalArgumentException("Display already has multiple stacks. display=" throw new IllegalArgumentException("Display already has multiple stacks. display=" + this); + this); } } if (childCount > 0) { if (stackCount > 0) { final ActivityStack stack = getStackAt(0); final ActivityStack stack = getDefaultTaskDisplayArea().getStackAt(0); if (stack.getChildCount() > 1) { if (stack.getChildCount() > 1) { throw new IllegalArgumentException("Display stack already has multiple tasks." throw new IllegalArgumentException("Display stack already has multiple tasks." + " display=" + this + " stack=" + stack); + " display=" + this + " stack=" + stack); Loading Loading
services/core/java/com/android/server/wm/ActivityRecord.java +11 −1 Original line number Original line Diff line number Diff line Loading @@ -7411,7 +7411,17 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A */ */ boolean isResumedActivityOnDisplay() { boolean isResumedActivityOnDisplay() { final DisplayContent display = getDisplay(); final DisplayContent display = getDisplay(); return display != null && this == display.mTaskContainers.getResumedActivity(); if (display == null) { return false; } for (int tdaNdx = display.getTaskDisplayAreaCount() - 1; tdaNdx >= 0; --tdaNdx) { final TaskDisplayArea taskDisplayArea = display.getTaskDisplayAreaAt(tdaNdx); final ActivityRecord resumedActivity = taskDisplayArea.getFocusedActivity(); if (resumedActivity != null) { return resumedActivity == this; } } return false; } } Loading
services/core/java/com/android/server/wm/ActivityStack.java +2 −2 Original line number Original line Diff line number Diff line Loading @@ -1119,8 +1119,8 @@ class ActivityStack extends Task { @Override @Override public boolean isAttached() { public boolean isAttached() { final DisplayContent display = getDisplay(); final TaskDisplayArea taskDisplayArea = getDisplayArea(); return display != null && !display.isRemoved(); return taskDisplayArea != null && !taskDisplayArea.isRemoved(); } } // TODO: Should each user have there own stacks? // TODO: Should each user have there own stacks? Loading
services/core/java/com/android/server/wm/ActivityStackSupervisor.java +24 −23 Original line number Original line Diff line number Diff line Loading @@ -385,15 +385,15 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks { private final MoveTaskToFullscreenHelper mMoveTaskToFullscreenHelper = private final MoveTaskToFullscreenHelper mMoveTaskToFullscreenHelper = new MoveTaskToFullscreenHelper(); new MoveTaskToFullscreenHelper(); private class MoveTaskToFullscreenHelper { private class MoveTaskToFullscreenHelper { private DisplayContent mToDisplay; private TaskDisplayArea mToDisplayArea; private boolean mOnTop; private boolean mOnTop; private Task mTopTask; private Task mTopTask; private boolean mSchedulePictureInPictureModeChange; private boolean mSchedulePictureInPictureModeChange; void process(ActivityStack fromStack, DisplayContent toDisplay, boolean onTop, void process(ActivityStack fromStack, TaskDisplayArea toDisplayArea, boolean onTop, boolean schedulePictureInPictureModeChange) { boolean schedulePictureInPictureModeChange) { mSchedulePictureInPictureModeChange = schedulePictureInPictureModeChange; mSchedulePictureInPictureModeChange = schedulePictureInPictureModeChange; mToDisplay = toDisplay; mToDisplayArea = toDisplayArea; mOnTop = onTop; mOnTop = onTop; mTopTask = fromStack.getTopMostTask(); mTopTask = fromStack.getTopMostTask(); Loading @@ -401,7 +401,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks { MoveTaskToFullscreenHelper::processLeafTask, this, PooledLambda.__(Task.class)); MoveTaskToFullscreenHelper::processLeafTask, this, PooledLambda.__(Task.class)); fromStack.forAllLeafTasks(c, false /* traverseTopToBottom */); fromStack.forAllLeafTasks(c, false /* traverseTopToBottom */); c.recycle(); c.recycle(); mToDisplay = null; mToDisplayArea = null; mTopTask = null; mTopTask = null; } } Loading @@ -411,19 +411,18 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks { task.getActivityType())) { task.getActivityType())) { final ActivityStack stack = (ActivityStack) task; final ActivityStack stack = (ActivityStack) task; stack.setWindowingMode(WINDOWING_MODE_FULLSCREEN); stack.setWindowingMode(WINDOWING_MODE_FULLSCREEN); if (mToDisplay.getDisplayId() != stack.getDisplayId()) { if (mToDisplayArea.getDisplayId() != stack.getDisplayId()) { stack.reparent(mToDisplay.getDefaultTaskDisplayArea(), mOnTop); stack.reparent(mToDisplayArea, mOnTop); } else if (mOnTop) { } else if (mOnTop) { mToDisplay.mTaskContainers.positionStackAtTop(stack, mToDisplayArea.positionStackAtTop(stack, false /* includingParents */); false /* includingParents */); } else { } else { mToDisplay.mTaskContainers.positionStackAtBottom(stack); mToDisplayArea.positionStackAtBottom(stack); } } return; return; } } final ActivityStack toStack = mToDisplay.mTaskContainers.getOrCreateStack( final ActivityStack toStack = mToDisplayArea.getOrCreateStack(null, mTmpOptions, task, null, mTmpOptions, task, task.getActivityType(), mOnTop); task.getActivityType(), mOnTop); if (task == toStack) { if (task == toStack) { // The task was reused as the root task. // The task was reused as the root task. return; return; Loading Loading @@ -1418,7 +1417,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks { mRootWindowContainer.getLaunchStack(null, options, task, ON_TOP); mRootWindowContainer.getLaunchStack(null, options, task, ON_TOP); if (stack != currentStack) { if (stack != currentStack) { moveHomeStackToFrontIfNeeded(flags, stack.getDisplay(), reason); moveHomeStackToFrontIfNeeded(flags, stack.getDisplayArea(), reason); task.reparent(stack, ON_TOP, REPARENT_KEEP_STACK_AT_FRONT, !ANIMATE, DEFER_RESUME, task.reparent(stack, ON_TOP, REPARENT_KEEP_STACK_AT_FRONT, !ANIMATE, DEFER_RESUME, reason); reason); currentStack = stack; currentStack = stack; Loading @@ -1437,7 +1436,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks { } } if (!reparented) { if (!reparented) { moveHomeStackToFrontIfNeeded(flags, currentStack.getDisplay(), reason); moveHomeStackToFrontIfNeeded(flags, currentStack.getDisplayArea(), reason); } } final ActivityRecord r = task.getTopNonFinishingActivity(); final ActivityRecord r = task.getTopNonFinishingActivity(); Loading @@ -1451,15 +1450,16 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks { currentStack, forceNonResizeable); currentStack, forceNonResizeable); } } private void moveHomeStackToFrontIfNeeded(int flags, DisplayContent display, String reason) { private void moveHomeStackToFrontIfNeeded(int flags, TaskDisplayArea taskDisplayArea, final ActivityStack focusedStack = display.getFocusedStack(); String reason) { final ActivityStack focusedStack = taskDisplayArea.getFocusedStack(); if ((display.getWindowingMode() == WINDOWING_MODE_FULLSCREEN if ((taskDisplayArea.getWindowingMode() == WINDOWING_MODE_FULLSCREEN && (flags & ActivityManager.MOVE_TASK_WITH_HOME) != 0) && (flags & ActivityManager.MOVE_TASK_WITH_HOME) != 0) || (focusedStack != null && focusedStack.isActivityTypeRecents())) { || (focusedStack != null && focusedStack.isActivityTypeRecents())) { // We move home stack to front when we are on a fullscreen display and caller has // We move home stack to front when we are on a fullscreen display area and caller has // requested the home activity to move with it. Or the previous stack is recents. // requested the home activity to move with it. Or the previous stack is recents. display.mTaskContainers.moveHomeStackToFront(reason); taskDisplayArea.moveHomeStackToFront(reason); } } } } Loading Loading @@ -1511,15 +1511,15 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks { mService.deferWindowLayout(); mService.deferWindowLayout(); try { try { final int windowingMode = fromStack.getWindowingMode(); final int windowingMode = fromStack.getWindowingMode(); final DisplayContent toDisplay = final TaskDisplayArea toDisplayArea = mRootWindowContainer mRootWindowContainer.getDisplayContent(toDisplayId); .getDisplayContent(toDisplayId).getDefaultTaskDisplayArea(); if (windowingMode == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY) { if (windowingMode == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY) { // We are moving all tasks from the docked stack to the fullscreen stack, // We are moving all tasks from the docked stack to the fullscreen stack, // which is dismissing the docked stack, so resize all other stacks to // which is dismissing the docked stack, so resize all other stacks to // fullscreen here already so we don't end up with resize trashing. // fullscreen here already so we don't end up with resize trashing. for (int i = toDisplay.getStackCount() - 1; i >= 0; --i) { for (int i = toDisplayArea.getStackCount() - 1; i >= 0; --i) { final ActivityStack otherStack = toDisplay.getStackAt(i); final ActivityStack otherStack = toDisplayArea.getStackAt(i); if (!otherStack.inSplitScreenSecondaryWindowingMode()) { if (!otherStack.inSplitScreenSecondaryWindowingMode()) { continue; continue; } } Loading @@ -1535,7 +1535,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks { if (fromStack.hasChild()) { if (fromStack.hasChild()) { mTmpOptions.setLaunchWindowingMode(WINDOWING_MODE_FULLSCREEN); mTmpOptions.setLaunchWindowingMode(WINDOWING_MODE_FULLSCREEN); mMoveTaskToFullscreenHelper.process( mMoveTaskToFullscreenHelper.process( fromStack, toDisplay, onTop, schedulePictureInPictureModeChange); fromStack, toDisplayArea, onTop, schedulePictureInPictureModeChange); } } mRootWindowContainer.ensureActivitiesVisible(null, 0, PRESERVE_WINDOWS); mRootWindowContainer.ensureActivitiesVisible(null, 0, PRESERVE_WINDOWS); Loading @@ -1546,6 +1546,7 @@ public class ActivityStackSupervisor implements RecentTasks.Callbacks { } } void moveTasksToFullscreenStackLocked(ActivityStack fromStack, boolean onTop) { void moveTasksToFullscreenStackLocked(ActivityStack fromStack, boolean onTop) { // TODO(b/153089193): Support moving within the same task display area mWindowManager.inSurfaceTransaction(() -> mWindowManager.inSurfaceTransaction(() -> moveTasksToFullscreenStackInSurfaceTransaction(fromStack, DEFAULT_DISPLAY, onTop)); moveTasksToFullscreenStackInSurfaceTransaction(fromStack, DEFAULT_DISPLAY, onTop)); } } Loading
services/core/java/com/android/server/wm/ActivityStartController.java +3 −2 Original line number Original line Diff line number Diff line Loading @@ -189,9 +189,10 @@ public class ActivityStartController { mSupervisor.beginDeferResume(); mSupervisor.beginDeferResume(); final ActivityStack homeStack; final ActivityStack homeStack; try { try { // TODO(multi-display-area): Support starting home in a task display area // Make sure home stack exist on display. // Make sure home stack exist on display. homeStack = display.mTaskContainers.getOrCreateStack(WINDOWING_MODE_FULLSCREEN, homeStack = display.getDefaultTaskDisplayArea().getOrCreateStack( ACTIVITY_TYPE_HOME, ON_TOP); WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_HOME, ON_TOP); } finally { } finally { mSupervisor.endDeferResume(); mSupervisor.endDeferResume(); } } Loading
services/core/java/com/android/server/wm/DisplayContent.java +119 −80 Original line number Original line Diff line number Diff line Loading @@ -2060,20 +2060,53 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo * activity type. Null is no compatible stack on the display. * activity type. Null is no compatible stack on the display. */ */ ActivityStack getStack(int windowingMode, int activityType) { ActivityStack getStack(int windowingMode, int activityType) { return mTaskContainers.getStack(windowingMode, activityType); for (int tdaNdx = getTaskDisplayAreaCount() - 1; tdaNdx >= 0; --tdaNdx) { final ActivityStack stack = getTaskDisplayAreaAt(tdaNdx) .getStack(windowingMode, activityType); if (stack != null) { return stack; } } return null; } } protected int getStackCount() { protected int getTaskDisplayAreaCount() { return mTaskContainers.mChildren.size(); // TODO(multi-display-area): Report actual display area count return 1; } protected TaskDisplayArea getTaskDisplayAreaAt(int index) { // TODO(multi-display-area): Report actual display area values return mTaskContainers; } } protected ActivityStack getStackAt(int index) { ActivityStack getStack(int rootTaskId) { return mTaskContainers.mChildren.get(index); for (int tdaNdx = getTaskDisplayAreaCount() - 1; tdaNdx >= 0; --tdaNdx) { final ActivityStack stack = getTaskDisplayAreaAt(tdaNdx).getStack(rootTaskId); if (stack != null) { return stack; } } return null; } protected int getStackCount() { int totalStackCount = 0; for (int i = getTaskDisplayAreaCount() - 1; i >= 0; --i) { totalStackCount += getTaskDisplayAreaAt(i).getStackCount(); } return totalStackCount; } } @VisibleForTesting @VisibleForTesting ActivityStack getTopStack() { ActivityStack getTopStack() { return mTaskContainers.getTopStack(); for (int i = getTaskDisplayAreaCount() - 1; i >= 0; --i) { final ActivityStack stack = getTaskDisplayAreaAt(i).getTopStack(); if (stack != null) { return stack; } } return null; } } /** /** Loading Loading @@ -2449,7 +2482,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo final PooledConsumer c = PooledLambda.obtainConsumer( final PooledConsumer c = PooledLambda.obtainConsumer( DisplayContent::processTaskForTouchExcludeRegion, this, DisplayContent::processTaskForTouchExcludeRegion, this, PooledLambda.__(Task.class), focusedTask, delta); PooledLambda.__(Task.class), focusedTask, delta); mTaskContainers.forAllTasks(c); forAllTasks(c); c.recycle(); c.recycle(); // If we removed the focused task above, add it back and only leave its // If we removed the focused task above, add it back and only leave its Loading Loading @@ -2630,9 +2663,8 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo } } void prepareFreezingTaskBounds() { void prepareFreezingTaskBounds() { for (int stackNdx = mTaskContainers.getChildCount() - 1; stackNdx >= 0; --stackNdx) { for (int tdaNdx = getTaskDisplayAreaCount() - 1; tdaNdx >= 0; --tdaNdx) { final ActivityStack stack = mTaskContainers.getChildAt(stackNdx); getTaskDisplayAreaAt(tdaNdx).prepareFreezingTaskBounds(); stack.prepareFreezingTaskBounds(); } } } } Loading Loading @@ -2738,8 +2770,8 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo final ActivityStack focusedStack = getFocusedStack(); final ActivityStack focusedStack = getFocusedStack(); if (focusedStack != null) { if (focusedStack != null) { proto.write(FOCUSED_ROOT_TASK_ID, focusedStack.getRootTaskId()); proto.write(FOCUSED_ROOT_TASK_ID, focusedStack.getRootTaskId()); final ActivityRecord focusedActivity = focusedStack.getDisplay().mTaskContainers final ActivityRecord focusedActivity = focusedStack.getDisplayArea() .getResumedActivity(); .getFocusedActivity(); if (focusedActivity != null) { if (focusedActivity != null) { focusedActivity.writeIdentifierToProto(proto, RESUMED_ACTIVITY); focusedActivity.writeIdentifierToProto(proto, RESUMED_ACTIVITY); } } Loading Loading @@ -2797,13 +2829,6 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo if (mLastFocus != mCurrentFocus) { if (mLastFocus != mCurrentFocus) { pw.print(" mLastFocus="); pw.println(mLastFocus); pw.print(" mLastFocus="); pw.println(mLastFocus); } } if (mTaskContainers.mPreferredTopFocusableStack != null) { pw.println(prefix + "mPreferredTopFocusableStack=" + mTaskContainers.mPreferredTopFocusableStack); } if (mTaskContainers.mLastFocusedStack != null) { pw.println(prefix + "mLastFocusedStack=" + mTaskContainers.mLastFocusedStack); } if (mLosingFocus.size() > 0) { if (mLosingFocus.size() > 0) { pw.println(); pw.println(); pw.println(" Windows losing focus:"); pw.println(" Windows losing focus:"); Loading Loading @@ -2837,10 +2862,9 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo } } pw.println(); pw.println(); pw.println(prefix + "Application tokens in top down Z order:"); pw.println(prefix + "Task display areas in top down Z order:"); for (int stackNdx = mTaskContainers.getChildCount() - 1; stackNdx >= 0; --stackNdx) { for (int tdaNdx = getTaskDisplayAreaCount() - 1; tdaNdx >= 0; --tdaNdx) { final ActivityStack stack = mTaskContainers.getChildAt(stackNdx); getTaskDisplayAreaAt(tdaNdx).dump(pw, prefix + " ", dumpAll); stack.dump(pw, prefix + " ", dumpAll); } } pw.println(); pw.println(); Loading Loading @@ -4002,7 +4026,9 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo } } // Initialize state of exiting applications. // Initialize state of exiting applications. mTaskContainers.setExitingTokensHasVisible(hasVisible); for (int i = getTaskDisplayAreaCount() - 1; i >= 0; --i) { getTaskDisplayAreaAt(i).setExitingTokensHasVisible(hasVisible); } } } void removeExistingTokensIfPossible() { void removeExistingTokensIfPossible() { Loading @@ -4014,7 +4040,9 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo } } // Time to remove any exiting applications? // Time to remove any exiting applications? mTaskContainers.removeExistingAppTokensIfPossible(); for (int i = getTaskDisplayAreaCount() - 1; i >= 0; --i) { getTaskDisplayAreaAt(i).removeExistingAppTokensIfPossible(); } } } @Override @Override Loading Loading @@ -4475,7 +4503,9 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo } } void assignStackOrdering() { void assignStackOrdering() { mTaskContainers.assignStackOrdering(getPendingTransaction()); for (int i = getTaskDisplayAreaCount() - 1; i >= 0; --i) { getTaskDisplayAreaAt(i).assignStackOrdering(getPendingTransaction()); } } } /** /** Loading Loading @@ -5002,13 +5032,15 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo || windowingMode == WINDOWING_MODE_MULTI_WINDOW); || windowingMode == WINDOWING_MODE_MULTI_WINDOW); } } ActivityStack createStack(int windowingMode, int activityType, boolean onTop) { @Nullable return mTaskContainers.createStack(windowingMode, activityType, onTop, null /* info */, null /* intent */, false /* createdByOrganizer */); } ActivityStack getFocusedStack() { ActivityStack getFocusedStack() { return mTaskContainers.getFocusedStack(); for (int i = getTaskDisplayAreaCount() - 1; i >= 0; --i) { final ActivityStack stack = getTaskDisplayAreaAt(i).getFocusedStack(); if (stack != null) { return stack; } } return null; } } /** /** Loading @@ -5016,11 +5048,15 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo * ACTIVITY_TYPE_STANDARD or ACTIVITY_TYPE_UNDEFINED * ACTIVITY_TYPE_STANDARD or ACTIVITY_TYPE_UNDEFINED */ */ void removeStacksInWindowingModes(int... windowingModes) { void removeStacksInWindowingModes(int... windowingModes) { mTaskContainers.removeStacksInWindowingModes(windowingModes); for (int i = getTaskDisplayAreaCount() - 1; i >= 0; --i) { getTaskDisplayAreaAt(i).removeStacksInWindowingModes(windowingModes); } } } void removeStacksWithActivityTypes(int... activityTypes) { void removeStacksWithActivityTypes(int... activityTypes) { mTaskContainers.removeStacksWithActivityTypes(activityTypes); for (int i = getTaskDisplayAreaCount() - 1; i >= 0; --i) { getTaskDisplayAreaAt(i).removeStacksWithActivityTypes(activityTypes); } } } ActivityRecord topRunningActivity() { ActivityRecord topRunningActivity() { Loading @@ -5037,7 +5073,14 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo * @return The top running activity. {@code null} if none is available. * @return The top running activity. {@code null} if none is available. */ */ ActivityRecord topRunningActivity(boolean considerKeyguardState) { ActivityRecord topRunningActivity(boolean considerKeyguardState) { return mTaskContainers.topRunningActivity(considerKeyguardState); for (int i = getTaskDisplayAreaCount() - 1; i >= 0; --i) { final ActivityRecord activity = getTaskDisplayAreaAt(i) .topRunningActivity(considerKeyguardState); if (activity != null) { return activity; } } return null; } } boolean updateDisplayOverrideConfigurationLocked() { boolean updateDisplayOverrideConfigurationLocked() { Loading Loading @@ -5149,7 +5192,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo // The display may be about to rotate seamlessly, and the animation of closing apps may // The display may be about to rotate seamlessly, and the animation of closing apps may // still animate in old rotation. So make sure the outdated animation won't show on the // still animate in old rotation. So make sure the outdated animation won't show on the // rotated display. // rotated display. mTaskContainers.forAllActivities(a -> { forAllActivities(a -> { if (a.nowVisible && a != mFixedRotationLaunchingApp if (a.nowVisible && a != mFixedRotationLaunchingApp && a.getWindowConfiguration().getRotation() != newRotation) { && a.getWindowConfiguration().getRotation() != newRotation) { final WindowContainer<?> w = a.getAnimatingContainer(); final WindowContainer<?> w = a.getAnimatingContainer(); Loading Loading @@ -5210,40 +5253,17 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo void remove() { void remove() { mRemoving = true; mRemoving = true; final boolean destroyContentOnRemoval = shouldDestroyContentOnRemove(); ActivityStack lastReparentedStack = null; ActivityStack lastReparentedStack = null; mTaskContainers.mPreferredTopFocusableStack = null; // Stacks could be reparented from the removed display to other display. While // reparenting the last stack of the removed display, the remove display is ready to be // released (no more ActivityStack). But, we cannot release it at that moment or the // related WindowContainer will also be removed. So, we set display as removed after // reparenting stack finished. final TaskDisplayArea toTaskDisplayArea = mRootWindowContainer.getDefaultTaskDisplayArea(); mRootWindowContainer.mStackSupervisor.beginDeferResume(); mRootWindowContainer.mStackSupervisor.beginDeferResume(); try { try { int numStacks = getStackCount(); int numTaskContainers = getTaskDisplayAreaCount(); // Keep the order from bottom to top. for (int tdaNdx = 0; tdaNdx < numTaskContainers; tdaNdx++) { for (int stackNdx = 0; stackNdx < numStacks; stackNdx++) { final ActivityStack lastReparentedStackFromArea = getTaskDisplayAreaAt(tdaNdx) final ActivityStack stack = getStackAt(stackNdx); .remove(); // Always finish non-standard type stacks. if (lastReparentedStackFromArea != null) { if (destroyContentOnRemoval || !stack.isActivityTypeStandardOrUndefined()) { lastReparentedStack = lastReparentedStackFromArea; stack.finishAllActivitiesImmediately(); } } else { // If default display is in split-window mode, set windowing mode of the stack // to split-screen secondary. Otherwise, set the windowing mode to undefined by // default to let stack inherited the windowing mode from the new display. final int windowingMode = toTaskDisplayArea.isSplitScreenModeActivated() ? WINDOWING_MODE_SPLIT_SCREEN_SECONDARY : WINDOWING_MODE_UNDEFINED; stack.reparent(toTaskDisplayArea, true /* onTop */); stack.setWindowingMode(windowingMode); lastReparentedStack = stack; } // Stacks may be removed from this display. Ensure each stack will be processed and // the loop will end. stackNdx -= numStacks - getStackCount(); numStacks = getStackCount(); } } } finally { } finally { mRootWindowContainer.mStackSupervisor.endDeferResume(); mRootWindowContainer.mStackSupervisor.endDeferResume(); Loading @@ -5270,12 +5290,27 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo return; return; } } final ActivityStack stack = getStackCount() == 1 ? getStackAt(0) : null; // Check if all task display areas have only the empty home stacks left. if (stack != null && stack.isActivityTypeHome() && !stack.hasChild()) { boolean onlyEmptyHomeStacksLeft = true; // Release this display if an empty home stack is the only thing left. for (int tdaNdx = getTaskDisplayAreaCount() - 1; tdaNdx >= 0; --tdaNdx) { // Since it is the last stack, this display will be released along with the stack final TaskDisplayArea taskDisplayArea = getTaskDisplayAreaAt(tdaNdx); // removal. if (taskDisplayArea.getStackCount() != 1) { stack.removeIfPossible(); onlyEmptyHomeStacksLeft = false; break; } final ActivityStack stack = taskDisplayArea.getStackAt(0); if (!stack.isActivityTypeHome() || stack.hasChild()) { onlyEmptyHomeStacksLeft = false; break; } } if (onlyEmptyHomeStacksLeft) { // Release this display if only empty home stack(s) are left. This display will be // released along with the stack(s) removal. for (int tdaNdx = getTaskDisplayAreaCount() - 1; tdaNdx >= 0; --tdaNdx) { final ActivityStack s = getTaskDisplayAreaAt(tdaNdx).getStackAt(0); s.removeIfPossible(); } } else if (getTopStack() == null) { } else if (getTopStack() == null) { removeIfPossible(); removeIfPossible(); mRootWindowContainer.mStackSupervisor mRootWindowContainer.mStackSupervisor Loading Loading @@ -5334,10 +5369,9 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo void ensureActivitiesVisible(ActivityRecord starting, int configChanges, void ensureActivitiesVisible(ActivityRecord starting, int configChanges, boolean preserveWindows, boolean notifyClients) { boolean preserveWindows, boolean notifyClients) { for (int stackNdx = getStackCount() - 1; stackNdx >= 0; --stackNdx) { for (int i = getTaskDisplayAreaCount() - 1; i >= 0; --i) { final ActivityStack stack = getStackAt(stackNdx); getTaskDisplayAreaAt(i).ensureActivitiesVisible(starting, configChanges, stack.ensureActivitiesVisible(starting, configChanges, preserveWindows, preserveWindows, notifyClients); notifyClients); } } } } Loading @@ -5350,13 +5384,18 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo } } void setDisplayToSingleTaskInstance() { void setDisplayToSingleTaskInstance() { final int childCount = getStackCount(); final int taskDisplayAreaCount = getTaskDisplayAreaCount(); if (childCount > 1) { if (taskDisplayAreaCount > 1) { throw new IllegalArgumentException( "Display already has multiple task display areas. display=" + this); } final int stackCount = getDefaultTaskDisplayArea().getStackCount(); if (stackCount > 1) { throw new IllegalArgumentException("Display already has multiple stacks. display=" throw new IllegalArgumentException("Display already has multiple stacks. display=" + this); + this); } } if (childCount > 0) { if (stackCount > 0) { final ActivityStack stack = getStackAt(0); final ActivityStack stack = getDefaultTaskDisplayArea().getStackAt(0); if (stack.getChildCount() > 1) { if (stack.getChildCount() > 1) { throw new IllegalArgumentException("Display stack already has multiple tasks." throw new IllegalArgumentException("Display stack already has multiple tasks." + " display=" + this + " stack=" + stack); + " display=" + this + " stack=" + stack); Loading