From 402a96f5887045c1685c756abbca66c6d47b8003 Mon Sep 17 00:00:00 2001 From: Ikram Gabiyev Date: Thu, 11 Jul 2024 15:00:15 -0700 Subject: [PATCH] Allow extra pixel for app bounds containment PiP Allow an extra one pixel delta on each side of the app bounds for source-rect-hint containment checks when swiping to enter PiP. Bug: 349821386 Flag: EXEMPT bugfix Test: swipe PiP to home with 21:9 video from landscape to portrait Change-Id: Ibc53e426b49cfcd58e977433358b9980732ac289 --- .../com/android/quickstep/util/SwipePipToHomeAnimator.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/quickstep/util/SwipePipToHomeAnimator.java b/quickstep/src/com/android/quickstep/util/SwipePipToHomeAnimator.java index 48ed67b27f..56e91ed2d8 100644 --- a/quickstep/src/com/android/quickstep/util/SwipePipToHomeAnimator.java +++ b/quickstep/src/com/android/quickstep/util/SwipePipToHomeAnimator.java @@ -139,6 +139,10 @@ public class SwipePipToHomeAnimator extends RectFSpringAnim { final float aspectRatio = destinationBounds.width() / (float) destinationBounds.height(); String reasonForCreateOverlay = null; // For debugging purpose. + + // Slightly larger app bounds to allow for off by 1 pixel source-rect-hint errors. + Rect overflowAppBounds = new Rect(appBounds.left - 1, appBounds.top - 1, + appBounds.right + 1, appBounds.bottom + 1); if (sourceRectHint.isEmpty()) { reasonForCreateOverlay = "Source rect hint is empty"; } else if (sourceRectHint.width() < destinationBounds.width() @@ -149,7 +153,7 @@ public class SwipePipToHomeAnimator extends RectFSpringAnim { // animation in this case. reasonForCreateOverlay = "Source rect hint is too small " + sourceRectHint; sourceRectHint.setEmpty(); - } else if (!appBounds.contains(sourceRectHint)) { + } else if (!overflowAppBounds.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 reasonForCreateOverlay = "Source rect hint exceeds display bounds " + sourceRectHint;