Merge "Remove obsolete test APIs of split screen" into sc-dev

This commit is contained in:
Riddle Hsu
2021-04-13 02:20:37 +00:00
committed by Android (Google) Code Review
8 changed files with 12 additions and 258 deletions

View File

@@ -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);

View File

@@ -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;
@@ -168,35 +166,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
@@ -366,20 +335,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

View File

@@ -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();

View File

@@ -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() {

View File

@@ -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.
*
@@ -2224,59 +2168,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()");

View File

@@ -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();
}

View File

@@ -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();
/**

View File

@@ -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
@@ -1198,8 +1195,6 @@ public class RecentTasksTest extends WindowTestsBase {
() -> mAtm.removeRootTasksWithActivityTypes(
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());