SF: Do not abort on duplicate hotplug disconnect
processHotplug expects the display token to exist for disconnect events,
so skip events that disconnect an already disconnected display.
Bug: 241286153
Test: HotplugTest.ignoresDuplicateDisconnection
Change-Id: I2b711317acc87f453f73a1aafcc8dd63cc1a8d33
diff --git a/services/surfaceflinger/DisplayHardware/HWComposer.cpp b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
index c71b1f9..15d5041 100644
--- a/services/surfaceflinger/DisplayHardware/HWComposer.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWComposer.cpp
@@ -252,11 +252,7 @@
}
bool HWComposer::isConnected(PhysicalDisplayId displayId) const {
- if (mDisplayData.count(displayId)) {
- return mDisplayData.at(displayId).hwcDisplay->isConnected();
- }
-
- return false;
+ return mDisplayData.count(displayId) && mDisplayData.at(displayId).hwcDisplay->isConnected();
}
std::vector<HWComposer::HWCDisplayMode> HWComposer::getModes(PhysicalDisplayId displayId) const {
@@ -946,18 +942,15 @@
return {};
}
- // The display will later be destroyed by a call to
- // destroyDisplay(). For now we just mark it disconnected.
- if (isConnected(*displayId)) {
- mDisplayData[*displayId].hwcDisplay->setConnected(false);
- } else {
+ if (!isConnected(*displayId)) {
LOG_HWC_DISPLAY_ERROR(hwcDisplayId, "Already disconnected");
+ return {};
}
- // The cleanup of Disconnect is handled through HWComposer::disconnectDisplay
- // via SurfaceFlinger's onHotplugReceived callback handling
- return DisplayIdentificationInfo{.id = *displayId,
- .name = std::string(),
- .deviceProductInfo = std::nullopt};
+
+ // The display will later be destroyed by a call to HWComposer::disconnectDisplay. For now, mark
+ // it as disconnected.
+ mDisplayData.at(*displayId).hwcDisplay->setConnected(false);
+ return DisplayIdentificationInfo{.id = *displayId};
}
void HWComposer::loadCapabilities() {