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

Commit dd09097e authored by Leon Scroggins's avatar Leon Scroggins Committed by Android (Google) Code Review
Browse files

Merge "Report hotplug error to framework" into main

parents 036c283b 9f0fc590
Loading
Loading
Loading
Loading
+5 −1
Original line number Diff line number Diff line
@@ -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;
    }
+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, _))