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

Commit 818f0a86 authored by Ben Lin's avatar Ben Lin Committed by Android (Google) Code Review
Browse files

Merge "Add config_canInternalDisplayHostDesktops to differentiate." into main

parents 1b0b0490 d584c10e
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -7256,6 +7256,9 @@
    <!-- Wear devices: An intent action that is used for remote intent. -->
    <string name="config_wearRemoteIntentAction" translatable="false" />

    <!-- Whether the current device's internal display can host desktop sessions.  -->
    <bool name="config_canInternalDisplayHostDesktops">false</bool>

    <!-- Whether desktop mode is supported on the current device  -->
    <bool name="config_isDesktopModeSupported">false</bool>

+3 −0
Original line number Diff line number Diff line
@@ -5754,6 +5754,9 @@
  <!-- Whether the developer option for desktop mode is supported on the current device  -->
  <java-symbol type="bool" name="config_isDesktopModeDevOptionSupported" />

  <!-- Whether the current device's internal display can host desktop sessions.  -->
  <java-symbol type="bool" name="config_canInternalDisplayHostDesktops" />

  <!-- Maximum number of active tasks on a given Desktop Windowing session. Set to 0 for unlimited. -->
  <java-symbol type="integer" name="config_maxDesktopWindowingActiveTasks"/>

+20 −9
Original line number Diff line number Diff line
@@ -219,6 +219,13 @@ public class DesktopModeStatus {
        return context.getResources().getBoolean(R.bool.config_isDesktopModeDevOptionSupported);
    }

    /**
     * Return {@code true} if the current device can host desktop sessions on its internal display.
     */
    public static boolean canInternalDisplayHostDesktops(@NonNull Context context) {
        return context.getResources().getBoolean(R.bool.config_canInternalDisplayHostDesktops);
    }

    /**
     * Return {@code true} if desktop mode dev option should be shown on current device
     */
@@ -231,21 +238,24 @@ public class DesktopModeStatus {
     * Return {@code true} if desktop mode dev option should be shown on current device
     */
    public static boolean canShowDesktopExperienceDevOption(@NonNull Context context) {
        return Flags.showDesktopExperienceDevOption() && isDeviceEligibleForDesktopMode(context);
        return Flags.showDesktopExperienceDevOption()
                && isInternalDisplayEligibleToHostDesktops(context);
    }

    /** Returns if desktop mode dev option should be enabled if there is no user override. */
    public static boolean shouldDevOptionBeEnabledByDefault(Context context) {
        return isDeviceEligibleForDesktopMode(context) && Flags.enableDesktopWindowingMode();
        return isInternalDisplayEligibleToHostDesktops(context)
                && Flags.enableDesktopWindowingMode();
    }

    /**
     * Return {@code true} if desktop mode is enabled and can be entered on the current device.
     */
    public static boolean canEnterDesktopMode(@NonNull Context context) {
        return (isDeviceEligibleForDesktopMode(context)
                && DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_MODE.isTrue())
                || isDesktopModeEnabledByDevOption(context);
        return (isInternalDisplayEligibleToHostDesktops(context)
                && DesktopModeFlags.ENABLE_DESKTOP_WINDOWING_MODE.isTrue()
                && (isDesktopModeSupported(context) || !enforceDeviceRestrictions())
                || isDesktopModeEnabledByDevOption(context));
    }

    /**
@@ -313,10 +323,11 @@ public class DesktopModeStatus {
    }

    /**
     * Return {@code true} if desktop mode is unrestricted and is supported in the device.
     * Return {@code true} if desktop sessions is unrestricted and can be host for the device's
     * internal display.
     */
    public static boolean isDeviceEligibleForDesktopMode(@NonNull Context context) {
        return !enforceDeviceRestrictions() || isDesktopModeSupported(context) || (
    public static boolean isInternalDisplayEligibleToHostDesktops(@NonNull Context context) {
        return !enforceDeviceRestrictions() || canInternalDisplayHostDesktops(context) || (
                Flags.enableDesktopModeThroughDevOption() && isDesktopModeDevOptionSupported(
                        context));
    }
@@ -325,7 +336,7 @@ public class DesktopModeStatus {
     * Return {@code true} if the developer option for desktop mode is unrestricted and is supported
     * in the device.
     *
     * Note that, if {@link #isDeviceEligibleForDesktopMode(Context)} is true, then
     * Note that, if {@link #isInternalDisplayEligibleToHostDesktops(Context)} is true, then
     * {@link #isDeviceEligibleForDesktopModeDevOption(Context)} is also true.
     */
    private static boolean isDeviceEligibleForDesktopModeDevOption(@NonNull Context context) {
+1 −1
Original line number Diff line number Diff line
@@ -113,7 +113,7 @@ class DesktopActivityOrientationChangeHandlerTest : ShellTestCase() {
                .strictness(Strictness.LENIENT)
                .spyStatic(DesktopModeStatus::class.java)
                .startMocking()
        doReturn(true).`when` { DesktopModeStatus.isDeviceEligibleForDesktopMode(any()) }
        doReturn(true).`when` { DesktopModeStatus.canEnterDesktopMode(any()) }

        testScope = CoroutineScope(Dispatchers.Unconfined + SupervisorJob())
        shellInit = spy(ShellInit(testExecutor))
+1 −8
Original line number Diff line number Diff line
@@ -30,7 +30,6 @@ import android.view.KeyEvent
import android.window.DisplayAreaInfo
import androidx.test.filters.SmallTest
import com.android.dx.mockito.inline.extended.ExtendedMockito.doAnswer
import com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn
import com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession
import com.android.dx.mockito.inline.extended.StaticMockitoSession
import com.android.hardware.input.Flags.FLAG_USE_KEY_GESTURE_EVENT_HANDLER
@@ -48,7 +47,6 @@ import com.android.wm.shell.common.DisplayLayout
import com.android.wm.shell.desktopmode.DesktopModeEventLogger.Companion.MinimizeReason
import com.android.wm.shell.desktopmode.DesktopTestHelpers.createFreeformTask
import com.android.wm.shell.desktopmode.common.ToggleTaskSizeInteraction
import com.android.wm.shell.shared.desktopmode.DesktopModeStatus
import com.android.wm.shell.sysui.ShellInit
import com.android.wm.shell.transition.FocusTransitionObserver
import com.android.wm.shell.windowdecor.DesktopModeWindowDecorViewModel
@@ -107,12 +105,7 @@ class DesktopModeKeyGestureHandlerTest : ShellTestCase() {
    @Before
    fun setUp() {
        Dispatchers.setMain(StandardTestDispatcher())
        mockitoSession =
            mockitoSession()
                .strictness(Strictness.LENIENT)
                .spyStatic(DesktopModeStatus::class.java)
                .startMocking()
        doReturn(true).`when` { DesktopModeStatus.isDeviceEligibleForDesktopMode(any()) }
        mockitoSession = mockitoSession().strictness(Strictness.LENIENT).startMocking()

        testScope = CoroutineScope(Dispatchers.Unconfined + SupervisorJob())
        shellInit = spy(ShellInit(testExecutor))
Loading