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

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

Merge "Introduce IWindowManager#isEligibleForDesktopMode()" into main

parents 2ca8bb2e fa9b5e9c
Loading
Loading
Loading
Loading
+18 −1
Original line number Diff line number Diff line
@@ -699,7 +699,7 @@ interface IWindowManager
    /**
     * Indicates the display should show system decors.
     * <p>
     * System decors include status bar, navigation bar, launcher.
     * System decors include status bar, navigation bar, launcher, and wallpaper.
     * </p>
     *
     * @param displayId The id of the display.
@@ -718,6 +718,23 @@ interface IWindowManager
     */
    void setShouldShowSystemDecors(int displayId, boolean shouldShow);

    /**
     * Indicates that the display is eligible for the desktop mode from WindowManager's perspective.
     * This includes:
     * - The default display;
     * - Any display that is allowed to switch the content mode between extended and mirroring
     * (which means it can dynamically add or remove system decors), and it is now in extended mode
     * (should currently show system decors).
     * <p>
     * System decors include status bar, navigation bar, launcher, and wallpaper.
     * </p>
     *
     * @param displayId The id of the display.
     * @return {@code true} if the display is eligible for the desktop mode from WindowManager's
     * perspective.
     */
    boolean isEligibleForDesktopMode(int displayId);

    /**
     * Indicates the policy for how the display should show IME.
     *
+20 −0
Original line number Diff line number Diff line
@@ -7613,6 +7613,26 @@ public class WindowManagerService extends IWindowManager.Stub
        }
    }

    @Override
    public boolean isEligibleForDesktopMode(int displayId) {
        if (!checkCallingPermission(INTERNAL_SYSTEM_WINDOW, "isEligibleForDesktopMode()")) {
            throw new SecurityException("Requires INTERNAL_SYSTEM_WINDOW permission");
        }

        synchronized (mGlobalLock) {
            final DisplayContent displayContent = mRoot.getDisplayContent(displayId);
            if (displayContent == null) {
                ProtoLog.e(WM_ERROR, "Attempted to check isEligibleForDesktopMode() "
                        + "for a display that does not exist: %d", displayId);
                return false;
            }
            if (!displayContent.isSystemDecorationsSupported()) {
                return false;
            }
            return displayContent.isDefaultDisplay || displayContent.allowContentModeSwitch();
        }
    }

    @Override
    public void setShouldShowSystemDecors(int displayId, boolean shouldShow) {
        if (!checkCallingPermission(INTERNAL_SYSTEM_WINDOW, "setShouldShowSystemDecors()")) {