diff options
| -rw-r--r-- | api/test-current.txt | 4 | ||||
| -rw-r--r-- | core/java/android/app/ActivityTaskManager.java | 12 | ||||
| -rw-r--r-- | core/java/android/app/IActivityTaskManager.aidl | 3 | ||||
| -rw-r--r-- | services/core/java/com/android/server/wm/ActivityTaskManagerService.java | 22 |
4 files changed, 26 insertions, 15 deletions
diff --git a/api/test-current.txt b/api/test-current.txt index cee560b00abe..9472ce2569d3 100644 --- a/api/test-current.txt +++ b/api/test-current.txt @@ -118,8 +118,8 @@ package android.app { method @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS) public void resizePinnedStack(int, android.graphics.Rect, boolean); method @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS) public void resizeTask(int, android.graphics.Rect); method @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS) public void setDisplayToSingleTaskInstance(int); - method @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS) public void setTaskWindowingMode(int, int, boolean) throws java.lang.SecurityException; - method @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS) public void setTaskWindowingModeSplitScreenPrimary(int, int, boolean, boolean, android.graphics.Rect, boolean) throws java.lang.SecurityException; + method @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS) public boolean setTaskWindowingMode(int, int, boolean) throws java.lang.SecurityException; + method @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS) public boolean setTaskWindowingModeSplitScreenPrimary(int, int, boolean, boolean, android.graphics.Rect, boolean) throws java.lang.SecurityException; method @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS) public void startSystemLockTaskMode(int); method @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS) public void stopSystemLockTaskMode(); method public static boolean supportsMultiWindow(android.content.Context); diff --git a/core/java/android/app/ActivityTaskManager.java b/core/java/android/app/ActivityTaskManager.java index 58bff7f4dc04..9ba56cf40161 100644 --- a/core/java/android/app/ActivityTaskManager.java +++ b/core/java/android/app/ActivityTaskManager.java @@ -182,12 +182,13 @@ public class ActivityTaskManager { * @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. + * @return Whether the task was successfully put into the specified windowing mode. */ @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS) - public void setTaskWindowingMode(int taskId, int windowingMode, boolean toTop) + public boolean setTaskWindowingMode(int taskId, int windowingMode, boolean toTop) throws SecurityException { try { - getService().setTaskWindowingMode(taskId, windowingMode, toTop); + return getService().setTaskWindowingMode(taskId, windowingMode, toTop); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } @@ -208,13 +209,14 @@ public class ActivityTaskManager { * docked stack. Pass {@code null} to use default bounds. * @param showRecents If the recents activity should be shown on the other side of the task * going into split-screen mode. + * @return Whether the task was successfully put into splitscreen. */ @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS) - public void setTaskWindowingModeSplitScreenPrimary(int taskId, int createMode, boolean toTop, + public boolean setTaskWindowingModeSplitScreenPrimary(int taskId, int createMode, boolean toTop, boolean animate, Rect initialBounds, boolean showRecents) throws SecurityException { try { - getService().setTaskWindowingModeSplitScreenPrimary(taskId, createMode, toTop, animate, - initialBounds, showRecents); + return getService().setTaskWindowingModeSplitScreenPrimary(taskId, createMode, toTop, + animate, initialBounds, showRecents); } catch (RemoteException e) { throw e.rethrowFromSystemServer(); } diff --git a/core/java/android/app/IActivityTaskManager.aidl b/core/java/android/app/IActivityTaskManager.aidl index 503f5c56c617..be2f144c2fe8 100644 --- a/core/java/android/app/IActivityTaskManager.aidl +++ b/core/java/android/app/IActivityTaskManager.aidl @@ -231,8 +231,9 @@ interface IActivityTaskManager { * @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. + * @return Whether the task was successfully put into the specified windowing mode. */ - void setTaskWindowingMode(int taskId, int windowingMode, boolean toTop); + boolean setTaskWindowingMode(int taskId, int windowingMode, boolean toTop); void moveTaskToStack(int taskId, int stackId, boolean toTop); /** * Resizes the input pinned stack to the given bounds with animation. diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java index 5a5976bf58ad..5f3e3a39490c 100644 --- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java +++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java @@ -2247,11 +2247,11 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { } @Override - public void setTaskWindowingMode(int taskId, int windowingMode, boolean toTop) { + public boolean setTaskWindowingMode(int taskId, int windowingMode, boolean toTop) { if (windowingMode == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY) { - setTaskWindowingModeSplitScreenPrimary(taskId, SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT, + return setTaskWindowingModeSplitScreenPrimary(taskId, + SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT, toTop, ANIMATE, null /* initialBounds */, true /* showRecents */); - return; } enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS, "setTaskWindowingMode()"); synchronized (mGlobalLock) { @@ -2261,7 +2261,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { MATCH_TASK_IN_STACKS_ONLY); if (task == null) { Slog.w(TAG, "setTaskWindowingMode: No task for id=" + taskId); - return; + return false; } if (DEBUG_STACK) Slog.d(TAG_STACK, "setTaskWindowingMode: moving task=" + taskId @@ -2278,6 +2278,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { stack.moveToFront("setTaskWindowingMode", task); } stack.setWindowingMode(windowingMode); + return true; } finally { Binder.restoreCallingIdentity(ident); } @@ -2696,6 +2697,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { * stack. Pass {@code null} to use default bounds. * @param showRecents If the recents activity should be shown on the other side of the task * going into split-screen mode. + * @return Whether the task was successfully put into splitscreen. */ @Override public boolean setTaskWindowingModeSplitScreenPrimary(int taskId, int createMode, @@ -2705,20 +2707,26 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { synchronized (mGlobalLock) { final long ident = Binder.clearCallingIdentity(); try { + if (isInLockTaskMode()) { + Slog.w(TAG, "setTaskWindowingModeSplitScreenPrimary: Is in lock task mode=" + + getLockTaskModeState()); + return false; + } + final Task task = mRootWindowContainer.anyTaskForId(taskId, MATCH_TASK_IN_STACKS_ONLY); if (task == null) { Slog.w(TAG, "setTaskWindowingModeSplitScreenPrimary: No task for id=" + taskId); return false; } - if (DEBUG_STACK) Slog.d(TAG_STACK, - "setTaskWindowingModeSplitScreenPrimary: moving task=" + taskId - + " to createMode=" + createMode + " toTop=" + toTop); if (!task.isActivityTypeStandardOrUndefined()) { throw new IllegalArgumentException("setTaskWindowingMode: Attempt to move" + " non-standard task " + taskId + " to split-screen windowing mode"); } + if (DEBUG_STACK) Slog.d(TAG_STACK, + "setTaskWindowingModeSplitScreenPrimary: moving task=" + taskId + + " to createMode=" + createMode + " toTop=" + toTop); mWindowManager.setDockedStackCreateStateLocked(createMode, initialBounds); final int windowingMode = task.getWindowingMode(); final ActivityStack stack = task.getStack(); |