SF: Switch to internal display setup
Rather than call the public hotplug() functions, which may have
undesired effects, set the internal state directly for a display in the
middle of being connected.
[Test execution time not significantly reduced]
Test: libsurfaceflinger_unittest passes on Pixel XL
Bug: 74827900
Change-Id: I604ff7267e7ea3af94095ca05e288ef18e248ee5
(cherry picked from commit a618d855a2c1192c3817863b373a9cbfcba3ffbb)
diff --git a/services/surfaceflinger/DisplayHardware/HWC2.cpp b/services/surfaceflinger/DisplayHardware/HWC2.cpp
index 47f4e46..0c77aba 100644
--- a/services/surfaceflinger/DisplayHardware/HWC2.cpp
+++ b/services/surfaceflinger/DisplayHardware/HWC2.cpp
@@ -129,6 +129,7 @@
auto display = std::make_unique<Display>(
*mComposer.get(), mCapabilities, displayId, DisplayType::Virtual);
+ display->setConnected(true);
*outDisplay = display.get();
*format = static_cast<android_pixel_format_t>(intFormat);
mDisplays.emplace(displayId, std::move(display));
@@ -168,6 +169,7 @@
auto newDisplay = std::make_unique<Display>(
*mComposer.get(), mCapabilities, displayId, displayType);
+ newDisplay->setConnected(true);
mDisplays.emplace(displayId, std::move(newDisplay));
} else if (connection == Connection::Disconnected) {
// The display will later be destroyed by a call to
@@ -209,16 +211,14 @@
// Display methods
Display::Display(android::Hwc2::Composer& composer,
- const std::unordered_set<Capability>& capabilities,
- hwc2_display_t id, DisplayType type)
- : mComposer(composer),
- mCapabilities(capabilities),
- mId(id),
- mIsConnected(false),
- mType(type)
-{
+ const std::unordered_set<Capability>& capabilities, hwc2_display_t id,
+ DisplayType type)
+ : mComposer(composer),
+ mCapabilities(capabilities),
+ mId(id),
+ mIsConnected(false),
+ mType(type) {
ALOGV("Created display %" PRIu64, id);
- setConnected(true);
}
Display::~Display() {