Merge "Fix issue with wrong mode when adding appeared task" into tm-dev

This commit is contained in:
Vinit Nayak
2022-03-28 18:42:59 +00:00
committed by Android (Google) Code Review

View File

@@ -97,6 +97,9 @@ public class RecentsAnimationController implements DeathRecipient {
*/ */
private static final long LATENCY_TRACKER_LOG_DELAY_MS = 300; private static final long LATENCY_TRACKER_LOG_DELAY_MS = 300;
// Constant for a yet-to-be-calculated {@link RemoteAnimationTarget#Mode} state
private static final int MODE_UNKNOWN = -1;
public static final int REORDER_KEEP_IN_PLACE = 0; public static final int REORDER_KEEP_IN_PLACE = 0;
public static final int REORDER_MOVE_TO_TOP = 1; public static final int REORDER_MOVE_TO_TOP = 1;
public static final int REORDER_MOVE_TO_ORIGINAL_POSITION = 2; public static final int REORDER_MOVE_TO_ORIGINAL_POSITION = 2;
@@ -704,7 +707,8 @@ public class RecentsAnimationController implements DeathRecipient {
if (isAnimatingTask(task) || skipAnimation(task)) { if (isAnimatingTask(task) || skipAnimation(task)) {
return; return;
} }
final RemoteAnimationTarget target = createTaskRemoteAnimation(task, finishedCallback); final RemoteAnimationTarget target = createTaskRemoteAnimation(task, MODE_OPENING,
finishedCallback);
if (target == null) { if (target == null) {
return; return;
} }
@@ -725,7 +729,7 @@ public class RecentsAnimationController implements DeathRecipient {
} }
} }
private RemoteAnimationTarget createTaskRemoteAnimation(Task task, private RemoteAnimationTarget createTaskRemoteAnimation(Task task, int mode,
OnAnimationFinishedCallback finishedCallback) { OnAnimationFinishedCallback finishedCallback) {
final SparseBooleanArray recentTaskIds = final SparseBooleanArray recentTaskIds =
mService.mAtmService.getRecentTasks().getRecentTaskIds(); mService.mAtmService.getRecentTasks().getRecentTaskIds();
@@ -737,7 +741,7 @@ public class RecentsAnimationController implements DeathRecipient {
TaskAnimationAdapter adapter = addAnimation(task, TaskAnimationAdapter adapter = addAnimation(task,
!recentTaskIds.get(taskId), true /* hidden */, finishedCallback); !recentTaskIds.get(taskId), true /* hidden */, finishedCallback);
mPendingNewTaskTargets.add(taskId); mPendingNewTaskTargets.add(taskId);
return adapter.createRemoteAnimationTarget(taskId); return adapter.createRemoteAnimationTarget(taskId, mode);
} }
void logRecentsAnimationStartTime(int durationMs) { void logRecentsAnimationStartTime(int durationMs) {
@@ -773,7 +777,7 @@ public class RecentsAnimationController implements DeathRecipient {
for (int i = mPendingAnimations.size() - 1; i >= 0; i--) { for (int i = mPendingAnimations.size() - 1; i >= 0; i--) {
final TaskAnimationAdapter taskAdapter = mPendingAnimations.get(i); final TaskAnimationAdapter taskAdapter = mPendingAnimations.get(i);
final RemoteAnimationTarget target = final RemoteAnimationTarget target =
taskAdapter.createRemoteAnimationTarget(INVALID_TASK_ID); taskAdapter.createRemoteAnimationTarget(INVALID_TASK_ID, MODE_UNKNOWN);
if (target != null) { if (target != null) {
targets.add(target); targets.add(target);
} else { } else {
@@ -1196,8 +1200,11 @@ public class RecentsAnimationController implements DeathRecipient {
* some cases where we are animating root tasks but need need leaf * some cases where we are animating root tasks but need need leaf
* ids for identification. If this is INVALID (-1), then mTaskId * ids for identification. If this is INVALID (-1), then mTaskId
* will be used. * will be used.
* @param overrideMode overrides the target's mode. If this is -1, the mode will be
* calculated relative to going to the target activity (ie. OPENING if
* this is the target task, CLOSING otherwise).
*/ */
RemoteAnimationTarget createRemoteAnimationTarget(int overrideTaskId) { RemoteAnimationTarget createRemoteAnimationTarget(int overrideTaskId, int overrideMode) {
final ActivityRecord topApp = mTask.getTopVisibleActivity(); final ActivityRecord topApp = mTask.getTopVisibleActivity();
final WindowState mainWindow = topApp != null final WindowState mainWindow = topApp != null
? topApp.findMainWindow() ? topApp.findMainWindow()
@@ -1208,7 +1215,9 @@ public class RecentsAnimationController implements DeathRecipient {
final Rect insets = mainWindow.getInsetsStateWithVisibilityOverride().calculateInsets( final Rect insets = mainWindow.getInsetsStateWithVisibilityOverride().calculateInsets(
mBounds, Type.systemBars(), false /* ignoreVisibility */).toRect(); mBounds, Type.systemBars(), false /* ignoreVisibility */).toRect();
InsetUtils.addInsets(insets, mainWindow.mActivityRecord.getLetterboxInsets()); InsetUtils.addInsets(insets, mainWindow.mActivityRecord.getLetterboxInsets());
final int mode = topApp.getActivityType() == mTargetActivityType final int mode = overrideMode != MODE_UNKNOWN
? overrideMode
: topApp.getActivityType() == mTargetActivityType
? MODE_OPENING ? MODE_OPENING
: MODE_CLOSING; : MODE_CLOSING;
if (overrideTaskId < 0) { if (overrideTaskId < 0) {