Loading core/res/res/values/config.xml +12 −4 Original line number Diff line number Diff line Loading @@ -3587,13 +3587,21 @@ --> <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. If the activity min width/height is greater than this percentage of the display smallest width, it will not be allowed to be shown in multi windowing modes. If the activity min height is greater than this percentage of the display height in portrait, 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.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 as a large screen device, which will have some multi window features enabled by default. Loading core/res/res/values/symbols.xml +1 −0 Original line number Diff line number Diff line Loading @@ -395,6 +395,7 @@ <java-symbol type="bool" name="config_supportsMultiDisplay" /> <java-symbol type="integer" name="config_supportsNonResizableMultiWindow" /> <java-symbol type="integer" name="config_respectsActivityMinWidthHeightMultiWindow" /> <java-symbol type="dimen" name="config_minPercentageMultiWindowSupportHeight" /> <java-symbol type="dimen" name="config_minPercentageMultiWindowSupportWidth" /> <java-symbol type="integer" name="config_largeScreenSmallestScreenWidthDp" /> <java-symbol type="bool" name="config_useLegacySplit" /> Loading services/core/java/com/android/server/wm/ActivityTaskManagerService.java +17 −5 Original line number Diff line number Diff line Loading @@ -580,19 +580,28 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { * windowing modes. * 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 * 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 * 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. */ 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. * If the activity min width/height is greater than this percentage of the display smallest * width, it will not be allowed to be shown in multi windowing modes. * If the activity min height is greater than this percentage of the display height in portrait, * 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]. */ float mMinPercentageMultiWindowSupportWidth; Loading Loading @@ -840,6 +849,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { com.android.internal.R.integer.config_supportsNonResizableMultiWindow); final int respectsActivityMinWidthHeightMultiWindow = mContext.getResources().getInteger( 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( com.android.internal.R.dimen.config_minPercentageMultiWindowSupportWidth); final int largeScreenSmallestScreenWidthDp = mContext.getResources().getInteger( Loading @@ -860,6 +871,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { mDevEnableNonResizableMultiWindow = devEnableNonResizableMultiWindow; mSupportsNonResizableMultiWindow = supportsNonResizableMultiWindow; mRespectsActivityMinWidthHeightMultiWindow = respectsActivityMinWidthHeightMultiWindow; mMinPercentageMultiWindowSupportHeight = minPercentageMultiWindowSupportHeight; mMinPercentageMultiWindowSupportWidth = minPercentageMultiWindowSupportWidth; mLargeScreenSmallestScreenWidthDp = largeScreenSmallestScreenWidthDp; final boolean multiWindowFormEnabled = freeformWindowManagement Loading services/core/java/com/android/server/wm/TaskDisplayArea.java +14 −4 Original line number Diff line number Diff line Loading @@ -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_UNSET; 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_STATES; Loading @@ -44,6 +45,7 @@ import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; import android.annotation.Nullable; import android.app.ActivityOptions; import android.app.WindowConfiguration; import android.content.res.Configuration; import android.os.UserHandle; import android.util.IntArray; import android.util.Slog; Loading Loading @@ -1705,10 +1707,18 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> { return true; } // Check if the request min width/height is supported in multi window. final int maxSupportMinDimensions = (int) (mAtmService.mMinPercentageMultiWindowSupportWidth * getConfiguration().smallestScreenWidthDp * mDisplayContent.getDisplayMetrics().density); return minWidth <= maxSupportMinDimensions && minHeight <= maxSupportMinDimensions; final Configuration config = getConfiguration(); final int orientation = config.orientation; if (orientation == ORIENTATION_LANDSCAPE) { 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; } } /** Loading services/tests/wmtests/src/com/android/server/wm/ActivityTaskManagerServiceTests.java +43 −8 Original line number Diff line number Diff line Loading @@ -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_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.doReturn; Loading Loading @@ -407,16 +409,16 @@ public class ActivityTaskManagerServiceTests extends WindowTestsBase { } @Test public void testSupportsMultiWindow_activityMinWidthHeight_smallerThanSupport() { public void testSupportsMultiWindow_landscape_checkActivityMinWidth() { // 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 supportedDimensions = (int) ((mAtm.mLargeScreenSmallestScreenWidthDp - 1) final int supportedWidth = (int) (mAtm.mLargeScreenSmallestScreenWidthDp * mAtm.mMinPercentageMultiWindowSupportWidth * density); final ActivityInfo.WindowLayout windowLayout = new ActivityInfo.WindowLayout(0, 0, 0, 0, 0, /* minWidth= */supportedDimensions, /* minHeight= */supportedDimensions); /* minWidth= */ supportedWidth, /* minHeight= */ 0); final ActivityRecord activity = new ActivityBuilder(mAtm) .setCreateTask(true) .setWindowLayout(windowLayout) Loading @@ -425,15 +427,48 @@ public class ActivityTaskManagerServiceTests extends WindowTestsBase { final Task task = activity.getTask(); final TaskDisplayArea tda = task.getDisplayArea(); tda.getConfiguration().smallestScreenWidthDp = mAtm.mLargeScreenSmallestScreenWidthDp - 1; tda.getConfiguration().screenWidthDp = mAtm.mLargeScreenSmallestScreenWidthDp - 1; tda.getConfiguration().orientation = ORIENTATION_LANDSCAPE; // Always check the activity min width/height. mAtm.mSupportsNonResizableMultiWindow = 1; assertFalse(activity.supportsMultiWindow()); assertFalse(task.supportsMultiWindow()); tda.getConfiguration().screenWidthDp = (int) Math.ceil( mAtm.mLargeScreenSmallestScreenWidthDp / mAtm.mMinPercentageMultiWindowSupportWidth); assertTrue(activity.supportsMultiWindow()); assertTrue(task.supportsMultiWindow()); } // The default config is relying on the screen size. Check for small screen mAtm.mSupportsNonResizableMultiWindow = 0; @Test 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(task.supportsMultiWindow()); Loading Loading
core/res/res/values/config.xml +12 −4 Original line number Diff line number Diff line Loading @@ -3587,13 +3587,21 @@ --> <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. If the activity min width/height is greater than this percentage of the display smallest width, it will not be allowed to be shown in multi windowing modes. If the activity min height is greater than this percentage of the display height in portrait, 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.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 as a large screen device, which will have some multi window features enabled by default. Loading
core/res/res/values/symbols.xml +1 −0 Original line number Diff line number Diff line Loading @@ -395,6 +395,7 @@ <java-symbol type="bool" name="config_supportsMultiDisplay" /> <java-symbol type="integer" name="config_supportsNonResizableMultiWindow" /> <java-symbol type="integer" name="config_respectsActivityMinWidthHeightMultiWindow" /> <java-symbol type="dimen" name="config_minPercentageMultiWindowSupportHeight" /> <java-symbol type="dimen" name="config_minPercentageMultiWindowSupportWidth" /> <java-symbol type="integer" name="config_largeScreenSmallestScreenWidthDp" /> <java-symbol type="bool" name="config_useLegacySplit" /> Loading
services/core/java/com/android/server/wm/ActivityTaskManagerService.java +17 −5 Original line number Diff line number Diff line Loading @@ -580,19 +580,28 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { * windowing modes. * 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 * 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 * 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. */ 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. * If the activity min width/height is greater than this percentage of the display smallest * width, it will not be allowed to be shown in multi windowing modes. * If the activity min height is greater than this percentage of the display height in portrait, * 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]. */ float mMinPercentageMultiWindowSupportWidth; Loading Loading @@ -840,6 +849,8 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { com.android.internal.R.integer.config_supportsNonResizableMultiWindow); final int respectsActivityMinWidthHeightMultiWindow = mContext.getResources().getInteger( 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( com.android.internal.R.dimen.config_minPercentageMultiWindowSupportWidth); final int largeScreenSmallestScreenWidthDp = mContext.getResources().getInteger( Loading @@ -860,6 +871,7 @@ public class ActivityTaskManagerService extends IActivityTaskManager.Stub { mDevEnableNonResizableMultiWindow = devEnableNonResizableMultiWindow; mSupportsNonResizableMultiWindow = supportsNonResizableMultiWindow; mRespectsActivityMinWidthHeightMultiWindow = respectsActivityMinWidthHeightMultiWindow; mMinPercentageMultiWindowSupportHeight = minPercentageMultiWindowSupportHeight; mMinPercentageMultiWindowSupportWidth = minPercentageMultiWindowSupportWidth; mLargeScreenSmallestScreenWidthDp = largeScreenSmallestScreenWidthDp; final boolean multiWindowFormEnabled = freeformWindowManagement Loading
services/core/java/com/android/server/wm/TaskDisplayArea.java +14 −4 Original line number Diff line number Diff line Loading @@ -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_UNSET; 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_STATES; Loading @@ -44,6 +45,7 @@ import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM; import android.annotation.Nullable; import android.app.ActivityOptions; import android.app.WindowConfiguration; import android.content.res.Configuration; import android.os.UserHandle; import android.util.IntArray; import android.util.Slog; Loading Loading @@ -1705,10 +1707,18 @@ final class TaskDisplayArea extends DisplayArea<WindowContainer> { return true; } // Check if the request min width/height is supported in multi window. final int maxSupportMinDimensions = (int) (mAtmService.mMinPercentageMultiWindowSupportWidth * getConfiguration().smallestScreenWidthDp * mDisplayContent.getDisplayMetrics().density); return minWidth <= maxSupportMinDimensions && minHeight <= maxSupportMinDimensions; final Configuration config = getConfiguration(); final int orientation = config.orientation; if (orientation == ORIENTATION_LANDSCAPE) { 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; } } /** Loading
services/tests/wmtests/src/com/android/server/wm/ActivityTaskManagerServiceTests.java +43 −8 Original line number Diff line number Diff line Loading @@ -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_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.doReturn; Loading Loading @@ -407,16 +409,16 @@ public class ActivityTaskManagerServiceTests extends WindowTestsBase { } @Test public void testSupportsMultiWindow_activityMinWidthHeight_smallerThanSupport() { public void testSupportsMultiWindow_landscape_checkActivityMinWidth() { // 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 supportedDimensions = (int) ((mAtm.mLargeScreenSmallestScreenWidthDp - 1) final int supportedWidth = (int) (mAtm.mLargeScreenSmallestScreenWidthDp * mAtm.mMinPercentageMultiWindowSupportWidth * density); final ActivityInfo.WindowLayout windowLayout = new ActivityInfo.WindowLayout(0, 0, 0, 0, 0, /* minWidth= */supportedDimensions, /* minHeight= */supportedDimensions); /* minWidth= */ supportedWidth, /* minHeight= */ 0); final ActivityRecord activity = new ActivityBuilder(mAtm) .setCreateTask(true) .setWindowLayout(windowLayout) Loading @@ -425,15 +427,48 @@ public class ActivityTaskManagerServiceTests extends WindowTestsBase { final Task task = activity.getTask(); final TaskDisplayArea tda = task.getDisplayArea(); tda.getConfiguration().smallestScreenWidthDp = mAtm.mLargeScreenSmallestScreenWidthDp - 1; tda.getConfiguration().screenWidthDp = mAtm.mLargeScreenSmallestScreenWidthDp - 1; tda.getConfiguration().orientation = ORIENTATION_LANDSCAPE; // Always check the activity min width/height. mAtm.mSupportsNonResizableMultiWindow = 1; assertFalse(activity.supportsMultiWindow()); assertFalse(task.supportsMultiWindow()); tda.getConfiguration().screenWidthDp = (int) Math.ceil( mAtm.mLargeScreenSmallestScreenWidthDp / mAtm.mMinPercentageMultiWindowSupportWidth); assertTrue(activity.supportsMultiWindow()); assertTrue(task.supportsMultiWindow()); } // The default config is relying on the screen size. Check for small screen mAtm.mSupportsNonResizableMultiWindow = 0; @Test 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(task.supportsMultiWindow()); Loading