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

Commit 6d0ae807 authored by Gil Dekel's avatar Gil Dekel
Browse files

SF: use a switch for events in configureLocked()

HotplugEvent is an enum, and its cases should be handled from within a
switch case in configureLocked().

Improve readability and reduce indentation via this refactor.

Flag: EXEMPT refactor
Bug: 393126541
Test: libsurfaceflinger_unittest
Change-Id: Icb1ec5b7691ec9162af052bbce5c36192ee6952b
parent bff87588
Loading
Loading
Loading
Loading
+14 −10
Original line number Diff line number Diff line
@@ -3758,13 +3758,16 @@ bool SurfaceFlinger::configureLocked() {
    }

    for (const auto [hwcDisplayId, event] : events) {
        if (auto info = getHwComposer().onHotplug(hwcDisplayId, event)) {
        auto info = getHwComposer().onHotplug(hwcDisplayId, event);
        if (!info) {
            continue;
        }

        const auto displayId = info->id;
            const ftl::Concat displayString("display ", displayId.value, "(HAL ID ", hwcDisplayId,
                                            ')');
            // TODO: b/393126541 - replace if with switch as all cases are handled.
            if (event == HWComposer::HotplugEvent::Connected ||
                event == HWComposer::HotplugEvent::LinkUnstable) {
        const ftl::Concat displayString("display ", displayId.value, "(HAL ID ", hwcDisplayId, ')');
        switch (event) {
            case HWComposer::HotplugEvent::Connected:
            case HWComposer::HotplugEvent::LinkUnstable: {
                const auto activeModeIdOpt =
                        processHotplugConnect(displayId, hwcDisplayId, std::move(*info),
                                              displayString.c_str(), event);
@@ -3793,12 +3796,13 @@ bool SurfaceFlinger::configureLocked() {
                LOG_ALWAYS_FATAL_IF(!snapshotOpt);

                mDisplayModeController.registerDisplay(*snapshotOpt, *activeModeIdOpt, config);
            } else { // event == HWComposer::HotplugEvent::Disconnected
                break;
            }
            case HWComposer::HotplugEvent::Disconnected:
                // Unregister before destroying the DisplaySnapshot below.
                mDisplayModeController.unregisterDisplay(displayId);

                processHotplugDisconnect(displayId, displayString.c_str());
            }
                break;
        }
    }