From 658e4702ce41d1b1553f1e0025d3b4fadd36af59 Mon Sep 17 00:00:00 2001 From: Ikram Gabiyev Date: Mon, 20 Mar 2023 17:36:52 +0000 Subject: [PATCH] Default to true for new pip size spec flag Make sure that if ENABLE_PIP_SIZE_LARGE_SCREEN is not read properly in PipSizeSpecHandler, we default to it being true. Bug: 274471047 Test: atest WMShellUnitTests:PipSizeSpecHandlerTest Change-Id: Ibaa327b8fe433aeab7599fd414be62d8c35fb660 --- .../wm/shell/pip/phone/PipSizeSpecHandler.java | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipSizeSpecHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipSizeSpecHandler.java index d03d075b38af7..ff5138d4bb915 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipSizeSpecHandler.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/phone/PipSizeSpecHandler.java @@ -212,24 +212,25 @@ public class PipSizeSpecHandler { */ @Override public Size getSizeForAspectRatio(Size size, float aspectRatio) { - // getting the percentage of the max size that current size takes float currAspectRatio = (float) size.getWidth() / size.getHeight(); + + // getting the percentage of the max size that current size takes Size currentMaxSize = getMaxSize(currAspectRatio); float currentPercent = (float) size.getWidth() / currentMaxSize.getWidth(); // getting the max size for the target aspect ratio Size updatedMaxSize = getMaxSize(aspectRatio); - int width = (int) (updatedMaxSize.getWidth() * currentPercent); - int height = (int) (updatedMaxSize.getHeight() * currentPercent); + int width = Math.round(updatedMaxSize.getWidth() * currentPercent); + int height = Math.round(updatedMaxSize.getHeight() * currentPercent); // adjust the dimensions if below allowed min edge size if (width < getMinEdgeSize() && aspectRatio <= 1) { width = getMinEdgeSize(); - height = (int) (width / aspectRatio); + height = Math.round(width / aspectRatio); } else if (height < getMinEdgeSize() && aspectRatio > 1) { height = getMinEdgeSize(); - width = (int) (height * aspectRatio); + width = Math.round(height * aspectRatio); } // reduce the dimensions of the updated size to the calculated percentage @@ -365,7 +366,7 @@ public class PipSizeSpecHandler { mContext = context; boolean enablePipSizeLargeScreen = SystemProperties - .getBoolean("persist.wm.debug.enable_pip_size_large_screen", false); + .getBoolean("persist.wm.debug.enable_pip_size_large_screen", true); // choose between two implementations of size spec logic if (enablePipSizeLargeScreen) {