Restrict the overridden min size for PiP

Per go/cdd-proposal-pip-size, the absolute minimum size when overridden
should be 48dp.

Bug: 174302616
Test: atest PinnedStackTests#testEnterPipWithTinyMinimalSize \
            WMShellUnitTests:com.android.wm.shell.pip
Merged-In: I2f0dfd9a79049aaf696fde8703994deaecce63f5
Change-Id: I2f0dfd9a79049aaf696fde8703994deaecce63f5
This commit is contained in:
Hongwei Wang
2021-03-02 09:21:22 -08:00
parent a1649935f1
commit 8c51113135
4 changed files with 18 additions and 5 deletions

View File

@@ -690,6 +690,13 @@
<!-- The default minimal size of a PiP task, in both dimensions. -->
<dimen name="default_minimal_size_pip_resizable_task">108dp</dimen>
<!--
The overridable minimal size of a PiP task, in both dimensions.
Different from default_minimal_size_pip_resizable_task, this is to limit the dimension
when the pinned stack size is overridden by app via minWidth/minHeight.
-->
<dimen name="overridable_minimal_size_pip_resizable_task">48dp</dimen>
<!-- Height of a task when in minimized mode from the top when launcher is resizable. -->
<dimen name="task_height_of_minimized_mode">80dp</dimen>

View File

@@ -1948,6 +1948,7 @@
<java-symbol type="fraction" name="config_dimBehindFadeDuration" />
<java-symbol type="dimen" name="default_minimal_size_resizable_task" />
<java-symbol type="dimen" name="default_minimal_size_pip_resizable_task" />
<java-symbol type="dimen" name="overridable_minimal_size_pip_resizable_task" />
<java-symbol type="dimen" name="task_height_of_minimized_mode" />
<java-symbol type="fraction" name="config_screenAutoBrightnessDozeScaleFactor" />
<java-symbol type="bool" name="config_allowPriorityVibrationsInLowPowerMode" />

View File

@@ -54,6 +54,7 @@ public class PipBoundsAlgorithm {
private float mMaxAspectRatio;
private int mDefaultStackGravity;
private int mDefaultMinSize;
private int mOverridableMinSize;
private Point mScreenEdgeInsets;
public PipBoundsAlgorithm(Context context, @NonNull PipBoundsState pipBoundsState) {
@@ -78,6 +79,8 @@ public class PipBoundsAlgorithm {
com.android.internal.R.integer.config_defaultPictureInPictureGravity);
mDefaultMinSize = res.getDimensionPixelSize(
com.android.internal.R.dimen.default_minimal_size_pip_resizable_task);
mOverridableMinSize = res.getDimensionPixelSize(
com.android.internal.R.dimen.overridable_minimal_size_pip_resizable_task);
final String screenEdgeInsetsDpString = res.getString(
com.android.internal.R.string.config_defaultPictureInPictureScreenEdgeInsets);
final Size screenEdgeInsetsDp = !screenEdgeInsetsDpString.isEmpty()
@@ -155,7 +158,10 @@ public class PipBoundsAlgorithm {
// -1 will be populated if an activity specifies defaultWidth/defaultHeight in <layout>
// without minWidth/minHeight
if (windowLayout.minWidth > 0 && windowLayout.minHeight > 0) {
return new Size(windowLayout.minWidth, windowLayout.minHeight);
// If either dimension is smaller than the allowed minimum, adjust them
// according to mOverridableMinSize
return new Size(Math.max(windowLayout.minWidth, mOverridableMinSize),
Math.max(windowLayout.minHeight, mOverridableMinSize));
}
return null;
}

View File

@@ -43,7 +43,6 @@ import com.android.wm.shell.ShellTestCase;
import com.android.wm.shell.TestShellExecutor;
import com.android.wm.shell.common.DisplayController;
import com.android.wm.shell.common.DisplayLayout;
import com.android.wm.shell.legacysplitscreen.LegacySplitScreen;
import com.android.wm.shell.legacysplitscreen.LegacySplitScreenController;
import com.android.wm.shell.pip.phone.PhonePipMenuController;
@@ -125,7 +124,7 @@ public class PipTaskOrganizerTest extends ShellTestCase {
@Test
public void startSwipePipToHome_updatesOverrideMinSize() {
final Size minSize = new Size(100, 80);
final Size minSize = new Size(400, 320);
mSpiedPipTaskOrganizer.startSwipePipToHome(mComponent1, createActivityInfo(minSize),
createPipParams(null));
@@ -153,7 +152,7 @@ public class PipTaskOrganizerTest extends ShellTestCase {
@Test
public void onTaskAppeared_updatesOverrideMinSize() {
final Size minSize = new Size(100, 80);
final Size minSize = new Size(400, 320);
mSpiedPipTaskOrganizer.onTaskAppeared(
createTaskInfo(mComponent1, createPipParams(null), minSize),
@@ -191,7 +190,7 @@ public class PipTaskOrganizerTest extends ShellTestCase {
mSpiedPipTaskOrganizer.onTaskAppeared(createTaskInfo(mComponent1,
createPipParams(null)), null /* leash */);
final Size minSize = new Size(100, 80);
final Size minSize = new Size(400, 320);
mSpiedPipTaskOrganizer.onTaskInfoChanged(createTaskInfo(mComponent2,
createPipParams(null), minSize));