Build metrics_dump tool in Android.

Replace Makefile with Android.bp.
Remove duplication of protos in proto directory.

Since we are now building the metrics_dump tool
under Android, use frameworks metrics.proto
directly. Also, reference cdm's wv_metrics.proto
from the cdm directory instead of creating a
subset in proto directory.

bug: 161783052
bug: 170607430

Test: build
  m -j128 metrics_dump
Test: metrics_dump [bugreport from adt-3-r.zip]
Test: metrics_dump [bugreport from sabrina-q.gz]
Test: metrics_dump --widevine [adb shell dumpsys media.metrics output]
Change-Id: I82c7e723453ac2a6335cb2bb732a376d535b9ea3
This commit is contained in:
Edwin Wong
2020-09-29 15:45:57 -07:00
parent 1381746ecb
commit d5d0652d4f
12 changed files with 372 additions and 451 deletions

View File

@@ -0,0 +1,56 @@
// Copyright 2020 Google LLC. All Rights Reserved. This file and proprietary
// source code may only be used and distributed under the Widevine License
// Agreement.
//
// Take a line as input, parse the metrics, and returns MediaMetrics
// structure as output.
#include <string>
#include <utility>
#include <vector>
namespace metrics_dump {
// This is the order of metrics prior to R release, do not change.
// We use this to index into a vector of tokens to retrieve metrics.
typedef enum {
kIndexQ,
kVersionQ,
kComponentQ,
kSessionQ,
kUidQ,
kPackageQ,
kPackageVersionQ,
kPidQ,
kFinalizedQ,
kTimestampQ,
kItemCountQ,
// kPropertiesQ serves as a sentinel to indicate properties follow
kPropertiesQ,
} QMediaMetricsItems;
// This is the order of metrics since R release, do not change.
// We use this to index into a vector of tokens to retrieve metrics.
typedef enum {
kIndexR,
kComponentR,
kTimestampR,
kPackageR,
kPidR,
kUidR,
// kPropertiesR serves as a sentinel to indicate properties follow
kPropertiesR,
} RMediaMetricsItems;
typedef struct {
std::string component, finalized, index, item_count;
std::string package, package_version, pid, session;
std::string timestamp, version, uid;
std::vector<std::pair<std::string, std::string>> properties;
} MediaMetrics;
bool is_q_metrics(const std::string &line);
void parse_metrics(const std::string& line, MediaMetrics* metrics);
void to_lower(std::string& lower);
}; // namespace metrics_dump