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());