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
This commit is contained in:
Toshiki Kikuchi
2022-12-20 17:00:59 +09:00
parent 7eb3a2db73
commit a936bec5b9
2 changed files with 37 additions and 8 deletions

View File

@@ -198,9 +198,8 @@ interface IActivityTaskManager {
* @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);

View File

@@ -65,6 +65,7 @@ import static android.provider.Settings.Global.HIDE_ERROR_DIALOGS;
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 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
}
@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 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
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);