Add dump of hdr event history
Track & dump the HDRLayerInfo callback history to
aid debugging when HDR brightness changes aren't
happening
Bug: 234181960
Test: adb shell dumpsys surfaceflinger --hdrinfo
Change-Id: Ia8376517877d4c7844af6be4d488299554c164f5
diff --git a/services/surfaceflinger/HdrLayerInfoReporter.cpp b/services/surfaceflinger/HdrLayerInfoReporter.cpp
index 9eefbe4..2788332 100644
--- a/services/surfaceflinger/HdrLayerInfoReporter.cpp
+++ b/services/surfaceflinger/HdrLayerInfoReporter.cpp
@@ -18,14 +18,22 @@
#define LOG_TAG "HdrLayerInfoReporter"
#define ATRACE_TAG ATRACE_TAG_GRAPHICS
+#include <android-base/stringprintf.h>
+#include <inttypes.h>
#include <utils/Trace.h>
#include "HdrLayerInfoReporter.h"
namespace android {
+using base::StringAppendF;
+
void HdrLayerInfoReporter::dispatchHdrLayerInfo(const HdrLayerInfo& info) {
ATRACE_CALL();
+ if (mHdrInfoHistory.size() == 0 || mHdrInfoHistory.back().info != info) {
+ mHdrInfoHistory.next() = EventHistoryEntry{info};
+ }
+
std::vector<sp<gui::IHdrLayerInfoListener>> toInvoke;
{
std::scoped_lock lock(mMutex);
@@ -62,4 +70,15 @@
mListeners.erase(wp<IBinder>(IInterface::asBinder(listener)));
}
+void HdrLayerInfoReporter::dump(std::string& result) const {
+ for (size_t i = 0; i < mHdrInfoHistory.size(); i++) {
+ const auto& event = mHdrInfoHistory[i];
+ const auto& info = event.info;
+ StringAppendF(&result,
+ "%" PRId64 ": numHdrLayers(%d), size(%dx%d), flags(%X), desiredRatio(%.2f)\n",
+ event.timestamp, info.numberOfHdrLayers, info.maxW, info.maxH, info.flags,
+ info.maxDesiredHdrSdrRatio);
+ }
+}
+
} // namespace android
\ No newline at end of file