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

Commit cbc24b90 authored by Chris Li's avatar Chris Li Committed by Android (Google) Code Review
Browse files

Merge "Refactor DisplayContent supportsSystemDecorations" into main

parents 99e82901 57e0a7c5
Loading
Loading
Loading
Loading
+38 −21
Original line number Diff line number Diff line
@@ -4267,7 +4267,8 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
            return DISPLAY_IME_POLICY_FALLBACK_DISPLAY;
        }
        final int imePolicy = mWmService.mDisplayWindowSettings.getImePolicyLocked(this);
        if (imePolicy == DISPLAY_IME_POLICY_FALLBACK_DISPLAY && forceDesktopMode()) {
        if (imePolicy == DISPLAY_IME_POLICY_FALLBACK_DISPLAY
                && isPublicSecondaryDisplayWithDesktopModeForceEnabled()) {
            // If the display has not explicitly requested for the IME to be hidden then it shall
            // show the IME locally.
            return DISPLAY_IME_POLICY_LOCAL;
@@ -4275,10 +4276,6 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
        return imePolicy;
    }

    boolean forceDesktopMode() {
        return mWmService.mForceDesktopModeOnExternalDisplays && !isDefaultDisplay && !isPrivate();
    }

    /** @see WindowManagerInternal#onToggleImeRequested */
    void onShowImeRequested() {
        if (mInputMethodWindow == null) {
@@ -4871,7 +4868,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp

    /** @return {@code true} if there is window to wait before enabling the screen. */
    boolean shouldWaitForSystemDecorWindowsOnBoot() {
        if (!isDefaultDisplay && !supportsSystemDecorations()) {
        if (!isDefaultDisplay && !isSystemDecorationsSupported()) {
            // Nothing to wait because the secondary display doesn't support system decorations,
            // there is no wallpaper, keyguard (status bar) or application (home) window to show
            // during booting.
@@ -5750,22 +5747,42 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
    /**
     * @see Display#FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS
     */
    boolean supportsSystemDecorations() {
        boolean forceDesktopModeOnDisplay = forceDesktopMode();

    boolean isSystemDecorationsSupported() {
        if (mDisplayId == mWmService.mVr2dDisplayId) {
            // VR virtual display will be used to run and render 2D app within a VR experience.
            return false;
        }
        if (!isTrusted()) {
            // Do not show system decorations on untrusted virtual display.
            return false;
        }
        if (mWmService.mDisplayWindowSettings.shouldShowSystemDecorsLocked(this)
                || (mDisplay.getFlags() & FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS) != 0) {
            // This display is configured to show system decorations.
            return true;
        }
        if (isPublicSecondaryDisplayWithDesktopModeForceEnabled()) {
            if (com.android.window.flags.Flags.rearDisplayDisableForceDesktopSystemDecorations()) {
            // System decorations should not be forced on a rear display due to security policies.
            forceDesktopModeOnDisplay =
                    forceDesktopModeOnDisplay && ((mDisplay.getFlags() & Display.FLAG_REAR) == 0);
                // System decorations should not be forced on a rear display due to security
                // policies.
                return (mDisplay.getFlags() & Display.FLAG_REAR) == 0;
            }
            // If the display is forced to desktop mode, treat it the same as it is configured to
            // show system decorations.
            return true;
        }
        return false;
    }

        return (mWmService.mDisplayWindowSettings.shouldShowSystemDecorsLocked(this)
                || (mDisplay.getFlags() & FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS) != 0
                || forceDesktopModeOnDisplay)
                // VR virtual display will be used to run and render 2D app within a VR experience.
                && mDisplayId != mWmService.mVr2dDisplayId
                // Do not show system decorations on untrusted virtual display.
                && isTrusted();
    /**
     * This is the development option to force enable desktop mode on all secondary public displays.
     * When this is enabled, it also force enable system decorations on those displays.
     *
     * If we need a per-display config to enable desktop mode for production, that config should
     * also check {@link #isSystemDecorationsSupported()} to avoid breaking any security policy.
     */
    boolean isPublicSecondaryDisplayWithDesktopModeForceEnabled() {
        return mWmService.mForceDesktopModeOnExternalDisplays && !isDefaultDisplay && !isPrivate();
    }

    /**
@@ -5776,7 +5793,7 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
     */
    boolean isHomeSupported() {
        return (mWmService.mDisplayWindowSettings.isHomeSupportedLocked(this) && isTrusted())
                || supportsSystemDecorations();
                || isSystemDecorationsSupported();
    }

    /**
+1 −1
Original line number Diff line number Diff line
@@ -659,7 +659,7 @@ public class DisplayPolicy {
            }
        } else {
            mHasStatusBar = false;
            mHasNavigationBar = mDisplayContent.supportsSystemDecorations();
            mHasNavigationBar = mDisplayContent.isSystemDecorationsSupported();
        }

        mRefreshRatePolicy = new RefreshRatePolicy(mService,
+2 −1
Original line number Diff line number Diff line
@@ -445,7 +445,8 @@ public class DisplayRotation {
        final boolean isTv = mContext.getPackageManager().hasSystemFeature(
                PackageManager.FEATURE_LEANBACK);
        mDefaultFixedToUserRotation =
                (isCar || isTv || mService.mIsPc || mDisplayContent.forceDesktopMode()
                (isCar || isTv || mService.mIsPc
                        || mDisplayContent.isPublicSecondaryDisplayWithDesktopModeForceEnabled()
                        || !mDisplayContent.shouldRotateWithContent())
                // For debug purposes the next line turns this feature off with:
                // $ adb shell setprop config.override_forced_orient true
+1 −1
Original line number Diff line number Diff line
@@ -143,7 +143,7 @@ class DisplayWindowSettings {
        }
        // No record is present so use default windowing mode policy.
        final boolean forceFreeForm = mService.mAtmService.mSupportsFreeformWindowManagement
                && (mService.mIsPc || dc.forceDesktopMode());
                && (mService.mIsPc || dc.isPublicSecondaryDisplayWithDesktopModeForceEnabled());
        if (forceFreeForm) {
            return WindowConfiguration.WINDOWING_MODE_FREEFORM;
        }
+1 −1
Original line number Diff line number Diff line
@@ -7700,7 +7700,7 @@ public class WindowManagerService extends IWindowManager.Stub
                        + "not exist: %d", displayId);
                return false;
            }
            return displayContent.supportsSystemDecorations();
            return displayContent.isSystemDecorationsSupported();
        }
    }

Loading