Merge "Compare min width/height with the longest screen side" into sc-dev am: 58854f38cc

Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15123858

Change-Id: I4fdd1fe3279d01e0cd661e3900e9f6b9650653f8
This commit is contained in:
Chris Li
2021-06-28 01:42:31 +00:00
committed by Automerger Merge Worker
6 changed files with 89 additions and 22 deletions

View File

@@ -3587,13 +3587,21 @@
--> -->
<integer name="config_respectsActivityMinWidthHeightMultiWindow">0</integer> <integer name="config_respectsActivityMinWidthHeightMultiWindow">0</integer>
<!-- This value is only used when the device checks activity min width/height to determine if it <!-- This value is only used when the device checks activity min height to determine if it
can be shown in multi windowing modes. can be shown in multi windowing modes.
If the activity min width/height is greater than this percentage of the display smallest If the activity min height is greater than this percentage of the display height in
width, it will not be allowed to be shown in multi windowing modes. portrait, it will not be allowed to be shown in multi windowing modes.
The value should be between [0 - 1]. The value should be between [0 - 1].
--> -->
<item name="config_minPercentageMultiWindowSupportWidth" format="float" type="dimen">0.3</item> <item name="config_minPercentageMultiWindowSupportHeight" format="float" type="dimen">0.3</item>
<!-- This value is only used when the device checks activity min width to determine if it
can be shown in multi windowing modes.
If the activity min width is greater than this percentage of the display width in
landscape, it will not be allowed to be shown in multi windowing modes.
The value should be between [0 - 1].
-->
<item name="config_minPercentageMultiWindowSupportWidth" format="float" type="dimen">0.5</item>
<!-- If the display smallest screen width is greater or equal to this value, we will treat it <!-- If the display smallest screen width is greater or equal to this value, we will treat it
as a large screen device, which will have some multi window features enabled by default. as a large screen device, which will have some multi window features enabled by default.

View File

@@ -395,6 +395,7 @@
<java-symbol type="bool" name="config_supportsMultiDisplay" /> <java-symbol type="bool" name="config_supportsMultiDisplay" />
<java-symbol type="integer" name="config_supportsNonResizableMultiWindow" /> <java-symbol type="integer" name="config_supportsNonResizableMultiWindow" />
<java-symbol type="integer" name="config_respectsActivityMinWidthHeightMultiWindow" /> <java-symbol type="integer" name="config_respectsActivityMinWidthHeightMultiWindow" />
<java-symbol type="dimen" name="config_minPercentageMultiWindowSupportHeight" />
<java-symbol type="dimen" name="config_minPercentageMultiWindowSupportWidth" /> <java-symbol type="dimen" name="config_minPercentageMultiWindowSupportWidth" />
<java-symbol type="integer" name="config_largeScreenSmallestScreenWidthDp" /> <java-symbol type="integer" name="config_largeScreenSmallestScreenWidthDp" />
<java-symbol type="bool" name="config_useLegacySplit" /> <java-symbol type="bool" name="config_useLegacySplit" />

View File

