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

Commit fb1c8643 authored by Wale Ogunwale's avatar Wale Ogunwale
Browse files

config_supportsMultiWindow for device to specify multi-window support

Devices that have the config set to false will not allow any multi-window
operation.

Also, added ActivityManager.supportsMultiWindow that checks the new config
and also returns false if the device is a low RAM device.

Bug: 27419483
Change-Id: I8dd85c17d290a5a752de3253beb3b34c17d7736d
parent 9d0aa47c
Loading
Loading
Loading
Loading
+21 −0
Original line number Original line Diff line number Diff line
@@ -647,6 +647,16 @@ public class ActivityManager {
            return stackId != PINNED_STACK_ID && stackId != FREEFORM_WORKSPACE_STACK_ID
            return stackId != PINNED_STACK_ID && stackId != FREEFORM_WORKSPACE_STACK_ID
                    && stackId != DOCKED_STACK_ID;
                    && stackId != DOCKED_STACK_ID;
        }
        }

        /**
         * Returns true if the input stack id should only be present on a device that supports
         * multi-window mode.
         * @see android.app.ActivityManager#supportsMultiWindow
         */
        public static boolean isMultiWindowStack(int stackId) {
            return isStaticStack(stackId) || stackId == PINNED_STACK_ID
                    || stackId == FREEFORM_WORKSPACE_STACK_ID || stackId == DOCKED_STACK_ID;
        }
    }
    }


    /**
    /**
@@ -867,6 +877,17 @@ public class ActivityManager {
        return getMaxRecentTasksStatic() / 2;
        return getMaxRecentTasksStatic() / 2;
    }
    }


    /**
     * Returns true if the system supports at least one form of multi-window.
     * E.g. freeform, split-screen, picture-in-picture.
     * @hide
     */
    static public boolean supportsMultiWindow() {
        return !isLowRamDeviceStatic()
                && Resources.getSystem().getBoolean(
                    com.android.internal.R.bool.config_supportsMultiWindow);
    }

    /**
    /**
     * Information you can set and retrieve about the current activity within the recent task list.
     * Information you can set and retrieve about the current activity within the recent task list.
     */
     */
+4 −0
Original line number Original line Diff line number Diff line
@@ -2479,4 +2479,8 @@
         handle wallpaper cropping.
         handle wallpaper cropping.
    -->
    -->
    <string name="config_wallpaperCropperPackage" translatable="false">com.android.wallpapercropper</string>
    <string name="config_wallpaperCropperPackage" translatable="false">com.android.wallpapercropper</string>

    <!-- True if the device supports at least one form of multi-window.
         E.g. freeform, split-screen, picture-in-picture. -->
    <bool name="config_supportsMultiWindow">true</bool>
</resources>
</resources>
+1 −0
Original line number Original line Diff line number Diff line
@@ -303,6 +303,7 @@
  <java-symbol type="bool" name="config_supportSpeakerNearUltrasound" />
  <java-symbol type="bool" name="config_supportSpeakerNearUltrasound" />
  <java-symbol type="bool" name="config_supportAudioSourceUnprocessed" />
  <java-symbol type="bool" name="config_supportAudioSourceUnprocessed" />
  <java-symbol type="bool" name="config_freeformWindowManagement" />
  <java-symbol type="bool" name="config_freeformWindowManagement" />
  <java-symbol type="bool" name="config_supportsMultiWindow" />
  <java-symbol type="bool" name="config_guestUserEphemeral" />
  <java-symbol type="bool" name="config_guestUserEphemeral" />
  <java-symbol type="string" name="config_defaultPictureInPictureBounds" />
  <java-symbol type="string" name="config_defaultPictureInPictureBounds" />
  <java-symbol type="string" name="config_centeredPictureInPictureBounds" />
  <java-symbol type="string" name="config_centeredPictureInPictureBounds" />
+11 −2
Original line number Original line Diff line number Diff line
@@ -1294,6 +1294,7 @@ public final class ActivityManagerService extends ActivityManagerNative
    boolean mAlwaysFinishActivities = false;
    boolean mAlwaysFinishActivities = false;
    boolean mLenientBackgroundCheck = false;
    boolean mLenientBackgroundCheck = false;
    boolean mForceResizableActivities;
    boolean mForceResizableActivities;
    boolean mSupportsMultiWindow;
    boolean mSupportsFreeformWindowManagement;
    boolean mSupportsFreeformWindowManagement;
    boolean mSupportsPictureInPicture;
    boolean mSupportsPictureInPicture;
    Rect mDefaultPinnedStackBounds;
    Rect mDefaultPinnedStackBounds;
