Add error detail metric to some session methods
[ Merge from http://go/wvgerrit/71726 ] Adds an error detail metric attribute to RestoreUsageSession and RestoreOfflineSession. These metrics will now report an additional attribute providing additional error detail for debugging. BUG: http://b/115517916 Test: CDM Unit Tests. Manually tried GPlay. Change-Id: Ib48361ef29d33a16150473d8967e4850bc0c623d
This commit is contained in:
@@ -285,8 +285,11 @@ CdmResponseType CdmEngine::GenerateKeyRequest(
|
||||
|
||||
if (license_type == kLicenseTypeRelease &&
|
||||
!session->license_received()) {
|
||||
sts = session->RestoreOfflineSession(key_set_id, kLicenseTypeRelease);
|
||||
session->GetMetrics()->cdm_session_restore_offline_session_.Increment(sts);
|
||||
CdmResponseType error_detail = NO_ERROR;
|
||||
sts = session->RestoreOfflineSession(key_set_id, kLicenseTypeRelease,
|
||||
&error_detail);
|
||||
session->GetMetrics()->cdm_session_restore_offline_session_.Increment(
|
||||
sts, error_detail);
|
||||
if (sts != KEY_ADDED) {
|
||||
LOGE("CdmEngine::GenerateKeyRequest: key release restoration failed,"
|
||||
"sts = %d", static_cast<int>(sts));
|
||||
@@ -418,8 +421,11 @@ CdmResponseType CdmEngine::RestoreKey(const CdmSessionId& session_id,
|
||||
}
|
||||
|
||||
CdmResponseType sts;
|
||||
sts = session->RestoreOfflineSession(key_set_id, kLicenseTypeOffline);
|
||||
session->GetMetrics()->cdm_session_restore_offline_session_.Increment(sts);
|
||||
CdmResponseType error_detail = NO_ERROR;
|
||||
sts = session->RestoreOfflineSession(key_set_id, kLicenseTypeOffline,
|
||||
&error_detail);
|
||||
session->GetMetrics()->cdm_session_restore_offline_session_.Increment(
|
||||
sts, error_detail);
|
||||
if (sts == NEED_PROVISIONING) {
|
||||
cert_provisioning_requested_security_level_ =
|
||||
session->GetRequestedSecurityLevel();
|
||||
@@ -1206,6 +1212,7 @@ CdmResponseType CdmEngine::RemoveOfflineLicense(
|
||||
|
||||
CdmResponseType CdmEngine::GetUsageInfo(const std::string& app_id,
|
||||
const CdmSecureStopId& ssid,
|
||||
CdmResponseType* error_detail,
|
||||
CdmUsageInfo* usage_info) {
|
||||
LOGI("CdmEngine::GetUsageInfo: %s", ssid.c_str());
|
||||
if (NULL == usage_property_set_.get()) {
|
||||
@@ -1254,8 +1261,7 @@ CdmResponseType CdmEngine::GetUsageInfo(const std::string& app_id,
|
||||
}
|
||||
}
|
||||
|
||||
status =
|
||||
usage_session_->RestoreUsageSession(usage_data);
|
||||
status = usage_session_->RestoreUsageSession(usage_data, error_detail);
|
||||
|
||||
if (KEY_ADDED != status) {
|
||||
LOGE("CdmEngine::GetUsageInfo: restore usage session error %d", status);
|
||||
@@ -1279,6 +1285,7 @@ CdmResponseType CdmEngine::GetUsageInfo(const std::string& app_id,
|
||||
}
|
||||
|
||||
CdmResponseType CdmEngine::GetUsageInfo(const std::string& app_id,
|
||||
CdmResponseType* error_detail,
|
||||
CdmUsageInfo* usage_info) {
|
||||
LOGI("CdmEngine::GetUsageInfo: %s", app_id.c_str());
|
||||
// Return a random usage report from a random security level
|
||||
@@ -1289,7 +1296,7 @@ CdmResponseType CdmEngine::GetUsageInfo(const std::string& app_id,
|
||||
return PARAMETER_NULL;
|
||||
}
|
||||
do {
|
||||
status = GetUsageInfo(app_id, security_level, usage_info);
|
||||
status = GetUsageInfo(app_id, security_level, error_detail, usage_info);
|
||||
|
||||
if (KEY_MESSAGE == status && !usage_info->empty()) {
|
||||
return status;
|
||||
@@ -1298,7 +1305,7 @@ CdmResponseType CdmEngine::GetUsageInfo(const std::string& app_id,
|
||||
|
||||
security_level = (kLevel3 == security_level) ? kLevelDefault : kLevel3;
|
||||
do {
|
||||
status = GetUsageInfo(app_id, security_level, usage_info);
|
||||
status = GetUsageInfo(app_id, security_level, error_detail, usage_info);
|
||||
if (NEED_PROVISIONING == status)
|
||||
return NO_ERROR; // Valid scenario that one of the security
|
||||
// levels has not been provisioned
|
||||
@@ -1308,6 +1315,7 @@ CdmResponseType CdmEngine::GetUsageInfo(const std::string& app_id,
|
||||
|
||||
CdmResponseType CdmEngine::GetUsageInfo(const std::string& app_id,
|
||||
SecurityLevel requested_security_level,
|
||||
CdmResponseType* error_detail,
|
||||
CdmUsageInfo* usage_info) {
|
||||
LOGI("CdmEngine::GetUsageInfo: %s, security level: %d", app_id.c_str(),
|
||||
requested_security_level);
|
||||
@@ -1350,7 +1358,7 @@ CdmResponseType CdmEngine::GetUsageInfo(const std::string& app_id,
|
||||
usage_info->resize(kUsageReportsPerRequest);
|
||||
|
||||
uint32_t index = rand() % usage_data.size();
|
||||
status = usage_session_->RestoreUsageSession(usage_data[index]);
|
||||
status = usage_session_->RestoreUsageSession(usage_data[index], error_detail);
|
||||
if (KEY_ADDED != status) {
|
||||
LOGE("CdmEngine::GetUsageInfo: restore usage session (%d) error %ld", index,
|
||||
status);
|
||||
@@ -1644,8 +1652,11 @@ CdmResponseType CdmEngine::LoadUsageSession(const CdmKeySetId& key_set_id,
|
||||
return LOAD_USAGE_INFO_MISSING;
|
||||
}
|
||||
|
||||
CdmResponseType status = session->RestoreUsageSession(usage_data);
|
||||
session->GetMetrics()->cdm_session_restore_usage_session_.Increment(status);
|
||||
CdmResponseType error_detail = NO_ERROR;
|
||||
CdmResponseType status = session->RestoreUsageSession(usage_data,
|
||||
&error_detail);
|
||||
session->GetMetrics()->cdm_session_restore_usage_session_.Increment(
|
||||
status, error_detail);
|
||||
if (KEY_ADDED != status) {
|
||||
LOGE("CdmEngine::LoadUsageSession: usage session error %ld", status);
|
||||
return status;
|
||||
|
||||
@@ -22,6 +22,15 @@
|
||||
|
||||
namespace {
|
||||
const size_t kKeySetIdLength = 14;
|
||||
|
||||
// Helper function for setting the error detail value.
|
||||
void SetErrorDetail(wvcdm::CdmResponseType* error_detail,
|
||||
wvcdm::CdmResponseType error_code) {
|
||||
if (error_detail != nullptr) {
|
||||
*error_detail = error_code;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
namespace wvcdm {
|
||||
@@ -200,7 +209,8 @@ CdmResponseType CdmSession::Init(CdmClientPropertySet* cdm_client_property_set,
|
||||
}
|
||||
|
||||
CdmResponseType CdmSession::RestoreOfflineSession(
|
||||
const CdmKeySetId& key_set_id, CdmLicenseType license_type) {
|
||||
const CdmKeySetId& key_set_id, CdmLicenseType license_type,
|
||||
CdmResponseType* error_detail) {
|
||||
if (!initialized_) {
|
||||
LOGE("CdmSession::RestoreOfflineSession: not initialized");
|
||||
return NOT_INITIALIZED_ERROR;
|
||||
@@ -272,6 +282,7 @@ CdmResponseType CdmSession::RestoreOfflineSession(
|
||||
license_parser_->RestoreLicenseForRelease(key_request_, key_response_);
|
||||
|
||||
if (result != NO_ERROR) {
|
||||
SetErrorDetail(error_detail, result);
|
||||
return RELEASE_LICENSE_ERROR_1;
|
||||
}
|
||||
} else {
|
||||
@@ -279,6 +290,7 @@ CdmResponseType CdmSession::RestoreOfflineSession(
|
||||
key_request_, key_response_, offline_key_renewal_response_,
|
||||
playback_start_time, last_playback_time, grace_period_end_time, this);
|
||||
if (result != NO_ERROR) {
|
||||
SetErrorDetail(error_detail, result);
|
||||
return RESTORE_OFFLINE_LICENSE_ERROR_2;
|
||||
}
|
||||
}
|
||||
@@ -308,7 +320,8 @@ CdmResponseType CdmSession::RestoreOfflineSession(
|
||||
}
|
||||
|
||||
CdmResponseType CdmSession::RestoreUsageSession(
|
||||
const DeviceFiles::CdmUsageData& usage_data) {
|
||||
const DeviceFiles::CdmUsageData& usage_data,
|
||||
CdmResponseType* error_detail) {
|
||||
if (!initialized_) {
|
||||
LOGE("CdmSession::RestoreUsageSession: not initialized");
|
||||
return NOT_INITIALIZED_ERROR;
|
||||
@@ -338,6 +351,7 @@ CdmResponseType CdmSession::RestoreUsageSession(
|
||||
sts = license_parser_->RestoreLicenseForRelease(key_request_, key_response_);
|
||||
|
||||
if (sts != NO_ERROR) {
|
||||
SetErrorDetail(error_detail, sts);
|
||||
return RELEASE_LICENSE_ERROR_2;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user