From 13daf6d3edb518507e66910f8e77f0d1920fcd74 Mon Sep 17 00:00:00 2001 From: Rahul Frias Date: Thu, 5 May 2022 15:41:20 -0700 Subject: [PATCH] Check L3 for secure stops [ Merge of http://go/wvgerrit/151512 ] Parameterizing GtsMediaDrm tests exposed a few issues. If secure stops were stored at L3 security level, retrieval would fail. This CL checks L3 if the secure stop was not found at the default security level. Bug: 221249079 Test: GtsMediaTestCases Change-Id: Ie88197f8e29457981d782199a76d38774f6faa67 --- libwvdrmengine/cdm/core/include/cdm_engine.h | 15 +++++++++--- libwvdrmengine/cdm/core/src/cdm_engine.cpp | 24 +++++++++++++++++++- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/libwvdrmengine/cdm/core/include/cdm_engine.h b/libwvdrmengine/cdm/core/include/cdm_engine.h index ce4b6822..2bc0a7a8 100644 --- a/libwvdrmengine/cdm/core/include/cdm_engine.h +++ b/libwvdrmengine/cdm/core/include/cdm_engine.h @@ -243,15 +243,24 @@ class CdmEngine { int* error_detail, CdmUsageInfo* usage_info); - // Retrieve the usage info for the specified pst. - // Returns UNKNOWN_ERROR if no usage info was found. - // id. If |error_detail| is not null, an additional error code may be provided + // Retrieve usage info whose PST is specified by |ssid| + // If |error_detail| is not null, an additional error code may be provided // in the event of an error. virtual CdmResponseType GetUsageInfo(const std::string& app_id, const CdmSecureStopId& ssid, int* error_detail, CdmUsageInfo* usage_info); + // Retrieve usage info for a given security level and whose + // PST is specified by |ssid|. + // If |error_detail| is not null, an additional error code may be provided + // in the event of an error. + virtual CdmResponseType GetUsageInfo(const std::string& app_id, + const CdmSecureStopId& ssid, + RequestedSecurityLevel security_level, + int* error_detail, + CdmUsageInfo* usage_info); + // Remove all usage records for the current origin. virtual CdmResponseType RemoveAllUsageInfo(const std::string& app_id, CdmSecurityLevel security_level); diff --git a/libwvdrmengine/cdm/core/src/cdm_engine.cpp b/libwvdrmengine/cdm/core/src/cdm_engine.cpp index 7e3dd60b..4a6a94f8 100644 --- a/libwvdrmengine/cdm/core/src/cdm_engine.cpp +++ b/libwvdrmengine/cdm/core/src/cdm_engine.cpp @@ -1385,6 +1385,28 @@ CdmResponseType CdmEngine::GetUsageInfo(const std::string& app_id, const CdmSecureStopId& ssid, int* error_detail, CdmUsageInfo* usage_info) { + // Try to find usage info at the default security level. If the + // security level is unprovisioned or we are unable to find it, + // try L3. + CdmResponseType status = + GetUsageInfo(app_id, ssid, kLevelDefault, error_detail, usage_info); + switch (status) { + case NEED_PROVISIONING: + case GET_USAGE_INFO_ERROR_1: + case GET_USAGE_INFO_ERROR_2: + case USAGE_INFO_NOT_FOUND: + status = GetUsageInfo(app_id, ssid, kLevel3, error_detail, usage_info); + return status; + default: + return status; + } +} + +CdmResponseType CdmEngine::GetUsageInfo(const std::string& app_id, + const CdmSecureStopId& ssid, + RequestedSecurityLevel security_level, + int* error_detail, + CdmUsageInfo* usage_info) { LOGI("app_id = %s, ssid = %s", IdToString(app_id), IdToString(ssid)); if (!usage_property_set_) { usage_property_set_.reset(new UsagePropertySet()); @@ -1393,7 +1415,7 @@ CdmResponseType CdmEngine::GetUsageInfo(const std::string& app_id, LOGE("Output |usage_info| is null"); return PARAMETER_NULL; } - usage_property_set_->set_security_level(kLevelDefault); + usage_property_set_->set_security_level(security_level); usage_property_set_->set_app_id(app_id); usage_session_.reset(new CdmSession(file_system_, metrics_->AddSession())); CdmResponseType status = usage_session_->Init(usage_property_set_.get());