@@ -12336,6 +12337,7 @@ public final class ActivityManagerService extends ActivityManagerNative
        final boolean supportsPictureInPicture =
        final boolean supportsPictureInPicture =
                mContext.getPackageManager().hasSystemFeature(FEATURE_PICTURE_IN_PICTURE);
                mContext.getPackageManager().hasSystemFeature(FEATURE_PICTURE_IN_PICTURE);
        final boolean supportsMultiWindow = ActivityManager.supportsMultiWindow();
        final String debugApp = Settings.Global.getString(resolver, DEBUG_APP);
        final String debugApp = Settings.Global.getString(resolver, DEBUG_APP);
        final boolean waitForDebugger = Settings.Global.getInt(resolver, WAIT_FOR_DEBUGGER, 0) != 0;
        final boolean waitForDebugger = Settings.Global.getInt(resolver, WAIT_FOR_DEBUGGER, 0) != 0;
        final boolean alwaysFinishActivities =
        final boolean alwaysFinishActivities =
@@ -12362,8 +12364,15 @@ public final class ActivityManagerService extends ActivityManagerNative
            mLenientBackgroundCheck = lenientBackgroundCheck;
            mLenientBackgroundCheck = lenientBackgroundCheck;
            mForceResizableActivities = forceResizable;
            mForceResizableActivities = forceResizable;
            mWindowManager.setForceResizableTasks(mForceResizableActivities);
            mWindowManager.setForceResizableTasks(mForceResizableActivities);
            if (supportsMultiWindow || forceResizable) {
                mSupportsMultiWindow = true;
                mSupportsFreeformWindowManagement = freeformWindowManagement || forceResizable;
                mSupportsFreeformWindowManagement = freeformWindowManagement || forceResizable;
                mSupportsPictureInPicture = supportsPictureInPicture || forceResizable;
                mSupportsPictureInPicture = supportsPictureInPicture || forceResizable;
            } else {
                mSupportsMultiWindow = false;
                mSupportsFreeformWindowManagement = false;
                mSupportsPictureInPicture = false;
            }
            // This happens before any activities are started, so we can
            // This happens before any activities are started, so we can
            // change mConfiguration in-place.
            // change mConfiguration in-place.
            updateConfigurationLocked(configuration, null, true);
            updateConfigurationLocked(configuration, null, true);
+6 −2
Original line number Original line Diff line number Diff line
@@ -2174,6 +2174,12 @@ public final class ActivityStackSupervisor implements DisplayListener {
     */
     */
    ActivityStack moveTaskToStackUncheckedLocked(
    ActivityStack moveTaskToStackUncheckedLocked(
            TaskRecord task, int stackId, boolean toTop, boolean forceFocus, String reason) {
            TaskRecord task, int stackId, boolean toTop, boolean forceFocus, String reason) {

        if (StackId.isMultiWindowStack(stackId) && !mService.mSupportsMultiWindow) {
            throw new IllegalStateException("moveTaskToStackUncheckedLocked: Device doesn't "
                    + "support multi-window task=" + task + " to stackId=" + stackId);
        }

        final ActivityRecord r = task.getTopActivity();
        final ActivityRecord r = task.getTopActivity();
        final ActivityStack prevStack = task.stack;
        final ActivityStack prevStack = task.stack;
        final boolean wasFocused = isFocusedStack(prevStack) && (topRunningActivityLocked() == r);
        final boolean wasFocused = isFocusedStack(prevStack) && (topRunningActivityLocked() == r);
@@ -2184,8 +2190,6 @@ public final class ActivityStackSupervisor implements DisplayListener {
        final boolean wasFront = isFrontStack(prevStack)
        final boolean wasFront = isFrontStack(prevStack)
                && (prevStack.topRunningActivityLocked() == r);
                && (prevStack.topRunningActivityLocked() == r);


        final int resizeMode = task.mResizeMode;

        if (stackId == DOCKED_STACK_ID && !task.isResizeable()) {
        if (stackId == DOCKED_STACK_ID && !task.isResizeable()) {
            // We don't allow moving a unresizeable task to the docked stack since the docked
            // We don't allow moving a unresizeable task to the docked stack since the docked
            // stack is used for split-screen mode and will cause things like the docked divider to
            // stack is used for split-screen mode and will cause things like the docked divider to
Loading