Merge "Fix weird animation when switching back to split pair from recents" into tm-dev

This commit is contained in:
Jerry Chang
2022-04-07 02:31:12 +00:00
committed by Android (Google) Code Review

View File

@@ -41,6 +41,7 @@ import android.os.Parcelable;
import android.os.RemoteException;
import android.util.ArrayMap;
import android.util.Log;
import android.util.SparseArray;
import android.view.IRecentsAnimationController;
import android.view.SurfaceControl;
import android.window.IRemoteTransition;
@@ -244,22 +245,28 @@ public class RemoteTransitionCompat implements Parcelable {
@SuppressLint("NewApi")
boolean merge(TransitionInfo info, SurfaceControl.Transaction t,
RecentsAnimationListener recents) {
ArrayList<TransitionInfo.Change> openingTasks = null;
SparseArray<TransitionInfo.Change> openingTasks = null;
boolean cancelRecents = false;
boolean homeGoingAway = false;
boolean hasChangingApp = false;
for (int i = info.getChanges().size() - 1; i >= 0; --i) {
final TransitionInfo.Change change = info.getChanges().get(i);
if (change.getMode() == TRANSIT_OPEN || change.getMode() == TRANSIT_TO_FRONT) {
if (change.getTaskInfo() != null) {
if (change.getTaskInfo().topActivityType == ACTIVITY_TYPE_HOME) {
final ActivityManager.RunningTaskInfo taskInfo = change.getTaskInfo();
if (taskInfo != null) {
if (taskInfo.topActivityType == ACTIVITY_TYPE_HOME) {
// canceling recents animation
cancelRecents = true;
}
if (openingTasks == null) {
openingTasks = new ArrayList<>();
openingTasks = new SparseArray<>();
}
openingTasks.add(change);
if (taskInfo.hasParentTask()) {
// Collects opening leaf tasks only since Launcher monitors leaf task
// ids to perform recents animation.
openingTasks.remove(taskInfo.parentTaskId);
}
openingTasks.put(taskInfo.taskId, change);
}
} else if (change.getMode() == TRANSIT_CLOSE
|| change.getMode() == TRANSIT_TO_BACK) {
@@ -287,7 +294,7 @@ public class RemoteTransitionCompat implements Parcelable {
int pauseMatches = 0;
if (!cancelRecents) {
for (int i = 0; i < openingTasks.size(); ++i) {
if (mPausingTasks.contains(openingTasks.get(i).getContainer())) {
if (mPausingTasks.contains(openingTasks.valueAt(i).getContainer())) {
++pauseMatches;
}
}
@@ -308,10 +315,11 @@ public class RemoteTransitionCompat implements Parcelable {
final RemoteAnimationTargetCompat[] targets =
new RemoteAnimationTargetCompat[openingTasks.size()];
for (int i = 0; i < openingTasks.size(); ++i) {
mOpeningLeashes.add(openingTasks.get(i).getLeash());
final TransitionInfo.Change change = openingTasks.valueAt(i);
mOpeningLeashes.add(change.getLeash());
// We are receiving new opening tasks, so convert to onTasksAppeared.
final RemoteAnimationTargetCompat target = new RemoteAnimationTargetCompat(
openingTasks.get(i), layer, info, t);
change, layer, info, t);
mLeashMap.put(mOpeningLeashes.get(i), target.leash);
t.reparent(target.leash, mInfo.getRootLeash());
t.setLayer(target.leash, layer);