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
This commit is contained in:
Alex Dale
2023-04-21 14:18:29 -07:00
parent c42627a23e
commit 666e26284f

View File

@@ -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<int>(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) {