mediametrics: locally aggregate legacy drm metrics

Bug: 134789967
Test: statsd_testdrive
Change-Id: I053e58d2bccc1a14fafcb2fcb0bd40ec7d1fad17
gugelfrei
Robert Shih 4 years ago
parent 93fb84c8d5
commit 5edf2451d0

@ -35,6 +35,9 @@
#include <statslog.h> #include <statslog.h>
#include <array>
#include <string>
namespace android { namespace android {
// mediadrm // mediadrm
@ -107,8 +110,14 @@ bool statsd_widevineCDM(const mediametrics::Item *item)
// drmmanager // drmmanager
bool statsd_drmmanager(const mediametrics::Item *item) bool statsd_drmmanager(const mediametrics::Item *item)
{ {
using namespace std::string_literals;
if (item == NULL) return false; if (item == NULL) return false;
if (!enabled_statsd) {
ALOGV("NOT sending: drmmanager data");
return true;
}
const nsecs_t timestamp = MediaMetricsService::roundTime(item->getTimestamp()); const nsecs_t timestamp = MediaMetricsService::roundTime(item->getTimestamp());
std::string pkgName = item->getPkgName(); std::string pkgName = item->getPkgName();
int64_t pkgVersionCode = item->getPkgVersionCode(); int64_t pkgVersionCode = item->getPkgVersionCode();
@ -123,16 +132,22 @@ bool statsd_drmmanager(const mediametrics::Item *item)
char *mime_types = NULL; char *mime_types = NULL;
(void) item->getCString("mime_types", &mime_types); (void) item->getCString("mime_types", &mime_types);
if (enabled_statsd) { // Corresponds to the 13 APIs tracked in the MediametricsDrmManagerReported statsd proto
android::util::stats_write(android::util::MEDIAMETRICS_DRMMANAGER_REPORTED, // Please see also DrmManager::kMethodIdMap
timestamp, pkgName.c_str(), pkgVersionCode, std::array<int64_t, 13> methodCounts{};
mediaApexVersion, for (size_t i = 0; i < methodCounts.size() ; i++) {
plugin_id, description, item->getInt64(("method"s + std::to_string(i)).c_str(), &methodCounts[i]);
method_id, mime_types);
} else {
ALOGV("NOT sending: drmmanager data");
} }
android::util::stats_write(android::util::MEDIAMETRICS_DRMMANAGER_REPORTED,
timestamp, pkgName.c_str(), pkgVersionCode, mediaApexVersion,
plugin_id, description, method_id, mime_types,
methodCounts[0], methodCounts[1], methodCounts[2],
methodCounts[3], methodCounts[4], methodCounts[5],
methodCounts[6], methodCounts[7], methodCounts[8],
methodCounts[9], methodCounts[10], methodCounts[11],
methodCounts[12]);
free(plugin_id); free(plugin_id);
free(description); free(description);
free(mime_types); free(mime_types);

Loading…
Cancel
Save