Loading core/res/res/values/config.xml +3 −0 Original line number Diff line number Diff line Loading @@ -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> Loading core/res/res/values/symbols.xml +3 −0 Original line number Diff line number Diff line Loading @@ -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"/> Loading libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/desktopmode/DesktopModeStatus.java +20 −9 Original line number Diff line number Diff line Loading @@ -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 */ Loading @@ -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)); } /** Loading Loading @@ -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)); } Loading @@ -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) { Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopActivityOrientationChangeHandlerTest.kt +1 −1 Original line number Diff line number Diff line Loading @@ -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)) Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopModeKeyGestureHandlerTest.kt +1 −8 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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 Loading Loading @@ -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 Loading
core/res/res/values/config.xml +3 −0 Original line number Diff line number Diff line Loading @@ -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> Loading
core/res/res/values/symbols.xml +3 −0 Original line number Diff line number Diff line Loading @@ -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"/> Loading
libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/desktopmode/DesktopModeStatus.java +20 −9 Original line number Diff line number Diff line Loading @@ -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 */ Loading @@ -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)); } /** Loading Loading @@ -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)); } Loading @@ -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) { Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopActivityOrientationChangeHandlerTest.kt +1 −1 Original line number Diff line number Diff line Loading @@ -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)) Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopModeKeyGestureHandlerTest.kt +1 −8 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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 Loading Loading @@ -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