Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9f0fc590 authored by Huihong Luo's avatar Huihong Luo Committed by Leon Scroggins III
Browse files

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
parent 79e5f98d
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -3395,8 +3395,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;
    }
+12 −0
Original line number Diff line number Diff line
@@ -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 {};
@@ -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);

@@ -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, _))