From a9f258cb12cfea2188107973a67b7223a74192a5 Mon Sep 17 00:00:00 2001 From: Hongwei Wang Date: Thu, 30 Jun 2022 13:21:22 -0700 Subject: [PATCH] Adjust the auto-pip app bounds for TaskBar When on tablet / large-screen devices where TaskBar is present, the bounds of the recents animation leash would be cut by TaskBar height, therefore we need to adjust the app bounds for auto-pip accordingly. Video: http://recall/-/aaaaaabFQoRHlzixHdtY/fmMql9z3gYIu98ntQYklQU Video: http://recall/-/aaaaaabFQoRHlzixHdtY/hvoqi4bBWyPMgwzEXXrnnC Bug: 201824622 Test: Enter PiP from GMM on tablet and unfolded foldables, both \ landscape and portrait, with TaskBar stashed and unstashed. Change-Id: Id91190b8f0045db4af0f2a3f1993149dc34457ab --- .../com/android/quickstep/AbsSwipeUpHandler.java | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java index 9dbfa83473..9eb4d62215 100644 --- a/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java +++ b/quickstep/src/com/android/quickstep/AbsSwipeUpHandler.java @@ -58,6 +58,7 @@ import android.animation.ValueAnimator; import android.annotation.TargetApi; import android.app.Activity; import android.app.ActivityManager; +import android.app.WindowConfiguration; import android.content.Context; import android.content.Intent; import android.graphics.Matrix; @@ -1421,6 +1422,16 @@ public abstract class AbsSwipeUpHandler, runningTaskTarget.taskInfo.pictureInPictureParams, homeRotation, mDp.hotseatBarSizePx); + final Rect appBounds = new Rect(); + final WindowConfiguration winConfig = taskInfo.configuration.windowConfiguration; + // Adjust the appBounds for TaskBar by using the calculated window crop Rect + // from TaskViewSimulator and fallback to the bounds in TaskInfo when it's originated + // from windowing modes other than full-screen. + if (winConfig.getWindowingMode() == WindowConfiguration.WINDOWING_MODE_FULLSCREEN) { + mRemoteTargetHandles[0].getTaskViewSimulator().getCurrentCropRect().round(appBounds); + } else { + appBounds.set(winConfig.getBounds()); + } final SwipePipToHomeAnimator.Builder builder = new SwipePipToHomeAnimator.Builder() .setContext(mContext) .setTaskId(runningTaskTarget.taskId) @@ -1428,7 +1439,7 @@ public abstract class AbsSwipeUpHandler, .setLeash(runningTaskTarget.leash) .setSourceRectHint( runningTaskTarget.taskInfo.pictureInPictureParams.getSourceRectHint()) - .setAppBounds(taskInfo.configuration.windowConfiguration.getBounds()) + .setAppBounds(appBounds) .setHomeToWindowPositionMap(homeToWindowPositionMap) .setStartBounds(startRect) .setDestinationBounds(destinationBounds)