From b9b673fb4ada1808ce11f22093a2f9d3a7e407a0 Mon Sep 17 00:00:00 2001 From: Winson Chung Date: Wed, 21 Jul 2021 21:28:51 -0700 Subject: [PATCH] Skip animating out bubble screenshot if surface is not ready Bug: 193634894 Test: atest SystemUITests Change-Id: Ifb2ba00be2e8dc497300feb39bacb88b9021df4a --- .../wm/shell/bubbles/BubbleStackView.java | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java index 92e455ce4e3ac..c0df06f2954f9 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleStackView.java @@ -45,6 +45,7 @@ import android.view.Choreographer; import android.view.LayoutInflater; import android.view.MotionEvent; import android.view.SurfaceControl; +import android.view.SurfaceHolder; import android.view.SurfaceView; import android.view.View; import android.view.ViewGroup; @@ -205,6 +206,7 @@ public class BubbleStackView extends FrameLayout * between bubble activities without needing both to be alive at the same time. */ private SurfaceView mAnimatingOutSurfaceView; + private boolean mAnimatingOutSurfaceReady; /** Container for the animating-out SurfaceView. */ private FrameLayout mAnimatingOutSurfaceContainer; @@ -811,6 +813,20 @@ public class BubbleStackView extends FrameLayout mAnimatingOutSurfaceView.setZOrderOnTop(true); mAnimatingOutSurfaceView.setCornerRadius(mCornerRadius); mAnimatingOutSurfaceView.setLayoutParams(new ViewGroup.LayoutParams(0, 0)); + mAnimatingOutSurfaceView.getHolder().addCallback(new SurfaceHolder.Callback() { + @Override + public void surfaceChanged(SurfaceHolder surfaceHolder, int i, int i1, int i2) {} + + @Override + public void surfaceCreated(SurfaceHolder surfaceHolder) { + mAnimatingOutSurfaceReady = true; + } + + @Override + public void surfaceDestroyed(SurfaceHolder surfaceHolder) { + mAnimatingOutSurfaceReady = false; + } + }); mAnimatingOutSurfaceContainer.addView(mAnimatingOutSurfaceView); mAnimatingOutSurfaceContainer.setPadding( @@ -2653,7 +2669,7 @@ public class BubbleStackView extends FrameLayout return; } - if (!mIsExpanded) { + if (!mIsExpanded || !mAnimatingOutSurfaceReady) { onComplete.accept(false); return; }