Add device files error detail to metrics.
[ Merge from http://go/wvgerrit/71923 ] Plumb through the device files error detail and add the detail to metrics. Bug: http://b/115382201 Test: Unit tests, manual GPlay. Change-Id: I18139f6712b6670be5fed863a97f9f03440745c7
This commit is contained in:
@@ -228,7 +228,7 @@ class CdmEngine {
|
||||
// id. 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,
|
||||
CdmResponseType* error_detail,
|
||||
int* error_detail,
|
||||
CdmUsageInfo* usage_info);
|
||||
|
||||
// Retrieve the usage info for the specified pst.
|
||||
@@ -237,7 +237,7 @@ class CdmEngine {
|
||||
// in the event of an error.
|
||||
virtual CdmResponseType GetUsageInfo(const std::string& app_id,
|
||||
const CdmSecureStopId& ssid,
|
||||
CdmResponseType* error_detail,
|
||||
int* error_detail,
|
||||
CdmUsageInfo* usage_info);
|
||||
|
||||
// Remove all usage records for the current origin.
|
||||
@@ -363,7 +363,7 @@ class CdmEngine {
|
||||
bool ValidateKeySystem(const CdmKeySystem& key_system);
|
||||
CdmResponseType GetUsageInfo(const std::string& app_id,
|
||||
SecurityLevel requested_security_level,
|
||||
CdmResponseType* error_detail,
|
||||
int* error_detail,
|
||||
CdmUsageInfo* usage_info);
|
||||
|
||||
void OnKeyReleaseEvent(const CdmKeySetId& key_set_id);
|
||||
|
||||
@@ -181,10 +181,10 @@ class CdmEngineMetricsImpl : public T {
|
||||
}
|
||||
|
||||
CdmResponseType GetUsageInfo(const std::string& app_id,
|
||||
CdmResponseType* error_detail,
|
||||
int* error_detail,
|
||||
CdmUsageInfo* usage_info) override {
|
||||
CdmResponseType sts;
|
||||
CdmResponseType error_detail_alt;
|
||||
int error_detail_alt;
|
||||
M_TIME(sts = T::GetUsageInfo(app_id, &error_detail_alt, usage_info),
|
||||
metrics_, cdm_engine_get_usage_info_, sts, error_detail_alt);
|
||||
if (error_detail != nullptr) {
|
||||
@@ -196,10 +196,10 @@ class CdmEngineMetricsImpl : public T {
|
||||
|
||||
CdmResponseType GetUsageInfo(const std::string& app_id,
|
||||
const CdmSecureStopId& ssid,
|
||||
CdmResponseType* error_detail,
|
||||
int* error_detail,
|
||||
CdmUsageInfo* usage_info) override {
|
||||
CdmResponseType sts;
|
||||
CdmResponseType error_detail_alt;
|
||||
int error_detail_alt;
|
||||
M_TIME(sts = T::GetUsageInfo(app_id, ssid, &error_detail_alt, usage_info),
|
||||
metrics_, cdm_engine_get_usage_info_, sts, error_detail_alt);
|
||||
if (error_detail != nullptr) {
|
||||
|
||||
@@ -60,12 +60,20 @@ class CdmSession {
|
||||
const CdmSessionId* forced_session_id,
|
||||
WvCdmEventListener* event_listener);
|
||||
|
||||
// Restores an offline session identified by the |key_set_id| and
|
||||
// |license_type|. The |error_detail| will be filled with an internal error
|
||||
// code. The |error_detail| may be a CdmResponseType or other error code type.
|
||||
// It is only suitable for additional logging or debugging.
|
||||
virtual CdmResponseType RestoreOfflineSession(
|
||||
const CdmKeySetId& key_set_id, CdmLicenseType license_type,
|
||||
CdmResponseType* error_detail);
|
||||
int* error_detail);
|
||||
// Restores an usage session from the provided |usage_data|.
|
||||
// The |error_detail| will be filled with an internal error code. The
|
||||
// |error_detail| may be a CdmResponseType or other error code type. It is
|
||||
// only suitable for additional logging or debugging.
|
||||
virtual CdmResponseType RestoreUsageSession(
|
||||
const DeviceFiles::CdmUsageData& usage_data,
|
||||
CdmResponseType* error_detail);
|
||||
int* error_detail);
|
||||
|
||||
virtual const CdmSessionId& session_id() { return session_id_; }
|
||||
virtual const CdmKeySetId& key_set_id() { return key_set_id_; }
|
||||
@@ -209,7 +217,9 @@ class CdmSession {
|
||||
bool GenerateKeySetId(CdmKeySetId* key_set_id);
|
||||
|
||||
CdmResponseType StoreLicense();
|
||||
bool StoreLicense(DeviceFiles::LicenseState state);
|
||||
|
||||
bool StoreLicense(DeviceFiles::LicenseState state,
|
||||
int* error_detail);
|
||||
|
||||
bool UpdateUsageInfo();
|
||||
|
||||
|
||||
@@ -30,24 +30,27 @@ class DeviceFiles {
|
||||
kLicenseStateUnknown,
|
||||
} LicenseState;
|
||||
|
||||
// All error response codes start with 5000 to avoid overlap with other error
|
||||
// spaces.
|
||||
enum ResponseType {
|
||||
kNoError = 0,
|
||||
kObjectNotInitialized = 1,
|
||||
kParameterNull = 2,
|
||||
kBasePathUnavailable = 3,
|
||||
kFileNotFound = 4,
|
||||
kFileOpenFailed = 5,
|
||||
kFileWriteError = 6,
|
||||
kFileReadError = 7,
|
||||
kInvalidFileSize = 8,
|
||||
kHashComputationFailed = 9,
|
||||
kFileHashMismatch = 10,
|
||||
kFileParseError1 = 11,
|
||||
kFileParseError2 = 12,
|
||||
kUnknownLicenseState = 13,
|
||||
kIncorrectFileType = 14,
|
||||
kIncorrectFileVersion = 15,
|
||||
kLicenseNotPresent = 16,
|
||||
kNoError = NO_ERROR,
|
||||
kResponseTypeBase = 5000,
|
||||
kObjectNotInitialized = kResponseTypeBase + 1,
|
||||
kParameterNull = kResponseTypeBase + 2,
|
||||
kBasePathUnavailable = kResponseTypeBase + 3,
|
||||
kFileNotFound = kResponseTypeBase + 4,
|
||||
kFileOpenFailed = kResponseTypeBase + 5,
|
||||
kFileWriteError = kResponseTypeBase + 6,
|
||||
kFileReadError = kResponseTypeBase + 7,
|
||||
kInvalidFileSize = kResponseTypeBase + 8,
|
||||
kHashComputationFailed = kResponseTypeBase + 9,
|
||||
kFileHashMismatch = kResponseTypeBase + 10,
|
||||
kFileParseError1 = kResponseTypeBase + 11,
|
||||
kFileParseError2 = kResponseTypeBase + 12,
|
||||
kUnknownLicenseState = kResponseTypeBase + 13,
|
||||
kIncorrectFileType = kResponseTypeBase + 14,
|
||||
kIncorrectFileVersion = kResponseTypeBase + 15,
|
||||
kLicenseNotPresent = kResponseTypeBase + 16,
|
||||
};
|
||||
|
||||
struct CdmUsageData {
|
||||
|
||||
@@ -285,7 +285,7 @@ CdmResponseType CdmEngine::GenerateKeyRequest(
|
||||
|
||||
if (license_type == kLicenseTypeRelease &&
|
||||
!session->license_received()) {
|
||||
CdmResponseType error_detail = NO_ERROR;
|
||||
int error_detail = NO_ERROR;
|
||||
sts = session->RestoreOfflineSession(key_set_id, kLicenseTypeRelease,
|
||||
&error_detail);
|
||||
session->GetMetrics()->cdm_session_restore_offline_session_.Increment(
|
||||
@@ -421,7 +421,7 @@ CdmResponseType CdmEngine::RestoreKey(const CdmSessionId& session_id,
|
||||
}
|
||||
|
||||
CdmResponseType sts;
|
||||
CdmResponseType error_detail = NO_ERROR;
|
||||
int error_detail = NO_ERROR;
|
||||
sts = session->RestoreOfflineSession(key_set_id, kLicenseTypeOffline,
|
||||
&error_detail);
|
||||
session->GetMetrics()->cdm_session_restore_offline_session_.Increment(
|
||||
@@ -1212,7 +1212,7 @@ CdmResponseType CdmEngine::RemoveOfflineLicense(
|
||||
|
||||
CdmResponseType CdmEngine::GetUsageInfo(const std::string& app_id,
|
||||
const CdmSecureStopId& ssid,
|
||||
CdmResponseType* error_detail,
|
||||
int* error_detail,
|
||||
CdmUsageInfo* usage_info) {
|
||||
LOGI("CdmEngine::GetUsageInfo: %s", ssid.c_str());
|
||||
if (NULL == usage_property_set_.get()) {
|
||||
@@ -1285,7 +1285,7 @@ CdmResponseType CdmEngine::GetUsageInfo(const std::string& app_id,
|
||||
}
|
||||
|
||||
CdmResponseType CdmEngine::GetUsageInfo(const std::string& app_id,
|
||||
CdmResponseType* error_detail,
|
||||
int* error_detail,
|
||||
CdmUsageInfo* usage_info) {
|
||||
LOGI("CdmEngine::GetUsageInfo: %s", app_id.c_str());
|
||||
// Return a random usage report from a random security level
|
||||
@@ -1315,7 +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,
|
||||
int* error_detail,
|
||||
CdmUsageInfo* usage_info) {
|
||||
LOGI("CdmEngine::GetUsageInfo: %s, security level: %d", app_id.c_str(),
|
||||
requested_security_level);
|
||||
@@ -1652,7 +1652,7 @@ CdmResponseType CdmEngine::LoadUsageSession(const CdmKeySetId& key_set_id,
|
||||
return LOAD_USAGE_INFO_MISSING;
|
||||
}
|
||||
|
||||
CdmResponseType error_detail = NO_ERROR;
|
||||
int error_detail = NO_ERROR;
|
||||
CdmResponseType status = session->RestoreUsageSession(usage_data,
|
||||
&error_detail);
|
||||
session->GetMetrics()->cdm_session_restore_usage_session_.Increment(
|
||||
|
||||
@@ -24,8 +24,8 @@ namespace {
|
||||
const size_t kKeySetIdLength = 14;
|
||||
|
||||
// Helper function for setting the error detail value.
|
||||
void SetErrorDetail(wvcdm::CdmResponseType* error_detail,
|
||||
wvcdm::CdmResponseType error_code) {
|
||||
template<typename T>
|
||||
void SetErrorDetail(int* error_detail, T error_code) {
|
||||
if (error_detail != nullptr) {
|
||||
*error_detail = error_code;
|
||||
}
|
||||
@@ -210,7 +210,7 @@ CdmResponseType CdmSession::Init(CdmClientPropertySet* cdm_client_property_set,
|
||||
|
||||
CdmResponseType CdmSession::RestoreOfflineSession(
|
||||
const CdmKeySetId& key_set_id, CdmLicenseType license_type,
|
||||
CdmResponseType* error_detail) {
|
||||
int* error_detail) {
|
||||
if (!initialized_) {
|
||||
LOGE("CdmSession::RestoreOfflineSession: not initialized");
|
||||
return NOT_INITIALIZED_ERROR;
|
||||
@@ -237,6 +237,7 @@ CdmResponseType CdmSession::RestoreOfflineSession(
|
||||
"CdmSession::RestoreOfflineSession: failed to retrieve license. "
|
||||
"sub error: %d, key set id = %s",
|
||||
sub_error_code, key_set_id.c_str());
|
||||
SetErrorDetail(error_detail, sub_error_code);
|
||||
return GET_LICENSE_ERROR;
|
||||
}
|
||||
|
||||
@@ -306,7 +307,7 @@ CdmResponseType CdmSession::RestoreOfflineSession(
|
||||
sts);
|
||||
return sts;
|
||||
}
|
||||
if (!StoreLicense(license_state)) {
|
||||
if (!StoreLicense(license_state, error_detail)) {
|
||||
LOGW(
|
||||
"CdmSession::RestoreUsageSession: unable to save updated usage "
|
||||
"info");
|
||||
@@ -320,8 +321,7 @@ CdmResponseType CdmSession::RestoreOfflineSession(
|
||||
}
|
||||
|
||||
CdmResponseType CdmSession::RestoreUsageSession(
|
||||
const DeviceFiles::CdmUsageData& usage_data,
|
||||
CdmResponseType* error_detail) {
|
||||
const DeviceFiles::CdmUsageData& usage_data, int* error_detail) {
|
||||
if (!initialized_) {
|
||||
LOGE("CdmSession::RestoreUsageSession: not initialized");
|
||||
return NOT_INITIALIZED_ERROR;
|
||||
@@ -686,7 +686,8 @@ CdmResponseType CdmSession::RenewKey(const CdmKeyResponse& key_response) {
|
||||
|
||||
if (is_offline_) {
|
||||
offline_key_renewal_response_ = key_response;
|
||||
if (!StoreLicense(DeviceFiles::kLicenseStateActive))
|
||||
if (!StoreLicense(DeviceFiles::kLicenseStateActive,
|
||||
nullptr /* error_detail */))
|
||||
return RENEW_KEY_ERROR_2;
|
||||
}
|
||||
return KEY_ADDED;
|
||||
@@ -721,7 +722,7 @@ CdmResponseType CdmSession::GenerateReleaseRequest(CdmKeyRequest* key_request) {
|
||||
}
|
||||
|
||||
if (is_offline_) { // Mark license as being released
|
||||
if (!StoreLicense(DeviceFiles::kLicenseStateReleasing))
|
||||
if (!StoreLicense(DeviceFiles::kLicenseStateReleasing, nullptr))
|
||||
return RELEASE_KEY_REQUEST_ERROR;
|
||||
} else if (!usage_provider_session_token_.empty()) {
|
||||
if (usage_support_type_ == kUsageEntrySupport) {
|
||||
@@ -846,7 +847,7 @@ CdmResponseType CdmSession::StoreLicense() {
|
||||
return OFFLINE_LICENSE_PROHIBITED;
|
||||
}
|
||||
|
||||
if (!StoreLicense(DeviceFiles::kLicenseStateActive)) {
|
||||
if (!StoreLicense(DeviceFiles::kLicenseStateActive, nullptr)) {
|
||||
LOGE("CdmSession::StoreLicense: Unable to store license");
|
||||
return STORE_LICENSE_ERROR_1;
|
||||
}
|
||||
@@ -891,15 +892,20 @@ CdmResponseType CdmSession::StoreLicense() {
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
bool CdmSession::StoreLicense(DeviceFiles::LicenseState state) {
|
||||
DeviceFiles::ResponseType sub_error_code = DeviceFiles::kNoError;
|
||||
return file_handle_->StoreLicense(
|
||||
bool CdmSession::StoreLicense(DeviceFiles::LicenseState state,
|
||||
int* error_detail) {
|
||||
DeviceFiles::ResponseType error_detail_alt = DeviceFiles::kNoError;
|
||||
bool result = file_handle_->StoreLicense(
|
||||
key_set_id_, state, offline_init_data_, key_request_, key_response_,
|
||||
offline_key_renewal_request_, offline_key_renewal_response_,
|
||||
offline_release_server_url_, policy_engine_->GetPlaybackStartTime(),
|
||||
policy_engine_->GetLastPlaybackTime(),
|
||||
policy_engine_->GetGracePeriodEndTime(), app_parameters_, usage_entry_,
|
||||
usage_entry_number_, &sub_error_code);
|
||||
usage_entry_number_, &error_detail_alt);
|
||||
if (error_detail != nullptr) {
|
||||
*error_detail = error_detail_alt;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
CdmResponseType CdmSession::RemoveKeys() {
|
||||
@@ -953,7 +959,7 @@ void CdmSession::OnTimerEvent(bool update_usage) {
|
||||
policy_engine_->DecryptionEvent();
|
||||
has_decrypted_since_last_report_ = false;
|
||||
if (is_offline_ && !is_release_) {
|
||||
StoreLicense(DeviceFiles::kLicenseStateActive);
|
||||
StoreLicense(DeviceFiles::kLicenseStateActive, nullptr);
|
||||
}
|
||||
}
|
||||
policy_engine_->OnTimerEvent();
|
||||
@@ -1030,7 +1036,7 @@ CdmResponseType CdmSession::UpdateUsageEntryInformation() {
|
||||
|
||||
if (is_offline_)
|
||||
StoreLicense(is_release_ ? DeviceFiles::kLicenseStateReleasing
|
||||
: DeviceFiles::kLicenseStateActive);
|
||||
: DeviceFiles::kLicenseStateActive, nullptr);
|
||||
else if (!usage_provider_session_token_.empty())
|
||||
UpdateUsageInfo();
|
||||
|
||||
|
||||
@@ -279,10 +279,10 @@ class SessionMetrics {
|
||||
ValueMetric<double> cdm_session_life_span_; // Milliseconds.
|
||||
EventMetric<kErrorCodeFieldNumber, CdmResponseType> cdm_session_renew_key_;
|
||||
CounterMetric<kErrorCodeFieldNumber, CdmResponseType,
|
||||
kErrorDetailFieldNumber, CdmResponseType>
|
||||
kErrorDetailFieldNumber, int32_t>
|
||||
cdm_session_restore_offline_session_;
|
||||
CounterMetric<kErrorCodeFieldNumber, CdmResponseType,
|
||||
kErrorDetailFieldNumber, CdmResponseType>
|
||||
kErrorDetailFieldNumber, int32_t>
|
||||
cdm_session_restore_usage_session_;
|
||||
|
||||
EventMetric<kKeyRequestTypeFieldNumber, CdmKeyRequestType>
|
||||
@@ -406,7 +406,7 @@ class EngineMetrics {
|
||||
CounterMetric<kErrorCodeFieldNumber, CdmResponseType>
|
||||
cdm_engine_get_secure_stop_ids_;
|
||||
EventMetric<kErrorCodeFieldNumber, CdmResponseType,
|
||||
kErrorDetailFieldNumber, CdmResponseType>
|
||||
kErrorDetailFieldNumber, int32_t>
|
||||
cdm_engine_get_usage_info_;
|
||||
EventMetric<kErrorCodeFieldNumber, CdmResponseType>
|
||||
cdm_engine_handle_provisioning_response_;
|
||||
|
||||
@@ -90,8 +90,8 @@ void SetAttributeField<drm_metrics::Attributes::kLicenseTypeFieldNumber,
|
||||
|
||||
template <>
|
||||
void SetAttributeField<drm_metrics::Attributes::kErrorDetailFieldNumber,
|
||||
CdmResponseType>(
|
||||
const CdmResponseType &error_detail,
|
||||
int32_t>(
|
||||
const int32_t &error_detail,
|
||||
drm_metrics::Attributes *attributes) {
|
||||
attributes->set_error_detail(error_detail);
|
||||
}
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
|
||||
#include <sstream>
|
||||
|
||||
#include "device_files.h"
|
||||
#include "gmock/gmock.h"
|
||||
#include "google/protobuf/text_format.h"
|
||||
#include "gtest/gtest.h"
|
||||
@@ -251,10 +252,10 @@ TEST_F(SessionMetricsTest, AllSessionMetrics) {
|
||||
session_metrics.SetSessionId(kSessionId1);
|
||||
session_metrics.cdm_session_life_span_.Record(1.0);
|
||||
session_metrics.cdm_session_renew_key_.Record(1.0, NO_ERROR);
|
||||
session_metrics.cdm_session_restore_offline_session_.Increment(NO_ERROR,
|
||||
UNKNOWN_ERROR);
|
||||
session_metrics.cdm_session_restore_usage_session_.Increment(NO_ERROR,
|
||||
UNKNOWN_ERROR);
|
||||
session_metrics.cdm_session_restore_offline_session_.Increment(
|
||||
NO_ERROR, DeviceFiles::ResponseType::kObjectNotInitialized);
|
||||
session_metrics.cdm_session_restore_usage_session_.Increment(
|
||||
NO_ERROR, DeviceFiles::ResponseType::kObjectNotInitialized);
|
||||
session_metrics.cdm_session_license_request_latency_ms_.Record(
|
||||
2.0, kKeyRequestTypeInitial);
|
||||
|
||||
|
||||
@@ -239,7 +239,7 @@ CdmResponseType WvContentDecryptionModule::GetUsageInfo(
|
||||
const std::string& app_id, const CdmIdentifier& identifier,
|
||||
CdmUsageInfo* usage_info) {
|
||||
CdmEngine* cdm_engine = EnsureCdmForIdentifier(identifier);
|
||||
CdmResponseType error_detail = NO_ERROR;
|
||||
int error_detail = NO_ERROR;
|
||||
return cdm_engine->GetUsageInfo(app_id, &error_detail, usage_info);
|
||||
}
|
||||
|
||||
@@ -247,7 +247,7 @@ CdmResponseType WvContentDecryptionModule::GetUsageInfo(
|
||||
const std::string& app_id, const CdmSecureStopId& ssid,
|
||||
const CdmIdentifier& identifier, CdmUsageInfo* usage_info) {
|
||||
CdmEngine* cdm_engine = EnsureCdmForIdentifier(identifier);
|
||||
CdmResponseType error_detail = NO_ERROR;
|
||||
int error_detail = NO_ERROR;
|
||||
return cdm_engine->GetUsageInfo(app_id, ssid, &error_detail, usage_info);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user