Fix issue with wrong mode when adding appeared task

- Currently the mode is calculated relative to whether the
  task being animated is the target task or not

Bug: 209694087
Test: Quickswitch and verify new task is MODE_OPENING
Change-Id: Ic22a2ef68dc0d48849d6c89344d24967ded4cf76
This commit is contained in:
Winson Chung
2021-12-14 00:29:56 +00:00
committed by Vinit Nayak
parent fe4b81853e
commit 0b9892e12b

View File

@@ -97,6 +97,9 @@ public class RecentsAnimationController implements DeathRecipient {
*/
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_MOVE_TO_TOP = 1;
public static final int REORDER_MOVE_TO_ORIGINAL_POSITION = 2;
@@ -704,7 +707,8 @@ public class RecentsAnimationController implements DeathRecipient {
if (isAnimatingTask(task) || skipAnimation(task)) {
return;
}
final RemoteAnimationTarget target = createTaskRemoteAnimation(task, finishedCallback);
final RemoteAnimationTarget target = createTaskRemoteAnimation(task, MODE_OPENING,
finishedCallback);
if (target == null) {
return;
}
@@ -725,7 +729,7 @@ public class RecentsAnimationController implements DeathRecipient {
}
}
private RemoteAnimationTarget createTaskRemoteAnimation(Task task,
private RemoteAnimationTarget createTaskRemoteAnimation(Task task, int mode,
OnAnimationFinishedCallback finishedCallback) {
final SparseBooleanArray recentTaskIds =
mService.mAtmService.getRecentTasks().getRecentTaskIds();
@@ -737,7 +741,7 @@ public class RecentsAnimationController implements DeathRecipient {
TaskAnimationAdapter adapter = addAnimation(task,
!recentTaskIds.get(taskId), true /* hidden */, finishedCallback);
mPendingNewTaskTargets.add(taskId);
return adapter.createRemoteAnimationTarget(taskId);
return adapter.createRemoteAnimationTarget(taskId, mode);
}
void logRecentsAnimationStartTime(int durationMs) {
@@ -773,7 +777,7 @@ public class RecentsAnimationController implements DeathRecipient {
for (int i = mPendingAnimations.size() - 1; i >= 0; i--) {
final TaskAnimationAdapter taskAdapter = mPendingAnimations.get(i);
final RemoteAnimationTarget target =
taskAdapter.createRemoteAnimationTarget(INVALID_TASK_ID);
taskAdapter.createRemoteAnimationTarget(INVALID_TASK_ID, MODE_UNKNOWN);
if (target != null) {
targets.add(target);
} else {
@@ -1196,8 +1200,11 @@ public class RecentsAnimationController implements DeathRecipient {
* some cases where we are animating root tasks but need need leaf
* ids for identification. If this is INVALID (-1), then mTaskId
* 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 WindowState mainWindow = topApp != null
? topApp.findMainWindow()
@@ -1208,9 +1215,11 @@ public class RecentsAnimationController implements DeathRecipient {
final Rect insets = mainWindow.getInsetsStateWithVisibilityOverride().calculateInsets(
mBounds, Type.systemBars(), false /* ignoreVisibility */).toRect();
InsetUtils.addInsets(insets, mainWindow.mActivityRecord.getLetterboxInsets());
final int mode = topApp.getActivityType() == mTargetActivityType
? MODE_OPENING
: MODE_CLOSING;
final int mode = overrideMode != MODE_UNKNOWN
? overrideMode
: topApp.getActivityType() == mTargetActivityType
? MODE_OPENING
: MODE_CLOSING;
if (overrideTaskId < 0) {
overrideTaskId = mTask.mTaskId;
}