Merge "Fixes a race condition when merge animation transition" into tm-qpr-dev

This commit is contained in:
Wei Sheng Shih
2022-06-20 10:48:23 +00:00
committed by Android (Google) Code Review

View File

@@ -186,6 +186,8 @@ public class RemoteTransitionCompat implements Parcelable {
} catch (RemoteException e) { } catch (RemoteException e) {
Log.e(TAG, "Error merging transition.", e); Log.e(TAG, "Error merging transition.", e);
} }
// commit taskAppeared after merge transition finished.
mRecentsSession.commitTasksAppearedIfNeeded(recents);
} }
}; };
mTransition = new RemoteTransition(remote, appThread); mTransition = new RemoteTransition(remote, appThread);
@@ -226,6 +228,7 @@ public class RemoteTransitionCompat implements Parcelable {
private PictureInPictureSurfaceTransaction mPipTransaction = null; private PictureInPictureSurfaceTransaction mPipTransaction = null;
private IBinder mTransition = null; private IBinder mTransition = null;
private boolean mKeyguardLocked = false; private boolean mKeyguardLocked = false;
private RemoteAnimationTargetCompat[] mAppearedTargets;
void setup(RecentsAnimationControllerCompat wrapped, TransitionInfo info, void setup(RecentsAnimationControllerCompat wrapped, TransitionInfo info,
IRemoteTransitionFinishedCallback finishCB, IRemoteTransitionFinishedCallback finishCB,
@@ -251,6 +254,7 @@ public class RemoteTransitionCompat implements Parcelable {
boolean merge(TransitionInfo info, SurfaceControl.Transaction t, boolean merge(TransitionInfo info, SurfaceControl.Transaction t,
RecentsAnimationListener recents) { RecentsAnimationListener recents) {
SparseArray<TransitionInfo.Change> openingTasks = null; SparseArray<TransitionInfo.Change> openingTasks = null;
mAppearedTargets = null;
boolean cancelRecents = false; boolean cancelRecents = false;
boolean homeGoingAway = false; boolean homeGoingAway = false;
boolean hasChangingApp = false; boolean hasChangingApp = false;
@@ -331,10 +335,17 @@ public class RemoteTransitionCompat implements Parcelable {
targets[i] = target; targets[i] = target;
} }
t.apply(); t.apply();
recents.onTasksAppeared(targets); mAppearedTargets = targets;
return true; return true;
} }
private void commitTasksAppearedIfNeeded(RecentsAnimationListener recents) {
if (mAppearedTargets != null) {
recents.onTasksAppeared(mAppearedTargets);
mAppearedTargets = null;
}
}
@Override public ThumbnailData screenshotTask(int taskId) { @Override public ThumbnailData screenshotTask(int taskId) {
try { try {
final TaskSnapshot snapshot = final TaskSnapshot snapshot =