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

Commit 4021b895 authored by Cicely Lambright's avatar Cicely Lambright Committed by Android (Google) Code Review
Browse files

Merge "Add method to check if the current display is in DesktopMode" into main

parents c120fc50 2c41fd90
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -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);
}
+11 −0
Original line number Diff line number Diff line
@@ -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. */
+21 −0
Original line number Diff line number Diff line
@@ -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