Loading libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopMode.java +3 −0 Original line number Diff line number Diff line Loading @@ -84,4 +84,7 @@ public interface DesktopMode { * Unregister a registered desktop-first listener */ void unregisterDesktopFirstListener(@NonNull DesktopFirstListener listener); /** Check is a specific displayId is in DesktopMode. */ boolean isDisplayInDesktopMode(int displayId); } libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +11 −0 Original line number Diff line number Diff line Loading @@ -6130,6 +6130,17 @@ class DesktopTasksController( } mainExecutor.execute { desktopFirstListenerManager.get().unregisterListener(listener) } } override fun isDisplayInDesktopMode(displayId: Int) = with(this@DesktopTasksController) { desktopState.isDesktopModeSupportedOnDisplay(displayId) && // TODO: b/440645027 - Simplify this call. userRepositories.current .getDeskDisplayStateForRemote() .filter { it.displayId == displayId } .filterNot { it.activeDeskId == INVALID_DISPLAY } .isNotEmpty() } } /** The interface for calls from outside the host process. */ Loading libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +21 −0 Original line number Diff line number Diff line Loading @@ -12227,6 +12227,27 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase() .activateDesk(wct = eq(wct), deskId = eq(110006), skipReorder = any()) } @Test fun isDesktopModeEnabledOnDisplay_cannotEnterDesktopMode_isFalse() { desktopState.canEnterDesktopMode = false clearInvocations(shellInit) controller = createController() assertThat(controller.asDesktopMode().isDisplayInDesktopMode(SECONDARY_DISPLAY_ID)) .isFalse() } @Test fun isDesktopModeEnabledOnDisplay_displayNotDesktop_isFalse() { assertThat(controller.asDesktopMode().isDisplayInDesktopMode(SECONDARY_DISPLAY_ID)) .isFalse() } @Test fun isDesktopModeEnabledOnDisplay_displayIsDesktop_isTrue() { assertThat(controller.asDesktopMode().isDisplayInDesktopMode(DEFAULT_DISPLAY)).isTrue() } private class RunOnStartTransitionCallback : ((IBinder) -> Unit) { var invocations = 0 private set Loading Loading
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopMode.java +3 −0 Original line number Diff line number Diff line Loading @@ -84,4 +84,7 @@ public interface DesktopMode { * Unregister a registered desktop-first listener */ void unregisterDesktopFirstListener(@NonNull DesktopFirstListener listener); /** Check is a specific displayId is in DesktopMode. */ boolean isDisplayInDesktopMode(int displayId); }
libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopTasksController.kt +11 −0 Original line number Diff line number Diff line Loading @@ -6130,6 +6130,17 @@ class DesktopTasksController( } mainExecutor.execute { desktopFirstListenerManager.get().unregisterListener(listener) } } override fun isDisplayInDesktopMode(displayId: Int) = with(this@DesktopTasksController) { desktopState.isDesktopModeSupportedOnDisplay(displayId) && // TODO: b/440645027 - Simplify this call. userRepositories.current .getDeskDisplayStateForRemote() .filter { it.displayId == displayId } .filterNot { it.activeDeskId == INVALID_DISPLAY } .isNotEmpty() } } /** The interface for calls from outside the host process. */ Loading
libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt +21 −0 Original line number Diff line number Diff line Loading @@ -12227,6 +12227,27 @@ class DesktopTasksControllerTest(flags: FlagsParameterization) : ShellTestCase() .activateDesk(wct = eq(wct), deskId = eq(110006), skipReorder = any()) } @Test fun isDesktopModeEnabledOnDisplay_cannotEnterDesktopMode_isFalse() { desktopState.canEnterDesktopMode = false clearInvocations(shellInit) controller = createController() assertThat(controller.asDesktopMode().isDisplayInDesktopMode(SECONDARY_DISPLAY_ID)) .isFalse() } @Test fun isDesktopModeEnabledOnDisplay_displayNotDesktop_isFalse() { assertThat(controller.asDesktopMode().isDisplayInDesktopMode(SECONDARY_DISPLAY_ID)) .isFalse() } @Test fun isDesktopModeEnabledOnDisplay_displayIsDesktop_isTrue() { assertThat(controller.asDesktopMode().isDisplayInDesktopMode(DEFAULT_DISPLAY)).isTrue() } private class RunOnStartTransitionCallback : ((IBinder) -> Unit) { var invocations = 0 private set Loading