Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 462fcf40 authored by Chris Li's avatar Chris Li Committed by Automerger Merge Worker
Browse files

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

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

Change-Id: I4fdd1fe3279d01e0cd661e3900e9f6b9650653f8
parents fb0e7c90 58854f38
Loading
Loading
Loading
Loading
+12 −4
Original line number Diff line number Diff line
@@ -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.
+1 −0
Original line number Diff line number Diff line
@@ -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" />
+17 −5
Original line number Diff line number Diff line
@@ -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;
@@ -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(
@@ -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
+14 −4
Original line number Diff line number Diff line
@@ -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;
@@ -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;
@@ -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;
        }
    }

    /**
+43 −8
Original line number Diff line number Diff line
@@ -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;
@@ -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)
@@ -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