Skip to content

Commit 9f0fc59

Browse files
Huihong LuoLeonScroggins
authored andcommitted
Report hotplug error to framework
When active mode can't be found for a display. Bug: 320703046 Test: atest libsurfaceflinger_unittest:HotplugTest Change-Id: I352a4b58e97620ee2ce8681fe4e7a1f3307bc0a4
1 parent 79e5f98 commit 9f0fc59

2 files changed

Lines changed: 17 additions & 1 deletion

File tree

services/surfaceflinger/SurfaceFlinger.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3395,8 +3395,12 @@ const char* SurfaceFlinger::processHotplug(PhysicalDisplayId displayId,
33953395

33963396
auto [displayModes, activeMode] = loadDisplayModes(displayId);
33973397
if (!activeMode) {
3398-
// TODO(b/241286153): Report hotplug failure to the framework.
33993398
ALOGE("Failed to hotplug display %s", to_string(displayId).c_str());
3399+
if (FlagManager::getInstance().hotplug2()) {
3400+
mScheduler->onHotplugConnectionError(mAppConnectionHandle,
3401+
static_cast<int32_t>(
3402+
DisplayHotplugEvent::ERROR_UNKNOWN));
3403+
}
34003404
getHwComposer().disconnectDisplay(displayId);
34013405
return nullptr;
34023406
}

services/surfaceflinger/tests/unittests/SurfaceFlinger_HotplugTest.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,14 @@
1717
#undef LOG_TAG
1818
#define LOG_TAG "LibSurfaceFlingerUnittests"
1919

20+
#include <aidl/android/hardware/graphics/common/DisplayHotplugEvent.h>
21+
#include <com_android_graphics_surfaceflinger_flags.h>
22+
#include <common/test/FlagUtils.h>
2023
#include "DisplayTransactionTestHelpers.h"
2124

25+
using namespace com::android::graphics::surfaceflinger;
26+
using ::aidl::android::hardware::graphics::common::DisplayHotplugEvent;
27+
2228
namespace android {
2329

2430
class HotplugTest : public DisplayTransactionTest {};
@@ -87,13 +93,19 @@ TEST_F(HotplugTest, ignoresDuplicateDisconnection) {
8793
}
8894

8995
TEST_F(HotplugTest, rejectsHotplugIfFailedToLoadDisplayModes) {
96+
SET_FLAG_FOR_TEST(flags::connected_display, true);
97+
9098
// Inject a primary display.
9199
PrimaryDisplayVariant::injectHwcDisplay(this);
92100

93101
using ExternalDisplay = ExternalDisplayVariant;
94102
constexpr bool kFailedHotplug = true;
95103
ExternalDisplay::setupHwcHotplugCallExpectations<kFailedHotplug>(this);
96104

105+
EXPECT_CALL(*mEventThread,
106+
onHotplugConnectionError(static_cast<int32_t>(DisplayHotplugEvent::ERROR_UNKNOWN)))
107+
.Times(1);
108+
97109
// Simulate a connect event that fails to load display modes due to HWC already having
98110
// disconnected the display but SF yet having to process the queued disconnect event.
99111
EXPECT_CALL(*mComposer, getActiveConfig(ExternalDisplay::HWC_DISPLAY_ID, _))

0 commit comments

Comments
 (0)