Skip to content

Commit dd09097

Browse files
LeonScrogginsAndroid (Google) Code Review
authored andcommitted
Merge "Report hotplug error to framework" into main
2 parents 036c283 + 9f0fc59 commit dd09097

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
@@ -3476,8 +3476,12 @@ const char* SurfaceFlinger::processHotplug(PhysicalDisplayId displayId,
34763476

34773477
auto [displayModes, activeMode] = loadDisplayModes(displayId);
34783478
if (!activeMode) {
3479-
// TODO(b/241286153): Report hotplug failure to the framework.
34803479
ALOGE("Failed to hotplug display %s", to_string(displayId).c_str());
3480+
if (FlagManager::getInstance().hotplug2()) {
3481+
mScheduler->onHotplugConnectionError(mAppConnectionHandle,
3482+
static_cast<int32_t>(
3483+
DisplayHotplugEvent::ERROR_UNKNOWN));
3484+
}
34813485
getHwComposer().disconnectDisplay(displayId);
34823486
return nullptr;
34833487
}

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)