Trigger transition in ATMS#resizeTask
This CL changes ATMS#resizeTask to trigger a transition if ShellTransition is enabled.
Also, this CL drops the returning value of the method as no one is using it now.
Bug: 263185856
Bug: 262631137
Test: adb shell am task resize $TASK_ID $x $y $width $height
Test: atest CrossAppDragAndDropTests#testDisallowGlobal
Test: atest CrossAppDragAndDropTests#testOnReceiveContentListener_EditText_GrantRead
Change-Id: I5b32166ceff00dadf7872e8f04564ebfaf8e9a98
diff --git a/core/java/android/app/IActivityTaskManager.aidl b/core/java/android/app/IActivityTaskManager.aidl
index f20503c..461aa3c 100644
--- a/core/java/android/app/IActivityTaskManager.aidl
+++ b/core/java/android/app/IActivityTaskManager.aidl
@@ -198,9 +198,8 @@
* @param taskId The id of the task to set the bounds for.
* @param bounds The new bounds.
* @param resizeMode Resize mode defined as {@code ActivityTaskManager#RESIZE_MODE_*} constants.
- * @return Return true on success. Otherwise false.
*/
- boolean resizeTask(int taskId, in Rect bounds, int resizeMode);
+ void resizeTask(int taskId, in Rect bounds, int resizeMode);
void moveRootTaskToDisplay(int taskId, int displayId);
void moveTaskToRootTask(int taskId, int rootTaskId, boolean toTop);
diff --git a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
index 1180df7..f4d76c2 100644
--- a/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
+++ b/services/core/java/com/android/server/wm/ActivityTaskManagerService.java
@@ -65,6 +65,7 @@
import static android.provider.Settings.System.FONT_SCALE;
import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.Display.INVALID_DISPLAY;
+import static android.view.WindowManager.TRANSIT_CHANGE;
import static android.view.WindowManager.TRANSIT_PIP;
import static android.view.WindowManagerPolicyConstants.KEYGUARD_GOING_AWAY_FLAG_TO_LAUNCHER_CLEAR_SNAPSHOT;
@@ -2843,7 +2844,7 @@
}
@Override
- public boolean resizeTask(int taskId, Rect bounds, int resizeMode) {
+ public void resizeTask(int taskId, Rect bounds, int resizeMode) {
enforceTaskPermission("resizeTask()");
final long ident = Binder.clearCallingIdentity();
try {
@@ -2852,19 +2853,48 @@
MATCH_ATTACHED_TASK_ONLY);
if (task == null) {
Slog.w(TAG, "resizeTask: taskId=" + taskId + " not found");
- return false;
+ return;
}
if (!task.getWindowConfiguration().canResizeTask()) {
Slog.w(TAG, "resizeTask not allowed on task=" + task);
- return false;
+ return;
}
// Reparent the task to the right root task if necessary
boolean preserveWindow = (resizeMode & RESIZE_MODE_PRESERVE_WINDOW) != 0;
- // After reparenting (which only resizes the task to the root task bounds),
- // resize the task to the actual bounds provided
- return task.resize(bounds, resizeMode, preserveWindow);
+ if (!getTransitionController().isShellTransitionsEnabled()) {
+ // After reparenting (which only resizes the task to the root task bounds),
+ // resize the task to the actual bounds provided
+ task.resize(bounds, resizeMode, preserveWindow);
+ return;
+ }
+
+ final Transition transition = new Transition(TRANSIT_CHANGE, 0 /* flags */,
+ getTransitionController(), mWindowManager.mSyncEngine);
+ if (mWindowManager.mSyncEngine.hasActiveSync()) {
+ mWindowManager.mSyncEngine.queueSyncSet(
+ () -> getTransitionController().moveToCollecting(transition),
+ () -> {
+ if (!task.getWindowConfiguration().canResizeTask()) {
+ Slog.w(TAG, "resizeTask not allowed on task=" + task);
+ transition.abort();
+ return;
+ }
+ getTransitionController().requestStartTransition(transition, task,
+ null /* remoteTransition */, null /* displayChange */);
+ getTransitionController().collect(task);
+ task.resize(bounds, resizeMode, preserveWindow);
+ transition.setReady(task, true);
+ });
+ } else {
+ getTransitionController().moveToCollecting(transition);
+ getTransitionController().requestStartTransition(transition, task,
+ null /* remoteTransition */, null /* displayChange */);
+ getTransitionController().collect(task);
+ task.resize(bounds, resizeMode, preserveWindow);
+ transition.setReady(task, true);
+ }
}
} finally {
Binder.restoreCallingIdentity(ident);