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

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

Merge "Do not show sysdecors for virtual display without...

Merge "Do not show sysdecors for virtual display without FLAG_SHOULD_SHOW_SYSTEM_DECORATIONS" into main
parents c7958409 8d36e279
Loading
Loading
Loading
Loading
+28 −10
Original line number Diff line number Diff line
@@ -3239,25 +3239,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;