From 666e26284f420526b85d4834334c28bc226b9e42 Mon Sep 17 00:00:00 2001 From: Alex Dale Date: Fri, 21 Apr 2023 14:18:29 -0700 Subject: [PATCH] Include metric history in dumpsys. [ Merge of http://go/wvgerrit/171470 ] Dumping the DRM plugin metrics will now include any saved instances of the CDM metrics that may be available. Bug: 239462891 Bug: 270166158 Test: adb shell dumpsys android.hardware.drm.IDrmFactory/widevine -m Test: atest GtsMediaTestCases Change-Id: I24d3e0771b50fd20212568a7fd5654691ae51f93 --- libwvdrmengine/src/WVDrmFactory.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/libwvdrmengine/src/WVDrmFactory.cpp b/libwvdrmengine/src/WVDrmFactory.cpp index 76c5c067..45df9eab 100644 --- a/libwvdrmengine/src/WVDrmFactory.cpp +++ b/libwvdrmengine/src/WVDrmFactory.cpp @@ -246,7 +246,7 @@ void WVDrmFactory::printCdmMetrics(int fd) { if (result != wvcdm::NO_ERROR) { dprintf(fd, " live_metrics:\n"); dprintf(fd, " error_message: \"%s\"\n", result.ToString().c_str()); - dprintf(fd, " error_code: %d\n", static_cast(result.code())); + dprintf(fd, " error_code: %d\n", result.ToInt()); } else if (snapshots.empty()) { // YAML does not support empty property values. const char kNoMetricsMessage[] = @@ -266,7 +266,24 @@ void WVDrmFactory::printCdmMetrics(int fd) { FormatWvMetricsSnapshotItem(fd, 2, snapshots[i], i); } } - // TODO(b/270166158): Print metrics history. + // Saved metrics. + snapshots.clear(); + result = cdm->GetAllSavedMetricsSnapshots(&snapshots); + if (result != wvcdm::NO_ERROR) { + dprintf(fd, " past_metrics:\n"); + dprintf(fd, " error_message: \"%s\"\n", result.ToString().c_str()); + dprintf(fd, " error_code: %d\n", result.ToInt()); + } else if (snapshots.empty()) { + // YAML does not support empty property values. + const char kNoMetricsMessage[] = + "Metrics not available, no instances have been created."; + dprintf(fd, " past_metrics: [] # %s\n", kNoMetricsMessage); + } else { + dprintf(fd, " past_metrics: # count = %zu\n", snapshots.size()); + for (size_t i = 0; i < snapshots.size(); i++) { + FormatWvMetricsSnapshotItem(fd, 2, snapshots[i], i); + } + } } void WVDrmFactory::printCdmProperties(int fd) {