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

Commit f348a8c4 authored by Treehugger Robot's avatar Treehugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Introduce isMultipleDesktopFrontendEnabledOnDisplay" into main

parents ce82bf55 25133aa6
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -171,6 +171,16 @@ public class DesktopModeStatus {
        return wm != null && wm.isEligibleForDesktopMode(display.getDisplayId());
    }

    /**
     * Returns true if the multi-desks frontend should be enabled on the display.
     */
    public static boolean isMultipleDesktopFrontendEnabledOnDisplay(@NonNull Context context,
            Display display) {
        return DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_FRONTEND.isTrue()
                && DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue()
                && isDesktopModeSupportedOnDisplay(context, display);
    }

    /**
     * Returns whether the multiple desktops feature is enabled for this device (both backend and
     * frontend implementations).
+10 −0
Original line number Diff line number Diff line
@@ -67,6 +67,16 @@ interface DesktopState {
    @get:JvmName("enableMultipleDesktops")
    val enableMultipleDesktops: Boolean

    /**
     * Returns true if the multi-desks frontend should be enabled on the display.
     */
    fun isMultipleDesktopFrontendEnabledOnDisplay(display: Display): Boolean

    /**
     *  Returns true if the multi-desks frontend should be enabled on the display with [displayId].
     */
    fun isMultipleDesktopFrontendEnabledOnDisplay(displayId: Int): Boolean

    /**
     * Checks if the display with id [displayId] should have desktop mode enabled or not. Internal
     * and external displays have separate logic.
+9 −0
Original line number Diff line number Diff line
@@ -99,6 +99,15 @@ class DesktopStateImpl(context: Context) : DesktopState {
                && DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_FRONTEND.isTrue
                && canEnterDesktopMode

    override fun isMultipleDesktopFrontendEnabledOnDisplay(display: Display): Boolean =
        DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_FRONTEND.isTrue
                && DesktopExperienceFlags.ENABLE_MULTIPLE_DESKTOPS_BACKEND.isTrue
                && isDesktopModeSupportedOnDisplay(display)

    override fun isMultipleDesktopFrontendEnabledOnDisplay(displayId: Int): Boolean =
        displayManager.getDisplay(displayId)?.let { isMultipleDesktopFrontendEnabledOnDisplay(it) }
            ?: false

    override fun isDesktopModeSupportedOnDisplay(displayId: Int): Boolean =
        displayManager.getDisplay(displayId)?.let { isDesktopModeSupportedOnDisplay(it) } ?: false

+6 −0
Original line number Diff line number Diff line
@@ -44,6 +44,12 @@ class FakeDesktopState : DesktopState {
    /** Override [canEnterDesktopMode] for a specific display. */
    val overrideDesktopModeSupportPerDisplay = mutableMapOf<Int, Boolean>()

    override fun isMultipleDesktopFrontendEnabledOnDisplay(display: Display): Boolean =
        enableMultipleDesktops && isDesktopModeSupportedOnDisplay(display)

    override fun isMultipleDesktopFrontendEnabledOnDisplay(displayId: Int): Boolean =
        enableMultipleDesktops && isDesktopModeSupportedOnDisplay(displayId)

    /**
     * This implementation returns [canEnterDesktopMode] unless overridden in
     * [overrideDesktopModeSupportPerDisplay].