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

Commit 8d36e279 authored by Lingyu Feng's avatar Lingyu Feng
Browse files

Do not show sysdecors for virtual display without FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS

Bug: 395037744
Change-Id: Ie279b964158bfdcc5722e4777a60dda7d84873b3
Test: manually
Flag: com.android.server.display.feature.flags.enable_display_content_mode_management
parent 74f42854
Loading
Loading
Loading
Loading
+28 −10
Original line number Diff line number Diff line
@@ -3250,25 +3250,43 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
            Slog.e(TAG, "ShouldShowSystemDecors shouldn't be updated when the flag is off.");
        }

        final boolean shouldShow;
        if (isDefaultDisplay) {
            shouldShow = true;
        } else if (isPrivate()) {
            shouldShow = false;
        } else {
            shouldShow = mDisplay.canHostTasks();
        final boolean shouldShowContent;
        if (!allowContentModeSwitch()) {
            return;
        }
        shouldShowContent = mDisplay.canHostTasks();

        if (shouldShow == mWmService.mDisplayWindowSettings.shouldShowSystemDecorsLocked(this)) {
        if (shouldShowContent == mWmService.mDisplayWindowSettings
                .shouldShowSystemDecorsLocked(this)) {
            return;
        }
        mWmService.mDisplayWindowSettings.setShouldShowSystemDecorsLocked(this, shouldShow);
        mWmService.mDisplayWindowSettings.setShouldShowSystemDecorsLocked(this, shouldShowContent);

        if (!shouldShow) {
        if (!shouldShowContent) {
            clearAllTasksOnDisplay(null /* clearTasksCallback */, false /* isRemovingDisplay */);
        }
    }

    private boolean allowContentModeSwitch() {
        // The default display should always show system decorations.
        if (isDefaultDisplay) {
            return false;
        }

        // Private display should never show system decorations.
        if (isPrivate()) {
            return false;
        }

        // TODO(b/391965805): Remove this after introducing FLAG_ALLOW_SYSTEM_DECORATIONS_CHANGE.
        // Virtual displays cannot add or remove system decorations during their lifecycle.
        if (mDisplay.getType() == Display.TYPE_VIRTUAL) {
            return false;
        }

        return true;
    }

    DisplayCutout loadDisplayCutout(int displayWidth, int displayHeight) {
        if (mDisplayPolicy == null || mInitialDisplayCutout == null) {
            return null;