[SF] Update DeviceProductInfo on hotplug reconnect
This change populates DeviceProductInfo on hotplug, even if we are
in legacy multi-display mode. This behaviour is guarded by sysprop
ro.surface_flinger.update_edid_on_hotplug_reconnect which is
turned off by default.
Bug: 160952291
Test: 1. connect display
2. adb shell dumpsys SurfaceFlinger | grep deviceProductInfo
3. connect different display
4. adb shell dumpsys SurfaceFlinger | grep deviceProductInfo
5. make sure DeviceProductInfo has changed.
Change-Id: I94751f678b1dd1196727ad38ab5e398fb6cf0393
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 2ff26a9..82d7b65 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -2313,7 +2313,7 @@
void SurfaceFlinger::processDisplayHotplugEventsLocked() {
for (const auto& event : mPendingHotplugEvents) {
- const std::optional<DisplayIdentificationInfo> info =
+ std::optional<DisplayIdentificationInfo> info =
getHwComposer().onHotplug(event.hwcDisplayId, event.connection);
if (!info) {
@@ -2335,9 +2335,9 @@
state.physical = {.id = displayId,
.type = getHwComposer().getDisplayConnectionType(displayId),
.hwcDisplayId = event.hwcDisplayId,
- .deviceProductInfo = info->deviceProductInfo};
+ .deviceProductInfo = std::move(info->deviceProductInfo)};
state.isSecure = true; // All physical displays are currently considered secure.
- state.displayName = info->name;
+ state.displayName = std::move(info->name);
sp<IBinder> token = new BBinder();
mCurrentState.displays.add(token, state);
@@ -2349,7 +2349,10 @@
const auto token = it->second;
auto& state = mCurrentState.displays.editValueFor(token);
- state.sequenceId = DisplayDeviceState{}.sequenceId;
+ state.sequenceId = DisplayDeviceState{}.sequenceId; // Generate new sequenceId
+ if (getHwComposer().updatesDeviceProductInfoOnHotplugReconnect()) {
+ state.physical->deviceProductInfo = std::move(info->deviceProductInfo);
+ }
}
} else {
ALOGV("Removing display %s", to_string(displayId).c_str());