Delay PiP transition to fullscreen until activities draw.
To avoid awful stretching.
Bug: 37473110
Test: Transition app fullscreen verify no awful video stretching.
Change-Id: I810a72207e45b8f83a63c9f0b3cc9a433569852c
diff --git a/services/core/java/com/android/server/wm/BoundsAnimationController.java b/services/core/java/com/android/server/wm/BoundsAnimationController.java
index e634552..7f3c89c 100644
--- a/services/core/java/com/android/server/wm/BoundsAnimationController.java
+++ b/services/core/java/com/android/server/wm/BoundsAnimationController.java
@@ -112,6 +112,8 @@
private final Interpolator mFastOutSlowInInterpolator;
private boolean mFinishAnimationAfterTransition = false;
+ private static final int WAIT_FOR_DRAW_TIMEOUT_MS = 3000;
+
BoundsAnimationController(Context context, AppTransition transition, Handler handler) {
mHandler = handler;
mAppTransition = transition;
@@ -175,6 +177,13 @@
}
}
+ final Runnable mResumeRunnable = new Runnable() {
+ @Override
+ public void run() {
+ resume();
+ }
+ };
+
@Override
public void onAnimationStart(Animator animation) {
if (DEBUG) Slog.d(TAG, "onAnimationStart: mTarget=" + mTarget
@@ -196,10 +205,26 @@
// the starting position so we don't jump at the beginning of the animation.
if (animatingToLargerSize()) {
mTarget.setPinnedStackSize(mFrom, mTmpRect);
+
+ // We pause the animation until the app has drawn at the new size.
+ // The target will notify us via BoundsAnimationController#resume.
+ // We do this here and pause the animation, rather than just defer starting it
+ // so we can enter the animating state and have WindowStateAnimator apply the
+ // correct logic to make this resize seamless.
+ if (mMoveToFullscreen) {
+ pause();
+ mHandler.postDelayed(mResumeRunnable, WAIT_FOR_DRAW_TIMEOUT_MS);
+ }
}
}
@Override
+ public void resume() {
+ mHandler.removeCallbacks(mResumeRunnable);
+ super.resume();
+ }
+
+ @Override
public void onAnimationUpdate(ValueAnimator animation) {
final float value = (Float) animation.getAnimatedValue();
final float remains = 1 - value;
@@ -371,4 +396,15 @@
animator.start();
return animator;
}
+
+ private void resume() {
+ for (int i = 0; i < mRunningAnimations.size(); i++) {
+ final BoundsAnimator b = mRunningAnimations.valueAt(i);
+ b.resume();
+ }
+ }
+
+ public void onAllWindowsDrawn() {
+ mHandler.post(this::resume);
+ }
}