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

Commit 728c4837 authored by Oleg Blinnikov's avatar Oleg Blinnikov
Browse files

Prevent disabling the default display.

Add checks in `DisplayManagerService.enableConnectedDisplay` and `DisplayManagerShellCommand` to ensure the default display (Display.DEFAULT_DISPLAY) cannot be disabled. Attempting to disable the default display will now be ignored by the service and result in an error message from the shell command.

Bug: 432573493
Test: manual
Flag: EXEMPT simple bugfix
Change-Id: Ia3d671e441e52839c70e2606bb6677eb0bea4fea
parent a25f320b
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
@@ -3945,6 +3945,10 @@ public final class DisplayManagerService extends SystemService {
    }

    void enableConnectedDisplay(int displayId, boolean enabled) {
        if (!enabled && displayId == Display.DEFAULT_DISPLAY) {
            Slog.w(TAG, "enableConnectedDisplay: Cannot disable default display");
            return;
        }
        synchronized (mSyncRoot) {
            final var logicalDisplay = mLogicalDisplayMapper.getDisplayLocked(displayId);
            if (logicalDisplay == null) {
+4 −0
Original line number Diff line number Diff line
@@ -786,6 +786,10 @@ class DisplayManagerShellCommand extends ShellCommand {
            getErrPrintWriter().println("Error: invalid displayId: '" + displayIdText + "'");
            return 1;
        }
        if (!enable && displayId == Display.DEFAULT_DISPLAY) {
            getErrPrintWriter().println("Error: cannot disable default display");
            return 1;
        }
        mService.enableConnectedDisplay(displayId, enable);
        return 0;
    }