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

Commit d3b08a78 authored by Gil Dekel's avatar Gil Dekel
Browse files

SF: Physical Display ID duplication avoidance

Currently, there are no safeguards against duplicate display IDs when
creating displays of any kind (physical or virtual). In rare cases where
duplicates occur, they cause critical failures in display management.

This patch introduces avoidance logic and checks against display ID
duplicates in SurfaceFlinger around creation of physical displays.

Flag: com.android.graphics.surfaceflinger.flags.stable_edid_ids
Bug: 421463565
Test: adb shell service call SurfaceFlinger 1037
Change-Id: I63ed72a232385a4a9236b2e229f562168cf28338
parent fe688b4b
Loading
Loading
Loading
Loading
+7 −0
Original line number Diff line number Diff line
@@ -3815,6 +3815,13 @@ std::optional<DisplayModeId> SurfaceFlinger::processHotplugConnect(
        PhysicalDisplayId displayId, hal::HWDisplayId hwcDisplayId,
        display::DisplayIdentificationInfo&& info, const char* displayString,
        HWComposer::HotplugEvent event) {
    if (FlagManager::getInstance().stable_edid_ids() &&
        info.hotplugStatus == display::HotplugStatus::Connected && hasDisplayWithId(displayId)) {
        ALOGE("Display with HAL ID %" PRIu64 " produced a duplicate display ID %" PRIu64 ".",
              hwcDisplayId, displayId.value);
        return std::nullopt;
    }

    auto [displayModes, activeMode] = loadDisplayModes(displayId);
    if (!activeMode) {
        ALOGE("Failed to hotplug %s", displayString);
+5 −0
Original line number Diff line number Diff line
@@ -1087,6 +1087,11 @@ private:
        return it == mDisplays.end() ? nullptr : it->second;
    }

    bool hasDisplayWithId(DisplayId displayId) const REQUIRES(mStateLock) {
        return hasDisplay(
                [displayId](const auto& display) { return display.getId() == displayId; });
    }

    std::vector<PhysicalDisplayId> getPhysicalDisplayIdsLocked() const REQUIRES(mStateLock);

    // mark a region of a layer stack dirty. this updates the dirty