Merge "Skip operation on content overlay if task's vanished" into sc-v2-dev am: 8dbc900327

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15361375

Change-Id: I95c5c79067599e11a13695d6e7419102613cef7a
This commit is contained in:
TreeHugger Robot
2021-07-22 21:39:33 +00:00
committed by Automerger Merge Worker

View File

@@ -1377,11 +1377,20 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
final ValueAnimator animator = ValueAnimator.ofFloat(1.0f, 0.0f); final ValueAnimator animator = ValueAnimator.ofFloat(1.0f, 0.0f);
animator.setDuration(mCrossFadeAnimationDuration); animator.setDuration(mCrossFadeAnimationDuration);
animator.addUpdateListener(animation -> { animator.addUpdateListener(animation -> {
final float alpha = (float) animation.getAnimatedValue(); if (mPipTransitionState.getTransitionState() == PipTransitionState.UNDEFINED) {
final SurfaceControl.Transaction transaction = // Could happen if onTaskVanished happens during the animation since we may have
mSurfaceControlTransactionFactory.getTransaction(); // set a start delay on this animation.
transaction.setAlpha(surface, alpha); Log.d(TAG, "Task vanished, skip fadeOutAndRemoveOverlay");
transaction.apply(); animation.removeAllListeners();
animation.removeAllUpdateListeners();
animation.cancel();
} else {
final float alpha = (float) animation.getAnimatedValue();
final SurfaceControl.Transaction transaction =
mSurfaceControlTransactionFactory.getTransaction();
transaction.setAlpha(surface, alpha);
transaction.apply();
}
}); });
animator.addListener(new AnimatorListenerAdapter() { animator.addListener(new AnimatorListenerAdapter() {
@Override @Override
@@ -1394,6 +1403,10 @@ public class PipTaskOrganizer implements ShellTaskOrganizer.TaskListener,
} }
private void removeContentOverlay(SurfaceControl surface, Runnable callback) { private void removeContentOverlay(SurfaceControl surface, Runnable callback) {
if (mPipTransitionState.getTransitionState() == PipTransitionState.UNDEFINED) {
// Avoid double removal, which is fatal.
return;
}
final SurfaceControl.Transaction tx = final SurfaceControl.Transaction tx =
mSurfaceControlTransactionFactory.getTransaction(); mSurfaceControlTransactionFactory.getTransaction();
tx.remove(surface); tx.remove(surface);