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

Commit 5d7de5f8 authored by Dominik Laskowski's avatar Dominik Laskowski
Browse files

SF: Clean up dumpsys for displays

Remove DisplayDevice::getDebugName. Add Dumper::Section to automate
indented sections with a heading.

Bug: 241285876
Test: dumpsys SurfaceFlinger --displays
Change-Id: I21a8e98bf26163e374810f0afbe649e694e5dda6
parent 59db956b
Loading
Loading
Loading
Loading
+1 −17
Original line number Diff line number Diff line
@@ -313,26 +313,10 @@ ui::Transform::RotationFlags DisplayDevice::getPrimaryDisplayRotationFlags() {
    return sPrimaryDisplayRotationFlags;
}

std::string DisplayDevice::getDebugName() const {
    using namespace std::string_literals;

    std::string name = "Display "s + to_string(getId()) + " ("s;

    name += isVirtual() ? "virtual"s : "physical"s;

    if (isPrimary()) {
        name += ", primary"s;
    }

    return name + ", \""s + mDisplayName + "\")"s;
}

void DisplayDevice::dump(utils::Dumper& dumper) const {
    using namespace std::string_view_literals;

    dumper.dump({}, getDebugName());

    utils::Dumper::Indent indent(dumper);
    dumper.dump("name"sv, '"' + mDisplayName + '"');
    dumper.dump("powerMode"sv, mPowerMode);

    if (mRefreshRateSelector) {
+0 −4
Original line number Diff line number Diff line
@@ -248,10 +248,6 @@ public:
    // release HWC resources (if any) for removable displays
    void disconnect();

    /* ------------------------------------------------------------------------
     * Debugging
     */
    std::string getDebugName() const;
    void dump(utils::Dumper&) const;

private:
+9 −6
Original line number Diff line number Diff line
@@ -54,6 +54,7 @@
#include <cutils/compiler.h>
#include <cutils/properties.h>
#include <ftl/algorithm.h>
#include <ftl/concat.h>
#include <ftl/fake_guard.h>
#include <ftl/future.h>
#include <ftl/unit.h>
@@ -3264,7 +3265,7 @@ void SurfaceFlinger::persistDisplayBrightness(bool needsComposite) {

                ALOGE_IF(error != NO_ERROR,
                         "Error setting display brightness for display %s: %d (%s)",
                         display->getDebugName().c_str(), error, strerror(error));
                         to_string(display->getId()).c_str(), error, strerror(error));
            }
            display->persistBrightness(needsComposite);
        }
@@ -4929,19 +4930,21 @@ void SurfaceFlinger::dumpDisplays(std::string& result) const {
    utils::Dumper dumper{result};

    for (const auto& [id, display] : mPhysicalDisplays) {
        utils::Dumper::Section section(dumper, ftl::Concat("Display ", id.value).str());

        display.snapshot().dump(dumper);

        if (const auto device = getDisplayDeviceLocked(id)) {
            device->dump(dumper);
        }

        utils::Dumper::Indent indent(dumper);
        display.snapshot().dump(dumper);
        dumper.eol();
    }

    for (const auto& [token, display] : mDisplays) {
        if (display->isVirtual()) {
            const auto displayId = display->getId();
            utils::Dumper::Section section(dumper,
                                           ftl::Concat("Virtual Display ", displayId.value).str());
            display->dump(dumper);
            dumper.eol();
        }
    }
}
+15 −0
Original line number Diff line number Diff line
@@ -63,6 +63,21 @@ public:
        Dumper& dumper;
    };

    struct Section {
        Section(Dumper& dumper, std::string_view heading) : dumper(dumper) {
            dumper.dump({}, heading);
            indent.emplace(dumper);
        }

        ~Section() {
            indent.reset();
            dumper.eol();
        }

        Dumper& dumper;
        std::optional<Indent> indent;
    };

private:
    std::string& mOut;
    int mIndent = 0;