diff options
34 files changed, 284 insertions, 563 deletions
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java index 5e61727fc1c3..2ba6e01b8966 100644 --- a/core/java/android/app/ActivityManager.java +++ b/core/java/android/app/ActivityManager.java @@ -670,138 +670,6 @@ public class ActivityManager { /** Invalid stack ID. */ public static final int INVALID_STACK_ID = -1; - /** First static stack ID. - * @hide */ - private static final int FIRST_STATIC_STACK_ID = 0; - - /** ID of stack where fullscreen activities are normally launched into. - * @hide */ - public static final int FULLSCREEN_WORKSPACE_STACK_ID = 1; - - /** ID of stack where freeform/resized activities are normally launched into. - * @hide */ - public static final int FREEFORM_WORKSPACE_STACK_ID = FULLSCREEN_WORKSPACE_STACK_ID + 1; - - /** ID of stack that occupies a dedicated region of the screen. - * @hide */ - public static final int DOCKED_STACK_ID = FREEFORM_WORKSPACE_STACK_ID + 1; - - /** ID of stack that always on top (always visible) when it exist. - * @hide */ - public static final int PINNED_STACK_ID = DOCKED_STACK_ID + 1; - - /** Last static stack stack ID. - * @hide */ - private static final int LAST_STATIC_STACK_ID = PINNED_STACK_ID; - - /** Start of ID range used by stacks that are created dynamically. - * @hide */ - public static final int FIRST_DYNAMIC_STACK_ID = LAST_STATIC_STACK_ID + 1; - - // TODO: Figure-out a way to remove this. - /** @hide */ - public static boolean isStaticStack(int stackId) { - return stackId >= FIRST_STATIC_STACK_ID && stackId <= LAST_STATIC_STACK_ID; - } - - // TODO: It seems this mostly means a stack on a secondary display now. Need to see if - // there are other meanings. If not why not just use information from the display? - /** @hide */ - public static boolean isDynamicStack(int stackId) { - return stackId >= FIRST_DYNAMIC_STACK_ID; - } - - /** - * Returns true if we try to maintain focus in the current stack when the top activity - * finishes. - * @hide - */ - // TODO: Figure-out a way to remove. Probably isn't needed in the new world... - public static boolean keepFocusInStackIfPossible(int stackId) { - return stackId == FREEFORM_WORKSPACE_STACK_ID - || stackId == DOCKED_STACK_ID || stackId == PINNED_STACK_ID; - } - - /** - * Returns true if the windows of tasks being moved to the target stack from the source - * stack should be replaced, meaning that window manager will keep the old window around - * until the new is ready. - * @hide - */ - public static boolean replaceWindowsOnTaskMove(int sourceStackId, int targetStackId) { - return sourceStackId == FREEFORM_WORKSPACE_STACK_ID - || targetStackId == FREEFORM_WORKSPACE_STACK_ID; - } - - /** - * Returns true if the top task in the task is allowed to return home when finished and - * there are other tasks in the stack. - * @hide - */ - public static boolean allowTopTaskToReturnHome(int stackId) { - return stackId != PINNED_STACK_ID; - } - - /** - * Returns true if the stack should be resized to match the bounds specified by - * {@link ActivityOptions#setLaunchBounds} when launching an activity into the stack. - * @hide - */ - public static boolean resizeStackWithLaunchBounds(int stackId) { - return stackId == PINNED_STACK_ID; - } - - /** - * Returns true if a window from the specified stack with {@param stackId} are normally - * fullscreen, i. e. they can become the top opaque fullscreen window, meaning that it - * controls system bars, lockscreen occluded/dismissing state, screen rotation animation, - * etc. - * @hide - */ - // TODO: What about the other side of docked stack if we move this to WindowConfiguration? - public static boolean normallyFullscreenWindows(int stackId) { - return stackId != PINNED_STACK_ID && stackId != FREEFORM_WORKSPACE_STACK_ID - && stackId != DOCKED_STACK_ID; - } - - /** Returns the stack id for the input windowing mode. - * @hide */ - // TODO: To be removed once we are not using stack id for stuff... - public static int getStackIdForWindowingMode(int windowingMode) { - switch (windowingMode) { - case WINDOWING_MODE_PINNED: return PINNED_STACK_ID; - case WINDOWING_MODE_FREEFORM: return FREEFORM_WORKSPACE_STACK_ID; - case WINDOWING_MODE_SPLIT_SCREEN_PRIMARY: return DOCKED_STACK_ID; - case WINDOWING_MODE_SPLIT_SCREEN_SECONDARY: return FULLSCREEN_WORKSPACE_STACK_ID; - case WINDOWING_MODE_FULLSCREEN: return FULLSCREEN_WORKSPACE_STACK_ID; - default: return INVALID_STACK_ID; - } - } - - /** Returns the windowing mode that should be used for this input stack id. - * @hide */ - // TODO: To be removed once we are not using stack id for stuff... - public static int getWindowingModeForStackId(int stackId, boolean inSplitScreenMode) { - final int windowingMode; - switch (stackId) { - case FULLSCREEN_WORKSPACE_STACK_ID: - windowingMode = inSplitScreenMode - ? WINDOWING_MODE_SPLIT_SCREEN_SECONDARY : WINDOWING_MODE_FULLSCREEN; - break; - case PINNED_STACK_ID: - windowingMode = WINDOWING_MODE_PINNED; - break; - case DOCKED_STACK_ID: - windowingMode = WINDOWING_MODE_SPLIT_SCREEN_PRIMARY; - break; - case FREEFORM_WORKSPACE_STACK_ID: - windowingMode = WINDOWING_MODE_FREEFORM; - break; - default : - windowingMode = WINDOWING_MODE_UNDEFINED; - } - return windowingMode; - } } /** diff --git a/core/java/android/app/ActivityOptions.java b/core/java/android/app/ActivityOptions.java index a68c3a5c29a6..f14831d1c658 100644 --- a/core/java/android/app/ActivityOptions.java +++ b/core/java/android/app/ActivityOptions.java @@ -17,7 +17,6 @@ package android.app; import static android.app.ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT; -import static android.app.ActivityManager.StackId.INVALID_STACK_ID; import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED; import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED; import static android.view.Display.INVALID_DISPLAY; diff --git a/core/java/android/app/WindowConfiguration.java b/core/java/android/app/WindowConfiguration.java index 6b4053842338..251863cae205 100644 --- a/core/java/android/app/WindowConfiguration.java +++ b/core/java/android/app/WindowConfiguration.java @@ -511,7 +511,8 @@ public class WindowConfiguration implements Parcelable, Comparable<WindowConfigu return windowingMode != WINDOWING_MODE_FREEFORM && windowingMode != WINDOWING_MODE_PINNED; } - private static String windowingModeToString(@WindowingMode int windowingMode) { + /** @hide */ + public static String windowingModeToString(@WindowingMode int windowingMode) { switch (windowingMode) { case WINDOWING_MODE_UNDEFINED: return "undefined"; case WINDOWING_MODE_FULLSCREEN: return "fullscreen"; diff --git a/core/java/android/view/WindowManagerInternal.java b/core/java/android/view/WindowManagerInternal.java index 98f8dc8e3a6d..69cc1002c5ba 100644 --- a/core/java/android/view/WindowManagerInternal.java +++ b/core/java/android/view/WindowManagerInternal.java @@ -335,8 +335,8 @@ public abstract class WindowManagerInternal { public abstract void setOnHardKeyboardStatusChangeListener( OnHardKeyboardStatusChangeListener listener); - /** Returns true if the stack with the input Id is currently visible. */ - public abstract boolean isStackVisible(int stackId); + /** Returns true if a stack in the windowing mode is currently visible. */ + public abstract boolean isStackVisible(int windowingMode); /** * @return True if and only if the docked divider is currently in resize mode. diff --git a/core/java/android/view/WindowManagerPolicy.java b/core/java/android/view/WindowManagerPolicy.java index da72535d54ec..137e551dbc9e 100644 --- a/core/java/android/view/WindowManagerPolicy.java +++ b/core/java/android/view/WindowManagerPolicy.java @@ -467,11 +467,8 @@ public interface WindowManagerPolicy { */ public boolean isDimming(); - /** - * @return the stack id this windows belongs to, or {@link StackId#INVALID_STACK_ID} if - * not attached to any stack. - */ - int getStackId(); + /** @return the current windowing mode of this window. */ + int getWindowingMode(); /** * Returns true if the window is current in multi-windowing mode. i.e. it shares the diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java index c7edb9aeb646..e460bf8d74ba 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java @@ -16,10 +16,6 @@ package com.android.systemui.recents.views; -import static android.app.ActivityManager.StackId.INVALID_STACK_ID; - -import android.animation.Animator; -import android.animation.ObjectAnimator; import android.animation.ValueAnimator; import android.animation.ValueAnimator.AnimatorUpdateListener; import android.app.ActivityOptions.OnAnimationStartedListener; diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java index 9d639647acdb..032d96631386 100644 --- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java +++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskView.java @@ -16,8 +16,6 @@ package com.android.systemui.recents.views; -import static android.app.ActivityManager.StackId.INVALID_STACK_ID; - import android.animation.Animator; import android.animation.AnimatorSet; import android.animation.ObjectAnimator; diff --git a/services/core/java/com/android/server/am/ActivityDisplay.java b/services/core/java/com/android/server/am/ActivityDisplay.java index 8bcbfbef8b5e..8839cfc06cb3 100644 --- a/services/core/java/com/android/server/am/ActivityDisplay.java +++ b/services/core/java/com/android/server/am/ActivityDisplay.java @@ -16,9 +16,6 @@ package com.android.server.am; -import static android.app.ActivityManager.StackId.FULLSCREEN_WORKSPACE_STACK_ID; -import static android.app.ActivityManager.StackId.INVALID_STACK_ID; -import static android.app.ActivityManager.StackId.getStackIdForWindowingMode; import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS; import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED; @@ -213,7 +210,11 @@ class ActivityDisplay extends ConfigurationContainer { if (windowingMode == WINDOWING_MODE_UNDEFINED) { // TODO: Should be okay to have stacks with with undefined windowing mode long term, but // have to set them to something for now due to logic that depending on them. - windowingMode = WINDOWING_MODE_FULLSCREEN; + windowingMode = getWindowingMode(); // Put in current display's windowing mode + if (windowingMode == WINDOWING_MODE_UNDEFINED) { + // Else fullscreen for now... + windowingMode = WINDOWING_MODE_FULLSCREEN; + } } final boolean inSplitScreenMode = hasSplitScreenStack(); @@ -228,24 +229,7 @@ class ActivityDisplay extends ConfigurationContainer { windowingMode = WINDOWING_MODE_SPLIT_SCREEN_SECONDARY; } - int stackId = INVALID_STACK_ID; - if (mDisplayId == DEFAULT_DISPLAY && (activityType == ACTIVITY_TYPE_STANDARD - || activityType == ACTIVITY_TYPE_UNDEFINED)) { - // TODO: Will be removed once we are no longer using static stack ids. - stackId = getStackIdForWindowingMode(windowingMode); - if (stackId == INVALID_STACK_ID) { - // Whatever...put in fullscreen stack for now. - stackId = FULLSCREEN_WORKSPACE_STACK_ID; - } - final T stack = getStack(stackId); - if (stack != null) { - return stack; - } - } - - if (stackId == INVALID_STACK_ID) { - stackId = mSupervisor.getNextStackId(); - } + final int stackId = mSupervisor.getNextStackId(); final T stack = createStackUnchecked(windowingMode, activityType, stackId, onTop); diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index e6fe620485da..13cb98068da4 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -27,14 +27,7 @@ import static android.Manifest.permission.START_TASKS_FROM_RECENTS; import static android.app.ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT; import static android.app.ActivityManager.LOCK_TASK_MODE_NONE; import static android.app.ActivityManager.RESIZE_MODE_PRESERVE_WINDOW; -import static android.app.ActivityManager.StackId.DOCKED_STACK_ID; -import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID; -import static android.app.ActivityManager.StackId.FIRST_DYNAMIC_STACK_ID; -import static android.app.ActivityManager.StackId.FULLSCREEN_WORKSPACE_STACK_ID; import static android.app.ActivityManager.StackId.INVALID_STACK_ID; -import static android.app.ActivityManager.StackId.PINNED_STACK_ID; -import static android.app.ActivityManager.StackId.getWindowingModeForStackId; -import static android.app.ActivityManager.StackId.isStaticStack; import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; @@ -3241,11 +3234,12 @@ public class ActivityManagerService extends IActivityManager.Stub // stack implementation changes in the future, keep in mind that the use of the fullscreen // stack is a means to move the activity to the main display and a moveActivityToDisplay() // option would be a better choice here. - if (r.requestedVrComponent != null && r.getStackId() >= FIRST_DYNAMIC_STACK_ID) { + if (r.requestedVrComponent != null && r.getDisplayId() != DEFAULT_DISPLAY) { Slog.i(TAG, "Moving " + r.shortComponentName + " from stack " + r.getStackId() + " to main stack for VR"); - setTaskWindowingMode(r.getTask().taskId, - WINDOWING_MODE_FULLSCREEN_OR_SPLIT_SCREEN_SECONDARY, true /* toTop */); + final ActivityStack stack = mStackSupervisor.getDefaultDisplay().getOrCreateStack( + WINDOWING_MODE_FULLSCREEN, r.getActivityType(), true /* toTop */); + moveTaskToStack(r.getTask().taskId, stack.mStackId, true /* toTop */); } mHandler.sendMessage( mHandler.obtainMessage(VR_MODE_CHANGE_MSG, 0, 0, r)); @@ -8084,8 +8078,8 @@ public class ActivityManagerService extends IActivityManager.Stub } private boolean isInPictureInPictureMode(ActivityRecord r) { - if (r == null || r.getStack() == null || !r.getStack().isPinnedStack() || - r.getStack().isInStackLocked(r) == null) { + if (r == null || r.getStack() == null || !r.inPinnedWindowingMode() + || r.getStack().isInStackLocked(r) == null) { return false; } @@ -8179,7 +8173,7 @@ public class ActivityManagerService extends IActivityManager.Stub // Only update the saved args from the args that are set r.pictureInPictureArgs.copyOnlySet(params); - if (r.getStack().getStackId() == PINNED_STACK_ID) { + if (r.inPinnedWindowingMode()) { // If the activity is already in picture-in-picture, update the pinned stack now // if it is not already expanding to fullscreen. Otherwise, the arguments will // be used the next time the activity enters PiP @@ -10005,14 +9999,15 @@ public class ActivityManagerService extends IActivityManager.Stub } } if ((flags & ActivityManager.RECENT_INGORE_DOCKED_STACK_TOP_TASK) != 0) { - if (stack != null && stack.isDockedStack() && stack.topTask() == tr) { + if (stack != null && stack.inSplitScreenPrimaryWindowingMode() + && stack.topTask() == tr) { if (DEBUG_RECENTS) Slog.d(TAG_RECENTS, "Skipping, top task in docked stack: " + tr); continue; } } if ((flags & ActivityManager.RECENT_INGORE_PINNED_STACK_TASKS) != 0) { - if (stack != null && stack.isPinnedStack()) { + if (stack != null && stack.inPinnedWindowingMode()) { if (DEBUG_RECENTS) Slog.d(TAG_RECENTS, "Skipping, pinned stack task: " + tr); continue; @@ -10609,7 +10604,7 @@ public class ActivityManagerService extends IActivityManager.Stub } final ActivityStack stack = r.getStack(); - if (stack == null || stack.mStackId != FREEFORM_WORKSPACE_STACK_ID) { + if (stack == null || !stack.inFreeformWindowingMode()) { throw new IllegalStateException( "exitFreeformMode: You can only go fullscreen from freeform."); } @@ -10677,27 +10672,20 @@ public class ActivityManagerService extends IActivityManager.Stub if (DEBUG_STACK) Slog.d(TAG_STACK, "moveTaskToStack: moving task=" + taskId + " to stackId=" + stackId + " toTop=" + toTop); - if (stackId == DOCKED_STACK_ID) { - mWindowManager.setDockedStackCreateState(DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT, - null /* initialBounds */); - } - ActivityStack stack = mStackSupervisor.getStack(stackId); + final ActivityStack stack = mStackSupervisor.getStack(stackId); if (stack == null) { - if (!isStaticStack(stackId)) { - throw new IllegalStateException( - "moveTaskToStack: No stack for stackId=" + stackId); - } - final ActivityDisplay display = task.getStack().getDisplay(); - final int windowingMode = - getWindowingModeForStackId(stackId, display.hasSplitScreenStack()); - stack = display.getOrCreateStack(windowingMode, - task.getStack().getActivityType(), toTop); + throw new IllegalStateException( + "moveTaskToStack: No stack for stackId=" + stackId); } if (!stack.isActivityTypeStandardOrUndefined()) { throw new IllegalArgumentException("moveTaskToStack: Attempt to move task " + taskId + " to stack " + stackId); } + if (stack.inSplitScreenPrimaryWindowingMode()) { + mWindowManager.setDockedStackCreateState( + DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT, null /* initialBounds */); + } task.reparent(stack, toTop, REPARENT_KEEP_STACK_AT_FRONT, ANIMATE, !DEFER_RESUME, "moveTaskToStack"); } finally { @@ -10769,7 +10757,7 @@ public class ActivityManagerService extends IActivityManager.Stub final ActivityStack stack = mStackSupervisor.getDefaultDisplay().getSplitScreenStack(); if (toTop) { - mStackSupervisor.resizeStackLocked(stack.mStackId, null /* destBounds */, + mStackSupervisor.resizeStackLocked(stack, null /* destBounds */, null /* tempTaskBounds */, null /* tempTaskInsetBounds */, true /* preserveWindows */, true /* allowResizeInDockedMode */, !DEFER_RESUME); @@ -10862,7 +10850,12 @@ public class ActivityManagerService extends IActivityManager.Stub stack.animateResizePinnedStack(null /* sourceHintBounds */, destBounds, animationDuration, false /* fromFullscreen */); } else { - mStackSupervisor.resizeStackLocked(stackId, destBounds, null /* tempTaskBounds */, + final ActivityStack stack = mStackSupervisor.getStack(stackId); + if (stack == null) { + Slog.w(TAG, "resizeStack: stackId " + stackId + " not found."); + return; + } + mStackSupervisor.resizeStackLocked(stack, destBounds, null /* tempTaskBounds */, null /* tempTaskInsetBounds */, preserveWindows, allowResizeInDockedMode, !DEFER_RESUME); } @@ -20697,9 +20690,10 @@ public class ActivityManagerService extends IActivityManager.Stub /** Helper method that requests bounds from WM and applies them to stack. */ private void resizeStackWithBoundsFromWindowManager(int stackId, boolean deferResume) { final Rect newStackBounds = new Rect(); - mStackSupervisor.getStack(stackId).getBoundsForNewConfiguration(newStackBounds); + final ActivityStack stack = mStackSupervisor.getStack(stackId); + stack.getBoundsForNewConfiguration(newStackBounds); mStackSupervisor.resizeStackLocked( - stackId, !newStackBounds.isEmpty() ? newStackBounds : null /* bounds */, + stack, !newStackBounds.isEmpty() ? newStackBounds : null /* bounds */, null /* tempTaskBounds */, null /* tempTaskInsetBounds */, false /* preserveWindows */, false /* allowResizeInDockedMode */, deferResume); } diff --git a/services/core/java/com/android/server/am/ActivityManagerShellCommand.java b/services/core/java/com/android/server/am/ActivityManagerShellCommand.java index 4c9342328ecf..f03d2d5352b7 100644 --- a/services/core/java/com/android/server/am/ActivityManagerShellCommand.java +++ b/services/core/java/com/android/server/am/ActivityManagerShellCommand.java @@ -73,10 +73,8 @@ import java.util.List; import static android.app.ActivityManager.RESIZE_MODE_SYSTEM; import static android.app.ActivityManager.RESIZE_MODE_USER; -import static android.app.ActivityManager.StackId.DOCKED_STACK_ID; import static android.app.ActivityManager.StackId.INVALID_STACK_ID; import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED; -import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY; import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED; import static android.view.Display.INVALID_DISPLAY; @@ -86,15 +84,6 @@ final class ActivityManagerShellCommand extends ShellCommand { public static final String NO_CLASS_ERROR_CODE = "Error type 3"; private static final String SHELL_PACKAGE_NAME = "com.android.shell"; - // Is the object moving in a positive direction? - private static final boolean MOVING_FORWARD = true; - // Is the object moving in the horizontal plan? - private static final boolean MOVING_HORIZONTALLY = true; - // Is the object current point great then its target point? - private static final boolean GREATER_THAN_TARGET = true; - // Amount we reduce the stack size by when testing a task re-size. - private static final int STACK_BOUNDS_INSET = 10; - // IPC interface to activity manager -- don't need to do additional security checks. final IActivityManager mInterface; @@ -1944,8 +1933,6 @@ final class ActivityManagerShellCommand extends ShellCommand { return runStackInfo(pw); case "move-top-activity-to-pinned-stack": return runMoveTopActivityToPinnedStack(pw); - case "size-docked-stack-test": - return runStackSizeDockedStackTest(pw); case "remove": return runStackRemove(pw); default: @@ -2143,89 +2130,6 @@ final class ActivityManagerShellCommand extends ShellCommand { return 0; } - int runStackSizeDockedStackTest(PrintWriter pw) throws RemoteException { - final PrintWriter err = getErrPrintWriter(); - final int stepSize = Integer.parseInt(getNextArgRequired()); - final String side = getNextArgRequired(); - final String delayStr = getNextArg(); - final int delayMs = (delayStr != null) ? Integer.parseInt(delayStr) : 0; - - ActivityManager.StackInfo info = mInterface.getStackInfo( - WINDOWING_MODE_SPLIT_SCREEN_PRIMARY, ACTIVITY_TYPE_UNDEFINED); - if (info == null) { - err.println("Docked stack doesn't exist"); - return -1; - } - if (info.bounds == null) { - err.println("Docked stack doesn't have a bounds"); - return -1; - } - Rect bounds = info.bounds; - - final boolean horizontalGrowth = "l".equals(side) || "r".equals(side); - final int changeSize = (horizontalGrowth ? bounds.width() : bounds.height()) / 2; - int currentPoint; - switch (side) { - case "l": - currentPoint = bounds.left; - break; - case "r": - currentPoint = bounds.right; - break; - case "t": - currentPoint = bounds.top; - break; - case "b": - currentPoint = bounds.bottom; - break; - default: - err.println("Unknown growth side: " + side); - return -1; - } - - final int startPoint = currentPoint; - final int minPoint = currentPoint - changeSize; - final int maxPoint = currentPoint + changeSize; - - int maxChange; - pw.println("Shrinking docked stack side=" + side); - pw.flush(); - while (currentPoint > minPoint) { - maxChange = Math.min(stepSize, currentPoint - minPoint); - currentPoint -= maxChange; - setBoundsSide(bounds, side, currentPoint); - int res = resizeStack(DOCKED_STACK_ID, bounds, delayMs); - if (res < 0) { - return res; - } - } - - pw.println("Growing docked stack side=" + side); - pw.flush(); - while (currentPoint < maxPoint) { - maxChange = Math.min(stepSize, maxPoint - currentPoint); - currentPoint += maxChange; - setBoundsSide(bounds, side, currentPoint); - int res = resizeStack(DOCKED_STACK_ID, bounds, delayMs); - if (res < 0) { - return res; - } - } - - pw.println("Back to Original size side=" + side); - pw.flush(); - while (currentPoint > startPoint) { - maxChange = Math.min(stepSize, currentPoint - startPoint); - currentPoint -= maxChange; - setBoundsSide(bounds, side, currentPoint); - int res = resizeStack(DOCKED_STACK_ID, bounds, delayMs); - if (res < 0) { - return res; - } - } - return 0; - } - void setBoundsSide(Rect bounds, String side, int value) { switch (side) { case "l": @@ -2687,10 +2591,6 @@ final class ActivityManagerShellCommand extends ShellCommand { pw.println(" Change docked stack to <LEFT,TOP,RIGHT,BOTTOM>"); pw.println(" and supplying temporary different task bounds indicated by"); pw.println(" <TASK_LEFT,TOP,RIGHT,BOTTOM>"); - pw.println(" size-docked-stack-test: <STEP_SIZE> <l|t|r|b> [DELAY_MS]"); - pw.println(" Test command for sizing docked stack by"); - pw.println(" <STEP_SIZE> increments from the side <l>eft, <t>op, <r>ight, or <b>ottom"); - pw.println(" applying the optional [DELAY_MS] between each step."); pw.println(" move-top-activity-to-pinned-stack: <STACK_ID> <LEFT,TOP,RIGHT,BOTTOM>"); pw.println(" Moves the top activity from"); pw.println(" <STACK_ID> to the pinned stack using <LEFT,TOP,RIGHT,BOTTOM> for the"); diff --git a/services/core/java/com/android/server/am/ActivityRecord.java b/services/core/java/com/android/server/am/ActivityRecord.java index 7b0b942a98f1..f544d3771aba 100644 --- a/services/core/java/com/android/server/am/ActivityRecord.java +++ b/services/core/java/com/android/server/am/ActivityRecord.java @@ -17,9 +17,7 @@ package com.android.server.am; import static android.app.ActivityManager.LOCK_TASK_MODE_NONE; -import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID; import static android.app.ActivityManager.StackId.INVALID_STACK_ID; -import static android.app.ActivityManager.StackId.PINNED_STACK_ID; import static android.app.ActivityManager.TaskDescription.ATTR_TASKDESCRIPTION_PREFIX; import static android.app.ActivityOptions.ANIM_CLIP_REVEAL; import static android.app.ActivityOptions.ANIM_CUSTOM; @@ -661,8 +659,7 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo return; } - final boolean inPictureInPictureMode = (task.getStackId() == PINNED_STACK_ID) && - (targetStackBounds != null); + final boolean inPictureInPictureMode = inPinnedWindowingMode() && targetStackBounds != null; if (inPictureInPictureMode != mLastReportedPictureInPictureMode || forceUpdate) { // Picture-in-picture mode changes also trigger a multi-window mode change as well, so // update that here in order @@ -684,10 +681,6 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo } } - boolean isFreeform() { - return task != null && task.getStackId() == FREEFORM_WORKSPACE_STACK_ID; - } - @Override protected int getChildCount() { // {@link ActivityRecord} is a leaf node and has no children. @@ -948,7 +941,7 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo // update the initial multi-window modes so that the callbacks are scheduled correctly when // the user leaves that mode. mLastReportedMultiWindowMode = !task.mFullscreen; - mLastReportedPictureInPictureMode = (task.getStackId() == PINNED_STACK_ID); + mLastReportedPictureInPictureMode = inPinnedWindowingMode(); } void removeWindowContainer() { diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java index 1940ca2b4c31..c9c71f7dd367 100644 --- a/services/core/java/com/android/server/am/ActivityStack.java +++ b/services/core/java/com/android/server/am/ActivityStack.java @@ -16,20 +16,19 @@ package com.android.server.am; -import static android.app.ActivityManager.StackId.DOCKED_STACK_ID; -import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID; -import static android.app.ActivityManager.StackId.FULLSCREEN_WORKSPACE_STACK_ID; import static android.app.ActivityManager.StackId.INVALID_STACK_ID; -import static android.app.ActivityManager.StackId.PINNED_STACK_ID; import static android.app.WindowConfiguration.ACTIVITY_TYPE_ASSISTANT; import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME; import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED; +import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED; import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY; import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_SECONDARY; import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED; +import static android.app.WindowConfiguration.activityTypeToString; +import static android.app.WindowConfiguration.windowingModeToString; import static android.content.pm.ActivityInfo.CONFIG_SCREEN_LAYOUT; import static android.content.pm.ActivityInfo.FLAG_RESUME_WHILE_PAUSING; import static android.content.pm.ActivityInfo.FLAG_SHOW_FOR_ALL_USERS; @@ -105,6 +104,7 @@ import android.app.ActivityOptions; import android.app.AppGlobals; import android.app.IActivityController; import android.app.ResultInfo; +import android.app.WindowConfiguration; import android.content.ComponentName; import android.content.Intent; import android.content.pm.ActivityInfo; @@ -460,7 +460,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai mWindowManager = mService.mWindowManager; mStackId = stackId; mCurrentUser = mService.mUserController.getCurrentUserId(); - mTaskPositioner = mStackId == FREEFORM_WORKSPACE_STACK_ID + mTaskPositioner = windowingMode == WINDOWING_MODE_FREEFORM ? new LaunchingTaskPositioner() : null; mTmpRect2.setEmpty(); setWindowingMode(windowingMode); @@ -509,7 +509,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai onParentChanged(); activityDisplay.addChild(this, onTop ? POSITION_TOP : POSITION_BOTTOM); - if (mStackId == DOCKED_STACK_ID) { + if (inSplitScreenPrimaryWindowingMode()) { // If we created a docked stack we want to resize it so it resizes all other stacks // in the system. mStackSupervisor.resizeDockedStackLocked( @@ -818,14 +818,6 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai return isActivityTypeHome() || isActivityTypeRecents(); } - final boolean isDockedStack() { - return mStackId == DOCKED_STACK_ID; - } - - final boolean isPinnedStack() { - return mStackId == PINNED_STACK_ID; - } - final boolean isOnHomeDisplay() { return mDisplayId == DEFAULT_DISPLAY; } @@ -1505,9 +1497,9 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai * needed. A stack is considered translucent if it don't contain a visible or * starting (about to be visible) activity that is fullscreen (opaque). * @param starting The currently starting activity or null if there is none. - * @param stackBehindId The id of the stack directly behind this one. + * @param stackBehind The stack directly behind this one. */ - private boolean isStackTranslucent(ActivityRecord starting, int stackBehindId) { + private boolean isStackTranslucent(ActivityRecord starting, ActivityStack stackBehind) { for (int taskNdx = mTaskHistory.size() - 1; taskNdx >= 0; --taskNdx) { final TaskRecord task = mTaskHistory.get(taskNdx); final ArrayList<ActivityRecord> activities = task.mActivities; @@ -1532,7 +1524,6 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai return false; } - final ActivityStack stackBehind = mStackSupervisor.getStack(stackBehindId); final boolean stackBehindHomeOrRecent = stackBehind != null && stackBehind.isHomeOrRecentsStack(); if (!isHomeOrRecentsStack() && r.frontOfTask && task.isOverHomeStack() @@ -1579,7 +1570,6 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai // Check position and visibility of this stack relative to the front stack on its display. final ActivityStack topStack = getTopStackOnDisplay(); - final int topStackId = topStack.mStackId; final int windowingMode = getWindowingMode(); final int activityType = getActivityType(); @@ -1587,7 +1577,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai // If the assistant stack is focused and translucent, then the docked stack is always // visible if (topStack.isActivityTypeAssistant()) { - return topStack.isStackTranslucent(starting, DOCKED_STACK_ID); + return topStack.isStackTranslucent(starting, this); } return true; } @@ -1612,18 +1602,16 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai } final ActivityStack stackBehindTop = (stackBehindTopIndex >= 0) ? displayStacks.get(stackBehindTopIndex) : null; - int stackBehindTopId = INVALID_STACK_ID; int stackBehindTopWindowingMode = WINDOWING_MODE_UNDEFINED; int stackBehindTopActivityType = ACTIVITY_TYPE_UNDEFINED; if (stackBehindTop != null) { - stackBehindTopId = stackBehindTop.mStackId; stackBehindTopWindowingMode = stackBehindTop.getWindowingMode(); stackBehindTopActivityType = stackBehindTop.getActivityType(); } final boolean alwaysOnTop = topStack.getWindowConfiguration().isAlwaysOnTop(); if (topStack.getWindowingMode() == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY || alwaysOnTop) { - if (stackIndex == stackBehindTopIndex) { + if (this == stackBehindTop) { // Stacks directly behind the docked or pinned stack are always visible. return true; } else if (alwaysOnTop && stackIndex == stackBehindTopIndex - 1) { @@ -1632,14 +1620,13 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai if (stackBehindTopWindowingMode == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY) { return true; } else if (stackBehindTopActivityType == ACTIVITY_TYPE_ASSISTANT) { - return displayStacks.get(stackBehindTopIndex).isStackTranslucent( - starting, mStackId); + return stackBehindTop.isStackTranslucent(starting, this); } } } if (topStack.isBackdropToTranslucentActivity() - && topStack.isStackTranslucent(starting, stackBehindTopId)) { + && topStack.isStackTranslucent(starting, stackBehindTop)) { // Stacks behind the fullscreen or assistant stack with a translucent activity are // always visible so they can act as a backdrop to the translucent activity. // For example, dialog activities @@ -1657,9 +1644,9 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai } } - if (StackId.isStaticStack(mStackId) - || isHomeOrRecentsStack() || isActivityTypeAssistant()) { - // Visibility of any static stack should have been determined by the conditions above. + if (isOnHomeDisplay()) { + // Visibility of any stack on default display should have been determined by the + // conditions above. return false; } @@ -1675,7 +1662,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai return false; } - if (!stack.isStackTranslucent(starting, INVALID_STACK_ID)) { + if (!stack.isStackTranslucent(starting, null /* stackBehind */)) { return false; } } @@ -1801,7 +1788,8 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai makeInvisible(r); } } - if (mStackId == FREEFORM_WORKSPACE_STACK_ID) { + final int windowingMode = getWindowingMode(); + if (windowingMode == WINDOWING_MODE_FREEFORM) { // The visibility of tasks and the activities they contain in freeform stack are // determined individually unlike other stacks where the visibility or fullscreen // status of an activity in a previous task affects other. @@ -1816,7 +1804,8 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai // show activities in the next application stack behind them vs. another // task in the home stack like recents. behindFullscreenActivity = true; - } else if (mStackId == FULLSCREEN_WORKSPACE_STACK_ID) { + } else if (windowingMode == WINDOWING_MODE_FULLSCREEN + || windowingMode == WINDOWING_MODE_SPLIT_SCREEN_SECONDARY) { if (DEBUG_VISIBILITY) Slog.v(TAG_VISIBILITY, "Skipping after task=" + task + " returning to non-application type=" + task.getTaskToReturnTo()); // Once we reach a fullscreen stack task that has a running activity and should @@ -1852,6 +1841,32 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai } /** + * Returns true if this stack should be resized to match the bounds specified by + * {@link ActivityOptions#setLaunchBounds} when launching an activity into the stack. + */ + boolean resizeStackWithLaunchBounds() { + return inPinnedWindowingMode(); + } + + /** + * Returns true if we try to maintain focus in the current stack when the top activity finishes. + */ + private boolean keepFocusInStackIfPossible() { + final int windowingMode = getWindowingMode(); + return windowingMode == WINDOWING_MODE_FREEFORM + || windowingMode == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY + || windowingMode == WINDOWING_MODE_PINNED; + } + + /** + * Returns true if the top task in the task is allowed to return home when finished and + * there are other tasks in the stack. + */ + boolean allowTopTaskToReturnHome() { + return !inPinnedWindowingMode(); + } + + /** * @return the top most visible activity that wants to dismiss Keyguard */ ActivityRecord getTopDismissingKeyguardActivity() { @@ -1867,7 +1882,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai */ boolean checkKeyguardVisibility(ActivityRecord r, boolean shouldBeVisible, boolean isTop) { - final boolean isInPinnedStack = r.getStack().getStackId() == PINNED_STACK_ID; + final boolean isInPinnedStack = r.inPinnedWindowingMode(); final boolean keyguardShowing = mStackSupervisor.mKeyguardController.isKeyguardShowing( mDisplayId != INVALID_DISPLAY ? mDisplayId : DEFAULT_DISPLAY); final boolean keyguardLocked = mStackSupervisor.mKeyguardController.isKeyguardLocked(); @@ -2617,7 +2632,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai private boolean resumeTopActivityInNextFocusableStack(ActivityRecord prev, ActivityOptions options, String reason) { - if ((!mFullscreen || !isOnHomeDisplay()) && adjustFocusToNextFocusableStackLocked(reason)) { + if (adjustFocusToNextFocusableStackLocked(reason)) { // Try to move focus to the next visible stack with a running activity if this // stack is not covering the entire screen or is on a secondary display (with no home // stack). @@ -2746,9 +2761,8 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai // make underlying task focused when this one will be finished. int returnToType = isLastTaskOverHome ? task.getTaskToReturnTo() : ACTIVITY_TYPE_STANDARD; - if (fromHomeOrRecents && StackId.allowTopTaskToReturnHome(mStackId)) { - returnToType = topTask == null - ? ACTIVITY_TYPE_HOME : topTask.getActivityType(); + if (fromHomeOrRecents && allowTopTaskToReturnHome()) { + returnToType = topTask == null ? ACTIVITY_TYPE_HOME : topTask.getActivityType(); } task.setTaskToReturnTo(returnToType); } @@ -2901,7 +2915,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai // Ensure the caller has requested not to trigger auto-enter PiP return false; } - if (pipCandidate == null || pipCandidate.getStackId() == PINNED_STACK_ID) { + if (pipCandidate == null || pipCandidate.inPinnedWindowingMode()) { // Ensure that we do not trigger entering PiP an activity on the pinned stack return false; } @@ -3291,7 +3305,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai final String myReason = reason + " adjustFocus"; if (next != r) { - if (next != null && StackId.keepFocusInStackIfPossible(mStackId) && isFocusable()) { + if (next != null && keepFocusInStackIfPossible() && isFocusable()) { // For freeform, docked, and pinned stacks we always keep the focus within the // stack as long as there is a running activity. return; @@ -3757,7 +3771,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai if (mode == FINISH_IMMEDIATELY || (prevState == ActivityState.PAUSED - && (mode == FINISH_AFTER_PAUSE || mStackId == PINNED_STACK_ID)) + && (mode == FINISH_AFTER_PAUSE || inPinnedWindowingMode())) || finishingActivityInNonFocusedStack || prevState == STOPPING || prevState == STOPPED @@ -4571,8 +4585,8 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai mWindowContainerController.positionChildAtBottom(tr.getWindowContainerController()); } - if (mStackId == PINNED_STACK_ID) { - mStackSupervisor.removeStackLocked(PINNED_STACK_ID); + if (inPinnedWindowingMode()) { + mStackSupervisor.removeStackLocked(mStackId); return true; } @@ -4687,7 +4701,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai for (int i = mTaskHistory.size() - 1; i >= 0; i--) { final TaskRecord task = mTaskHistory.get(i); if (task.isResizeable()) { - if (mStackId == FREEFORM_WORKSPACE_STACK_ID) { + if (inFreeformWindowingMode()) { // For freeform stack we don't adjust the size of the tasks to match that // of the stack, but we do try to make sure the tasks are still contained // with the bounds of the stack. @@ -5097,7 +5111,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai task.setStack(null); // Notify if a task from the pinned stack is being removed (or moved depending on the mode) - if (mStackId == PINNED_STACK_ID) { + if (inPinnedWindowingMode()) { mService.mTaskChangeNotificationController.notifyActivityUnpinned(); } } @@ -5248,7 +5262,9 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai @Override public String toString() { return "ActivityStack{" + Integer.toHexString(System.identityHashCode(this)) - + " stackId=" + mStackId + ", " + mTaskHistory.size() + " tasks}"; + + " stackId=" + mStackId + " type=" + activityTypeToString(getActivityType()) + + " mode=" + windowingModeToString(getWindowingMode()) + ", " + + mTaskHistory.size() + " tasks}"; } void onLockTaskPackagesUpdatedLocked() { diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java index da2827a6aedc..bac71c7672eb 100644 --- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java +++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java @@ -21,11 +21,7 @@ import static android.Manifest.permission.INTERNAL_SYSTEM_WINDOW; import static android.Manifest.permission.START_ANY_ACTIVITY; import static android.Manifest.permission.START_TASKS_FROM_RECENTS; import static android.app.ActivityManager.START_TASK_TO_FRONT; -import static android.app.ActivityManager.StackId.DOCKED_STACK_ID; -import static android.app.ActivityManager.StackId.FIRST_DYNAMIC_STACK_ID; -import static android.app.ActivityManager.StackId.FULLSCREEN_WORKSPACE_STACK_ID; import static android.app.ActivityManager.StackId.INVALID_STACK_ID; -import static android.app.ActivityManager.StackId.PINNED_STACK_ID; import static android.app.ITaskStackListener.FORCED_RESIZEABLE_REASON_SECONDARY_DISPLAY; import static android.app.ITaskStackListener.FORCED_RESIZEABLE_REASON_SPLIT_SCREEN; import static android.app.WindowConfiguration.ACTIVITY_TYPE_ASSISTANT; @@ -35,10 +31,13 @@ import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED; import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; +import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN_OR_SPLIT_SCREEN_SECONDARY; import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED; import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY; import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_SECONDARY; import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED; +import static android.app.WindowConfiguration.activityTypeToString; +import static android.app.WindowConfiguration.windowingModeToString; import static android.content.pm.PackageManager.PERMISSION_DENIED; import static android.content.pm.PackageManager.PERMISSION_GRANTED; import static android.os.PowerManager.PARTIAL_WAKE_LOCK; @@ -295,7 +294,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D DisplayManager mDisplayManager; /** Counter for next free stack ID to use for dynamic activity stacks. */ - private int mNextFreeStackId = FIRST_DYNAMIC_STACK_ID; + private int mNextFreeStackId = 0; /** * Maps the task identifier that activities are currently being started in to the userId of the @@ -2105,8 +2104,8 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D // moveTaskToStackUncheckedLocked() should already placed the task on top, // still need moveTaskToFrontLocked() below for any transition settings. } - if (StackId.resizeStackWithLaunchBounds(stack.mStackId)) { - resizeStackLocked(stack.mStackId, bounds, null /* tempTaskBounds */, + if (stack.resizeStackWithLaunchBounds()) { + resizeStackLocked(stack, bounds, null /* tempTaskBounds */, null /* tempTaskInsetBounds */, !PRESERVE_WINDOWS, true /* allowResizeInDockedMode */, !DEFER_RESUME); } else { @@ -2417,7 +2416,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D case WINDOWING_MODE_SPLIT_SCREEN_SECONDARY: return r.supportsSplitScreenWindowingMode(); } - if (StackId.isDynamicStack(stack.mStackId)) { + if (!stack.isOnHomeDisplay()) { return r.canBeLaunchedOnDisplay(displayId); } Slog.e(TAG, "isValidLaunchStack: Unexpected stack=" + stack); @@ -2511,18 +2510,15 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D return null; } - void resizeStackLocked(int stackId, Rect bounds, Rect tempTaskBounds, Rect tempTaskInsetBounds, - boolean preserveWindows, boolean allowResizeInDockedMode, boolean deferResume) { - if (stackId == DOCKED_STACK_ID) { + void resizeStackLocked(ActivityStack stack, Rect bounds, Rect tempTaskBounds, + Rect tempTaskInsetBounds, boolean preserveWindows, boolean allowResizeInDockedMode, + boolean deferResume) { + + if (stack.inSplitScreenPrimaryWindowingMode()) { resizeDockedStackLocked(bounds, tempTaskBounds, tempTaskInsetBounds, null, null, preserveWindows, deferResume); return; } - final ActivityStack stack = getStack(stackId); - if (stack == null) { - Slog.w(TAG, "resizeStack: stackId " + stackId + " not found."); - return; - } final boolean splitScreenActive = getDefaultDisplay().hasSplitScreenStack(); if (!allowResizeInDockedMode @@ -2532,7 +2528,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D return; } - Trace.traceBegin(TRACE_TAG_ACTIVITY_MANAGER, "am.resizeStack_" + stackId); + Trace.traceBegin(TRACE_TAG_ACTIVITY_MANAGER, "am.resizeStack_" + stack.mStackId); mWindowManager.deferSurfaceLayout(); try { if (stack.supportsSplitScreenWindowingMode()) { @@ -2584,8 +2580,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D /** * TODO: This should just change the windowing mode and resize vs. actually moving task around. - * Can do that once we are no longer using static stack ids. Specially when - * {@link ActivityManager.StackId#FULLSCREEN_WORKSPACE_STACK_ID} is removed. + * Can do that once we are no longer using static stack ids. */ private void moveTasksToFullscreenStackInSurfaceTransaction(ActivityStack fromStack, int toDisplayId, boolean onTop) { @@ -2606,7 +2601,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D if (!otherStack.inSplitScreenSecondaryWindowingMode()) { continue; } - resizeStackLocked(otherStack.mStackId, null, null, null, PRESERVE_WINDOWS, + resizeStackLocked(otherStack, null, null, null, PRESERVE_WINDOWS, true /* allowResizeInDockedMode */, DEFER_RESUME); } @@ -2744,7 +2739,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D tempRect /* outStackBounds */, otherTaskRect /* outTempTaskBounds */, true /* ignoreVisibility */); - resizeStackLocked(current.mStackId, !tempRect.isEmpty() ? tempRect : null, + resizeStackLocked(current, !tempRect.isEmpty() ? tempRect : null, !otherTaskRect.isEmpty() ? otherTaskRect : tempOtherTaskBounds, tempOtherTaskInsetBounds, preserveWindows, true /* allowResizeInDockedMode */, deferResume); @@ -2979,8 +2974,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D int getNextStackId() { while (true) { - if (mNextFreeStackId >= FIRST_DYNAMIC_STACK_ID - && getStack(mNextFreeStackId) == null) { + if (getStack(mNextFreeStackId) == null) { break; } mNextFreeStackId++; @@ -3160,7 +3154,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D // Resize the pinned stack to match the current size of the task the activity we are // going to be moving is currently contained in. We do this to have the right starting // animation bounds for the pinned stack to the desired bounds the caller wants. - resizeStackLocked(PINNED_STACK_ID, task.mBounds, null /* tempTaskBounds */, + resizeStackLocked(stack, task.mBounds, null /* tempTaskBounds */, null /* tempTaskInsetBounds */, !PRESERVE_WINDOWS, true /* allowResizeInDockedMode */, !DEFER_RESUME); @@ -3653,7 +3647,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D // Also dismiss the pinned stack whenever we switch users. Removing the pinned stack will // also cause all tasks to be moved to the fullscreen stack at a position that is // appropriate. - removeStackLocked(PINNED_STACK_ID); + removeStacksInWindowingModes(WINDOWING_MODE_PINNED); mUserStackInFront.put(mCurrentUser, focusStackId); final int restoreStackId = mUserStackInFront.get(userId, mHomeStack.mStackId); @@ -3896,7 +3890,9 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D for (int stackNdx = stacks.size() - 1; stackNdx >= 0; --stackNdx) { final ActivityStack stack = stacks.get(stackNdx); pw.println(); - pw.println(" Stack #" + stack.mStackId + ":"); + pw.println(" Stack #" + stack.mStackId + + ": type=" + activityTypeToString(getActivityType()) + + " mode=" + windowingModeToString(getWindowingMode())); pw.println(" mFullscreen=" + stack.mFullscreen); pw.println(" isSleeping=" + stack.shouldSleepActivities()); pw.println(" mBounds=" + stack.mBounds); @@ -4315,8 +4311,8 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D // The task landed on an inappropriate display somehow, move it to the default // display. // TODO(multi-display): Find proper stack for the task on the default display. - mService.moveTaskToStack(task.taskId, FULLSCREEN_WORKSPACE_STACK_ID, - true /* toTop */); + mService.setTaskWindowingMode(task.taskId, + WINDOWING_MODE_FULLSCREEN_OR_SPLIT_SCREEN_SECONDARY, true /* toTop */); launchOnSecondaryDisplayFailed = true; } else { // The task might have landed on a display different from requested. @@ -4402,7 +4398,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D void scheduleUpdatePictureInPictureModeIfNeeded(TaskRecord task, ActivityStack prevStack) { final ActivityStack stack = task.getStack(); if (prevStack == null || prevStack == stack - || (prevStack.mStackId != PINNED_STACK_ID && stack.mStackId != PINNED_STACK_ID)) { + || (!prevStack.inPinnedWindowingMode() && !stack.inPinnedWindowingMode())) { return; } diff --git a/services/core/java/com/android/server/am/ActivityStarter.java b/services/core/java/com/android/server/am/ActivityStarter.java index d444c6638c71..830008395ad5 100644 --- a/services/core/java/com/android/server/am/ActivityStarter.java +++ b/services/core/java/com/android/server/am/ActivityStarter.java @@ -26,11 +26,6 @@ import static android.app.ActivityManager.START_RETURN_INTENT_TO_CALLER; import static android.app.ActivityManager.START_RETURN_LOCK_TASK_MODE_VIOLATION; import static android.app.ActivityManager.START_SUCCESS; import static android.app.ActivityManager.START_TASK_TO_FRONT; -import static android.app.ActivityManager.StackId; -import static android.app.ActivityManager.StackId.DOCKED_STACK_ID; -import static android.app.ActivityManager.StackId.INVALID_STACK_ID; -import static android.app.ActivityManager.StackId.PINNED_STACK_ID; -import static android.app.ActivityManager.StackId.isDynamicStack; import static android.app.WindowConfiguration.ACTIVITY_TYPE_ASSISTANT; import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME; import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; @@ -610,15 +605,19 @@ class ActivityStarter { mSupervisor.reportTaskToFrontNoLaunch(mStartActivity); } - int startedActivityStackId = INVALID_STACK_ID; + ActivityStack startedActivityStack = null; final ActivityStack currentStack = r.getStack(); if (currentStack != null) { - startedActivityStackId = currentStack.mStackId; + startedActivityStack = currentStack; } else if (mTargetStack != null) { - startedActivityStackId = targetStack.mStackId; + startedActivityStack = targetStack; } - if (startedActivityStackId == DOCKED_STACK_ID) { + if (startedActivityStack == null) { + return; + } + + if (startedActivityStack.inSplitScreenPrimaryWindowingMode()) { final ActivityStack homeStack = mSupervisor.getDefaultDisplay().getStack( WINDOWING_MODE_UNDEFINED, ACTIVITY_TYPE_HOME); final boolean homeStackVisible = homeStack != null && homeStack.isVisible(); @@ -634,14 +633,14 @@ class ActivityStarter { boolean clearedTask = (mLaunchFlags & (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK)) == (FLAG_ACTIVITY_NEW_TASK | FLAG_ACTIVITY_CLEAR_TASK) && (mReuseTask != null); - if (startedActivityStackId == PINNED_STACK_ID && (result == START_TASK_TO_FRONT - || result == START_DELIVERED_TO_TOP || clearedTask)) { + if (startedActivityStack.inPinnedWindowingMode() + && (result == START_TASK_TO_FRONT || result == START_DELIVERED_TO_TOP + || clearedTask)) { // The activity was already running in the pinned stack so it wasn't started, but either // brought to the front or the new intent was delivered to it since it was already in // front. Notify anyone interested in this piece of information. mService.mTaskChangeNotificationController.notifyPinnedActivityRestartAttempt( clearedTask); - return; } } @@ -1427,7 +1426,7 @@ class ActivityStarter { // in any task/stack, however it could launch other activities like ResolverActivity, // and we want those to stay in the original task. if ((mStartActivity.isResolverActivity() || mStartActivity.noDisplay) && mSourceRecord != null - && mSourceRecord.isFreeform()) { + && mSourceRecord.inFreeformWindowingMode()) { mAddingToTask = true; } } @@ -2001,9 +2000,9 @@ class ActivityStarter { return; } - final int stackId = task.getStackId(); - if (StackId.resizeStackWithLaunchBounds(stackId)) { - mService.resizeStack(stackId, bounds, true, !PRESERVE_WINDOWS, ANIMATE, -1); + final ActivityStack stack = task.getStack(); + if (stack != null && stack.resizeStackWithLaunchBounds()) { + mService.resizeStack(stack.mStackId, bounds, true, !PRESERVE_WINDOWS, ANIMATE, -1); } else { task.updateOverrideConfiguration(bounds); } @@ -2119,7 +2118,7 @@ class ActivityStarter { mSupervisor.getStacksOnDefaultDisplay(); for (int stackNdx = homeDisplayStacks.size() - 1; stackNdx >= 0; --stackNdx) { stack = homeDisplayStacks.get(stackNdx); - if (isDynamicStack(stack.mStackId)) { + if (!stack.isOnHomeDisplay()) { if (DEBUG_FOCUS || DEBUG_STACK) Slog.d(TAG_FOCUS, "computeStackFocus: Setting focused stack=" + stack); return stack; @@ -2138,7 +2137,6 @@ class ActivityStarter { private boolean canLaunchIntoFocusedStack(ActivityRecord r, boolean newTask) { final ActivityStack focusedStack = mSupervisor.mFocusedStack; final boolean canUseFocusedStack; - final int focusedStackId = mSupervisor.mFocusedStack.mStackId; if (focusedStack.isActivityTypeAssistant()) { canUseFocusedStack = r.isActivityTypeAssistant(); } else { @@ -2161,7 +2159,7 @@ class ActivityStarter { default: // Dynamic stacks behave similarly to the fullscreen stack and can contain any // resizeable task. - canUseFocusedStack = isDynamicStack(focusedStackId) + canUseFocusedStack = !focusedStack.isOnHomeDisplay() && r.canBeLaunchedOnDisplay(focusedStack.mDisplayId); } } @@ -2205,7 +2203,7 @@ class ActivityStarter { return mSupervisor.mFocusedStack; } - if (parentStack != null && parentStack.isDockedStack()) { + if (parentStack != null && parentStack.inSplitScreenPrimaryWindowingMode()) { // If parent was in docked stack, the natural place to launch another activity // will be fullscreen, so it can appear alongside the docked window. final int activityType = mSupervisor.resolveActivityType(r, mOptions, task); diff --git a/services/core/java/com/android/server/am/KeyguardController.java b/services/core/java/com/android/server/am/KeyguardController.java index 5c48f90df189..ba541e6eea16 100644 --- a/services/core/java/com/android/server/am/KeyguardController.java +++ b/services/core/java/com/android/server/am/KeyguardController.java @@ -16,7 +16,6 @@ package com.android.server.am; -import static android.app.ActivityManager.StackId.DOCKED_STACK_ID; import static android.os.Trace.TRACE_TAG_ACTIVITY_MANAGER; import static android.view.Display.DEFAULT_DISPLAY; import static android.view.Display.INVALID_DISPLAY; diff --git a/services/core/java/com/android/server/am/TaskRecord.java b/services/core/java/com/android/server/am/TaskRecord.java index 0d8df7968e96..5491da103b91 100644 --- a/services/core/java/com/android/server/am/TaskRecord.java +++ b/services/core/java/com/android/server/am/TaskRecord.java @@ -18,10 +18,7 @@ package com.android.server.am; import static android.app.ActivityManager.RESIZE_MODE_FORCED; import static android.app.ActivityManager.RESIZE_MODE_SYSTEM; -import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID; -import static android.app.ActivityManager.StackId.FULLSCREEN_WORKSPACE_STACK_ID; import static android.app.ActivityManager.StackId.INVALID_STACK_ID; -import static android.app.ActivityManager.StackId.PINNED_STACK_ID; import static android.app.WindowConfiguration.ACTIVITY_TYPE_ASSISTANT; import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME; import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS; @@ -31,6 +28,7 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED; import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY; +import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_SECONDARY; import static android.content.Intent.FLAG_ACTIVITY_NEW_DOCUMENT; import static android.content.Intent.FLAG_ACTIVITY_RETAIN_IN_RECENTS; import static android.content.pm.ActivityInfo.FLAG_RELINQUISH_TASK_IDENTITY; @@ -520,7 +518,7 @@ class TaskRecord extends ConfigurationContainer implements TaskWindowContainerLi // All we can do for now is update the bounds so it can be used when the task is // added to window manager. updateOverrideConfiguration(bounds); - if (getStackId() != FREEFORM_WORKSPACE_STACK_ID) { + if (!inFreeformWindowingMode()) { // re-restore the task so it can have the proper stack association. mService.mStackSupervisor.restoreRecentTaskLocked(this, null); } @@ -616,8 +614,7 @@ class TaskRecord extends ConfigurationContainer implements TaskWindowContainerLi * @return whether the task was reparented */ // TODO: Inspect all call sites and change to just changing windowing mode of the stack vs. - // re-parenting the task. Can only be done when we are no longer using static stack Ids like - /** {@link ActivityManager.StackId#FULLSCREEN_WORKSPACE_STACK_ID} */ + // re-parenting the task. Can only be done when we are no longer using static stack Ids. boolean reparent(ActivityStack preferredStack, int position, @ReparentMoveStackMode int moveStackMode, boolean animate, boolean deferResume, boolean schedulePictureInPictureModeChange, String reason) { @@ -630,12 +627,12 @@ class TaskRecord extends ConfigurationContainer implements TaskWindowContainerLi return false; } - final int sourceStackId = getStackId(); - final int stackId = toStack.getStackId(); + final int toStackWindowingMode = toStack.getWindowingMode(); final ActivityRecord topActivity = getTopActivity(); - final boolean mightReplaceWindow = StackId.replaceWindowsOnTaskMove(sourceStackId, stackId) - && topActivity != null; + final boolean mightReplaceWindow = + replaceWindowsOnTaskMove(getWindowingMode(), toStackWindowingMode) + && topActivity != null; if (mightReplaceWindow) { // We are about to relaunch the activity because its configuration changed due to // being maximized, i.e. size change. The activity will first remove the old window @@ -707,10 +704,10 @@ class TaskRecord extends ConfigurationContainer implements TaskWindowContainerLi toStack.prepareFreezingTaskBounds(); // Make sure the task has the appropriate bounds/size for the stack it is in. - final int toStackWindowingMode = toStack.getWindowingMode(); final boolean toStackSplitScreenPrimary = toStackWindowingMode == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY; - if (stackId == FULLSCREEN_WORKSPACE_STACK_ID + if ((toStackWindowingMode == WINDOWING_MODE_FULLSCREEN + || toStackWindowingMode == WINDOWING_MODE_SPLIT_SCREEN_SECONDARY) && !Objects.equals(mBounds, toStack.mBounds)) { kept = resize(toStack.mBounds, RESIZE_MODE_SYSTEM, !mightReplaceWindow, deferResume); @@ -751,7 +748,7 @@ class TaskRecord extends ConfigurationContainer implements TaskWindowContainerLi // TODO: Handle incorrect request to move before the actual move, not after. final boolean inSplitScreenMode = supervisor.getDefaultDisplay().hasSplitScreenStack(); supervisor.handleNonResizableTaskIfNeeded(this, preferredStack.getWindowingMode(), - DEFAULT_DISPLAY, stackId); + DEFAULT_DISPLAY, toStack.mStackId); boolean successful = (preferredStack == toStack); if (successful && toStack.getWindowingMode() == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY) { @@ -761,6 +758,18 @@ class TaskRecord extends ConfigurationContainer implements TaskWindowContainerLi return successful; } + /** + * Returns true if the windows of tasks being moved to the target stack from the source + * stack should be replaced, meaning that window manager will keep the old window around + * until the new is ready. + * @hide + */ + private static boolean replaceWindowsOnTaskMove( + int sourceWindowingMode, int targetWindowingMode) { + return sourceWindowingMode == WINDOWING_MODE_FREEFORM + || targetWindowingMode == WINDOWING_MODE_FREEFORM; + } + void cancelWindowTransition() { mWindowContainerController.cancelWindowTransition(); } @@ -1263,7 +1272,7 @@ class TaskRecord extends ConfigurationContainer implements TaskWindowContainerLi mService.notifyTaskPersisterLocked(this, false); } - if (getStackId() == PINNED_STACK_ID) { + if (inPinnedWindowingMode()) { // We normally notify listeners of task stack changes on pause, however pinned stack // activities are normally in the paused state so no notification will be sent there // before the activity is removed. We send it here so instead. @@ -1493,7 +1502,7 @@ class TaskRecord extends ConfigurationContainer implements TaskWindowContainerLi * @return True if the requested bounds are okay for a resizing request. */ private boolean canResizeToBounds(Rect bounds) { - if (bounds == null || getStackId() != FREEFORM_WORKSPACE_STACK_ID) { + if (bounds == null || !inFreeformWindowingMode()) { // Note: If not on the freeform workspace, we ignore the bounds. return true; } @@ -1911,7 +1920,7 @@ class TaskRecord extends ConfigurationContainer implements TaskWindowContainerLi // If the task has no requested minimal size, we'd like to enforce a minimal size // so that the user can not render the task too small to manipulate. We don't need // to do this for the pinned stack as the bounds are controlled by the system. - if (getStackId() != PINNED_STACK_ID) { + if (!inPinnedWindowingMode()) { if (minWidth == INVALID_MIN_SIZE) { minWidth = mService.mStackSupervisor.mDefaultMinSizeOfResizeableTask; } @@ -2085,7 +2094,7 @@ class TaskRecord extends ConfigurationContainer implements TaskWindowContainerLi return; } - if (inStack.mStackId == FREEFORM_WORKSPACE_STACK_ID) { + if (inStack.inFreeformWindowingMode()) { if (!isResizeable()) { throw new IllegalArgumentException("Can not position non-resizeable task=" + this + " in stack=" + inStack); diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java index db7817ec4955..354c4f0bb667 100644 --- a/services/core/java/com/android/server/policy/PhoneWindowManager.java +++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java @@ -18,13 +18,14 @@ package com.android.server.policy; import static android.Manifest.permission.INTERNAL_SYSTEM_WINDOW; import static android.Manifest.permission.SYSTEM_ALERT_WINDOW; -import static android.app.ActivityManager.StackId.DOCKED_STACK_ID; -import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID; import static android.app.AppOpsManager.OP_SYSTEM_ALERT_WINDOW; import static android.app.AppOpsManager.OP_TOAST_WINDOW; import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME; import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; +import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; +import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY; +import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_SECONDARY; import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED; import static android.content.Context.CONTEXT_RESTRICTED; import static android.content.Context.DISPLAY_SERVICE; @@ -2844,7 +2845,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { boolean keyguardLocked = isKeyguardLocked(); boolean hideDockDivider = attrs.type == TYPE_DOCK_DIVIDER - && !mWindowManagerInternal.isStackVisible(DOCKED_STACK_ID); + && !mWindowManagerInternal.isStackVisible(WINDOWING_MODE_SPLIT_SCREEN_PRIMARY); return (keyguardLocked && !allowWhenLocked && win.getDisplayId() == DEFAULT_DISPLAY) || hideDockDivider; } @@ -5445,7 +5446,10 @@ public class PhoneWindowManager implements WindowManagerPolicy { boolean appWindow = attrs.type >= FIRST_APPLICATION_WINDOW && attrs.type < FIRST_SYSTEM_WINDOW; - final int stackId = win.getStackId(); + final int windowingMode = win.getWindowingMode(); + final boolean inFullScreenOrSplitScreenSecondaryWindowingMode = + windowingMode == WINDOWING_MODE_FULLSCREEN + || windowingMode == WINDOWING_MODE_SPLIT_SCREEN_SECONDARY; if (mTopFullscreenOpaqueWindowState == null && affectsSystemUi) { if ((fl & FLAG_FORCE_NOT_FULLSCREEN) != 0) { mForceStatusBar = true; @@ -5464,7 +5468,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { // represent should be hidden or if we should hide the lockscreen. For attached app // windows we defer the decision to the window it is attached to. if (appWindow && attached == null) { - if (attrs.isFullscreen() && StackId.normallyFullscreenWindows(stackId)) { + if (attrs.isFullscreen() && inFullScreenOrSplitScreenSecondaryWindowingMode) { if (DEBUG_LAYOUT) Slog.v(TAG, "Fullscreen window: " + win); mTopFullscreenOpaqueWindowState = win; if (mTopFullscreenOpaqueOrDimmingWindowState == null) { @@ -5495,7 +5499,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { // Keep track of the window if it's dimming but not necessarily fullscreen. if (mTopFullscreenOpaqueOrDimmingWindowState == null && affectsSystemUi - && win.isDimming() && StackId.normallyFullscreenWindows(stackId)) { + && win.isDimming() && inFullScreenOrSplitScreenSecondaryWindowingMode) { mTopFullscreenOpaqueOrDimmingWindowState = win; } @@ -5503,7 +5507,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { // separately, because both the "real fullscreen" opaque window and the one for the docked // stack can control View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR. if (mTopDockedOpaqueWindowState == null && affectsSystemUi && appWindow && attached == null - && attrs.isFullscreen() && stackId == DOCKED_STACK_ID) { + && attrs.isFullscreen() && windowingMode == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY) { mTopDockedOpaqueWindowState = win; if (mTopDockedOpaqueOrDimmingWindowState == null) { mTopDockedOpaqueOrDimmingWindowState = win; @@ -5513,7 +5517,7 @@ public class PhoneWindowManager implements WindowManagerPolicy { // Also keep track of any windows that are dimming but not necessarily fullscreen in the // docked stack. if (mTopDockedOpaqueOrDimmingWindowState == null && affectsSystemUi && win.isDimming() - && stackId == DOCKED_STACK_ID) { + && windowingMode == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY) { mTopDockedOpaqueOrDimmingWindowState = win; } @@ -5608,8 +5612,9 @@ public class PhoneWindowManager implements WindowManagerPolicy { changes |= FINISH_LAYOUT_REDO_LAYOUT; } } else if (topIsFullscreen - && !mWindowManagerInternal.isStackVisible(FREEFORM_WORKSPACE_STACK_ID) - && !mWindowManagerInternal.isStackVisible(DOCKED_STACK_ID)) { + && !mWindowManagerInternal.isStackVisible(WINDOWING_MODE_FREEFORM) + && !mWindowManagerInternal.isStackVisible( + WINDOWING_MODE_SPLIT_SCREEN_PRIMARY)) { if (DEBUG_LAYOUT) Slog.v(TAG, "** HIDING status bar"); if (mStatusBarController.setBarShowingLw(false)) { changes |= FINISH_LAYOUT_REDO_LAYOUT; @@ -8009,9 +8014,10 @@ public class PhoneWindowManager implements WindowManagerPolicy { } private int updateSystemBarsLw(WindowState win, int oldVis, int vis) { - final boolean dockedStackVisible = mWindowManagerInternal.isStackVisible(DOCKED_STACK_ID); + final boolean dockedStackVisible = + mWindowManagerInternal.isStackVisible(WINDOWING_MODE_SPLIT_SCREEN_PRIMARY); final boolean freeformStackVisible = - mWindowManagerInternal.isStackVisible(FREEFORM_WORKSPACE_STACK_ID); + mWindowManagerInternal.isStackVisible(WINDOWING_MODE_FREEFORM); final boolean resizing = mWindowManagerInternal.isDockedDividerResizing(); // We need to force system bars when the docked stack is visible, when the freeform stack diff --git a/services/core/java/com/android/server/wm/AppWindowToken.java b/services/core/java/com/android/server/wm/AppWindowToken.java index a1eeff842fc4..1b463c7889de 100644 --- a/services/core/java/com/android/server/wm/AppWindowToken.java +++ b/services/core/java/com/android/server/wm/AppWindowToken.java @@ -823,7 +823,7 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree // For freeform windows, we can't freeze the bounds at the moment because this would make // the resizing unresponsive. - if (task == null || task.inFreeformWorkspace()) { + if (task == null || task.inFreeformWindowingMode()) { return false; } diff --git a/services/core/java/com/android/server/wm/ConfigurationContainer.java b/services/core/java/com/android/server/wm/ConfigurationContainer.java index 9e028d38a220..5bfea98969bf 100644 --- a/services/core/java/com/android/server/wm/ConfigurationContainer.java +++ b/services/core/java/com/android/server/wm/ConfigurationContainer.java @@ -21,7 +21,9 @@ import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME; import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS; import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED; +import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; +import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED; import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY; import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_SECONDARY; import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED; @@ -182,6 +184,11 @@ public abstract class ConfigurationContainer<E extends ConfigurationContainer> { return windowingMode == WINDOWING_MODE_SPLIT_SCREEN_SECONDARY; } + public boolean inSplitScreenPrimaryWindowingMode() { + return mFullConfiguration.windowConfiguration.getWindowingMode() + == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY; + } + /** * Returns true if this container can be put in either * {@link WindowConfiguration#WINDOWING_MODE_SPLIT_SCREEN_PRIMARY} or @@ -192,6 +199,14 @@ public abstract class ConfigurationContainer<E extends ConfigurationContainer> { return mFullConfiguration.windowConfiguration.supportSplitScreenWindowingMode(); } + public boolean inPinnedWindowingMode() { + return mFullConfiguration.windowConfiguration.getWindowingMode() == WINDOWING_MODE_PINNED; + } + + public boolean inFreeformWindowingMode() { + return mFullConfiguration.windowConfiguration.getWindowingMode() == WINDOWING_MODE_FREEFORM; + } + /** Returns the activity type associated with the the configuration container. */ /*@WindowConfiguration.ActivityType*/ public int getActivityType() { diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java index 0e68a8f64e5f..036e803ef975 100644 --- a/services/core/java/com/android/server/wm/DisplayContent.java +++ b/services/core/java/com/android/server/wm/DisplayContent.java @@ -16,10 +16,8 @@ package com.android.server.wm; -import static android.app.ActivityManager.StackId.DOCKED_STACK_ID; -import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID; -import static android.app.ActivityManager.StackId.PINNED_STACK_ID; import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED; +import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED; import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY; @@ -979,8 +977,8 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo } // In the presence of the PINNED stack or System Alert - // windows we unforuntately can not seamlessly rotate. - if (getStackById(PINNED_STACK_ID) != null) { + // windows we unfortunately can not seamlessly rotate. + if (getStack(WINDOWING_MODE_PINNED) != null) { mayRotateSeamlessly = false; } for (int i = 0; i < mService.mSessions.size(); i++) { @@ -1773,7 +1771,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo mTaskStackContainers.addStackToDisplay(stack, onTop); } - if (stackId == DOCKED_STACK_ID) { + if (stack.inSplitScreenPrimaryWindowingMode()) { mDividerControllerLocked.notifyDockedStackExistsChanged(true); } return stack; @@ -2037,7 +2035,7 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo final WindowState imeWin = mService.mInputMethodWindow; final boolean imeVisible = imeWin != null && imeWin.isVisibleLw() && imeWin.isDisplayedLw() && !mDividerControllerLocked.isImeHideRequested(); - final boolean dockVisible = isStackVisible(DOCKED_STACK_ID); + final boolean dockVisible = isStackVisible(WINDOWING_MODE_SPLIT_SCREEN_PRIMARY); final TaskStack imeTargetStack = mService.getImeFocusStackLocked(); final int imeDockSide = (dockVisible && imeTargetStack != null) ? imeTargetStack.getDockSide() : DOCKED_INVALID; @@ -2260,10 +2258,10 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo return "Display " + mDisplayId + " name=\"" + mDisplayInfo.name + "\""; } - /** Checks if stack with provided id is visible on this display. */ - boolean isStackVisible(int stackId) { - final TaskStack stack = getStackById(stackId); - return (stack != null && stack.isVisible()); + /** Returns true if the stack in the windowing mode is visible. */ + boolean isStackVisible(int windowingMode) { + final TaskStack stack = getStack(windowingMode); + return stack != null && stack.isVisible(); } /** @@ -3556,7 +3554,8 @@ class DisplayContent extends WindowContainer<DisplayContent.DisplayChildWindowCo @Override int getOrientation() { - if (isStackVisible(DOCKED_STACK_ID) || isStackVisible(FREEFORM_WORKSPACE_STACK_ID)) { + if (isStackVisible(WINDOWING_MODE_SPLIT_SCREEN_PRIMARY) + || isStackVisible(WINDOWING_MODE_FREEFORM)) { // Apps and their containers are not allowed to specify an orientation while the // docked or freeform stack is visible...except for the home stack/task if the // docked stack is minimized and it actually set something. diff --git a/services/core/java/com/android/server/wm/DockedStackDividerController.java b/services/core/java/com/android/server/wm/DockedStackDividerController.java index 6f441b98ea7c..629af669d614 100644 --- a/services/core/java/com/android/server/wm/DockedStackDividerController.java +++ b/services/core/java/com/android/server/wm/DockedStackDividerController.java @@ -16,8 +16,6 @@ package com.android.server.wm; -import static android.app.ActivityManager.StackId.DOCKED_STACK_ID; -import static android.app.ActivityManager.StackId.INVALID_STACK_ID; import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY; import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_SECONDARY; import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED; @@ -588,7 +586,7 @@ public class DockedStackDividerController implements DimLayerUser { private boolean containsAppInDockedStack(ArraySet<AppWindowToken> apps) { for (int i = apps.size() - 1; i >= 0; i--) { final AppWindowToken token = apps.valueAt(i); - if (token.getTask() != null && token.getTask().mStack.mStackId == DOCKED_STACK_ID) { + if (token.getTask() != null && token.inSplitScreenPrimaryWindowingMode()) { return true; } } diff --git a/services/core/java/com/android/server/wm/InputMonitor.java b/services/core/java/com/android/server/wm/InputMonitor.java index 5057f632461c..238cb9f1dfea 100644 --- a/services/core/java/com/android/server/wm/InputMonitor.java +++ b/services/core/java/com/android/server/wm/InputMonitor.java @@ -16,7 +16,6 @@ package com.android.server.wm; -import static android.app.ActivityManager.StackId.PINNED_STACK_ID; import static android.view.Display.DEFAULT_DISPLAY; import static android.view.WindowManager.INPUT_CONSUMER_NAVIGATION; import static android.view.WindowManager.INPUT_CONSUMER_PIP; @@ -650,7 +649,7 @@ final class InputMonitor implements InputManagerService.WindowManagerCallbacks { final boolean hasFocus = w == mInputFocus; final boolean isVisible = w.isVisibleLw(); - if (w.getStackId() == PINNED_STACK_ID) { + if (w.inPinnedWindowingMode()) { if (mAddPipInputConsumerHandle && (inputWindowHandle.layer <= pipInputConsumer.mWindowHandle.layer)) { // Update the bounds of the Pip input consumer to match the Pinned stack diff --git a/services/core/java/com/android/server/wm/StackWindowController.java b/services/core/java/com/android/server/wm/StackWindowController.java index c0a4cb72a348..c0e5fd4b1fdd 100644 --- a/services/core/java/com/android/server/wm/StackWindowController.java +++ b/services/core/java/com/android/server/wm/StackWindowController.java @@ -16,8 +16,6 @@ package com.android.server.wm; -import static android.app.ActivityManager.StackId.PINNED_STACK_ID; - import android.content.res.Configuration; import android.graphics.Rect; import android.os.Handler; @@ -280,8 +278,9 @@ public class StackWindowController if (stack.getWindowConfiguration().tasksAreFloating()) { // Floating tasks should not be resized to the screen's bounds. - if (mStackId == PINNED_STACK_ID && bounds.width() == mTmpDisplayBounds.width() && - bounds.height() == mTmpDisplayBounds.height()) { + if (stack.inPinnedWindowingMode() + && bounds.width() == mTmpDisplayBounds.width() + && bounds.height() == mTmpDisplayBounds.height()) { // If the bounds we are animating is the same as the fullscreen stack // dimensions, then apply the same inset calculations that we normally do for // the fullscreen stack, without intersecting it with the display bounds diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index 7e8d13084225..6c6934fcedc7 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -17,8 +17,6 @@ package com.android.server.wm; import static android.app.ActivityManager.RESIZE_MODE_SYSTEM_SCREEN_ROTATION; -import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID; -import static android.app.ActivityManager.StackId.PINNED_STACK_ID; import static android.content.pm.ActivityInfo.RESIZE_MODE_FORCE_RESIZABLE_LANDSCAPE_ONLY; import static android.content.pm.ActivityInfo.RESIZE_MODE_FORCE_RESIZABLE_PORTRAIT_ONLY; import static android.content.pm.ActivityInfo.RESIZE_MODE_FORCE_RESIZABLE_PRESERVE_ORIENTATION; @@ -213,7 +211,7 @@ class Task extends WindowContainer<AppWindowToken> implements DimLayer.DimLayerU // then we want to preserve our insets so that there will not // be a jump in the area covered by system decorations. We rely // on the pinned animation to later unset this value. - if (stack.mStackId == PINNED_STACK_ID) { + if (stack.inPinnedWindowingMode()) { mPreserveNonFloatingState = true; } else { mPreserveNonFloatingState = false; @@ -492,7 +490,7 @@ class Task extends WindowContainer<AppWindowToken> implements DimLayer.DimLayerU final boolean dockedResizing = displayContent != null && displayContent.mDividerControllerLocked.isResizing(); if (useCurrentBounds()) { - if (inFreeformWorkspace() && getMaxVisibleBounds(out)) { + if (inFreeformWindowingMode() && getMaxVisibleBounds(out)) { return; } @@ -598,14 +596,6 @@ class Task extends WindowContainer<AppWindowToken> implements DimLayer.DimLayerU return (tokensCount != 0) && mChildren.get(tokensCount - 1).mShowForAllUsers; } - boolean inFreeformWorkspace() { - return mStack != null && mStack.mStackId == FREEFORM_WORKSPACE_STACK_ID; - } - - boolean inPinnedWorkspace() { - return mStack != null && mStack.mStackId == PINNED_STACK_ID; - } - /** * When we are in a floating stack (Freeform, Pinned, ...) we calculate * insets differently. However if we are animating to the fullscreen stack diff --git a/services/core/java/com/android/server/wm/TaskPositioner.java b/services/core/java/com/android/server/wm/TaskPositioner.java index c58212cd8235..87de1514c053 100644 --- a/services/core/java/com/android/server/wm/TaskPositioner.java +++ b/services/core/java/com/android/server/wm/TaskPositioner.java @@ -20,7 +20,6 @@ import static android.app.ActivityManager.DOCKED_STACK_CREATE_MODE_BOTTOM_OR_RIG import static android.app.ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT; import static android.app.ActivityManager.RESIZE_MODE_USER; import static android.app.ActivityManager.RESIZE_MODE_USER_FORCED; -import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID; import static android.content.res.Configuration.ORIENTATION_LANDSCAPE; import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER; import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ORIENTATION; @@ -649,7 +648,7 @@ class TaskPositioner implements DimLayer.DimLayerUser { * shouldn't be shown. */ private int getDimSide(int x) { - if (mTask.mStack.mStackId != FREEFORM_WORKSPACE_STACK_ID + if (!mTask.mStack.inFreeformWindowingMode() || !mTask.mStack.fillsParent() || mTask.mStack.getConfiguration().orientation != ORIENTATION_LANDSCAPE) { return CTRL_NONE; diff --git a/services/core/java/com/android/server/wm/TaskStack.java b/services/core/java/com/android/server/wm/TaskStack.java index 652788377005..3780d194c201 100644 --- a/services/core/java/com/android/server/wm/TaskStack.java +++ b/services/core/java/com/android/server/wm/TaskStack.java @@ -18,8 +18,6 @@ package com.android.server.wm; import static android.app.ActivityManager.DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT; import static android.app.ActivityManager.DOCKED_STACK_CREATE_MODE_BOTTOM_OR_RIGHT; -import static android.app.ActivityManager.StackId.DOCKED_STACK_ID; -import static android.app.ActivityManager.StackId.PINNED_STACK_ID; import static android.app.WindowConfiguration.ACTIVITY_TYPE_ASSISTANT; import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME; import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS; @@ -409,7 +407,7 @@ public class TaskStack extends WindowContainer<Task> implements DimLayer.DimLaye return false; } - if (mStackId == PINNED_STACK_ID) { + if (inPinnedWindowingMode()) { getAnimationOrCurrentBounds(mTmpRect2); boolean updated = mDisplayContent.mPinnedStackControllerLocked.onTaskStackBoundsChanged( mTmpRect2, mTmpRect3); @@ -443,21 +441,19 @@ public class TaskStack extends WindowContainer<Task> implements DimLayer.DimLaye mTmpRect2.set(mBounds); mDisplayContent.rotateBounds(mRotation, newRotation, mTmpRect2); - switch (mStackId) { - case DOCKED_STACK_ID: - repositionDockedStackAfterRotation(mTmpRect2); - snapDockedStackAfterRotation(mTmpRect2); - final int newDockSide = getDockSide(mTmpRect2); - - // Update the dock create mode and clear the dock create bounds, these - // might change after a rotation and the original values will be invalid. - mService.setDockedStackCreateStateLocked( - (newDockSide == DOCKED_LEFT || newDockSide == DOCKED_TOP) - ? DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT - : DOCKED_STACK_CREATE_MODE_BOTTOM_OR_RIGHT, - null); - mDisplayContent.getDockedDividerController().notifyDockSideChanged(newDockSide); - break; + if (inSplitScreenPrimaryWindowingMode()) { + repositionDockedStackAfterRotation(mTmpRect2); + snapDockedStackAfterRotation(mTmpRect2); + final int newDockSide = getDockSide(mTmpRect2); + + // Update the dock create mode and clear the dock create bounds, these + // might change after a rotation and the original values will be invalid. + mService.setDockedStackCreateStateLocked( + (newDockSide == DOCKED_LEFT || newDockSide == DOCKED_TOP) + ? DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT + : DOCKED_STACK_CREATE_MODE_BOTTOM_OR_RIGHT, + null); + mDisplayContent.getDockedDividerController().notifyDockSideChanged(newDockSide); } mBoundsAfterRotation.set(mTmpRect2); @@ -688,7 +684,7 @@ public class TaskStack extends WindowContainer<Task> implements DimLayer.DimLaye Rect bounds = null; final TaskStack dockedStack = dc.getDockedStackIgnoringVisibility(); - if (mStackId == DOCKED_STACK_ID + if (inSplitScreenPrimaryWindowingMode() || (dockedStack != null && inSplitScreenSecondaryWindowingMode() && !dockedStack.fillsParent())) { // The existence of a docked stack affects the size of other static stack created since @@ -703,10 +699,10 @@ public class TaskStack extends WindowContainer<Task> implements DimLayer.DimLaye } final boolean dockedOnTopOrLeft = mService.mDockedStackCreateMode == DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT; - getStackDockedModeBounds(mTmpRect, bounds, mStackId, mTmpRect2, + getStackDockedModeBounds(mTmpRect, bounds, mTmpRect2, mDisplayContent.mDividerControllerLocked.getContentWidth(), dockedOnTopOrLeft); - } else if (mStackId == PINNED_STACK_ID) { + } else if (inPinnedWindowingMode()) { // Update the bounds based on any changes to the display info getAnimationOrCurrentBounds(mTmpRect2); boolean updated = mDisplayContent.mPinnedStackControllerLocked.onTaskStackBoundsChanged( @@ -791,7 +787,7 @@ public class TaskStack extends WindowContainer<Task> implements DimLayer.DimLaye mDisplayContent.getLogicalDisplayRect(mTmpRect); dockedStack.getRawBounds(mTmpRect2); final boolean dockedOnTopOrLeft = dockedSide == DOCKED_TOP || dockedSide == DOCKED_LEFT; - getStackDockedModeBounds(mTmpRect, outStackBounds, mStackId, mTmpRect2, + getStackDockedModeBounds(mTmpRect, outStackBounds, mTmpRect2, mDisplayContent.mDividerControllerLocked.getContentWidth(), dockedOnTopOrLeft); } @@ -800,16 +796,15 @@ public class TaskStack extends WindowContainer<Task> implements DimLayer.DimLaye * Outputs the bounds a stack should be given the presence of a docked stack on the display. * @param displayRect The bounds of the display the docked stack is on. * @param outBounds Output bounds that should be used for the stack. - * @param stackId Id of stack we are calculating the bounds for. * @param dockedBounds Bounds of the docked stack. * @param dockDividerWidth We need to know the width of the divider make to the output bounds * close to the side of the dock. * @param dockOnTopOrLeft If the docked stack is on the top or left side of the screen. */ private void getStackDockedModeBounds( - Rect displayRect, Rect outBounds, int stackId, Rect dockedBounds, int dockDividerWidth, + Rect displayRect, Rect outBounds, Rect dockedBounds, int dockDividerWidth, boolean dockOnTopOrLeft) { - final boolean dockedStack = stackId == DOCKED_STACK_ID; + final boolean dockedStack = inSplitScreenPrimaryWindowingMode(); final boolean splitHorizontally = displayRect.width() > displayRect.height(); outBounds.set(displayRect); @@ -866,7 +861,7 @@ public class TaskStack extends WindowContainer<Task> implements DimLayer.DimLaye } void resetDockedStackToMiddle() { - if (mStackId != DOCKED_STACK_ID) { + if (inSplitScreenPrimaryWindowingMode()) { throw new IllegalStateException("Not a docked stack=" + this); } @@ -913,7 +908,7 @@ public class TaskStack extends WindowContainer<Task> implements DimLayer.DimLaye mAnimationBackgroundSurface = null; } - if (mStackId == DOCKED_STACK_ID) { + if (inSplitScreenPrimaryWindowingMode()) { mDisplayContent.mDividerControllerLocked.notifyDockedStackExistsChanged(false); } @@ -1035,8 +1030,8 @@ public class TaskStack extends WindowContainer<Task> implements DimLayer.DimLaye } boolean shouldIgnoreInput() { - return isAdjustedForMinimizedDockedStack() || mStackId == DOCKED_STACK_ID && - isMinimizedDockAndHomeStackResizable(); + return isAdjustedForMinimizedDockedStack() || + (inSplitScreenPrimaryWindowingMode() && isMinimizedDockAndHomeStackResizable()); } /** @@ -1471,7 +1466,7 @@ public class TaskStack extends WindowContainer<Task> implements DimLayer.DimLaye postExclude.set(mTmpRect); } - final boolean isFreeformed = task.inFreeformWorkspace(); + final boolean isFreeformed = task.inFreeformWindowingMode(); if (task != focusedTask || isFreeformed) { if (isFreeformed) { // If the task is freeformed, enlarge the area to account for outside @@ -1529,7 +1524,7 @@ public class TaskStack extends WindowContainer<Task> implements DimLayer.DimLaye } } - if (mStackId == PINNED_STACK_ID) { + if (inPinnedWindowingMode()) { try { mService.mActivityManager.notifyPinnedStackAnimationStarted(); } catch (RemoteException e) { @@ -1561,7 +1556,7 @@ public class TaskStack extends WindowContainer<Task> implements DimLayer.DimLaye mService.requestTraversal(); } - if (mStackId == PINNED_STACK_ID) { + if (inPinnedWindowingMode()) { // Update to the final bounds if requested. This is done here instead of in the bounds // animator to allow us to coordinate this after we notify the PiP mode changed @@ -1595,7 +1590,7 @@ public class TaskStack extends WindowContainer<Task> implements DimLayer.DimLaye * bounds and we have a deferred PiP mode changed callback set with the animation. */ public boolean deferScheduleMultiWindowModeChanged() { - if (mStackId == PINNED_STACK_ID) { + if (inPinnedWindowingMode()) { return (mBoundsAnimatingRequested || mBoundsAnimating); } return false; diff --git a/services/core/java/com/android/server/wm/WallpaperController.java b/services/core/java/com/android/server/wm/WallpaperController.java index 7213c9518d16..629cc868aeb7 100644 --- a/services/core/java/com/android/server/wm/WallpaperController.java +++ b/services/core/java/com/android/server/wm/WallpaperController.java @@ -18,7 +18,7 @@ package com.android.server.wm; import com.android.internal.util.ToBooleanFunction; -import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID; +import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM; import static android.view.ViewGroup.LayoutParams.MATCH_PARENT; import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WALLPAPER; import static android.view.WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED; @@ -447,7 +447,7 @@ class WallpaperController { private void findWallpaperTarget(DisplayContent dc) { mFindResults.reset(); - if (dc.isStackVisible(FREEFORM_WORKSPACE_STACK_ID)) { + if (dc.isStackVisible(WINDOWING_MODE_FREEFORM)) { // In freeform mode we set the wallpaper as its own target, so we don't need an // additional window to make it visible. mFindResults.setUseTopWallpaperAsTarget(true); diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java index 1fb218875aa2..4279d2ef89e2 100644 --- a/services/core/java/com/android/server/wm/WindowManagerService.java +++ b/services/core/java/com/android/server/wm/WindowManagerService.java @@ -2384,7 +2384,7 @@ public class WindowManagerService extends IWindowManager.Stub final Rect insets = new Rect(); final Rect stableInsets = new Rect(); Rect surfaceInsets = null; - final boolean freeform = win != null && win.inFreeformWorkspace(); + final boolean freeform = win != null && win.inFreeformWindowingMode(); if (win != null) { // Containing frame will usually cover the whole screen, including dialog windows. // For freeform workspace windows it will not cover the whole screen and it also @@ -2794,7 +2794,7 @@ public class WindowManagerService extends IWindowManager.Stub for (final WindowState win : mWindowMap.values()) { final Task task = win.getTask(); if (task != null && mTmpTaskIds.get(task.mTaskId, -1) != -1 - && task.inFreeformWorkspace()) { + && task.inFreeformWindowingMode()) { final AppWindowToken appToken = win.mAppToken; if (appToken != null && appToken.mAppAnimator != null) { appToken.mAppAnimator.startProlongAnimation(scaleUp ? @@ -7604,10 +7604,10 @@ public class WindowManagerService extends IWindowManager.Stub } @Override - public boolean isStackVisible(int stackId) { + public boolean isStackVisible(int windowingMode) { synchronized (mWindowMap) { final DisplayContent dc = getDefaultDisplayContentLocked(); - return dc.isStackVisible(stackId); + return dc.isStackVisible(windowingMode); } } diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index 4ff0f3913f42..4cb2a9de8ee7 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -16,10 +16,7 @@ package com.android.server.wm; -import static android.app.ActivityManager.StackId; -import static android.app.ActivityManager.StackId.FREEFORM_WORKSPACE_STACK_ID; import static android.app.ActivityManager.StackId.INVALID_STACK_ID; -import static android.app.ActivityManager.StackId.PINNED_STACK_ID; import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER; import static android.view.Display.DEFAULT_DISPLAY; import static android.view.ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_CONTENT; @@ -815,13 +812,12 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP final WindowState imeWin = mService.mInputMethodWindow; // IME is up and obscuring this window. Adjust the window position so it is visible. if (imeWin != null && imeWin.isVisibleNow() && mService.mInputMethodTarget == this) { - final int stackId = getStackId(); - if (stackId == FREEFORM_WORKSPACE_STACK_ID + if (inFreeformWindowingMode() && mContainingFrame.bottom > contentFrame.bottom) { // In freeform we want to move the top up directly. // TODO: Investigate why this is contentFrame not parentFrame. mContainingFrame.top -= mContainingFrame.bottom - contentFrame.bottom; - } else if (stackId != PINNED_STACK_ID + } else if (!inPinnedWindowingMode() && mContainingFrame.bottom > parentFrame.bottom) { // But in docked we want to behave like fullscreen and behave as if the task // were given smaller bounds for the purposes of layout. Skip adjustments for @@ -898,7 +894,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP // For pinned workspace the frame isn't limited in any particular // way since SystemUI controls the bounds. For freeform however // we want to keep things inside the content frame. - final Rect limitFrame = task.inPinnedWorkspace() ? mFrame : mContentFrame; + final Rect limitFrame = task.inPinnedWindowingMode() ? mFrame : mContentFrame; // Keep the frame out of the blocked system area, limit it in size to the content area // and make sure that there is always a minimum visible so that the user can drag it // into a usable area.. @@ -1662,9 +1658,9 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP // // Anyway we don't need to synchronize position and content updates for these // windows since they aren't at the base layer and could be moved around anyway. - if (!computeDragResizing() && mAttrs.type == TYPE_BASE_APPLICATION && - !mWinAnimator.isForceScaled() && !isGoneForLayoutLw() && - !getTask().inPinnedWorkspace()) { + if (!computeDragResizing() && mAttrs.type == TYPE_BASE_APPLICATION + && !mWinAnimator.isForceScaled() && !isGoneForLayoutLw() + && !getTask().inPinnedWindowingMode()) { setResizedWhileNotDragResizing(true); } } @@ -2196,12 +2192,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP } } - // TODO: Strange usage of word workspace here and above. - boolean inPinnedWorkspace() { - final Task task = getTask(); - return task != null && task.inPinnedWorkspace(); - } - void applyAdjustForImeIfNeeded() { final Task task = getTask(); if (task != null && task.mStack != null && task.mStack.isAdjustedForIme()) { @@ -2235,7 +2225,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP } else { getVisibleBounds(mTmpRect); } - if (inFreeformWorkspace()) { + if (inFreeformWindowingMode()) { // For freeform windows we the touch region to include the whole surface for the // shadows. final DisplayMetrics displayMetrics = getDisplayContent().getDisplayMetrics(); @@ -2938,8 +2928,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP return mTmpRect; } - @Override - public int getStackId() { + private int getStackId() { final TaskStack stack = getStack(); if (stack == null) { return INVALID_STACK_ID; @@ -2983,11 +2972,6 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP } } - boolean inFreeformWorkspace() { - final Task task = getTask(); - return task != null && task.inFreeformWorkspace(); - } - @Override public boolean isInMultiWindowMode() { final Task task = getTask(); @@ -3105,7 +3089,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP // background. return (getDisplayContent().mDividerControllerLocked.isResizing() || mAppToken != null && !mAppToken.mFrozenBounds.isEmpty()) && - !task.inFreeformWorkspace() && !isGoneForLayoutLw(); + !task.inFreeformWindowingMode() && !isGoneForLayoutLw(); } @@ -3756,7 +3740,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP windowInfo.accessibilityIdOfAnchor = mAttrs.accessibilityIdOfAnchor; windowInfo.focused = isFocused(); Task task = getTask(); - windowInfo.inPictureInPicture = (task != null) && task.inPinnedWorkspace(); + windowInfo.inPictureInPicture = (task != null) && task.inPinnedWindowingMode(); if (mIsChildWindow) { windowInfo.parentToken = getParentWindow().mClient.asBinder(); @@ -4219,7 +4203,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP // If a freeform window is animating from a position where it would be cutoff, it would be // cutoff during the animation. We don't want that, so for the duration of the animation // we ignore the decor cropping and depend on layering to position windows correctly. - final boolean cropToDecor = !(inFreeformWorkspace() && isAnimatingLw()); + final boolean cropToDecor = !(inFreeformWindowingMode() && isAnimatingLw()); if (cropToDecor) { // Intersect with the decor rect, offsetted by window position. systemDecorRect.intersect(decorRect.left - left, decorRect.top - top, @@ -4303,7 +4287,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP // scale for the animation using the source hint rect // (see WindowStateAnimator#setSurfaceBoundariesLocked()). if (isDragResizeChanged() || isResizedWhileNotDragResizing() - || (surfaceInsetsChanging() && !inPinnedWorkspace())) { + || (surfaceInsetsChanging() && !inPinnedWindowingMode())) { mLastSurfaceInsets.set(mAttrs.surfaceInsets); setDragResizing(); diff --git a/services/core/java/com/android/server/wm/WindowStateAnimator.java b/services/core/java/com/android/server/wm/WindowStateAnimator.java index 1b7e52788631..f5443210a172 100644 --- a/services/core/java/com/android/server/wm/WindowStateAnimator.java +++ b/services/core/java/com/android/server/wm/WindowStateAnimator.java @@ -1112,7 +1112,7 @@ class WindowStateAnimator { */ private boolean useFinalClipRect() { return (isAnimationSet() && resolveStackClip() == STACK_CLIP_AFTER_ANIM) - || mDestroyPreservedSurfaceUponRedraw || mWin.inPinnedWorkspace(); + || mDestroyPreservedSurfaceUponRedraw || mWin.inPinnedWindowingMode(); } /** @@ -1177,7 +1177,7 @@ class WindowStateAnimator { return false; } - if (w.inPinnedWorkspace()) { + if (w.inPinnedWindowingMode()) { return false; } diff --git a/services/tests/servicestests/src/com/android/server/am/ActivityStarterTests.java b/services/tests/servicestests/src/com/android/server/am/ActivityStarterTests.java index 855b82c233e0..e1623b075ef1 100644 --- a/services/tests/servicestests/src/com/android/server/am/ActivityStarterTests.java +++ b/services/tests/servicestests/src/com/android/server/am/ActivityStarterTests.java @@ -20,7 +20,6 @@ import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED; -import android.app.ActivityManager; import android.content.ComponentName; import android.graphics.Rect; import android.platform.test.annotations.Presubmit; @@ -83,7 +82,7 @@ public class ActivityStarterTests extends ActivityTestsBase { assertTrue(task2.getStack() instanceof PinnedActivityStack); mStarter.updateBounds(task2, bounds); - verify(mService, times(1)).resizeStack(eq(ActivityManager.StackId.PINNED_STACK_ID), + verify(mService, times(1)).resizeStack(eq(task2.getStack().mStackId), eq(bounds), anyBoolean(), anyBoolean(), anyBoolean(), anyInt()); // In the case of no animation, the stack and task bounds should be set immediately. @@ -94,4 +93,4 @@ public class ActivityStarterTests extends ActivityTestsBase { assertEquals(task2.mBounds, null); } } -}
\ No newline at end of file +} diff --git a/services/tests/servicestests/src/com/android/server/wm/TaskStackContainersTests.java b/services/tests/servicestests/src/com/android/server/wm/TaskStackContainersTests.java index 536a504ff572..71bcae7cd639 100644 --- a/services/tests/servicestests/src/com/android/server/wm/TaskStackContainersTests.java +++ b/services/tests/servicestests/src/com/android/server/wm/TaskStackContainersTests.java @@ -16,26 +16,23 @@ package com.android.server.wm; -import static android.app.ActivityManager.StackId.PINNED_STACK_ID; +import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD; +import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; -import android.content.res.Configuration; import org.junit.Test; import org.junit.runner.RunWith; import org.junit.Before; import org.junit.After; -import android.graphics.Rect; import android.platform.test.annotations.Presubmit; import android.support.test.filters.SmallTest; import android.support.test.runner.AndroidJUnit4; -import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - /** * Tests for the {@link DisplayContent.TaskStackContainers} container in {@link DisplayContent}. * @@ -52,12 +49,8 @@ public class TaskStackContainersTests extends WindowTestsBase { @Before public void setUp() throws Exception { super.setUp(); - final Configuration overrideConfig = new Configuration(); - overrideConfig.windowConfiguration.setWindowingMode(WINDOWING_MODE_PINNED); - mPinnedStack = new StackWindowController(PINNED_STACK_ID, null, - mDisplayContent.getDisplayId(), true /* onTop */, new Rect(), sWm).mContainer; - mPinnedStack.onOverrideConfigurationChanged(overrideConfig); - + mPinnedStack = createStackControllerOnStackOnDisplay( + WINDOWING_MODE_PINNED, ACTIVITY_TYPE_STANDARD, mDisplayContent).mContainer; // Stack should contain visible app window to be considered visible. final Task pinnedTask = createTaskInStack(mPinnedStack, 0 /* userId */); assertFalse(mPinnedStack.isVisible()); diff --git a/services/tests/servicestests/src/com/android/server/wm/WindowTestsBase.java b/services/tests/servicestests/src/com/android/server/wm/WindowTestsBase.java index 4e810f2c3973..56a3fb094280 100644 --- a/services/tests/servicestests/src/com/android/server/wm/WindowTestsBase.java +++ b/services/tests/servicestests/src/com/android/server/wm/WindowTestsBase.java @@ -36,8 +36,6 @@ import android.support.test.InstrumentationRegistry; import android.view.IWindow; import android.view.WindowManager; -import static android.app.ActivityManager.StackId.FIRST_DYNAMIC_STACK_ID; -import static android.app.ActivityManager.StackId.INVALID_STACK_ID; import static android.app.AppOpsManager.OP_NONE; import static android.view.DisplayAdjustments.DEFAULT_DISPLAY_ADJUSTMENTS; import static android.view.WindowManager.LayoutParams.FIRST_APPLICATION_WINDOW; @@ -70,7 +68,7 @@ class WindowTestsBase { // make sure we don't collide with any existing display. If we run into no other display, the // added display should be treated as default. This cannot be the default display private static int sNextDisplayId = DEFAULT_DISPLAY + 1; - private static int sNextStackId = FIRST_DYNAMIC_STACK_ID; + static int sNextStackId = 1000; private static boolean sOneTimeSetupDone = false; DisplayContent mDisplayContent; diff --git a/tests/permission/src/com/android/framework/permission/tests/WindowManagerPermissionTests.java b/tests/permission/src/com/android/framework/permission/tests/WindowManagerPermissionTests.java index 4aeae70ec979..9c4da1f72e38 100644 --- a/tests/permission/src/com/android/framework/permission/tests/WindowManagerPermissionTests.java +++ b/tests/permission/src/com/android/framework/permission/tests/WindowManagerPermissionTests.java @@ -24,7 +24,6 @@ import android.test.suitebuilder.annotation.SmallTest; import android.view.IWindowManager; import junit.framework.TestCase; -import static android.app.ActivityManager.StackId.INVALID_STACK_ID; import static android.view.Display.DEFAULT_DISPLAY; /** |