Adds HAL metrics support for Media Drm
Adds support to fetch metrics from vendor and convert them to a proto
bundle returned from a call to getMetrics.
Bug: 64001676
Test: CTS test for metrics and GPlay test
Change-Id: I05634dd1bf092e64e2d0e77c4c0e243340af48e3
diff --git a/drm/libmediadrm/DrmHal.cpp b/drm/libmediadrm/DrmHal.cpp
index 48f4479..c24db57 100644
--- a/drm/libmediadrm/DrmHal.cpp
+++ b/drm/libmediadrm/DrmHal.cpp
@@ -48,6 +48,7 @@
using drm::V1_0::SecureStopId;
using drm::V1_1::SecurityLevel;
using drm::V1_0::Status;
+using ::android::hardware::drm::V1_1::DrmMetricGroup;
using ::android::hardware::hidl_array;
using ::android::hardware::hidl_string;
using ::android::hardware::hidl_vec;
@@ -1111,12 +1112,48 @@
return toStatusT(status);
}
-status_t DrmHal::getMetrics(PersistableBundle* item) {
- if (item == nullptr) {
- return UNEXPECTED_NULL;
+status_t DrmHal::getMetrics(PersistableBundle* metrics) {
+ if (metrics == nullptr) {
+ return UNEXPECTED_NULL;
+ }
+ mMetrics.Export(metrics);
+
+ // Append vendor metrics if they are supported.
+ if (mPluginV1_1 != NULL) {
+ String8 vendor;
+ String8 description;
+ if (getPropertyStringInternal(String8("vendor"), vendor) != OK
+ || vendor.isEmpty()) {
+ ALOGE("Get vendor failed or is empty");
+ vendor = "NONE";
+ }
+ if (getPropertyStringInternal(String8("description"), description) != OK
+ || description.isEmpty()) {
+ ALOGE("Get description failed or is empty.");
+ description = "NONE";
+ }
+ vendor += ".";
+ vendor += description;
+
+ hidl_vec<DrmMetricGroup> pluginMetrics;
+ status_t err = UNKNOWN_ERROR;
+
+ Return<void> status = mPluginV1_1->getMetrics(
+ [&](Status status, hidl_vec<DrmMetricGroup> pluginMetrics) {
+ if (status != Status::OK) {
+ ALOGV("Error getting plugin metrics: %d", status);
+ } else {
+ PersistableBundle pluginBundle;
+ if (MediaDrmMetrics::HidlMetricsToBundle(
+ pluginMetrics, &pluginBundle) == OK) {
+ metrics->putPersistableBundle(String16(vendor), pluginBundle);
+ }
+ }
+ err = toStatusT(status);
+ });
+ return status.isOk() ? err : DEAD_OBJECT;
}
- mMetrics.Export(item);
return OK;
}