@@ -580,19 +580,28 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
* windowing modes. * windowing modes.
* 0: If it is a small screen (smallest width < {@link #mLargeScreenSmallestScreenWidthDp}), * 0: If it is a small screen (smallest width < {@link #mLargeScreenSmallestScreenWidthDp}),
* the device compares the activity min width/height with the min multi windowing modes * the device compares the activity min width/height with the min multi windowing modes
* dimensions {@link #mMinPercentageMultiWindowSupportWidth} the device supports to * dimensions {@link #mMinPercentageMultiWindowSupportHeight} the device supports to
* determine whether the activity can be shown in multi windowing modes * determine whether the activity can be shown in multi windowing modes
* 1: The device always compare the activity min width/height with the min multi windowing * 1: The device always compare the activity min width/height with the min multi windowing
* modes dimensions {@link #mMinPercentageMultiWindowSupportWidth} the device supports to * modes dimensions {@link #mMinPercentageMultiWindowSupportHeight} the device supports to
* determine whether it can be shown in multi windowing modes. * determine whether it can be shown in multi windowing modes.
*/ */
int mRespectsActivityMinWidthHeightMultiWindow; int mRespectsActivityMinWidthHeightMultiWindow;
/** /**
* This value is only used when the device checks activity min width/height to determine if it * This value is only used when the device checks activity min height to determine if it
* can be shown in multi windowing modes. * can be shown in multi windowing modes.
* If the activity min width/height is greater than this percentage of the display smallest * If the activity min height is greater than this percentage of the display height in portrait,
* width, it will not be allowed to be shown in multi windowing modes. * it will not be allowed to be shown in multi windowing modes.
* The value should be between [0 - 1].
*/
float mMinPercentageMultiWindowSupportHeight;
/**
* This value is only used when the device checks activity min width to determine if it
* can be shown in multi windowing modes.
* If the activity min width is greater than this percentage of the display width in landscape,
* it will not be allowed to be shown in multi windowing modes.
* The value should be between [0 - 1]. * The value should be between [0 - 1].
*/ */
float mMinPercentageMultiWindowSupportWidth; float mMinPercentageMultiWindowSupportWidth;
@@ -840,6 +849,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
com.android.internal.R.integer.config_supportsNonResizableMultiWindow); com.android.internal.R.integer.config_supportsNonResizableMultiWindow);
final int respectsActivityMinWidthHeightMultiWindow = mContext.getResources().getInteger( final int respectsActivityMinWidthHeightMultiWindow = mContext.getResources().getInteger(
com.android.internal.R.integer.config_respectsActivityMinWidthHeightMultiWindow); com.android.internal.R.integer.config_respectsActivityMinWidthHeightMultiWindow);
final float minPercentageMultiWindowSupportHeight = mContext.getResources().getFloat(
com.android.internal.R.dimen.config_minPercentageMultiWindowSupportHeight);
final float minPercentageMultiWindowSupportWidth = mContext.getResources().getFloat( final float minPercentageMultiWindowSupportWidth = mContext.getResources().getFloat(
com.android.internal.R.dimen.config_minPercentageMultiWindowSupportWidth); com.android.internal.R.dimen.config_minPercentageMultiWindowSupportWidth);
final int largeScreenSmallestScreenWidthDp = mContext.getResources().getInteger( final int largeScreenSmallestScreenWidthDp = mContext.getResources().getInteger(
@@ -860,6 +871,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
mDevEnableNonResizableMultiWindow = devEnableNonResizableMultiWindow; mDevEnableNonResizableMultiWindow = devEnableNonResizableMultiWindow;
mSupportsNonResizableMultiWindow = supportsNonResizableMultiWindow; mSupportsNonResizableMultiWindow = supportsNonResizableMultiWindow;
mRespectsActivityMinWidthHeightMultiWindow = respectsActivityMinWidthHeightMultiWindow; mRespectsActivityMinWidthHeightMultiWindow = respectsActivityMinWidthHeightMultiWindow;
mMinPercentageMultiWindowSupportHeight = minPercentageMultiWindowSupportHeight;
mMinPercentageMultiWindowSupportWidth = minPercentageMultiWindowSupportWidth; mMinPercentageMultiWindowSupportWidth = minPercentageMultiWindowSupportWidth;
mLargeScreenSmallestScreenWidthDp = largeScreenSmallestScreenWidthDp; mLargeScreenSmallestScreenWidthDp = largeScreenSmallestScreenWidthDp;
final boolean multiWindowFormEnabled = freeformWindowManagement final boolean multiWindowFormEnabled = freeformWindowManagement

View File

@@ -31,6 +31,7 @@ import static android.content.Intent.FLAG_ACTIVITY_LAUNCH_ADJACENT;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_BEHIND; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_BEHIND;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSET;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED; import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_ORIENTATION; import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_ORIENTATION;
import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_STATES; import static com.android.internal.protolog.ProtoLogGroup.WM_DEBUG_STATES;
@@ -44,6 +45,7 @@ import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
import android.annotation.Nullable; import android.annotation.Nullable;
import android.app.ActivityOptions; import android.app.ActivityOptions;
import android.app.WindowConfiguration; import android.app.WindowConfiguration;
import android.content.res.Configuration;
import android.os.UserHandle; import android.os.UserHandle;
import android.util.IntArray; import android.util.IntArray;
import android.util.Slog; import android.util.Slog;
@@ -1705,10 +1707,18 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> {
return true; return true;
} }
// Check if the request min width/height is supported in multi window. // Check if the request min width/height is supported in multi window.
final int maxSupportMinDimensions = (int) (mAtmService.mMinPercentageMultiWindowSupportWidth final Configuration config = getConfiguration();
* getConfiguration().smallestScreenWidthDp final int orientation = config.orientation;
* mDisplayContent.getDisplayMetrics().density); if (orientation == ORIENTATION_LANDSCAPE) {
return minWidth <= maxSupportMinDimensions && minHeight <= maxSupportMinDimensions; final int maxSupportMinWidth = (int) (mAtmService.mMinPercentageMultiWindowSupportWidth
* config.screenWidthDp * mDisplayContent.getDisplayMetrics().density);
return minWidth <= maxSupportMinWidth;
} else {
final int maxSupportMinHeight =
(int) (mAtmService.mMinPercentageMultiWindowSupportHeight
* config.screenHeightDp * mDisplayContent.getDisplayMetrics().density);
return minHeight <= maxSupportMinHeight;
}
} }
/** /**

View File

@@ -18,6 +18,8 @@ package com.android.server.wm;
import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE; import static android.content.pm.ActivityInfo.RESIZE_MODE_RESIZEABLE;
import static android.content.pm.ActivityInfo.RESIZE_MODE_UNRESIZEABLE; import static android.content.pm.ActivityInfo.RESIZE_MODE_UNRESIZEABLE;
import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
import static android.content.res.Configuration.ORIENTATION_PORTRAIT;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.any; import static com.android.dx.mockito.inline.extended.ExtendedMockito.any;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn; import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
@@ -407,16 +409,16 @@ public class ActivityTaskManagerServiceTests extends WindowTestsBase {
} }
@Test @Test
public void testSupportsMultiWindow_activityMinWidthHeight_smallerThanSupport() { public void testSupportsMultiWindow_landscape_checkActivityMinWidth() {
// This is smaller than the min dimensions device support in multi window, // This is smaller than the min dimensions device support in multi window,
// the activity will be supported in multi window // the activity will be supported in multi window
final float density = mContext.getResources().getDisplayMetrics().density; final float density = mContext.getResources().getDisplayMetrics().density;
final int supportedDimensions = (int) ((mAtm.mLargeScreenSmallestScreenWidthDp - 1) final int supportedWidth = (int) (mAtm.mLargeScreenSmallestScreenWidthDp
* mAtm.mMinPercentageMultiWindowSupportWidth * density); * mAtm.mMinPercentageMultiWindowSupportWidth * density);
final ActivityInfo.WindowLayout windowLayout = final ActivityInfo.WindowLayout windowLayout =
new ActivityInfo.WindowLayout(0, 0, 0, 0, 0, new ActivityInfo.WindowLayout(0, 0, 0, 0, 0,
/* minWidth= */supportedDimensions, /* minWidth= */ supportedWidth,
/* minHeight= */supportedDimensions); /* minHeight= */ 0);
final ActivityRecord activity = new ActivityBuilder(mAtm) final ActivityRecord activity = new ActivityBuilder(mAtm)
.setCreateTask(true) .setCreateTask(true)
.setWindowLayout(windowLayout) .setWindowLayout(windowLayout)
@@ -425,15 +427,48 @@ public class ActivityTaskManagerServiceTests extends WindowTestsBase {
final Task task = activity.getTask(); final Task task = activity.getTask();
final TaskDisplayArea tda = task.getDisplayArea(); final TaskDisplayArea tda = task.getDisplayArea();
tda.getConfiguration().smallestScreenWidthDp = mAtm.mLargeScreenSmallestScreenWidthDp - 1; tda.getConfiguration().smallestScreenWidthDp = mAtm.mLargeScreenSmallestScreenWidthDp - 1;
tda.getConfiguration().screenWidthDp = mAtm.mLargeScreenSmallestScreenWidthDp - 1;
tda.getConfiguration().orientation = ORIENTATION_LANDSCAPE;
// Always check the activity min width/height. assertFalse(activity.supportsMultiWindow());
mAtm.mSupportsNonResizableMultiWindow = 1; assertFalse(task.supportsMultiWindow());
tda.getConfiguration().screenWidthDp = (int) Math.ceil(
mAtm.mLargeScreenSmallestScreenWidthDp
/ mAtm.mMinPercentageMultiWindowSupportWidth);
assertTrue(activity.supportsMultiWindow()); assertTrue(activity.supportsMultiWindow());
assertTrue(task.supportsMultiWindow()); assertTrue(task.supportsMultiWindow());
}
// The default config is relying on the screen size. Check for small screen @Test
mAtm.mSupportsNonResizableMultiWindow = 0; public void testSupportsMultiWindow_portrait_checkActivityMinHeight() {
// This is smaller than the min dimensions device support in multi window,
// the activity will be supported in multi window
final float density = mContext.getResources().getDisplayMetrics().density;
final int supportedHeight = (int) (mAtm.mLargeScreenSmallestScreenWidthDp
* mAtm.mMinPercentageMultiWindowSupportHeight * density);
final ActivityInfo.WindowLayout windowLayout =
new ActivityInfo.WindowLayout(0, 0, 0, 0, 0,
/* minWidth= */ 0,
/* minHeight= */ supportedHeight);
final ActivityRecord activity = new ActivityBuilder(mAtm)
.setCreateTask(true)
.setWindowLayout(windowLayout)
.setResizeMode(RESIZE_MODE_RESIZEABLE)
.build();
final Task task = activity.getTask();
final TaskDisplayArea tda = task.getDisplayArea();
tda.getConfiguration().smallestScreenWidthDp = mAtm.mLargeScreenSmallestScreenWidthDp - 1;
tda.getConfiguration().screenHeightDp = mAtm.mLargeScreenSmallestScreenWidthDp - 1;
tda.getConfiguration().orientation = ORIENTATION_PORTRAIT;
assertFalse(activity.supportsMultiWindow());
assertFalse(task.supportsMultiWindow());
tda.getConfiguration().screenHeightDp = (int) Math.ceil(
mAtm.mLargeScreenSmallestScreenWidthDp
/ mAtm.mMinPercentageMultiWindowSupportHeight);
assertTrue(activity.supportsMultiWindow()); assertTrue(activity.supportsMultiWindow());
assertTrue(task.supportsMultiWindow()); assertTrue(task.supportsMultiWindow());

View File

@@ -484,7 +484,8 @@ public class SystemServicesTestRule implements TestRule {
mSupportsFreeformWindowManagement = true; mSupportsFreeformWindowManagement = true;
mSupportsPictureInPicture = true; mSupportsPictureInPicture = true;
mDevEnableNonResizableMultiWindow = false; mDevEnableNonResizableMultiWindow = false;
mMinPercentageMultiWindowSupportWidth = 0.3f; mMinPercentageMultiWindowSupportHeight = 0.3f;
mMinPercentageMultiWindowSupportWidth = 0.5f;
mLargeScreenSmallestScreenWidthDp = 600; mLargeScreenSmallestScreenWidthDp = 600;
mSupportsNonResizableMultiWindow = 0; mSupportsNonResizableMultiWindow = 0;
mRespectsActivityMinWidthHeightMultiWindow = 0; mRespectsActivityMinWidthHeightMultiWindow = 0;