| commit | cbb8f80935d62c836eea13f8d4a97e1aca6ac753 | [log] [tgz] |
|---|---|---|
| author | Hongwei Wang <hwwang@google.com> | Tue Mar 05 16:37:04 2024 -0800 |
| committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | Thu Mar 07 20:53:45 2024 +0000 |
| tree | ffd1f2f078485d6db8aaa8031018a59c78094947 | |
| parent | bda4fa18cb8deadde3b6841e0a53443162ac6aff [diff] |
Fallback to default aspect ratio if not provided This is to fix the regression introduced by ag/26340832. When apps like YT provide empty aspect ratio via PictureInPictureParams, the zero value would be used to calculate the min / max allowed size and causes the PiP window to be resized unexpectedly. Video: http://recall/-/aaaaaabFQoRHlzixHdtY/frCUwuTnpvVPMqFs3C5Gnk Bug: 328051931 Test: manual, follow the reproduce steps, see video (cherry picked from https://googleplex-android-review.googlesource.com/q/commit:63c0f02a731151d7b5ec6ea3a1a1466f0774cc32) Merged-In: Icab07e634cbd3c19668640203b586f10219c0410 Change-Id: Icab07e634cbd3c19668640203b586f10219c0410
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java index 2cdec81..84afed1 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipController.java
@@ -979,7 +979,13 @@ // cache current min/max size Point minSize = mPipBoundsState.getMinSize(); Point maxSize = mPipBoundsState.getMaxSize(); - mPipBoundsState.updateMinMaxSize(pictureInPictureParams.getAspectRatioFloat()); + final float aspectRatioFloat; + if (pictureInPictureParams.hasSetAspectRatio()) { + aspectRatioFloat = pictureInPictureParams.getAspectRatioFloat(); + } else { + aspectRatioFloat = mPipBoundsAlgorithm.getDefaultAspectRatio(); + } + mPipBoundsState.updateMinMaxSize(aspectRatioFloat); final Rect entryBounds = mPipTaskOrganizer.startSwipePipToHome(componentName, activityInfo, pictureInPictureParams); // restore min/max size, as this is referenced later in OnDisplayChangingListener and needs