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

Commit 78d12877 authored by Pierre Barbier de Reuille's avatar Pierre Barbier de Reuille
Browse files

Clean the flag enable_connected_display_management

Remove all code using it, and the flag itself.

Updated the tests to remove those assuming the flag is off and adapt the
other ones.

Test: atest DisplayManagerServiceTest
Test: atest LogicalDisplayMapperTest
Test: atest ExternalDisplayPolicyTest
Flag: EXEMPT (flag cleanup)
Fix: 388021153
Change-Id: I4d53806a66a2e85f49eb6db57c49fe6c2cfb869e
parent 775913ed
Loading
Loading
Loading
Loading
+13 −31
Original line number Diff line number Diff line
@@ -2246,10 +2246,6 @@ public final class DisplayManagerService extends SystemService {

    @GuardedBy("mSyncRoot")
    private void handleLogicalDisplayDisconnectedLocked(LogicalDisplay display) {
        if (!mFlags.isConnectedDisplayManagementEnabled()) {
            Slog.e(TAG, "DisplayDisconnected shouldn't be received when the flag is off");
            return;
        }
        releaseDisplayAndEmitEvent(display, DisplayManagerGlobal.EVENT_DISPLAY_DISCONNECTED);
        mExternalDisplayPolicy.handleLogicalDisplayDisconnectedLocked(display);
    }
@@ -2315,11 +2311,6 @@ public final class DisplayManagerService extends SystemService {

    @SuppressLint("AndroidFrameworkRequiresPermission")
    private void handleLogicalDisplayConnectedLocked(LogicalDisplay display) {
        if (!mFlags.isConnectedDisplayManagementEnabled()) {
            Slog.e(TAG, "DisplayConnected shouldn't be received when the flag is off");
            return;
        }

        setupLogicalDisplay(display);

        if (ExternalDisplayPolicy.isExternalDisplayLocked(display)) {
@@ -2346,9 +2337,6 @@ public final class DisplayManagerService extends SystemService {
    private void handleLogicalDisplayAddedLocked(LogicalDisplay display) {
        final int displayId = display.getDisplayIdLocked();
        final boolean isDefault = displayId == Display.DEFAULT_DISPLAY;
        if (!mFlags.isConnectedDisplayManagementEnabled()) {
            setupLogicalDisplay(display);
        }

        // Wake up waitForDefaultDisplay.
        if (isDefault) {
@@ -2443,9 +2431,8 @@ public final class DisplayManagerService extends SystemService {
    }

    private void handleLogicalDisplayRemovedLocked(@NonNull LogicalDisplay display) {
        // With display management, the display is removed when disabled, and it might still exist.
        // The display is removed when disabled, and it might still exist.
        // Resources must only be released when the disconnected signal is received.
        if (mFlags.isConnectedDisplayManagementEnabled()) {
        if (display.isValidLocked()) {
            updateViewportPowerStateLocked(display);
        }
@@ -2456,9 +2443,6 @@ public final class DisplayManagerService extends SystemService {
        if (display.isValidLocked()) {
            applyDisplayChangedLocked(display);
        }
        } else {
            releaseDisplayAndEmitEvent(display, DisplayManagerGlobal.EVENT_DISPLAY_REMOVED);
        }
        if (mDisplayTopologyCoordinator != null) {
            mDisplayTopologyCoordinator.onDisplayRemoved(display.getDisplayIdLocked());
        }
@@ -4565,14 +4549,12 @@ public final class DisplayManagerService extends SystemService {
            final int callingPid = Binder.getCallingPid();
            final int callingUid = Binder.getCallingUid();

            if (mFlags.isConnectedDisplayManagementEnabled()) {
            if ((internalEventFlagsMask
                    & DisplayManagerGlobal
                    .INTERNAL_EVENT_FLAG_DISPLAY_CONNECTION_CHANGED) != 0) {
                mContext.enforceCallingOrSelfPermission(MANAGE_DISPLAYS,
                        "Permission required to get signals about connection events.");
            }
            }

            final long token = Binder.clearCallingIdentity();
            try {
+4 −11
Original line number Diff line number Diff line
@@ -179,12 +179,10 @@ class DisplayManagerShellCommand extends ShellCommand {
        pw.println("    Sets brightness to docked + idle screen brightness mode");
        pw.println("  undock");
        pw.println("    Sets brightness to active (normal) screen brightness mode");
        if (mFlags.isConnectedDisplayManagementEnabled()) {
        pw.println("  enable-display DISPLAY_ID");
        pw.println("    Enable the DISPLAY_ID. Only possible if this is a connected display.");
        pw.println("  disable-display DISPLAY_ID");
        pw.println("    Disable the DISPLAY_ID. Only possible if this is a connected display.");
        }
        pw.println("  power-reset DISPLAY_ID");
        pw.println("    Turn the DISPLAY_ID power to a state the display supposed to have.");
        pw.println("  power-off DISPLAY_ID");
@@ -601,11 +599,6 @@ class DisplayManagerShellCommand extends ShellCommand {
    }

    private int setDisplayEnabled(boolean enable) {
        if (!mFlags.isConnectedDisplayManagementEnabled()) {
            getErrPrintWriter()
                    .println("Error: external display management is not available on this device.");
            return 1;
        }
        final String displayIdText = getNextArg();
        if (displayIdText == null) {
            getErrPrintWriter().println("Error: no displayId specified");
+0 −42
Original line number Diff line number Diff line
@@ -142,14 +142,6 @@ class ExternalDisplayPolicy {
            mDisplayIdsWaitingForBootCompletion.clear();
        }

        if (!mFlags.isConnectedDisplayManagementEnabled()) {
            if (DEBUG) {
                Slog.d(TAG, "External display management is not enabled on your device:"
                                    + " cannot register thermal listener.");
            }
            return;
        }

        if (!mFlags.isConnectedDisplayErrorHandlingEnabled()) {
            if (DEBUG) {
                Slog.d(TAG, "ConnectedDisplayErrorHandlingEnabled is not enabled on your device:"
@@ -173,14 +165,6 @@ class ExternalDisplayPolicy {
            return;
        }

        if (!mFlags.isConnectedDisplayManagementEnabled()) {
            if (DEBUG) {
                Slog.d(TAG, "setExternalDisplayEnabledLocked: External display management is not"
                                    + " enabled on your device, cannot enable/disable display.");
            }
            return;
        }

        if (enabled && !isExternalDisplayAllowed()) {
            Slog.w(TAG, "setExternalDisplayEnabledLocked: External display can not be enabled"
                                + " because it is currently not allowed.");
@@ -202,14 +186,6 @@ class ExternalDisplayPolicy {
            return;
        }

        if (!mFlags.isConnectedDisplayManagementEnabled()) {
            if (DEBUG) {
                Slog.d(TAG, "handleExternalDisplayConnectedLocked connected display management"
                                    + " flag is off");
            }
            return;
        }

        if (!mIsBootCompleted) {
            mDisplayIdsWaitingForBootCompletion.add(logicalDisplay.getDisplayIdLocked());
            return;
@@ -251,10 +227,6 @@ class ExternalDisplayPolicy {
    void handleLogicalDisplayDisconnectedLocked(@NonNull final LogicalDisplay logicalDisplay) {
        // Type of the display here is always UNKNOWN, so we can't verify it is an external display

        if (!mFlags.isConnectedDisplayManagementEnabled()) {
            return;
        }

        var displayId = logicalDisplay.getDisplayIdLocked();
        if (mDisplayIdsWaitingForBootCompletion.remove(displayId)) {
            return;
@@ -271,10 +243,6 @@ class ExternalDisplayPolicy {
            return;
        }

        if (!mFlags.isConnectedDisplayManagementEnabled()) {
            return;
        }

        mExternalDisplayStatsService.onDisplayAdded(logicalDisplay.getDisplayIdLocked());
    }

@@ -289,10 +257,6 @@ class ExternalDisplayPolicy {
            }
        }

        if (!mFlags.isConnectedDisplayManagementEnabled()) {
            return;
        }

        if (isShown) {
            mExternalDisplayStatsService.onPresentationWindowAdded(displayId);
        } else {
@@ -306,12 +270,6 @@ class ExternalDisplayPolicy {
            return;
        }

        if (!mFlags.isConnectedDisplayManagementEnabled()) {
            Slog.e(TAG, "disableExternalDisplayLocked shouldn't be called when the"
                                + " connected display management flag is off");
            return;
        }

        if (!mFlags.isConnectedDisplayErrorHandlingEnabled()) {
            if (DEBUG) {
                Slog.d(TAG, "disableExternalDisplayLocked shouldn't be called when the"
+16 −38
Original line number Diff line number Diff line
@@ -823,7 +823,6 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
                if (wasPreviouslyUpdated) {
                    // The display isn't actually removed from our internal data structures until
                    // after the notification is sent; see {@link #sendUpdatesForDisplaysLocked}.
                    if (mFlags.isConnectedDisplayManagementEnabled()) {
                    if (mDisplaysEnabledCache.get(displayId)) {
                        // We still need to send LOGICAL_DISPLAY_EVENT_DISCONNECTED
                        reloop = true;
@@ -832,10 +831,6 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
                        mUpdatedLogicalDisplays.delete(displayId);
                        logicalDisplayEventMask |= LOGICAL_DISPLAY_EVENT_DISCONNECTED;
                    }
                    } else {
                        mUpdatedLogicalDisplays.delete(displayId);
                        logicalDisplayEventMask |= LOGICAL_DISPLAY_EVENT_REMOVED;
                    }
                } else {
                    // This display never left this class, safe to remove without notification
                    mLogicalDisplays.removeAt(i);
@@ -845,20 +840,15 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {

            // The display is new.
            } else if (!wasPreviouslyUpdated) {
                if (mFlags.isConnectedDisplayManagementEnabled()) {
                // We still need to send LOGICAL_DISPLAY_EVENT_ADDED
                reloop = true;
                logicalDisplayEventMask |= LOGICAL_DISPLAY_EVENT_CONNECTED;
                } else {
                    logicalDisplayEventMask |= LOGICAL_DISPLAY_EVENT_ADDED;
                }
            // Underlying displays device has changed to a different one.
            } else if (!TextUtils.equals(mTempDisplayInfo.uniqueId, newDisplayInfo.uniqueId)) {
                logicalDisplayEventMask |= LOGICAL_DISPLAY_EVENT_SWAPPED;

            // Something about the display device has changed.
            } else if (mFlags.isConnectedDisplayManagementEnabled()
                    && wasPreviouslyEnabled != isCurrentlyEnabled) {
            } else if (wasPreviouslyEnabled != isCurrentlyEnabled) {
                int event = isCurrentlyEnabled ? LOGICAL_DISPLAY_EVENT_ADDED :
                        LOGICAL_DISPLAY_EVENT_REMOVED;
                logicalDisplayEventMask |= event;
@@ -936,17 +926,13 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
        sendUpdatesForDisplaysLocked(LOGICAL_DISPLAY_EVENT_DEVICE_STATE_TRANSITION);
        sendUpdatesForGroupsLocked(DISPLAY_GROUP_EVENT_ADDED);
        sendUpdatesForDisplaysLocked(LOGICAL_DISPLAY_EVENT_REMOVED);
        if (mFlags.isConnectedDisplayManagementEnabled()) {
        sendUpdatesForDisplaysLocked(LOGICAL_DISPLAY_EVENT_DISCONNECTED);
        }
        sendUpdatesForDisplaysLocked(LOGICAL_DISPLAY_EVENT_BASIC_CHANGED);
        sendUpdatesForDisplaysLocked(LOGICAL_DISPLAY_EVENT_REFRESH_RATE_CHANGED);
        sendUpdatesForDisplaysLocked(LOGICAL_DISPLAY_EVENT_STATE_CHANGED);
        sendUpdatesForDisplaysLocked(LOGICAL_DISPLAY_EVENT_FRAME_RATE_OVERRIDES_CHANGED);
        sendUpdatesForDisplaysLocked(LOGICAL_DISPLAY_EVENT_SWAPPED);
        if (mFlags.isConnectedDisplayManagementEnabled()) {
        sendUpdatesForDisplaysLocked(LOGICAL_DISPLAY_EVENT_CONNECTED);
        }
        sendUpdatesForDisplaysLocked(LOGICAL_DISPLAY_EVENT_ADDED);
        sendUpdatesForDisplaysLocked(LOGICAL_DISPLAY_EVENT_HDR_SDR_RATIO_CHANGED);
        sendUpdatesForGroupsLocked(DISPLAY_GROUP_EVENT_CHANGED);
@@ -996,25 +982,17 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
                        + "display=" + id + " with device=" + uniqueId);
            }

            if (mFlags.isConnectedDisplayManagementEnabled()) {
            if (logicalDisplayEvent == LOGICAL_DISPLAY_EVENT_ADDED) {
                mDisplaysEnabledCache.put(id, true);
            } else if (logicalDisplayEvent == LOGICAL_DISPLAY_EVENT_REMOVED) {
                mDisplaysEnabledCache.delete(id);
            }
            }

            mListener.onLogicalDisplayEventLocked(display, logicalDisplayEvent);

            if (mFlags.isConnectedDisplayManagementEnabled()) {
            if (logicalDisplayEvent == LOGICAL_DISPLAY_EVENT_DISCONNECTED) {
                mLogicalDisplays.delete(id);
            }
            } else if (logicalDisplayEvent == LOGICAL_DISPLAY_EVENT_REMOVED) {
                // We wait until we sent the EVENT_REMOVED event before actually removing the
                // display.
                mLogicalDisplays.delete(id);
            }
        }
    }

+0 −10
Original line number Diff line number Diff line
@@ -42,10 +42,6 @@ public class DisplayManagerFlags {
            Flags.FLAG_ENABLE_PORT_IN_DISPLAY_LAYOUT,
            Flags::enablePortInDisplayLayout);

    private final FlagState mConnectedDisplayManagementFlagState = new FlagState(
            Flags.FLAG_ENABLE_CONNECTED_DISPLAY_MANAGEMENT,
            Flags::enableConnectedDisplayManagement);

    private final FlagState mAdaptiveToneImprovements1 = new FlagState(
            Flags.FLAG_ENABLE_ADAPTIVE_TONE_IMPROVEMENTS_1,
            Flags::enableAdaptiveToneImprovements1);
@@ -269,11 +265,6 @@ public class DisplayManagerFlags {
        return mPortInDisplayLayoutFlagState.isEnabled();
    }

    /** Returns whether connected display management is enabled or not. */
    public boolean isConnectedDisplayManagementEnabled() {
        return mConnectedDisplayManagementFlagState.isEnabled();
    }

    /** Returns whether power throttling clamper is enabled on not. */
    public boolean isPowerThrottlingClamperEnabled() {
        return mPowerThrottlingClamperFlagState.isEnabled();
@@ -572,7 +563,6 @@ public class DisplayManagerFlags {
        pw.println(" " + mAdaptiveToneImprovements2);
        pw.println(" " + mBackUpSmoothDisplayAndForcePeakRefreshRateFlagState);
        pw.println(" " + mConnectedDisplayErrorHandlingFlagState);
        pw.println(" " + mConnectedDisplayManagementFlagState);
        pw.println(" " + mDisplayOffloadFlagState);
        pw.println(" " + mExternalDisplayLimitModeState);
        pw.println(" " + mDisplayTopology);
Loading