Ignore exit animation when view is detached from window.

After first launched activity start remove starting window, there start
a second activity with a new task, so there will trigger a open/close
task transition while playing starting window exit animation, but since
the first launched activity is going to destory, there will goes to
clear all window for that activity.
For client side we can ignore the animation after it was detached from
window.

Bug: 190040281
Test: manual
Change-Id: Idd939feb72163d585e14db480b1e374e41597928
This commit is contained in:
wilsonshih
2021-06-15 18:03:21 +08:00
parent 5c86c0c10e
commit 84837512a1

View File

@@ -235,7 +235,8 @@ public class SplashScreenExitAnimation implements Animator.AnimatorListener {
}
void onAnimationProgress(float linearProgress) {
if (mFirstWindowSurface == null || !mFirstWindowSurface.isValid()) {
if (mFirstWindowSurface == null || !mFirstWindowSurface.isValid()
|| !mSplashScreenView.isAttachedToWindow()) {
return;
}
@@ -267,15 +268,20 @@ public class SplashScreenExitAnimation implements Animator.AnimatorListener {
return;
}
final SurfaceControl.Transaction tx = mTransactionPool.acquire();
tx.setFrameTimelineVsync(Choreographer.getSfInstance().getVsyncId());
if (mSplashScreenView.isAttachedToWindow()) {
tx.setFrameTimelineVsync(Choreographer.getSfInstance().getVsyncId());
SyncRtSurfaceTransactionApplier.SurfaceParams
params = new SyncRtSurfaceTransactionApplier.SurfaceParams
.Builder(mFirstWindowSurface)
.withWindowCrop(null)
.withMergeTransaction(tx)
.build();
mApplier.scheduleApply(params);
SyncRtSurfaceTransactionApplier.SurfaceParams
params = new SyncRtSurfaceTransactionApplier.SurfaceParams
.Builder(mFirstWindowSurface)
.withWindowCrop(null)
.withMergeTransaction(tx)
.build();
mApplier.scheduleApply(params);
} else {
tx.setWindowCrop(mFirstWindowSurface, null);
tx.apply();
}
mTransactionPool.release(tx);
Choreographer.getSfInstance().postCallback(CALLBACK_COMMIT,
@@ -287,13 +293,14 @@ public class SplashScreenExitAnimation implements Animator.AnimatorListener {
if (DEBUG_EXIT_ANIMATION) {
Slog.v(TAG, "vanish animation finished");
}
mSplashScreenView.post(() -> {
if (mSplashScreenView.isAttachedToWindow()) {
mSplashScreenView.setVisibility(GONE);
if (mFinishCallback != null) {
mFinishCallback.run();
mFinishCallback = null;
}
});
}
if (mShiftUpAnimation != null) {
mShiftUpAnimation.finish();
}