diff options
Diffstat (limited to 'libs')
8 files changed, 237 insertions, 96 deletions
diff --git a/libs/WindowManager/Shell/res/values/config.xml b/libs/WindowManager/Shell/res/values/config.xml index a541c590575f..c2ba064ac7b6 100644 --- a/libs/WindowManager/Shell/res/values/config.xml +++ b/libs/WindowManager/Shell/res/values/config.xml @@ -45,9 +45,6 @@ <!-- Allow PIP to resize to a slightly bigger state upon touch/showing the menu --> <bool name="config_pipEnableResizeForMenu">true</bool> - <!-- PiP minimum size, which is a % based off the shorter side of display width and height --> - <fraction name="config_pipShortestEdgePercent">40%</fraction> - <!-- Time (duration in milliseconds) that the shell waits for an app to close the PiP by itself if a custom action is present before closing it. --> <integer name="config_pipForceCloseDelay">1000</integer> @@ -91,11 +88,45 @@ 16x16 </string> + <!-- Default percentages for the PIP size logic. + 1. Determine max widths + Subtract width of system UI and default padding from the shortest edge of the device. + This is the max width. + 2. Calculate Default and Mins + Default is config_pipSystemPreferredDefaultSizePercent of max-width/height. + Min is config_pipSystemPreferredMinimumSizePercent of it. --> + <item name="config_pipSystemPreferredDefaultSizePercent" format="float" type="dimen">0.6</item> + <item name="config_pipSystemPreferredMinimumSizePercent" format="float" type="dimen">0.5</item> + <!-- Default percentages for the PIP size logic when the Display is close to square. + This is used instead when the display is square-ish, like fold-ables when unfolded, + to make sure that default PiP does not cover the hinge (halfway of the display). + 0. Determine if the display is square-ish + If min(displayWidth, displayHeight) / max(displayWidth, displayHeight) is greater than + config_pipSquareDisplayThresholdForSystemPreferredSize, we use the percent for + square display listed below. + 1. Determine max widths + Subtract width of system UI and default padding from the shortest edge of the device. + This is the max width. + 2. Calculate Default and Mins + Default is config_pipSystemPreferredDefaultSizePercentForSquareDisplay of max-width/height. + Min is config_pipSystemPreferredMinimumSizePercentForSquareDisplay of it. --> + <item name="config_pipSquareDisplayThresholdForSystemPreferredSize" + format="float" type="dimen">0.95</item> + <item name="config_pipSystemPreferredDefaultSizePercentForSquareDisplay" + format="float" type="dimen">0.5</item> + <item name="config_pipSystemPreferredMinimumSizePercentForSquareDisplay" + format="float" type="dimen">0.4</item> + <!-- The percentage of the screen width to use for the default width or height of picture-in-picture windows. Regardless of the percent set here, calculated size will never - be smaller than @dimen/default_minimal_size_pip_resizable_task. --> + be smaller than @dimen/default_minimal_size_pip_resizable_task. + This is used in legacy spec, use config_pipSystemPreferredDefaultSizePercent instead. --> <item name="config_pictureInPictureDefaultSizePercent" format="float" type="dimen">0.23</item> + <!-- PiP minimum size, which is a % based off the shorter side of display width and height. + This is used in legacy spec, use config_pipSystemPreferredMinimumSizePercent instead. --> + <fraction name="config_pipShortestEdgePercent">40%</fraction> + <!-- The default aspect ratio for picture-in-picture windows. --> <item name="config_pictureInPictureDefaultAspectRatio" format="float" type="dimen"> 1.777778 diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java index 0867a44c1998..313d0d24b459 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/BubbleController.java @@ -2335,6 +2335,11 @@ public class BubbleController implements ConfigurationChangeListener, mMainExecutor.execute(() -> mController.setBubbleBarLocation(location)); } + + @Override + public void setBubbleBarBounds(Rect bubbleBarBounds) { + mMainExecutor.execute(() -> mBubblePositioner.setBubbleBarBounds(bubbleBarBounds)); + } } private class BubblesImpl implements Bubbles { diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/IBubbles.aidl b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/IBubbles.aidl index 16134d3e5a70..c9f0f0d61713 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/IBubbles.aidl +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/IBubbles.aidl @@ -44,4 +44,6 @@ interface IBubbles { oneway void showUserEducation(in int positionX, in int positionY) = 8; oneway void setBubbleBarLocation(in BubbleBarLocation location) = 9; + + oneway void setBubbleBarBounds(in Rect bubbleBarBounds) = 10; }
\ No newline at end of file diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarAnimationHelper.java b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarAnimationHelper.java index 8af4c75b5733..45ad6319bbf8 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarAnimationHelper.java +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/bubbles/bar/BubbleBarAnimationHelper.java @@ -166,13 +166,8 @@ public class BubbleBarAnimationHelper { bbev.setTaskViewAlpha(0f); bbev.setVisibility(VISIBLE); - // Set the pivot point for the scale, so the view animates out from the bubble bar. - Rect bubbleBarBounds = mPositioner.getBubbleBarBounds(); - mExpandedViewContainerMatrix.setScale( - 1f - EXPANDED_VIEW_ANIMATE_SCALE_AMOUNT, - 1f - EXPANDED_VIEW_ANIMATE_SCALE_AMOUNT, - bubbleBarBounds.centerX(), - bubbleBarBounds.top); + setScaleFromBubbleBar(mExpandedViewContainerMatrix, + 1f - EXPANDED_VIEW_ANIMATE_SCALE_AMOUNT); bbev.setAnimationMatrix(mExpandedViewContainerMatrix); @@ -214,8 +209,8 @@ public class BubbleBarAnimationHelper { } bbev.setScaleX(1f); bbev.setScaleY(1f); - mExpandedViewContainerMatrix.setScaleX(1f); - mExpandedViewContainerMatrix.setScaleY(1f); + + setScaleFromBubbleBar(mExpandedViewContainerMatrix, 1f); PhysicsAnimator.getInstance(mExpandedViewContainerMatrix).cancel(); PhysicsAnimator.getInstance(mExpandedViewContainerMatrix) @@ -240,6 +235,16 @@ public class BubbleBarAnimationHelper { mExpandedViewAlphaAnimator.reverse(); } + private void setScaleFromBubbleBar(AnimatableScaleMatrix matrix, float scale) { + // Set the pivot point for the scale, so the view animates out from the bubble bar. + Rect bubbleBarBounds = mPositioner.getBubbleBarBounds(); + matrix.setScale( + scale, + scale, + bubbleBarBounds.centerX(), + bubbleBarBounds.top); + } + /** * Animate the expanded bubble when it is being dragged */ diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/common/pip/PhoneSizeSpecSource.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/common/pip/PhoneSizeSpecSource.kt index 18c7bdd6d5ba..7eb0f267b312 100644 --- a/libs/WindowManager/Shell/src/com/android/wm/shell/common/pip/PhoneSizeSpecSource.kt +++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/pip/PhoneSizeSpecSource.kt @@ -18,7 +18,6 @@ package com.android.wm.shell.common.pip import android.content.Context import android.content.res.Resources -import android.os.SystemProperties import android.util.Size import com.android.wm.shell.R import java.io.PrintWriter @@ -36,30 +35,81 @@ class PhoneSizeSpecSource( private var mOverrideMinSize: Size? = null - /** Default and minimum percentages for the PIP size logic. */ - private val mDefaultSizePercent: Float - private val mMinimumSizePercent: Float + /** + * Default percentages for the PIP size logic. + * 1. Determine max widths + * Subtract width of system UI and default padding from the shortest edge of the device. + * This is the max width. + * 2. Calculate Default and Mins + * Default is mSystemPreferredDefaultSizePercent of max-width/height. + * Min is mSystemPreferredMinimumSizePercent of it. + * + * NOTE: Do not use this directly, use the mPreferredDefaultSizePercent getter instead. + */ + private var mSystemPreferredDefaultSizePercent = 0.6f + /** Minimum percentages for the PIP size logic. */ + private var mSystemPreferredMinimumSizePercent = 0.5f + + /** Threshold to categorize the Display as square, calculated as min(w, h) / max(w, h). */ + private var mSquareDisplayThresholdForSystemPreferredSize = 0.95f + /** + * Default percentages for the PIP size logic when the Display is square-ish. + * This is used instead when the display is square-ish, like fold-ables when unfolded, + * to make sure that default PiP does not cover the hinge (halfway of the display). + * 1. Determine max widths + * Subtract width of system UI and default padding from the shortest edge of the device. + * This is the max width. + * 2. Calculate Default and Mins + * Default is mSystemPreferredDefaultSizePercent of max-width/height. + * Min is mSystemPreferredMinimumSizePercent of it. + * + * NOTE: Do not use this directly, use the mPreferredDefaultSizePercent getter instead. + */ + private var mSystemPreferredDefaultSizePercentForSquareDisplay = 0.5f + /** Minimum percentages for the PIP size logic. */ + private var mSystemPreferredMinimumSizePercentForSquareDisplay = 0.4f + + private val mIsSquareDisplay + get() = minOf(pipDisplayLayoutState.displayLayout.width(), + pipDisplayLayoutState.displayLayout.height()).toFloat() / + maxOf(pipDisplayLayoutState.displayLayout.width(), + pipDisplayLayoutState.displayLayout.height()) > + mSquareDisplayThresholdForSystemPreferredSize + private val mPreferredDefaultSizePercent + get() = if (mIsSquareDisplay) mSystemPreferredDefaultSizePercentForSquareDisplay else + mSystemPreferredDefaultSizePercent + + private val mPreferredMinimumSizePercent + get() = if (mIsSquareDisplay) mSystemPreferredMinimumSizePercentForSquareDisplay else + mSystemPreferredMinimumSizePercent /** Aspect ratio that the PIP size spec logic optimizes for. */ private var mOptimizedAspectRatio = 0f init { - mDefaultSizePercent = SystemProperties - .get("com.android.wm.shell.pip.phone.def_percentage", "0.6").toFloat() - mMinimumSizePercent = SystemProperties - .get("com.android.wm.shell.pip.phone.min_percentage", "0.5").toFloat() - reloadResources() } private fun reloadResources() { - val res: Resources = context.getResources() + val res: Resources = context.resources mDefaultMinSize = res.getDimensionPixelSize( R.dimen.default_minimal_size_pip_resizable_task) mOverridableMinSize = res.getDimensionPixelSize( R.dimen.overridable_minimal_size_pip_resizable_task) + mSystemPreferredDefaultSizePercent = res.getFloat( + R.dimen.config_pipSystemPreferredDefaultSizePercent) + mSystemPreferredMinimumSizePercent = res.getFloat( + R.dimen.config_pipSystemPreferredMinimumSizePercent) + + mSquareDisplayThresholdForSystemPreferredSize = res.getFloat( + R.dimen.config_pipSquareDisplayThresholdForSystemPreferredSize) + mSystemPreferredDefaultSizePercentForSquareDisplay = res.getFloat( + R.dimen.config_pipSystemPreferredDefaultSizePercentForSquareDisplay) + mSystemPreferredMinimumSizePercentForSquareDisplay = res.getFloat( + R.dimen.config_pipSystemPreferredMinimumSizePercentForSquareDisplay) + val requestedOptAspRatio = res.getFloat(R.dimen.config_pipLargeScreenOptimizedAspectRatio) // make sure the optimized aspect ratio is valid with a default value to fall back to mOptimizedAspectRatio = if (requestedOptAspRatio > 1) { @@ -128,7 +178,7 @@ class PhoneSizeSpecSource( return minSize } val maxSize = getMaxSize(aspectRatio) - val defaultWidth = Math.max(Math.round(maxSize.width * mDefaultSizePercent), + val defaultWidth = Math.max(Math.round(maxSize.width * mPreferredDefaultSizePercent), minSize.width) val defaultHeight = Math.round(defaultWidth / aspectRatio) return Size(defaultWidth, defaultHeight) @@ -146,8 +196,8 @@ class PhoneSizeSpecSource( return adjustOverrideMinSizeToAspectRatio(aspectRatio)!! } val maxSize = getMaxSize(aspectRatio) - var minWidth = Math.round(maxSize.width * mMinimumSizePercent) - var minHeight = Math.round(maxSize.height * mMinimumSizePercent) + var minWidth = Math.round(maxSize.width * mPreferredMinimumSizePercent) + var minHeight = Math.round(maxSize.height * mPreferredMinimumSizePercent) // make sure the calculated min size is not smaller than the allowed default min size if (aspectRatio > 1f) { @@ -244,8 +294,8 @@ class PhoneSizeSpecSource( pw.println(innerPrefix + "mOverrideMinSize=" + mOverrideMinSize) pw.println(innerPrefix + "mOverridableMinSize=" + mOverridableMinSize) pw.println(innerPrefix + "mDefaultMinSize=" + mDefaultMinSize) - pw.println(innerPrefix + "mDefaultSizePercent=" + mDefaultSizePercent) - pw.println(innerPrefix + "mMinimumSizePercent=" + mMinimumSizePercent) + pw.println(innerPrefix + "mDefaultSizePercent=" + mPreferredDefaultSizePercent) + pw.println(innerPrefix + "mMinimumSizePercent=" + mPreferredMinimumSizePercent) pw.println(innerPrefix + "mOptimizedAspectRatio=" + mOptimizedAspectRatio) } }
\ No newline at end of file diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/phone/PhoneSizeSpecSourceTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/phone/PhoneSizeSpecSourceTest.java index 3d5cd6939d1b..85f1da5322ea 100644 --- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/phone/PhoneSizeSpecSourceTest.java +++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/pip/phone/PhoneSizeSpecSourceTest.java @@ -16,33 +16,26 @@ package com.android.wm.shell.pip.phone; -import static com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession; - -import static org.mockito.ArgumentMatchers.anyInt; -import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.when; import android.content.Context; import android.content.res.Resources; -import android.os.SystemProperties; import android.testing.AndroidTestingRunner; import android.util.Size; import android.view.DisplayInfo; -import com.android.dx.mockito.inline.extended.StaticMockitoSession; +import com.android.wm.shell.R; import com.android.wm.shell.ShellTestCase; import com.android.wm.shell.common.DisplayLayout; import com.android.wm.shell.common.pip.PhoneSizeSpecSource; import com.android.wm.shell.common.pip.PipDisplayLayoutState; import com.android.wm.shell.common.pip.SizeSpecSource; -import org.junit.After; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.Mock; -import org.mockito.exceptions.misusing.InvalidUseOfMatchersException; import java.util.HashMap; import java.util.Map; @@ -63,15 +56,24 @@ public class PhoneSizeSpecSourceTest extends ShellTestCase { private static final float DEFAULT_PERCENT = 0.6f; /** Minimum sizing percentage */ private static final float MIN_PERCENT = 0.5f; + /** Threshold to determine if a Display is square-ish. */ + private static final float SQUARE_DISPLAY_THRESHOLD = 0.95f; + /** Default sizing percentage for square-ish Display. */ + private static final float SQUARE_DISPLAY_DEFAULT_PERCENT = 0.5f; + /** Minimum sizing percentage for square-ish Display. */ + private static final float SQUARE_DISPLAY_MIN_PERCENT = 0.4f; /** Aspect ratio that the new PIP size spec logic optimizes for. */ private static final float OPTIMIZED_ASPECT_RATIO = 9f / 16; - /** A map of aspect ratios to be tested to expected sizes */ - private static Map<Float, Size> sExpectedMaxSizes; - private static Map<Float, Size> sExpectedDefaultSizes; - private static Map<Float, Size> sExpectedMinSizes; - /** A static mockito session object to mock {@link SystemProperties} */ - private static StaticMockitoSession sStaticMockitoSession; + /** Maps of aspect ratios to be tested to expected sizes on non-square Display. */ + private static Map<Float, Size> sNonSquareDisplayExpectedMaxSizes; + private static Map<Float, Size> sNonSquareDisplayExpectedDefaultSizes; + private static Map<Float, Size> sNonSquareDisplayExpectedMinSizes; + + /** Maps of aspect ratios to be tested to expected sizes on square Display. */ + private static Map<Float, Size> sSquareDisplayExpectedMaxSizes; + private static Map<Float, Size> sSquareDisplayExpectedDefaultSizes; + private static Map<Float, Size> sSquareDisplayExpectedMinSizes; @Mock private Context mContext; @Mock private Resources mResources; @@ -80,49 +82,55 @@ public class PhoneSizeSpecSourceTest extends ShellTestCase { private SizeSpecSource mSizeSpecSource; /** - * Sets up static Mockito session for SystemProperties and mocks necessary static methods. + * Initializes the map with the aspect ratios to be tested and corresponding expected max sizes. + * This is to initialize the expectations on non-square Display only. */ - private static void setUpStaticSystemPropertiesSession() { - sStaticMockitoSession = mockitoSession() - .mockStatic(SystemProperties.class).startMocking(); - when(SystemProperties.get(anyString(), anyString())).thenAnswer(invocation -> { - String property = invocation.getArgument(0); - if (property.equals("com.android.wm.shell.pip.phone.def_percentage")) { - return Float.toString(DEFAULT_PERCENT); - } else if (property.equals("com.android.wm.shell.pip.phone.min_percentage")) { - return Float.toString(MIN_PERCENT); - } - - // throw an exception if illegal arguments are used for these tests - throw new InvalidUseOfMatchersException( - String.format("Argument %s does not match", property) - ); - }); + private static void initNonSquareDisplayExpectedSizes() { + sNonSquareDisplayExpectedMaxSizes = new HashMap<>(); + sNonSquareDisplayExpectedDefaultSizes = new HashMap<>(); + sNonSquareDisplayExpectedMinSizes = new HashMap<>(); + + sNonSquareDisplayExpectedMaxSizes.put(16f / 9, new Size(1000, 563)); + sNonSquareDisplayExpectedDefaultSizes.put(16f / 9, new Size(600, 338)); + sNonSquareDisplayExpectedMinSizes.put(16f / 9, new Size(501, 282)); + + sNonSquareDisplayExpectedMaxSizes.put(4f / 3, new Size(893, 670)); + sNonSquareDisplayExpectedDefaultSizes.put(4f / 3, new Size(536, 402)); + sNonSquareDisplayExpectedMinSizes.put(4f / 3, new Size(447, 335)); + + sNonSquareDisplayExpectedMaxSizes.put(3f / 4, new Size(670, 893)); + sNonSquareDisplayExpectedDefaultSizes.put(3f / 4, new Size(402, 536)); + sNonSquareDisplayExpectedMinSizes.put(3f / 4, new Size(335, 447)); + + sNonSquareDisplayExpectedMaxSizes.put(9f / 16, new Size(563, 1001)); + sNonSquareDisplayExpectedDefaultSizes.put(9f / 16, new Size(338, 601)); + sNonSquareDisplayExpectedMinSizes.put(9f / 16, new Size(282, 501)); } /** * Initializes the map with the aspect ratios to be tested and corresponding expected max sizes. + * This is to initialize the expectations on square Display only. */ - private static void initExpectedSizes() { - sExpectedMaxSizes = new HashMap<>(); - sExpectedDefaultSizes = new HashMap<>(); - sExpectedMinSizes = new HashMap<>(); - - sExpectedMaxSizes.put(16f / 9, new Size(1000, 563)); - sExpectedDefaultSizes.put(16f / 9, new Size(600, 338)); - sExpectedMinSizes.put(16f / 9, new Size(501, 282)); - - sExpectedMaxSizes.put(4f / 3, new Size(893, 670)); - sExpectedDefaultSizes.put(4f / 3, new Size(536, 402)); - sExpectedMinSizes.put(4f / 3, new Size(447, 335)); - - sExpectedMaxSizes.put(3f / 4, new Size(670, 893)); - sExpectedDefaultSizes.put(3f / 4, new Size(402, 536)); - sExpectedMinSizes.put(3f / 4, new Size(335, 447)); - - sExpectedMaxSizes.put(9f / 16, new Size(563, 1001)); - sExpectedDefaultSizes.put(9f / 16, new Size(338, 601)); - sExpectedMinSizes.put(9f / 16, new Size(282, 501)); + private static void initSquareDisplayExpectedSizes() { + sSquareDisplayExpectedMaxSizes = new HashMap<>(); + sSquareDisplayExpectedDefaultSizes = new HashMap<>(); + sSquareDisplayExpectedMinSizes = new HashMap<>(); + + sSquareDisplayExpectedMaxSizes.put(16f / 9, new Size(1000, 563)); + sSquareDisplayExpectedDefaultSizes.put(16f / 9, new Size(500, 281)); + sSquareDisplayExpectedMinSizes.put(16f / 9, new Size(400, 225)); + + sSquareDisplayExpectedMaxSizes.put(4f / 3, new Size(893, 670)); + sSquareDisplayExpectedDefaultSizes.put(4f / 3, new Size(447, 335)); + sSquareDisplayExpectedMinSizes.put(4f / 3, new Size(357, 268)); + + sSquareDisplayExpectedMaxSizes.put(3f / 4, new Size(670, 893)); + sSquareDisplayExpectedDefaultSizes.put(3f / 4, new Size(335, 447)); + sSquareDisplayExpectedMinSizes.put(3f / 4, new Size(268, 357)); + + sSquareDisplayExpectedMaxSizes.put(9f / 16, new Size(563, 1001)); + sSquareDisplayExpectedDefaultSizes.put(9f / 16, new Size(282, 501)); + sSquareDisplayExpectedMinSizes.put(9f / 16, new Size(225, 400)); } private void forEveryTestCaseCheck(Map<Float, Size> expectedSizes, @@ -137,20 +145,38 @@ public class PhoneSizeSpecSourceTest extends ShellTestCase { @Before public void setUp() { - initExpectedSizes(); - - when(mResources.getDimensionPixelSize(anyInt())).thenReturn(DEFAULT_MIN_EDGE_SIZE); - when(mResources.getFloat(anyInt())).thenReturn(OPTIMIZED_ASPECT_RATIO); - when(mResources.getString(anyInt())).thenReturn("0x0"); + initNonSquareDisplayExpectedSizes(); + initSquareDisplayExpectedSizes(); + + when(mResources.getFloat(R.dimen.config_pipSystemPreferredDefaultSizePercent)) + .thenReturn(DEFAULT_PERCENT); + when(mResources.getFloat(R.dimen.config_pipSystemPreferredMinimumSizePercent)) + .thenReturn(MIN_PERCENT); + when(mResources.getDimensionPixelSize(R.dimen.default_minimal_size_pip_resizable_task)) + .thenReturn(DEFAULT_MIN_EDGE_SIZE); + when(mResources.getFloat(R.dimen.config_pipLargeScreenOptimizedAspectRatio)) + .thenReturn(OPTIMIZED_ASPECT_RATIO); + when(mResources.getString(R.string.config_defaultPictureInPictureScreenEdgeInsets)) + .thenReturn("0x0"); when(mResources.getDisplayMetrics()) .thenReturn(getContext().getResources().getDisplayMetrics()); + when(mResources.getFloat(R.dimen.config_pipSquareDisplayThresholdForSystemPreferredSize)) + .thenReturn(SQUARE_DISPLAY_THRESHOLD); + when(mResources.getFloat( + R.dimen.config_pipSystemPreferredDefaultSizePercentForSquareDisplay)) + .thenReturn(SQUARE_DISPLAY_DEFAULT_PERCENT); + when(mResources.getFloat( + R.dimen.config_pipSystemPreferredMinimumSizePercentForSquareDisplay)) + .thenReturn(SQUARE_DISPLAY_MIN_PERCENT); // set up the mock context for spec handler specifically when(mContext.getResources()).thenReturn(mResources); + } + private void setupSizeSpecWithDisplayDimension(int width, int height) { DisplayInfo displayInfo = new DisplayInfo(); - displayInfo.logicalWidth = DISPLAY_EDGE_SIZE; - displayInfo.logicalHeight = DISPLAY_EDGE_SIZE; + displayInfo.logicalWidth = width; + displayInfo.logicalHeight = height; // use the parent context (not the mocked one) to obtain the display layout // this is done to avoid unnecessary mocking while allowing for custom display dimensions @@ -159,38 +185,57 @@ public class PhoneSizeSpecSourceTest extends ShellTestCase { mPipDisplayLayoutState = new PipDisplayLayoutState(mContext); mPipDisplayLayoutState.setDisplayLayout(displayLayout); - setUpStaticSystemPropertiesSession(); mSizeSpecSource = new PhoneSizeSpecSource(mContext, mPipDisplayLayoutState); // no overridden min edge size by default mSizeSpecSource.setOverrideMinSize(null); } - @After - public void cleanUp() { - sStaticMockitoSession.finishMocking(); + @Test + public void testGetMaxSize_nonSquareDisplay() { + setupSizeSpecWithDisplayDimension(DISPLAY_EDGE_SIZE * 2, DISPLAY_EDGE_SIZE); + forEveryTestCaseCheck(sNonSquareDisplayExpectedMaxSizes, + (aspectRatio) -> mSizeSpecSource.getMaxSize(aspectRatio)); + } + + @Test + public void testGetDefaultSize_nonSquareDisplay() { + setupSizeSpecWithDisplayDimension(DISPLAY_EDGE_SIZE * 2, DISPLAY_EDGE_SIZE); + forEveryTestCaseCheck(sNonSquareDisplayExpectedDefaultSizes, + (aspectRatio) -> mSizeSpecSource.getDefaultSize(aspectRatio)); + } + + @Test + public void testGetMinSize_nonSquareDisplay() { + setupSizeSpecWithDisplayDimension(DISPLAY_EDGE_SIZE * 2, DISPLAY_EDGE_SIZE); + forEveryTestCaseCheck(sNonSquareDisplayExpectedMinSizes, + (aspectRatio) -> mSizeSpecSource.getMinSize(aspectRatio)); } @Test - public void testGetMaxSize() { - forEveryTestCaseCheck(sExpectedMaxSizes, + public void testGetMaxSize_squareDisplay() { + setupSizeSpecWithDisplayDimension(DISPLAY_EDGE_SIZE, DISPLAY_EDGE_SIZE); + forEveryTestCaseCheck(sSquareDisplayExpectedMaxSizes, (aspectRatio) -> mSizeSpecSource.getMaxSize(aspectRatio)); } @Test - public void testGetDefaultSize() { - forEveryTestCaseCheck(sExpectedDefaultSizes, + public void testGetDefaultSize_squareDisplay() { + setupSizeSpecWithDisplayDimension(DISPLAY_EDGE_SIZE, DISPLAY_EDGE_SIZE); + forEveryTestCaseCheck(sSquareDisplayExpectedDefaultSizes, (aspectRatio) -> mSizeSpecSource.getDefaultSize(aspectRatio)); } @Test - public void testGetMinSize() { - forEveryTestCaseCheck(sExpectedMinSizes, + public void testGetMinSize_squareDisplay() { + setupSizeSpecWithDisplayDimension(DISPLAY_EDGE_SIZE, DISPLAY_EDGE_SIZE); + forEveryTestCaseCheck(sSquareDisplayExpectedMinSizes, (aspectRatio) -> mSizeSpecSource.getMinSize(aspectRatio)); } @Test public void testGetSizeForAspectRatio_noOverrideMinSize() { + setupSizeSpecWithDisplayDimension(DISPLAY_EDGE_SIZE * 2, DISPLAY_EDGE_SIZE); // an initial size with 16:9 aspect ratio Size initSize = new Size(600, 337); @@ -202,6 +247,7 @@ public class PhoneSizeSpecSourceTest extends ShellTestCase { @Test public void testGetSizeForAspectRatio_withOverrideMinSize() { + setupSizeSpecWithDisplayDimension(DISPLAY_EDGE_SIZE * 2, DISPLAY_EDGE_SIZE); // an initial size with a 1:1 aspect ratio Size initSize = new Size(OVERRIDE_MIN_EDGE_SIZE, OVERRIDE_MIN_EDGE_SIZE); mSizeSpecSource.setOverrideMinSize(initSize); diff --git a/libs/hwui/Android.bp b/libs/hwui/Android.bp index 341c3e8cf373..02fa5f2608ab 100644 --- a/libs/hwui/Android.bp +++ b/libs/hwui/Android.bp @@ -31,6 +31,7 @@ license { aconfig_declarations { name: "hwui_flags", package: "com.android.graphics.hwui.flags", + container: "system", srcs: [ "aconfig/hwui_flags.aconfig", ], diff --git a/libs/hwui/aconfig/hwui_flags.aconfig b/libs/hwui/aconfig/hwui_flags.aconfig index 659bcdc6852d..50f8b3929e1e 100644 --- a/libs/hwui/aconfig/hwui_flags.aconfig +++ b/libs/hwui/aconfig/hwui_flags.aconfig @@ -1,4 +1,5 @@ package: "com.android.graphics.hwui.flags" +container: "system" flag { name: "clip_shader" |