From cdb9690a8785f5ca9b339cf1a8572be6577bee9e Mon Sep 17 00:00:00 2001 From: Hongwei Wang Date: Thu, 11 Apr 2024 15:56:39 -0700 Subject: [PATCH] Add debugging information on PiP content overlay Added the reason for creating the overlay. Updated SwipePipToHomeAnimator constructor also due to the fact the source rect hint from Builder class is never empty. Bug: 330488822 Test: manually, follow the reproduce path Flag: NA Change-Id: Id98ce799d7c96fff3279c0df0fa49084a49d563a --- .../util/SwipePipToHomeAnimator.java | 22 +++++++++++-------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/quickstep/src/com/android/quickstep/util/SwipePipToHomeAnimator.java b/quickstep/src/com/android/quickstep/util/SwipePipToHomeAnimator.java index 6c89be1ec4..f823affef9 100644 --- a/quickstep/src/com/android/quickstep/util/SwipePipToHomeAnimator.java +++ b/quickstep/src/com/android/quickstep/util/SwipePipToHomeAnimator.java @@ -112,7 +112,7 @@ public class SwipePipToHomeAnimator extends RectFSpringAnim { @NonNull ActivityInfo activityInfo, int appIconSizePx, @NonNull SurfaceControl leash, - @Nullable Rect sourceRectHint, + @NonNull Rect sourceRectHint, @NonNull Rect appBounds, @NonNull Matrix homeToWindowPositionMap, @NonNull RectF startBounds, @@ -135,22 +135,25 @@ public class SwipePipToHomeAnimator extends RectFSpringAnim { mDestinationBoundsTransformed.set(destinationBoundsTransformed); mSurfaceTransactionHelper = new PipSurfaceTransactionHelper(cornerRadius, shadowRadius); - if (sourceRectHint != null && (sourceRectHint.width() < destinationBounds.width() - || sourceRectHint.height() < destinationBounds.height())) { + String reasonForCreateOverlay = null; // For debugging purpose. + if (sourceRectHint.isEmpty()) { + reasonForCreateOverlay = "Source rect hint is empty"; + } else if (sourceRectHint.width() < destinationBounds.width() + || sourceRectHint.height() < destinationBounds.height()) { // This is a situation in which the source hint rect on at least one axis is smaller // than the destination bounds, which presents a problem because we would have to scale // up that axis to fit the bounds. So instead, just fallback to the non-source hint // animation in this case. - sourceRectHint = null; - } - - if (sourceRectHint != null && !appBounds.contains(sourceRectHint)) { + reasonForCreateOverlay = "Source rect hint is too small " + sourceRectHint; + sourceRectHint.setEmpty(); + } else if (!appBounds.contains(sourceRectHint)) { // This is a situation in which the source hint rect is outside the app bounds, so it is // not a valid rectangle to use for cropping app surface - sourceRectHint = null; + sourceRectHint.setEmpty(); + reasonForCreateOverlay = "Source rect hint exceeds display bounds " + sourceRectHint; } - if (sourceRectHint == null) { + if (sourceRectHint.isEmpty()) { mSourceRectHint.setEmpty(); mSourceHintRectInsets = null; @@ -162,6 +165,7 @@ public class SwipePipToHomeAnimator extends RectFSpringAnim { new IconProvider(context).getIcon(mActivityInfo), appIconSizePx); final SurfaceControl.Transaction tx = new SurfaceControl.Transaction(); mPipContentOverlay.attach(tx, mLeash); + Log.d(TAG, getContentOverlay() + " is created: " + reasonForCreateOverlay); } else { mSourceRectHint.set(sourceRectHint); mSourceHintRectInsets = new Rect(sourceRectHint.left - appBounds.left,