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
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index e191c95..0c332af 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -1309,25 +1309,6 @@
     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 @@
                 }
 
                 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 @@
         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);