diff options
| author | 2017-10-07 17:09:03 +0000 | |
|---|---|---|
| committer | 2017-10-07 17:09:03 +0000 | |
| commit | 41afbd363e435e9c9774a5a93b2472f9246bb1e6 (patch) | |
| tree | cf79e1a92811c9b58d05e1f1e895ce87a0961a79 | |
| parent | 86a36a6c6f78f2dee3f13f2d7456ac55d4bfd39b (diff) | |
| parent | 388945c01d4e00701e0157c96390eeac4b307b8a (diff) | |
Merge "Changed to allow removal of remaining static stack ids from CTS."
6 files changed, 130 insertions, 40 deletions
diff --git a/api/test-current.txt b/api/test-current.txt index 38b15b418a4a..f10e3d679e08 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -3866,7 +3866,9 @@ package android.app { method public void removeOnUidImportanceListener(android.app.ActivityManager.OnUidImportanceListener); method public void removeStacksInWindowingModes(int[]) throws java.lang.SecurityException; method public void removeStacksWithActivityTypes(int[]) throws java.lang.SecurityException; + method public void resizeStack(int, android.graphics.Rect) throws java.lang.SecurityException; method public deprecated void restartPackage(java.lang.String); + method public void setTaskWindowingMode(int, int, boolean) throws java.lang.SecurityException; method public static void setVrThread(int); method public void setWatchHeapLimit(long); method public static boolean supportsMultiWindow(android.content.Context); @@ -4019,11 +4021,7 @@ package android.app { } public static class ActivityManager.StackId { - field public static final int DOCKED_STACK_ID = 3; // 0x3 - field public static final int FREEFORM_WORKSPACE_STACK_ID = 2; // 0x2 - field public static final int FULLSCREEN_WORKSPACE_STACK_ID = 1; // 0x1 field public static final int INVALID_STACK_ID = -1; // 0xffffffff - field public static final int PINNED_STACK_ID = 4; // 0x4 } public static class ActivityManager.TaskDescription implements android.os.Parcelable { diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java index 26f96fbeede1..ecb346b03f56 100644 --- a/core/java/android/app/ActivityManager.java +++ b/core/java/android/app/ActivityManager.java @@ -674,16 +674,20 @@ public class ActivityManager { * @hide */ private static final int FIRST_STATIC_STACK_ID = 0; - /** ID of stack where fullscreen activities are normally launched into. */ + /** 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. */ + /** 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. */ + /** 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. */ + /** 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. @@ -2025,12 +2029,49 @@ public class ActivityManager { } /** + * Sets the windowing mode for a specific task. Only works on tasks of type + * {@link WindowConfiguration#ACTIVITY_TYPE_STANDARD} + * @param taskId The id of the task to set the windowing mode for. + * @param windowingMode The windowing mode to set for the task. + * @param toTop If the task should be moved to the top once the windowing mode changes. + * @hide + */ + @TestApi + @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS) + public void setTaskWindowingMode(int taskId, int windowingMode, boolean toTop) + throws SecurityException { + try { + getService().setTaskWindowingMode(taskId, windowingMode, toTop); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + + /** + * Resizes the input stack id to the given bounds. + * @param stackId Id of the stack to resize. + * @param bounds Bounds to resize the stack to or {@code null} for fullscreen. + * @hide + */ + @TestApi + @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS) + public void resizeStack(int stackId, Rect bounds) throws SecurityException { + try { + getService().resizeStack(stackId, bounds, false /* allowResizeInDockedMode */, + false /* preserveWindows */, false /* animate */, -1 /* animationDuration */); + } catch (RemoteException e) { + throw e.rethrowFromSystemServer(); + } + } + + /** * Removes stacks in the windowing modes from the system if they are of activity type * ACTIVITY_TYPE_STANDARD or ACTIVITY_TYPE_UNDEFINED * * @hide */ @TestApi + @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS) public void removeStacksInWindowingModes(int[] windowingModes) throws SecurityException { try { getService().removeStacksInWindowingModes(windowingModes); @@ -2045,6 +2086,7 @@ public class ActivityManager { * @hide */ @TestApi + @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS) public void removeStacksWithActivityTypes(int[] activityTypes) throws SecurityException { try { getService().removeStacksWithActivityTypes(activityTypes); diff --git a/core/java/android/app/IActivityManager.aidl b/core/java/android/app/IActivityManager.aidl index 955b46300ea0..c042e71747f5 100644 --- a/core/java/android/app/IActivityManager.aidl +++ b/core/java/android/app/IActivityManager.aidl @@ -361,6 +361,15 @@ interface IActivityManager { void killUid(int appId, int userId, in String reason); void setUserIsMonkey(boolean monkey); void hang(in IBinder who, boolean allowRestart); + + /** + * Sets the windowing mode for a specific task. Only works on tasks of type + * {@link WindowConfiguration#ACTIVITY_TYPE_STANDARD} + * @param taskId The id of the task to set the windowing mode for. + * @param windowingMode The windowing mode to set for the task. + * @param toTop If the task should be moved to the top once the windowing mode changes. + */ + void setTaskWindowingMode(int taskId, int windowingMode, boolean toTop); void moveTaskToStack(int taskId, int stackId, boolean toTop); /** * Resizes the input stack id to the given bounds. diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java index 5160474f091a..3043c7f8889f 100644 --- a/services/core/java/com/android/server/am/ActivityManagerService.java +++ b/services/core/java/com/android/server/am/ActivityManagerService.java @@ -38,6 +38,7 @@ 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; +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.content.pm.PackageManager.FEATURE_ACTIVITIES_ON_SECONDARY_DISPLAYS; @@ -3243,7 +3244,8 @@ public class ActivityManagerService extends IActivityManager.Stub if (r.requestedVrComponent != null && r.getStackId() >= FIRST_DYNAMIC_STACK_ID) { Slog.i(TAG, "Moving " + r.shortComponentName + " from stack " + r.getStackId() + " to main stack for VR"); - moveTaskToStack(r.getTask().taskId, FULLSCREEN_WORKSPACE_STACK_ID, true /* toTop */); + setTaskWindowingMode(r.getTask().taskId, + WINDOWING_MODE_FULLSCREEN_OR_SPLIT_SCREEN_SECONDARY, true /* toTop */); } mHandler.sendMessage( mHandler.obtainMessage(VR_MODE_CHANGE_MSG, 0, 0, r)); @@ -10625,6 +10627,42 @@ public class ActivityManagerService extends IActivityManager.Stub } @Override + public void setTaskWindowingMode(int taskId, int windowingMode, boolean toTop) { + enforceCallingPermission(MANAGE_ACTIVITY_STACKS, "setTaskWindowingMode()"); + synchronized (this) { + final long ident = Binder.clearCallingIdentity(); + try { + final TaskRecord task = mStackSupervisor.anyTaskForIdLocked(taskId); + if (task == null) { + Slog.w(TAG, "setTaskWindowingMode: No task for id=" + taskId); + return; + } + + if (DEBUG_STACK) Slog.d(TAG_STACK, "setTaskWindowingMode: moving task=" + taskId + + " to windowingMode=" + windowingMode + " toTop=" + toTop); + if (windowingMode == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY) { + mWindowManager.setDockedStackCreateState(DOCKED_STACK_CREATE_MODE_TOP_OR_LEFT, + null /* initialBounds */); + } + + if (!task.isActivityTypeStandardOrUndefined()) { + throw new IllegalArgumentException("setTaskWindowingMode: Attempt to move task " + + taskId + " to non-standard windowin mode=" + windowingMode); + } + final ActivityDisplay display = task.getStack().getDisplay(); + final ActivityStack stack = display.getOrCreateStack(windowingMode, + task.getStack().getActivityType(), toTop); + // TODO: We should just change the windowing mode for the task vs. creating and + // moving it to a stack. + task.reparent(stack, toTop, REPARENT_KEEP_STACK_AT_FRONT, ANIMATE, !DEFER_RESUME, + "moveTaskToStack"); + } finally { + Binder.restoreCallingIdentity(ident); + } + } + } + + @Override public void moveTaskToStack(int taskId, int stackId, boolean toTop) { enforceCallingPermission(MANAGE_ACTIVITY_STACKS, "moveTaskToStack()"); synchronized (this) { diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java index 34eaab234381..7cdaf9e034a3 100644 --- a/services/core/java/com/android/server/am/ActivityStack.java +++ b/services/core/java/com/android/server/am/ActivityStack.java @@ -5089,7 +5089,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai if (isAttached()) { getDisplay().positionChildAtBottom(this); } - if (!isHomeOrRecentsStack()) { + if (!isActivityTypeHome()) { remove(); } } diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java index 42f3550da8b9..9d329c229c6d 100644 --- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java +++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java @@ -2625,38 +2625,41 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D // the picture-in-picture mode. final boolean schedulePictureInPictureModeChange = inPinnedWindowingMode; final ArrayList<TaskRecord> tasks = fromStack.getAllTasks(); - final int size = tasks.size(); - final ActivityStack fullscreenStack = toDisplay.getOrCreateStack( - WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, onTop); - if (onTop) { - final int returnToType = - toDisplay.getTopVisibleStackActivityType(WINDOWING_MODE_PINNED); - for (int i = 0; i < size; i++) { - final TaskRecord task = tasks.get(i); - final boolean isTopTask = i == (size - 1); - if (inPinnedWindowingMode) { - // Update the return-to to reflect where the pinned stack task was moved - // from so that we retain the stack that was previously visible if the - // pinned stack is recreated. See moveActivityToPinnedStackLocked(). - task.setTaskToReturnTo(returnToType); + if (!tasks.isEmpty()) { + final int size = tasks.size(); + final ActivityStack fullscreenStack = toDisplay.getOrCreateStack( + WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, onTop); + + if (onTop) { + final int returnToType = + toDisplay.getTopVisibleStackActivityType(WINDOWING_MODE_PINNED); + for (int i = 0; i < size; i++) { + final TaskRecord task = tasks.get(i); + final boolean isTopTask = i == (size - 1); + if (inPinnedWindowingMode) { + // Update the return-to to reflect where the pinned stack task was moved + // from so that we retain the stack that was previously visible if the + // pinned stack is recreated. See moveActivityToPinnedStackLocked(). + task.setTaskToReturnTo(returnToType); + } + // Defer resume until all the tasks have been moved to the fullscreen stack + task.reparent(fullscreenStack, ON_TOP, REPARENT_MOVE_STACK_TO_FRONT, + isTopTask /* animate */, DEFER_RESUME, + schedulePictureInPictureModeChange, + "moveTasksToFullscreenStack - onTop"); + } + } else { + for (int i = 0; i < size; i++) { + final TaskRecord task = tasks.get(i); + // Position the tasks in the fullscreen stack in order at the bottom of the + // stack. Also defer resume until all the tasks have been moved to the + // fullscreen stack. + task.reparent(fullscreenStack, i /* position */, + REPARENT_LEAVE_STACK_IN_PLACE, !ANIMATE, DEFER_RESUME, + schedulePictureInPictureModeChange, + "moveTasksToFullscreenStack - NOT_onTop"); } - // Defer resume until all the tasks have been moved to the fullscreen stack - task.reparent(fullscreenStack, ON_TOP, REPARENT_MOVE_STACK_TO_FRONT, - isTopTask /* animate */, DEFER_RESUME, - schedulePictureInPictureModeChange, - "moveTasksToFullscreenStack - onTop"); - } - } else { - for (int i = 0; i < size; i++) { - final TaskRecord task = tasks.get(i); - // Position the tasks in the fullscreen stack in order at the bottom of the - // stack. Also defer resume until all the tasks have been moved to the - // fullscreen stack. - task.reparent(fullscreenStack, i /* position */, - REPARENT_LEAVE_STACK_IN_PLACE, !ANIMATE, DEFER_RESUME, - schedulePictureInPictureModeChange, - "moveTasksToFullscreenStack - NOT_onTop"); } } |