From da6437fe5e5e9a4347169692e60017c3cbbfeee0 Mon Sep 17 00:00:00 2001 From: Alex Dale Date: Mon, 1 May 2023 15:37:34 -0700 Subject: [PATCH] Exclude the default CDM from metrics history. [ Merge of http://go/wvgerrit/173410 ] The DRM plugin opens and closes many CDMs using the default identifier. These metrics are not needed when checking the metric history and will no longer be stored. Default CDM metrics will continue to appear in the live metrics list. Bug: 239462891 Bug: 270166158 Test: adb shell dumpsys android.hardware.drm.IDrmFactory/widevine -m Change-Id: I64662a44e9c084cc0f08c5a3f013dbf86374ac2d --- libwvdrmengine/cdm/include/cdm_identifier.h | 2 +- libwvdrmengine/cdm/src/wv_content_decryption_module.cpp | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/libwvdrmengine/cdm/include/cdm_identifier.h b/libwvdrmengine/cdm/include/cdm_identifier.h index ecccdec7..5d7a52dc 100644 --- a/libwvdrmengine/cdm/include/cdm_identifier.h +++ b/libwvdrmengine/cdm/include/cdm_identifier.h @@ -47,7 +47,7 @@ struct CdmIdentifier { // to the default cdm. E.g. no spoid, origin or app package name. Use this // comparison in lieu of the == operator when checking to see if the // identifier would cause the default provisioned certificate to be used. - bool IsEquivalentToDefault() { + bool IsEquivalentToDefault() const { return spoid == EMPTY_SPOID && origin == EMPTY_ORIGIN && app_package_name == EMPTY_APP_PACKAGE_NAME; } diff --git a/libwvdrmengine/cdm/src/wv_content_decryption_module.cpp b/libwvdrmengine/cdm/src/wv_content_decryption_module.cpp index 9ce0108f..b10d8a63 100644 --- a/libwvdrmengine/cdm/src/wv_content_decryption_module.cpp +++ b/libwvdrmengine/cdm/src/wv_content_decryption_module.cpp @@ -565,6 +565,10 @@ CdmResponseType WvContentDecryptionModule::GetCurrentMetricsInternal( void WvContentDecryptionModule::SaveMetrics( const CdmIdentifier& identifier, drm_metrics::WvCdmMetrics&& metrics) { if (saved_metrics_snapshots_ == nullptr) return; + // The DRM plugin opens and closes many CDMs using the default + // identifier. These metrics are not needed when checking the + // metric history. + if (identifier.IsEquivalentToDefault()) return; saved_metrics_snapshots_->PushMetrics( WvMetricsSnapshot::MakeSnapshot(identifier, std::move(metrics))); }