Loading services/surfaceflinger/SurfaceFlinger.cpp +5 −1 Original line number Diff line number Diff line Loading @@ -3476,8 +3476,12 @@ const char* SurfaceFlinger::processHotplug(PhysicalDisplayId displayId, auto [displayModes, activeMode] = loadDisplayModes(displayId); if (!activeMode) { // TODO(b/241286153): Report hotplug failure to the framework. ALOGE("Failed to hotplug display %s", to_string(displayId).c_str()); if (FlagManager::getInstance().hotplug2()) { mScheduler->onHotplugConnectionError(mAppConnectionHandle, static_cast<int32_t>( DisplayHotplugEvent::ERROR_UNKNOWN)); } getHwComposer().disconnectDisplay(displayId); return nullptr; } Loading services/surfaceflinger/tests/unittests/SurfaceFlinger_HotplugTest.cpp +12 −0 Original line number Diff line number Diff line Loading @@ -17,8 +17,14 @@ #undef LOG_TAG #define LOG_TAG "LibSurfaceFlingerUnittests" #include <aidl/android/hardware/graphics/common/DisplayHotplugEvent.h> #include <com_android_graphics_surfaceflinger_flags.h> #include <common/test/FlagUtils.h> #include "DisplayTransactionTestHelpers.h" using namespace com::android::graphics::surfaceflinger; using ::aidl::android::hardware::graphics::common::DisplayHotplugEvent; namespace android { class HotplugTest : public DisplayTransactionTest {}; Loading Loading @@ -87,6 +93,8 @@ TEST_F(HotplugTest, ignoresDuplicateDisconnection) { } TEST_F(HotplugTest, rejectsHotplugIfFailedToLoadDisplayModes) { SET_FLAG_FOR_TEST(flags::connected_display, true); // Inject a primary display. PrimaryDisplayVariant::injectHwcDisplay(this); Loading @@ -94,6 +102,10 @@ TEST_F(HotplugTest, rejectsHotplugIfFailedToLoadDisplayModes) { constexpr bool kFailedHotplug = true; ExternalDisplay::setupHwcHotplugCallExpectations<kFailedHotplug>(this); EXPECT_CALL(*mEventThread, onHotplugConnectionError(static_cast<int32_t>(DisplayHotplugEvent::ERROR_UNKNOWN))) .Times(1); // Simulate a connect event that fails to load display modes due to HWC already having // disconnected the display but SF yet having to process the queued disconnect event. EXPECT_CALL(*mComposer, getActiveConfig(ExternalDisplay::HWC_DISPLAY_ID, _)) Loading Loading
services/surfaceflinger/SurfaceFlinger.cpp +5 −1 Original line number Diff line number Diff line Loading @@ -3476,8 +3476,12 @@ const char* SurfaceFlinger::processHotplug(PhysicalDisplayId displayId, auto [displayModes, activeMode] = loadDisplayModes(displayId); if (!activeMode) { // TODO(b/241286153): Report hotplug failure to the framework. ALOGE("Failed to hotplug display %s", to_string(displayId).c_str()); if (FlagManager::getInstance().hotplug2()) { mScheduler->onHotplugConnectionError(mAppConnectionHandle, static_cast<int32_t>( DisplayHotplugEvent::ERROR_UNKNOWN)); } getHwComposer().disconnectDisplay(displayId); return nullptr; } Loading
services/surfaceflinger/tests/unittests/SurfaceFlinger_HotplugTest.cpp +12 −0 Original line number Diff line number Diff line Loading @@ -17,8 +17,14 @@ #undef LOG_TAG #define LOG_TAG "LibSurfaceFlingerUnittests" #include <aidl/android/hardware/graphics/common/DisplayHotplugEvent.h> #include <com_android_graphics_surfaceflinger_flags.h> #include <common/test/FlagUtils.h> #include "DisplayTransactionTestHelpers.h" using namespace com::android::graphics::surfaceflinger; using ::aidl::android::hardware::graphics::common::DisplayHotplugEvent; namespace android { class HotplugTest : public DisplayTransactionTest {}; Loading Loading @@ -87,6 +93,8 @@ TEST_F(HotplugTest, ignoresDuplicateDisconnection) { } TEST_F(HotplugTest, rejectsHotplugIfFailedToLoadDisplayModes) { SET_FLAG_FOR_TEST(flags::connected_display, true); // Inject a primary display. PrimaryDisplayVariant::injectHwcDisplay(this); Loading @@ -94,6 +102,10 @@ TEST_F(HotplugTest, rejectsHotplugIfFailedToLoadDisplayModes) { constexpr bool kFailedHotplug = true; ExternalDisplay::setupHwcHotplugCallExpectations<kFailedHotplug>(this); EXPECT_CALL(*mEventThread, onHotplugConnectionError(static_cast<int32_t>(DisplayHotplugEvent::ERROR_UNKNOWN))) .Times(1); // Simulate a connect event that fails to load display modes due to HWC already having // disconnected the display but SF yet having to process the queued disconnect event. EXPECT_CALL(*mComposer, getActiveConfig(ExternalDisplay::HWC_DISPLAY_ID, _)) Loading