Added metrics history for WV CDM for Android.

[ Merge of http://go/wvgerrit/171271 ]

There is a need to maintain a short history of metrics from CDMs which
have been deleted.  This CL adds this ability to the Android version
of the WV CDM.  The history cannot yet be maintained for long, as the
WV CDM instance is destroyed if unused.

Further changes are required to the plugin to maintain the history
beyond the life-cycle of the CDM instance, and to properly format
its output.

Bug: 239462891
Bug: 270166158
Test: adb shell dumpsys android.hardware.drm.IDrmFactory/widevine -m
Test: atest GtsMediaTestCases
Change-Id: I81c0996602722a9795fc3951030d20bb39b5816b
This commit is contained in:
Alex Dale
2023-04-18 20:15:16 -07:00
parent 5ce29c42da
commit c42627a23e
7 changed files with 259 additions and 80 deletions

View File

@@ -19,6 +19,7 @@
#include <list>
#include <sstream>
#include <string>
#include <utility>
#include "Utils.h"
#include "android-base/macros.h"
@@ -754,24 +755,23 @@ Status WVDrmPlugin::unprovisionDevice() {
::ndk::ScopedAStatus WVDrmPlugin::getMetrics(
vector<::aidl::android::hardware::drm::DrmMetricGroup>* _aidl_return) {
_aidl_return->clear();
CdmIdentifier identifier;
auto status = mCdmIdentifierBuilder.getCdmIdentifier(&identifier);
if (status != Status::OK) {
*_aidl_return = vector<DrmMetricGroup>();
return toNdkScopedAStatus(status);
}
drm_metrics::WvCdmMetrics proto_metrics;
CdmResponseType result = mCDM->GetMetrics(identifier, &proto_metrics);
const CdmResponseType result = mCDM->GetCurrentMetrics(identifier, &proto_metrics);
if (result != wvcdm::NO_ERROR) {
*_aidl_return = vector<DrmMetricGroup>();
return toNdkScopedAStatus(mapCdmResponseType(result));
}
vector<DrmMetricGroup> wvMetrics;
::wvcdm::WvMetricsAdapter adapter;
::wvcdm::WvMetricsAdapter::ToWvMetrics(proto_metrics, &wvMetrics);
*_aidl_return = wvMetrics;
*_aidl_return = std::move(wvMetrics);
return toNdkScopedAStatus(Status::OK);
}
@@ -1196,7 +1196,8 @@ Status WVDrmPlugin::unprovisionDevice() {
if (status != Status::OK) {
ALOGE("Unexpected error retrieving cdm identifier: %d", status.get());
} else {
status = mapCdmResponseType(mCDM->GetMetrics(identifier, &metrics));
status =
mapCdmResponseType(mCDM->GetCurrentMetrics(identifier, &metrics));
}
}
if (status == Status::OK) {

View File

@@ -241,7 +241,7 @@ class MockCDM : public WvContentDecryptionModule {
MOCK_METHOD(bool, IsValidServiceCertificate, (const std::string &),
(override));
MOCK_METHOD(CdmResponseType, GetMetrics,
MOCK_METHOD(CdmResponseType, GetCurrentMetrics,
(const CdmIdentifier &, drm_metrics::WvCdmMetrics *), (override));
MOCK_METHOD(CdmResponseType, GetDecryptHashError,
@@ -1175,7 +1175,7 @@ TEST_F(WVDrmPluginHalTest, ReturnsExpectedPropertyValues) {
.WillOnce(DoAll(SetArgPointee<2>(wvcdm::QUERY_VALUE_NOT_SUPPORTED),
testing::Return(CdmResponseType(wvcdm::NO_ERROR))));
EXPECT_CALL(*mCdm, GetMetrics(_, _))
EXPECT_CALL(*mCdm, GetCurrentMetrics(_, _))
.WillOnce(DoAll(SetArgPointee<1>(expected_metrics),
testing::Return(CdmResponseType(wvcdm::NO_ERROR))));