diff options
8 files changed, 12 insertions, 258 deletions
diff --git a/core/api/test-current.txt b/core/api/test-current.txt index 752f654d9b55..a38f9f4768d3 100644 --- a/core/api/test-current.txt +++ b/core/api/test-current.txt @@ -157,10 +157,7 @@ package android.app { method @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_TASKS) public void moveTaskToRootTask(int, int, boolean); method @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_TASKS) public void removeRootTasksInWindowingModes(@NonNull int[]); method @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_TASKS) public void removeRootTasksWithActivityTypes(@NonNull int[]); - method @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_TASKS) public void resizePrimarySplitScreen(@NonNull android.graphics.Rect, @NonNull android.graphics.Rect); method @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_TASKS) public void resizeTask(int, android.graphics.Rect); - method @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_TASKS) public boolean setTaskWindowingMode(int, int, boolean) throws java.lang.SecurityException; - method @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_TASKS) public boolean setTaskWindowingModeSplitScreenPrimary(int, boolean); method @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_TASKS) public void startSystemLockTaskMode(int); method @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_TASKS) 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 a24f8716b1cc..627017ce0893 100644 --- a/core/java/android/app/ActivityTaskManager.java +++ b/core/java/android/app/ActivityTaskManager.java @@ -16,8 +16,6 @@ package android.app; -import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY; - import android.annotation.NonNull; import android.annotation.Nullable; import android.annotation.RequiresPermission; @@ -169,35 +167,6 @@ public class ActivityTaskManager { }; /** - * 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. - * @return Whether the task was successfully put into the specified windowing mode. - */ - @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_TASKS) - public boolean setTaskWindowingMode(int taskId, int windowingMode, boolean toTop) - throws SecurityException { - try { - return getService().setTaskWindowingMode(taskId, windowingMode, toTop); - } catch (RemoteException e) { - throw e.rethrowFromSystemServer(); - } - } - - /** - * Moves the input task to the primary-split-screen stack. - * @param taskId Id of task to move. - * @param toTop If the task and stack should be moved to the top. - * @return Whether the task was successfully put into splitscreen. - */ - @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_TASKS) - public boolean setTaskWindowingModeSplitScreenPrimary(int taskId, boolean toTop) { - return setTaskWindowingMode(taskId, WINDOWING_MODE_SPLIT_SCREEN_PRIMARY, toTop); - } - - /** * Removes root tasks in the windowing modes from the system if they are of activity type * ACTIVITY_TYPE_STANDARD or ACTIVITY_TYPE_UNDEFINED */ @@ -367,20 +336,6 @@ public class ActivityTaskManager { } /** - * Resize docked stack & its task to given stack & task bounds. - * @param rootTaskBounds Bounds to resize stack. - * @param taskBounds Bounds to resize task. - */ - @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_TASKS) - public void resizePrimarySplitScreen(@NonNull Rect rootTaskBounds, @NonNull Rect taskBounds) { - try { - getService().resizePrimarySplitScreen(rootTaskBounds, taskBounds, null, null, null); - } catch (RemoteException e) { - throw e.rethrowFromSystemServer(); - } - } - - /** * Clears launch params for the given package. * @param packageNames the names of the packages of which the launch params are to be cleared */ diff --git a/core/java/android/app/IActivityTaskManager.aidl b/core/java/android/app/IActivityTaskManager.aidl index e5a969ac98ad..346882ee7298 100644 --- a/core/java/android/app/IActivityTaskManager.aidl +++ b/core/java/android/app/IActivityTaskManager.aidl @@ -87,8 +87,6 @@ import java.util.List; // surface exposed. // TODO(b/174041603): Create a builder interface for things like startActivityXXX(...) to reduce // interface duplication. -// TODO(b/174040691): Clean-up/remove all obsolete or unused interfaces like things that should be -// going through task organizer now. interface IActivityTaskManager { int startActivity(in IApplicationThread caller, in String callingPackage, in String callingFeatureId, in Intent intent, in String resolvedType, @@ -206,15 +204,6 @@ interface IActivityTaskManager { boolean resizeTask(int taskId, in Rect bounds, int resizeMode); void moveRootTaskToDisplay(int taskId, int displayId); - /** - * 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. - * @return Whether the task was successfully put into the specified windowing mode. - */ - boolean setTaskWindowingMode(int taskId, int windowingMode, boolean toTop); void moveTaskToRootTask(int taskId, int rootTaskId, boolean toTop); /** @@ -258,29 +247,6 @@ interface IActivityTaskManager { void suppressResizeConfigChanges(boolean suppress); - /** - * Resizes the docked stack, and all other stacks as the result of the dock stack bounds change. - * - * @param dockedBounds The bounds for the docked stack. - * @param tempDockedTaskBounds The temporary bounds for the tasks in the docked stack, which - * might be different from the stack bounds to allow more - * flexibility while resizing, or {@code null} if they should be the - * same as the stack bounds. - * @param tempDockedTaskInsetBounds The temporary bounds for the tasks to calculate the insets. - * When resizing, we usually "freeze" the layout of a task. To - * achieve that, we also need to "freeze" the insets, which - * gets achieved by changing task bounds but not bounds used - * to calculate the insets in this transient state - * @param tempOtherTaskBounds The temporary bounds for the tasks in all other stacks, or - * {@code null} if they should be the same as the stack bounds. - * @param tempOtherTaskInsetBounds Like {@code tempDockedTaskInsetBounds}, but for the other - * stacks. - * @throws RemoteException - */ - void resizePrimarySplitScreen(in Rect dockedBounds, in Rect tempDockedTaskBounds, - in Rect tempDockedTaskInsetBounds, - in Rect tempOtherTaskBounds, in Rect tempOtherTaskInsetBounds); - /** Returns an interface enabling the management of window organizers. */ IWindowOrganizerController getWindowOrganizerController(); diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/legacysplitscreen/LegacySplitScreenController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/legacysplitscreen/LegacySplitScreenController.java index d25bef197359..9eacaecc4f50 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/legacysplitscreen/LegacySplitScreenController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/legacysplitscreen/LegacySplitScreenController.java @@ -21,6 +21,7 @@ import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME; import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS; 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.content.res.Configuration.ORIENTATION_LANDSCAPE; import static android.view.Display.DEFAULT_DISPLAY; @@ -41,8 +42,6 @@ import android.window.TaskOrganizer; import android.window.WindowContainerToken; import android.window.WindowContainerTransaction; -import androidx.annotation.Nullable; - import com.android.internal.policy.DividerSnapAlgorithm; import com.android.wm.shell.R; import com.android.wm.shell.ShellTaskOrganizer; @@ -63,7 +62,6 @@ import java.lang.ref.WeakReference; import java.util.ArrayList; import java.util.List; import java.util.concurrent.CopyOnWriteArrayList; -import java.util.concurrent.TimeUnit; import java.util.function.BiConsumer; import java.util.function.Consumer; @@ -496,13 +494,15 @@ public class LegacySplitScreenController implements DisplayController.OnDisplays public boolean splitPrimaryTask() { try { - if (ActivityTaskManager.getService().getLockTaskModeState() == LOCK_TASK_MODE_PINNED - || isSplitActive()) { + if (ActivityTaskManager.getService().getLockTaskModeState() == LOCK_TASK_MODE_PINNED) { return false; } } catch (RemoteException e) { return false; } + if (isSplitActive() || mSplits.mPrimary == null) { + return false; + } // Try fetching the top running task. final List<RunningTaskInfo> runningTasks = @@ -523,8 +523,12 @@ public class LegacySplitScreenController implements DisplayController.OnDisplays return false; } - return ActivityTaskManager.getInstance().setTaskWindowingModeSplitScreenPrimary( - topRunningTask.taskId, true /* onTop */); + final WindowContainerTransaction wct = new WindowContainerTransaction(); + // Clear out current windowing mode before reparenting to split task. + wct.setWindowingMode(topRunningTask.token, WINDOWING_MODE_UNDEFINED); + wct.reparent(topRunningTask.token, mSplits.mPrimary.token, true /* onTop */); + mWindowManagerProxy.applySyncTransaction(wct); + return true; } public void dismissSplitToPrimaryTask() { diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java index 7ae42cc9396a..a0beee4afcb9 100644 --- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java +++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java @@ -35,9 +35,7 @@ import static android.app.ActivityManagerInternal.ALLOW_NON_FULL; import static android.app.ActivityTaskManager.INVALID_TASK_ID; import static android.app.ActivityTaskManager.RESIZE_MODE_PRESERVE_WINDOW; import static android.app.WindowConfiguration.ACTIVITY_TYPE_DREAM; -import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN; import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED; -import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED; import static android.content.Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS; import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK; import static android.content.pm.ActivityInfo.RESIZE_MODE_UNRESIZEABLE; @@ -114,7 +112,6 @@ import static com.android.server.wm.RecentsAnimationController.REORDER_MOVE_TO_O import static com.android.server.wm.RootWindowContainer.MATCH_ATTACHED_TASK_ONLY; import static com.android.server.wm.RootWindowContainer.MATCH_ATTACHED_TASK_OR_RECENT_TASKS; import static com.android.server.wm.Task.REPARENT_KEEP_ROOT_TASK_AT_FRONT; -import static com.android.server.wm.WindowContainer.POSITION_TOP; import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_NORMAL; import android.Manifest; @@ -147,7 +144,6 @@ import android.app.PictureInPictureParams; import android.app.ProfilerInfo; import android.app.RemoteAction; import android.app.WaitResult; -import android.app.WindowConfiguration; import android.app.admin.DevicePolicyCache; import android.app.assist.AssistContent; import android.app.assist.AssistStructure; @@ -227,7 +223,6 @@ import android.view.WindowManager; import android.window.IWindowOrganizerController; import android.window.SplashScreenView.SplashScreenViewParcelable; import android.window.TaskSnapshot; -import android.window.WindowContainerTransaction; import com.android.internal.R; import com.android.internal.annotations.VisibleForTesting; @@ -1897,57 +1892,6 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { return null; } - @Override - public boolean setTaskWindowingMode(int taskId, int windowingMode, boolean toTop) { - enforceTaskPermission("setTaskWindowingMode()"); - synchronized (mGlobalLock) { - final long ident = Binder.clearCallingIdentity(); - try { - if (isInLockTaskMode() && windowingMode != WINDOWING_MODE_FULLSCREEN) { - Slog.w(TAG, "setTaskWindowingMode: Is in lock task mode=" - + getLockTaskModeState()); - return false; - } - - if (WindowConfiguration.isSplitScreenWindowingMode(windowingMode)) { - return setTaskWindowingModeSplitScreen(taskId, windowingMode, toTop); - } - final Task task = mRootWindowContainer.anyTaskForId(taskId, - MATCH_ATTACHED_TASK_ONLY); - if (task == null) { - Slog.w(TAG, "setTaskWindowingMode: No task for id=" + taskId); - return false; - } - - ProtoLog.d(WM_DEBUG_TASKS, "setTaskWindowingMode: moving task=%d " - + "to windowingMode=%d toTop=%b", taskId, windowingMode, toTop); - - if (!task.isActivityTypeStandardOrUndefined()) { - throw new IllegalArgumentException("setTaskWindowingMode: Attempt to move" - + " non-standard task " + taskId + " to windowing mode=" - + windowingMode); - } - - final Task rootTask = task.getRootTask(); - if (toTop) { - rootTask.moveToFront("setTaskWindowingMode", task); - } - // Convert some windowing-mode changes into root-task reparents for split-screen. - if (rootTask.inSplitScreenWindowingMode()) { - rootTask.getDisplayArea().onSplitScreenModeDismissed(); - - } else { - rootTask.setWindowingMode(windowingMode); - rootTask.mDisplayContent.ensureActivitiesVisible(null, 0, PRESERVE_WINDOWS, - true /* notifyClients */); - } - return true; - } finally { - Binder.restoreCallingIdentity(ident); - } - } - } - /** * Sets the locusId for a particular activity. * @@ -2225,59 +2169,6 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { } /** - * Moves the specified task into a split-screen tile. - */ - private boolean setTaskWindowingModeSplitScreen(int taskId, int windowingMode, boolean toTop) { - if (!WindowConfiguration.isSplitScreenWindowingMode(windowingMode)) { - throw new IllegalArgumentException("Calling setTaskWindowingModeSplitScreen with non" - + "split-screen mode: " + windowingMode); - } - - final Task task = mRootWindowContainer.anyTaskForId(taskId, - MATCH_ATTACHED_TASK_ONLY); - if (task == null) { - Slog.w(TAG, "setTaskWindowingModeSplitScreenPrimary: No task for id=" + taskId); - return false; - } - if (!task.isActivityTypeStandardOrUndefined()) { - throw new IllegalArgumentException("setTaskWindowingMode: Attempt to move" - + " non-standard task " + taskId + " to split-screen windowing mode"); - } - if (!task.supportsSplitScreenWindowingMode()) { - return false; - } - - final int prevMode = task.getWindowingMode(); - if (prevMode == windowingMode) { - // The task is already in split-screen and with correct windowing mode. - return true; - } - - moveTaskToSplitScreenPrimaryTask(task, toTop); - return prevMode != task.getWindowingMode(); - } - - void moveTaskToSplitScreenPrimaryTask(Task task, boolean toTop) { - final TaskDisplayArea taskDisplayArea = task.getDisplayArea(); - final Task primarySplitTask = taskDisplayArea.getRootSplitScreenPrimaryTask(); - if (primarySplitTask == null) { - throw new IllegalStateException("Can't enter split without associated organized task"); - } - - if (toTop) { - taskDisplayArea.positionChildAt(POSITION_TOP, primarySplitTask, - false /* includingParents */); - } - WindowContainerTransaction wct = new WindowContainerTransaction(); - // Clear out current windowing mode before reparenting to split taks. - wct.setWindowingMode( - task.getRootTask().mRemoteToken.toWindowContainerToken(), WINDOWING_MODE_UNDEFINED); - wct.reparent(task.getRootTask().mRemoteToken.toWindowContainerToken(), - primarySplitTask.mRemoteToken.toWindowContainerToken(), toTop); - mWindowOrganizerController.applyTransaction(wct); - } - - /** * Removes root tasks in the input windowing modes from the system if they are of activity type * ACTIVITY_TYPE_STANDARD or ACTIVITY_TYPE_UNDEFINED */ @@ -3400,47 +3291,6 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { return true; } - // TODO(b/149338177): remove when CTS no-longer requires it - @Override - public void resizePrimarySplitScreen(Rect dockedBounds, Rect tempDockedTaskBounds, - Rect tempDockedTaskInsetBounds, - Rect tempOtherTaskBounds, Rect tempOtherTaskInsetBounds) { - enforceTaskPermission("resizePrimarySplitScreen()"); - final long ident = Binder.clearCallingIdentity(); - try { - synchronized (mGlobalLock) { - final TaskDisplayArea tc = mRootWindowContainer.getDefaultTaskDisplayArea(); - final Task primary = tc.getRootSplitScreenPrimaryTask(); - final Task secondary = tc.getTask(t -> t.mCreatedByOrganizer && t.isRootTask() - && t.inSplitScreenSecondaryWindowingMode()); - if (primary == null || secondary == null) { - return; - } - final WindowContainerTransaction wct = new WindowContainerTransaction(); - final Rect primaryRect = - tempDockedTaskInsetBounds != null ? tempDockedTaskInsetBounds - : (tempDockedTaskBounds != null ? tempDockedTaskBounds - : dockedBounds); - wct.setBounds(primary.mRemoteToken.toWindowContainerToken(), primaryRect); - Rect otherRect = tempOtherTaskInsetBounds != null ? tempOtherTaskInsetBounds - : tempOtherTaskBounds; - if (otherRect == null) { - // Temporary estimation... again this is just for tests. - otherRect = new Rect(secondary.getBounds()); - if (tc.getBounds().width() > tc.getBounds().height()) { - otherRect.left = primaryRect.right + 6; - } else { - otherRect.top = primaryRect.bottom + 6; - } - } - wct.setBounds(secondary.mRemoteToken.toWindowContainerToken(), otherRect); - mWindowOrganizerController.applyTransaction(wct); - } - } finally { - Binder.restoreCallingIdentity(ident); - } - } - @Override public void setSplitScreenResizing(boolean resizing) { enforceTaskPermission("setSplitScreenResizing()"); diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java index f149603143ed..86904991616f 100644 --- a/services/core/java/com/android/server/wm/Task.java +++ b/services/core/java/com/android/server/wm/Task.java @@ -5405,16 +5405,6 @@ class Task extends WindowContainer<WindowContainer> { // Nothing else to do if we don't have a window container yet. E.g. call from ctor. return; } - - if (windowingMode == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY && alreadyInSplitScreenMode) { - // We already have a root split-screen task in this display, so just move the - // tasks over. - // TODO: Figure-out how to do all the stuff in - // AMS.setTaskWindowingModeSplitScreenPrimary - throw new IllegalArgumentException("Setting primary split-screen windowing mode" - + " while there is already one isn't currently supported"); - //return; - } } finally { mAtmService.continueWindowLayout(); } diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java index 20bd3df6bc3f..ee9c8ffb8a39 100644 --- a/services/core/java/com/android/server/wm/WindowState.java +++ b/services/core/java/com/android/server/wm/WindowState.java @@ -452,10 +452,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP /** The frames used to compute a temporal layout appearance. */ private WindowFrames mSimulatedWindowFrames; - /** - * Usually empty. Set to the task's tempInsetFrame. See - *{@link android.app.IActivityTaskManager#resizePrimarySplitScreen}. - */ + /** Usually the same as {@link #getBounds()}. */ private final Rect mInsetFrame = new Rect(); /** diff --git a/services/tests/wmtests/src/com/android/server/wm/RecentTasksTest.java b/services/tests/wmtests/src/com/android/server/wm/RecentTasksTest.java index 8b812a93d091..5d6a5c0b5167 100644 --- a/services/tests/wmtests/src/com/android/server/wm/RecentTasksTest.java +++ b/services/tests/wmtests/src/com/android/server/wm/RecentTasksTest.java @@ -1032,9 +1032,6 @@ public class RecentTasksTest extends WindowTestsBase { assertNotRestoreTask(() -> mAtm.cancelTaskWindowTransition(taskId)); assertNotRestoreTask( () -> mAtm.resizeTask(taskId, null /* bounds */, 0 /* resizeMode */)); - assertNotRestoreTask( - () -> mAtm.setTaskWindowingMode(taskId, WINDOWING_MODE_FULLSCREEN, - false/* toTop */)); } @Test @@ -1199,8 +1196,6 @@ public class RecentTasksTest extends WindowTestsBase { new int[]{ACTIVITY_TYPE_UNDEFINED})); assertSecurityException(expectCallable, () -> mAtm.removeTask(0)); assertSecurityException(expectCallable, - () -> mAtm.setTaskWindowingMode(0, WINDOWING_MODE_UNDEFINED, true)); - assertSecurityException(expectCallable, () -> mAtm.moveTaskToRootTask(0, INVALID_STACK_ID, true)); assertSecurityException(expectCallable, () -> mAtm.getAllRootTaskInfos()); assertSecurityException(expectCallable, |