Output metrics in YAML format

Merge from http://go/wvgerrit/158917

Use go/yamllint as reference and obfuscate portion of output to
run on an online yaml validator.

Sample output: http://go/cl/481370906

Test: Netflix, Play TV and Movies, Youtube
Test: adb shell dumpsys android.hardware.drm.IDrmFactory/widevine
Test: ./build_and_run_all_unit_tests.sh

Bug: 239462891
Change-Id: I1abf1aa50aa25b97b1f6c10995c324d6de04d056
This commit is contained in:
Edwin Wong
2022-10-16 20:31:42 +00:00
parent 3cfe7c7299
commit c70e3deb8b
8 changed files with 1036 additions and 1303 deletions

View File

@@ -22,6 +22,7 @@
#include "WVUUID.h"
#include "android-base/properties.h"
#include "cutils/properties.h"
#include "error_string_util.h"
#include "wv_cdm_constants.h"
#include "wv_content_decryption_module.h"
#include "wv_metrics.h"
@@ -176,7 +177,7 @@ string WVDrmFactory::stringToHex(const string& s) {
}
void WVDrmFactory::printCdmMetrics(int fd) {
dprintf(fd, "\n**** Widevine Cdm Metrics ****\n");
dprintf(fd, "widevine_cdm_metrics:\n");
// Verify that the version of the library that we linked against is
// compatible with the version of the headers we compiled against.
@@ -190,32 +191,33 @@ void WVDrmFactory::printCdmMetrics(int fd) {
cdm->GetMetrics(&metrics, &full_list_returned);
if (metrics.empty()) {
dprintf(fd,
"Metrics not available, please retry while streaming a video\n");
" error_message: Metrics not available, please retry while streaming a video.\n");
} else if (!full_list_returned) {
dprintf(fd,
"Not all metrics are returned due to some GetMetric error, "
" error_message: Not all metrics are returned due to some GetMetric error, "
"please check logcat for possible GetMetric errors.\n");
}
if (result == wvcdm::NO_ERROR) {
for (auto& metric : metrics) {
dprintf(fd, "*** Metric size=%zu\n", metric.DebugString().size());
dprintf(fd, " - serialized_proto_bytes: %zu\n", metric.ByteSizeLong());
string formatted;
wv_metrics::FormatWvCdmMetrics(metric, formatted);
dprintf(fd, "%s\n", formatted.c_str());
}
} else {
dprintf(fd, "GetMetrics failed, error=%d\n", result);
dprintf(fd, " error_message: %s\n", ::wvcdm::CdmResponseTypeToString(result).c_str());
dprintf(fd, " error_code: %d\n", result);
}
}
void WVDrmFactory::printCdmProperties(int fd) {
dprintf(fd, "\nwidevine_cdm_properties:\n");
dprintf(fd, " - widevine_cdm_properties:\n");
android::sp<wvcdm::WvContentDecryptionModule> cdm(getCDM());
const bool isLevel1 =
cdm->IsSecurityLevelSupported(wvcdm::CdmSecurityLevel::kSecurityLevelL1);
dprintf(fd, " default_security_level: '%s'\n", isLevel1 ? "L1" : "L3");
dprintf(fd, " default_security_level: \"%s\"\n", isLevel1 ? "L1" : "L3");
const std::map<string, string> cdmProperties = {
{"version_widevine_cdm", wvcdm::QUERY_KEY_WVCDM_VERSION},
@@ -251,7 +253,7 @@ void WVDrmFactory::printCdmProperties(int fd) {
cdm->QueryStatus(wvcdm::RequestedSecurityLevel::kLevelDefault,
property.second, &value);
string outString = stringToHex(value);
dprintf(fd, " %s: '%s'\n", property.first.c_str(), outString.c_str());
dprintf(fd, " %s: \"%s\"\n", property.first.c_str(), outString.c_str());
value.clear();
}
}