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

Commit 7ce8764e authored by Marin Shalamanov's avatar Marin Shalamanov
Browse files

SF: Store DeviceProductInfo in DisplayDeviceState

After a hotplug we store DeviceProductInfo in
DisplayDeviceState, so it can be used later without calling
into HardwareComposer and parsing the EDID.

Bug: 149075047
Test: atest libsurfaceflinger_unittest
Test: 1. flash a device
      2. boot a device connected to a display
      3. Check for sensible DeviceProductInfo:
         adb shell dumpsys SurfaceFlinger | grep deviceProductInfo
         adb shell dumpsys display | grep deviceProductInfo
      4. reboot without a display
      5. Check that  DeviceProductInfo is empty / null in
         adb shell dumpsys SurfaceFlinger | grep deviceProductInfo
         adb shell dumpsys display | grep deviceProductInfo
Change-Id: Ide3354c1779c2ced88954c7b50e5500568d8482b
parent e5cceea2
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -192,7 +192,7 @@ struct DisplayDeviceState {
        DisplayId id;
        DisplayConnectionType type;
        hardware::graphics::composer::hal::HWDisplayId hwcDisplayId;

        std::optional<DeviceProductInfo> deviceProductInfo;
        bool operator==(const Physical& other) const {
            return id == other.id && type == other.type && hwcDisplayId == other.hwcDisplayId;
        }
+5 −22
Original line number Diff line number Diff line
@@ -1309,25 +1309,6 @@ status_t SurfaceFlinger::getHdrCapabilities(const sp<IBinder>& displayToken,
    return NO_ERROR;
}

std::optional<DeviceProductInfo> SurfaceFlinger::getDeviceProductInfoLocked(
        DisplayId displayId) const {
    const auto hwcDisplayId = getHwComposer().fromPhysicalDisplayId(displayId);
    LOG_FATAL_IF(!hwcDisplayId);

    uint8_t port;
    DisplayIdentificationData data;
    if (!getHwComposer().getDisplayIdentificationData(*hwcDisplayId, &port, &data)) {
        ALOGV("%s: No identification data.", __FUNCTION__);
        return {};
    }

    const auto info = parseDisplayIdentificationData(port, data);
    if (!info) {
        return {};
    }
    return info->deviceProductInfo;
}

status_t SurfaceFlinger::getDisplayedContentSamplingAttributes(const sp<IBinder>& displayToken,
                                                               ui::PixelFormat* outFormat,
                                                               ui::Dataspace* outDataspace,
@@ -2422,8 +2403,10 @@ void SurfaceFlinger::processDisplayHotplugEventsLocked() {
                }

                DisplayDeviceState state;
                state.physical = {displayId, getHwComposer().getDisplayConnectionType(displayId),
                                  event.hwcDisplayId};
                state.physical = {.id = displayId,
                                  .type = getHwComposer().getDisplayConnectionType(displayId),
                                  .hwcDisplayId = event.hwcDisplayId,
                                  .deviceProductInfo = info->deviceProductInfo};
                state.isSecure = true; // All physical displays are currently considered secure.
                state.displayName = info->name;

@@ -2539,7 +2522,7 @@ sp<DisplayDevice> SurfaceFlinger::setupNewDisplayDeviceInternal(
        LOG_ALWAYS_FATAL_IF(!displayId);
        auto activeConfigId = HwcConfigIndexType(getHwComposer().getActiveConfigIndex(*displayId));
        display->setActiveConfig(activeConfigId);
        display->setDeviceProductInfo(getDeviceProductInfoLocked(*displayId));
        display->setDeviceProductInfo(state.physical->deviceProductInfo);
    }

    display->setLayerStack(state.layerStack);
+8 −7
Original line number Diff line number Diff line
@@ -609,13 +609,12 @@ struct HwcDisplayVariant {

        if (PhysicalDisplay::HAS_IDENTIFICATION_DATA) {
            EXPECT_CALL(*test->mComposer, getDisplayIdentificationData(HWC_DISPLAY_ID, _, _))
                    .WillRepeatedly(
                            DoAll(SetArgPointee<1>(PhysicalDisplay::PORT),
                    .WillOnce(DoAll(SetArgPointee<1>(PhysicalDisplay::PORT),
                                    SetArgPointee<2>(PhysicalDisplay::GET_IDENTIFICATION_DATA()),
                                    Return(Error::NONE)));
        } else {
            EXPECT_CALL(*test->mComposer, getDisplayIdentificationData(HWC_DISPLAY_ID, _, _))
                    .WillRepeatedly(Return(Error::UNSUPPORTED));
                    .WillOnce(Return(Error::UNSUPPORTED));
        }
    }

@@ -1822,7 +1821,7 @@ void SetupNewDisplayDeviceInternalTest::setupNewDisplayDeviceInternalTest() {
        ASSERT_TRUE(displayId);
        const auto hwcDisplayId = Case::Display::HWC_DISPLAY_ID_OPT::value;
        ASSERT_TRUE(hwcDisplayId);
        state.physical = {*displayId, *connectionType, *hwcDisplayId};
        state.physical = {.id = *displayId, .type = *connectionType, .hwcDisplayId = *hwcDisplayId};
    }

    state.isSecure = static_cast<bool>(Case::Display::SECURE);
@@ -1998,7 +1997,9 @@ void HandleTransactionLockedTest::verifyDisplayIsConnected(const sp<IBinder>& di
        ASSERT_TRUE(displayId);
        const auto hwcDisplayId = Case::Display::HWC_DISPLAY_ID_OPT::value;
        ASSERT_TRUE(hwcDisplayId);
        expectedPhysical = {*displayId, *connectionType, *hwcDisplayId};
        expectedPhysical = {.id = *displayId,
                            .type = *connectionType,
                            .hwcDisplayId = *hwcDisplayId};
    }

    // The display should have been set up in the current display state
+1 −1
Original line number Diff line number Diff line
@@ -629,7 +629,7 @@ public:
            if (const auto type = mCreationArgs.connectionType) {
                LOG_ALWAYS_FATAL_IF(!displayId);
                LOG_ALWAYS_FATAL_IF(!mHwcDisplayId);
                state.physical = {*displayId, *type, *mHwcDisplayId};
                state.physical = {.id = *displayId, .type = *type, .hwcDisplayId = *mHwcDisplayId};
            }

            state.isSecure = mCreationArgs.isSecure;