Apply recommended type and name changes to metrics.
Bug: 36220619 BUG: 64071905 Test: Re-ran existing unit tests. Ran GTS tests. Tested with Google Play. Change-Id: I79ddc8ed3290e6d74364cf96305054e55243c5ff
This commit is contained in:
@@ -67,6 +67,7 @@ CryptoSession::CryptoSession(metrics::CryptoMetrics* metrics)
|
||||
usage_table_header_(NULL),
|
||||
request_id_base_(0),
|
||||
cipher_mode_(kCipherModeCtr) {
|
||||
assert(metrics);
|
||||
Init();
|
||||
life_span_.Start();
|
||||
}
|
||||
@@ -163,8 +164,7 @@ bool CryptoSession::GetTokenFromKeybox(std::string* token) {
|
||||
metrics_,
|
||||
oemcrypto_get_key_data_,
|
||||
status,
|
||||
metrics::Pow2Bucket(buf_size),
|
||||
requested_security_level_);
|
||||
metrics::Pow2Bucket(buf_size));
|
||||
if (OEMCrypto_SUCCESS == status) {
|
||||
token->swap(temp_buffer);
|
||||
return true;
|
||||
@@ -247,21 +247,13 @@ bool CryptoSession::GetProvisioningToken(std::string* token) {
|
||||
CdmSecurityLevel CryptoSession::GetSecurityLevel() {
|
||||
LOGV("CryptoSession::GetSecurityLevel");
|
||||
if (!initialized_) {
|
||||
M_RECORD(metrics_, oemcrypto_security_level_, 0,
|
||||
kSecurityLevelUninitialized, requested_security_level_);
|
||||
return kSecurityLevelUninitialized;
|
||||
}
|
||||
|
||||
wvcdm::metrics::TimerMetric timer;
|
||||
timer.Start();
|
||||
|
||||
std::string security_level =
|
||||
OEMCrypto_SecurityLevel(requested_security_level_);
|
||||
double clock_time = timer.AsUs();
|
||||
|
||||
if ((security_level.size() != 2) || (security_level.at(0) != 'L')) {
|
||||
M_RECORD(metrics_, oemcrypto_security_level_, clock_time,
|
||||
kSecurityLevelUnknown, requested_security_level_);
|
||||
return kSecurityLevelUnknown;
|
||||
}
|
||||
|
||||
@@ -281,8 +273,6 @@ CdmSecurityLevel CryptoSession::GetSecurityLevel() {
|
||||
break;
|
||||
}
|
||||
|
||||
M_RECORD(metrics_, oemcrypto_security_level_, clock_time,
|
||||
cdm_security_level, requested_security_level_);
|
||||
return cdm_security_level;
|
||||
}
|
||||
|
||||
@@ -306,16 +296,10 @@ bool CryptoSession::GetInternalDeviceUniqueId(std::string* device_id) {
|
||||
size_t id_length = 32;
|
||||
id.resize(id_length);
|
||||
|
||||
OEMCryptoResult sts;
|
||||
M_TIME(
|
||||
sts = OEMCrypto_GetDeviceID(
|
||||
&id[0],
|
||||
&id_length,
|
||||
requested_security_level_),
|
||||
metrics_,
|
||||
oemcrypto_get_device_id_,
|
||||
sts,
|
||||
requested_security_level_);
|
||||
OEMCryptoResult sts = OEMCrypto_GetDeviceID(&id[0], &id_length,
|
||||
requested_security_level_);
|
||||
// Increment the count of times this method was called.
|
||||
metrics_->oemcrypto_get_device_id_.Increment(sts);
|
||||
|
||||
if (OEMCrypto_SUCCESS != sts) {
|
||||
return false;
|
||||
@@ -355,12 +339,10 @@ bool CryptoSession::GetApiVersion(uint32_t* version) {
|
||||
if (!initialized_) {
|
||||
return false;
|
||||
}
|
||||
M_TIME(
|
||||
*version = OEMCrypto_APIVersion(requested_security_level_),
|
||||
metrics_,
|
||||
oemcrypto_api_version_,
|
||||
*version,
|
||||
requested_security_level_);
|
||||
|
||||
*version = OEMCrypto_APIVersion(requested_security_level_);
|
||||
// Record the version into the metrics.
|
||||
metrics_->oemcrypto_api_version_.Record(*version);
|
||||
|
||||
return true;
|
||||
}
|
||||
@@ -390,8 +372,7 @@ bool CryptoSession::GetSystemId(uint32_t* system_id) {
|
||||
metrics_,
|
||||
oemcrypto_get_key_data_,
|
||||
sts,
|
||||
metrics::Pow2Bucket(buf_size),
|
||||
requested_security_level_);
|
||||
metrics::Pow2Bucket(buf_size));
|
||||
|
||||
if (OEMCrypto_SUCCESS != sts) {
|
||||
LOGE("CryptoSession::GetSystemId: OEMCrypto_GetKeyData failed with %d",
|
||||
@@ -551,8 +532,7 @@ bool CryptoSession::GetProvisioningId(std::string* provisioning_id) {
|
||||
metrics_,
|
||||
oemcrypto_get_key_data_,
|
||||
sts,
|
||||
metrics::Pow2Bucket(buf_size),
|
||||
requested_security_level_);
|
||||
metrics::Pow2Bucket(buf_size));
|
||||
if (OEMCrypto_SUCCESS != sts) {
|
||||
return false;
|
||||
}
|
||||
@@ -563,14 +543,8 @@ bool CryptoSession::GetProvisioningId(std::string* provisioning_id) {
|
||||
}
|
||||
|
||||
uint8_t CryptoSession::GetSecurityPatchLevel() {
|
||||
uint8_t patch;
|
||||
M_TIME(
|
||||
patch = OEMCrypto_Security_Patch_Level(
|
||||
requested_security_level_),
|
||||
metrics_,
|
||||
oemcrypto_security_patch_level_,
|
||||
patch,
|
||||
requested_security_level_);
|
||||
uint8_t patch = OEMCrypto_Security_Patch_Level(requested_security_level_);
|
||||
metrics_->oemcrypto_security_patch_level_.Record(patch);
|
||||
return patch;
|
||||
}
|
||||
|
||||
@@ -585,15 +559,7 @@ CdmResponseType CryptoSession::Open(SecurityLevel requested_security_level) {
|
||||
|
||||
OEMCrypto_SESSION sid;
|
||||
requested_security_level_ = requested_security_level;
|
||||
OEMCryptoResult sts;
|
||||
M_TIME(
|
||||
sts = OEMCrypto_OpenSession(
|
||||
&sid,
|
||||
requested_security_level),
|
||||
metrics_,
|
||||
oemcrypto_open_session_,
|
||||
sts,
|
||||
requested_security_level);
|
||||
OEMCryptoResult sts = OEMCrypto_OpenSession(&sid, requested_security_level);
|
||||
if (OEMCrypto_SUCCESS == sts) {
|
||||
oec_session_id_ = static_cast<CryptoSessionId>(sid);
|
||||
LOGV("OpenSession: id= %ld", (uint32_t)oec_session_id_);
|
||||
@@ -608,15 +574,10 @@ CdmResponseType CryptoSession::Open(SecurityLevel requested_security_level) {
|
||||
sts, session_count_, (int)initialized_);
|
||||
return UNKNOWN_ERROR;
|
||||
}
|
||||
OEMCryptoResult random_sts;
|
||||
M_TIME(
|
||||
random_sts = OEMCrypto_GetRandom(
|
||||
reinterpret_cast<uint8_t*>(&request_id_base_),
|
||||
sizeof(request_id_base_)),
|
||||
metrics_,
|
||||
oemcrypto_get_random_,
|
||||
random_sts,
|
||||
metrics::Pow2Bucket(sizeof(request_id_base_)));
|
||||
OEMCryptoResult random_sts = OEMCrypto_GetRandom(
|
||||
reinterpret_cast<uint8_t*>(&request_id_base_),
|
||||
sizeof(request_id_base_));
|
||||
metrics_->oemcrypto_get_random_.Increment(random_sts);
|
||||
++request_id_index_;
|
||||
|
||||
CdmUsageSupportType usage_support_type;
|
||||
@@ -660,12 +621,8 @@ void CryptoSession::Close() {
|
||||
AutoLock auto_lock(crypto_lock_);
|
||||
if (!open_) return;
|
||||
|
||||
M_TIME(
|
||||
close_sts = OEMCrypto_CloseSession(
|
||||
oec_session_id_),
|
||||
metrics_,
|
||||
oemcrypto_close_session_,
|
||||
close_sts);
|
||||
close_sts = OEMCrypto_CloseSession(oec_session_id_);
|
||||
metrics_->oemcrypto_close_session_.Increment(close_sts);
|
||||
if (OEMCrypto_SUCCESS == close_sts)
|
||||
open_ = false;
|
||||
update_usage_table = update_usage_table_after_close_session_;
|
||||
@@ -1187,7 +1144,6 @@ CdmResponseType CryptoSession::Decrypt(const CdmDecryptionParameters& params) {
|
||||
metrics_,
|
||||
oemcrypto_copy_buffer_,
|
||||
sts,
|
||||
requested_security_level_,
|
||||
metrics::Pow2Bucket(params.encrypt_length));
|
||||
|
||||
if (sts == OEMCrypto_ERROR_BUFFER_TOO_LARGE &&
|
||||
@@ -1287,12 +1243,8 @@ CdmResponseType CryptoSession::UpdateUsageInformation() {
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
OEMCryptoResult status;
|
||||
M_TIME(
|
||||
status = OEMCrypto_UpdateUsageTable(),
|
||||
metrics_,
|
||||
oemcrypto_update_usage_table_,
|
||||
status);
|
||||
OEMCryptoResult status = OEMCrypto_UpdateUsageTable();
|
||||
metrics_->oemcrypto_update_usage_table_.Increment(status);
|
||||
if (status != OEMCrypto_SUCCESS) {
|
||||
LOGE("CryptoSession::UsageUsageInformation: error=%ld", status);
|
||||
return UNKNOWN_ERROR;
|
||||
@@ -1309,15 +1261,9 @@ CdmResponseType CryptoSession::DeactivateUsageInformation(
|
||||
const_cast<char*>(provider_session_token.data()));
|
||||
|
||||
// TODO(fredgc or rfrias): make sure oec_session_id_ is valid.
|
||||
OEMCryptoResult status;
|
||||
M_TIME(
|
||||
status = OEMCrypto_DeactivateUsageEntry(
|
||||
(uint32_t)oec_session_id_,
|
||||
pst,
|
||||
provider_session_token.length()),
|
||||
metrics_,
|
||||
oemcrypto_deactivate_usage_entry_,
|
||||
status);
|
||||
OEMCryptoResult status = OEMCrypto_DeactivateUsageEntry(
|
||||
(uint32_t)oec_session_id_, pst, provider_session_token.length());
|
||||
metrics_->oemcrypto_deactivate_usage_entry_.Increment(status);
|
||||
|
||||
switch (status) {
|
||||
case OEMCrypto_SUCCESS:
|
||||
@@ -1347,17 +1293,10 @@ CdmResponseType CryptoSession::GenerateUsageReport(
|
||||
const_cast<char*>(provider_session_token.data()));
|
||||
|
||||
size_t usage_length = 0;
|
||||
OEMCryptoResult status;
|
||||
M_TIME(
|
||||
status = OEMCrypto_ReportUsage(
|
||||
oec_session_id_,
|
||||
pst,
|
||||
provider_session_token.length(),
|
||||
NULL,
|
||||
&usage_length),
|
||||
metrics_,
|
||||
oemcrypto_report_usage_,
|
||||
status);
|
||||
OEMCryptoResult status = OEMCrypto_ReportUsage(
|
||||
oec_session_id_, pst, provider_session_token.length(),
|
||||
NULL, &usage_length);
|
||||
metrics_->oemcrypto_report_usage_.Increment(status);
|
||||
|
||||
if (OEMCrypto_SUCCESS != status) {
|
||||
if (OEMCrypto_ERROR_SHORT_BUFFER != status) {
|
||||
@@ -1369,16 +1308,13 @@ CdmResponseType CryptoSession::GenerateUsageReport(
|
||||
|
||||
std::vector<uint8_t> buffer(usage_length);
|
||||
|
||||
M_TIME(
|
||||
status = OEMCrypto_ReportUsage(
|
||||
status = OEMCrypto_ReportUsage(
|
||||
oec_session_id_,
|
||||
pst,
|
||||
provider_session_token.length(),
|
||||
&buffer[0],
|
||||
&usage_length),
|
||||
metrics_,
|
||||
oemcrypto_report_usage_,
|
||||
status);
|
||||
&usage_length);
|
||||
metrics_->oemcrypto_report_usage_.Increment(status);
|
||||
|
||||
if (OEMCrypto_SUCCESS != status) {
|
||||
LOGE("CryptoSession::GenerateUsageReport: Report Usage error=%ld", status);
|
||||
@@ -1452,19 +1388,10 @@ CdmResponseType CryptoSession::ReleaseUsageInformation(
|
||||
const uint8_t* sig = reinterpret_cast<const uint8_t*>(signature.data());
|
||||
const uint8_t* pst = msg + GetOffset(message, provider_session_token);
|
||||
|
||||
OEMCryptoResult status;
|
||||
M_TIME(
|
||||
status = OEMCrypto_DeleteUsageEntry(
|
||||
oec_session_id_,
|
||||
pst,
|
||||
provider_session_token.length(),
|
||||
msg,
|
||||
message.length(),
|
||||
sig,
|
||||
signature.length()),
|
||||
metrics_,
|
||||
oemcrypto_delete_usage_entry_,
|
||||
status);
|
||||
OEMCryptoResult status = OEMCrypto_DeleteUsageEntry(
|
||||
oec_session_id_, pst, provider_session_token.length(),
|
||||
msg, message.length(), sig, signature.length());
|
||||
metrics_->oemcrypto_delete_usage_entry_.Increment(status);
|
||||
|
||||
if (OEMCrypto_SUCCESS != status) {
|
||||
LOGE("CryptoSession::ReleaseUsageInformation: Report Usage error=%ld",
|
||||
@@ -1484,13 +1411,10 @@ CdmResponseType CryptoSession::DeleteUsageInformation(
|
||||
OEMCryptoResult status;
|
||||
{
|
||||
AutoLock auto_lock(crypto_lock_);
|
||||
M_TIME(
|
||||
status = OEMCrypto_ForceDeleteUsageEntry(
|
||||
reinterpret_cast<const uint8_t*>(provider_session_token.c_str()),
|
||||
provider_session_token.length()),
|
||||
metrics_,
|
||||
oemcrypto_force_delete_usage_entry_,
|
||||
status);
|
||||
status = OEMCrypto_ForceDeleteUsageEntry(
|
||||
reinterpret_cast<const uint8_t*>(provider_session_token.c_str()),
|
||||
provider_session_token.length());
|
||||
metrics_->oemcrypto_force_delete_usage_entry_.Increment(status);
|
||||
if (OEMCrypto_SUCCESS != status) {
|
||||
LOGE("CryptoSession::DeleteUsageInformation: Delete Usage Table error "
|
||||
"= %ld", status);
|
||||
@@ -1508,15 +1432,10 @@ CdmResponseType CryptoSession::DeleteMultipleUsageInformation(
|
||||
{
|
||||
AutoLock auto_lock(crypto_lock_);
|
||||
for (size_t i=0; i < provider_session_tokens.size(); ++i) {
|
||||
OEMCryptoResult status;
|
||||
M_TIME(
|
||||
status = OEMCrypto_ForceDeleteUsageEntry(
|
||||
reinterpret_cast<const uint8_t*>(
|
||||
provider_session_tokens[i].c_str()),
|
||||
provider_session_tokens[i].length()),
|
||||
metrics_,
|
||||
oemcrypto_force_delete_usage_entry_,
|
||||
status);
|
||||
OEMCryptoResult status = OEMCrypto_ForceDeleteUsageEntry(
|
||||
reinterpret_cast<const uint8_t*>(provider_session_tokens[i].c_str()),
|
||||
provider_session_tokens[i].length());
|
||||
metrics_->oemcrypto_force_delete_usage_entry_.Increment(status);
|
||||
if (OEMCrypto_SUCCESS != status) {
|
||||
LOGW("CryptoSession::DeleteMultipleUsageInformation: "
|
||||
"Delete Usage Table error =%ld", status);
|
||||
@@ -1533,11 +1452,8 @@ CdmResponseType CryptoSession::DeleteAllUsageReports() {
|
||||
OEMCryptoResult status;
|
||||
{
|
||||
AutoLock auto_lock(crypto_lock_);
|
||||
M_TIME(
|
||||
status = OEMCrypto_DeleteOldUsageTable(),
|
||||
metrics_,
|
||||
oemcrypto_delete_usage_table_,
|
||||
status);
|
||||
status = OEMCrypto_DeleteOldUsageTable();
|
||||
metrics_->oemcrypto_delete_usage_table_.Increment(status);
|
||||
if (OEMCrypto_SUCCESS != status) {
|
||||
LOGE("CryptoSession::DeleteAllUsageReports: Delete Usage Table error "
|
||||
"=%ld", status);
|
||||
@@ -1549,13 +1465,9 @@ CdmResponseType CryptoSession::DeleteAllUsageReports() {
|
||||
}
|
||||
|
||||
bool CryptoSession::IsAntiRollbackHwPresent() {
|
||||
bool is_present;
|
||||
M_TIME(
|
||||
is_present = OEMCrypto_IsAntiRollbackHwPresent(requested_security_level_),
|
||||
metrics_,
|
||||
oemcrypto_is_anti_rollback_hw_present_,
|
||||
is_present,
|
||||
requested_security_level_);
|
||||
bool is_present =
|
||||
OEMCrypto_IsAntiRollbackHwPresent(requested_security_level_);
|
||||
metrics_->oemcrypto_is_anti_rollback_hw_present_.Record(is_present);
|
||||
return is_present;
|
||||
}
|
||||
|
||||
@@ -1568,14 +1480,8 @@ bool CryptoSession::GenerateNonce(uint32_t* nonce) {
|
||||
LOGV("CryptoSession::GenerateNonce: Lock");
|
||||
AutoLock auto_lock(crypto_lock_);
|
||||
|
||||
OEMCryptoResult result;
|
||||
M_TIME(
|
||||
result = OEMCrypto_GenerateNonce(
|
||||
oec_session_id_,
|
||||
nonce),
|
||||
metrics_,
|
||||
oemcrypto_generate_nonce_,
|
||||
result);
|
||||
OEMCryptoResult result = OEMCrypto_GenerateNonce(oec_session_id_, nonce);
|
||||
metrics_->oemcrypto_generate_nonce_.Increment(result);
|
||||
return OEMCrypto_SUCCESS == result;
|
||||
}
|
||||
|
||||
@@ -1758,20 +1664,17 @@ bool CryptoSession::GetHdcpCapabilities(HdcpCapability* current,
|
||||
LOGE("CryptoSession::GetHdcpCapabilities: |current|, |max| cannot be NULL");
|
||||
return false;
|
||||
}
|
||||
OEMCryptoResult status;
|
||||
M_TIME(
|
||||
status = OEMCrypto_GetHDCPCapability(
|
||||
requested_security_level_,
|
||||
current,
|
||||
max),
|
||||
metrics_,
|
||||
oemcrypto_get_hdcp_capability_,
|
||||
status,
|
||||
requested_security_level_);
|
||||
OEMCryptoResult status = OEMCrypto_GetHDCPCapability(
|
||||
requested_security_level_, current, max);
|
||||
|
||||
if (OEMCrypto_SUCCESS != status) {
|
||||
metrics_->oemcrypto_current_hdcp_capability_.SetError(status);
|
||||
metrics_->oemcrypto_max_hdcp_capability_.SetError(status);
|
||||
LOGW("OEMCrypto_GetHDCPCapability fails with %d", status);
|
||||
return false;
|
||||
}
|
||||
metrics_->oemcrypto_current_hdcp_capability_.Record(*current);
|
||||
metrics_->oemcrypto_max_hdcp_capability_.Record(*max);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -1798,15 +1701,8 @@ bool CryptoSession::GetRandom(size_t data_length, uint8_t* random_data) {
|
||||
LOGE("CryptoSession::GetRandom: random data destination not provided");
|
||||
return false;
|
||||
}
|
||||
OEMCryptoResult sts;
|
||||
M_TIME(
|
||||
sts = OEMCrypto_GetRandom(
|
||||
random_data,
|
||||
data_length),
|
||||
metrics_,
|
||||
oemcrypto_get_random_,
|
||||
sts,
|
||||
metrics::Pow2Bucket(data_length));
|
||||
OEMCryptoResult sts = OEMCrypto_GetRandom(random_data, data_length);
|
||||
metrics_->oemcrypto_get_random_.Increment(sts);
|
||||
|
||||
if (sts != OEMCrypto_SUCCESS) {
|
||||
LOGE("OEMCrypto_GetRandom fails with %d", sts);
|
||||
@@ -1825,19 +1721,16 @@ bool CryptoSession::GetNumberOfOpenSessions(size_t* count) {
|
||||
}
|
||||
|
||||
size_t sessions_count;
|
||||
OEMCryptoResult status;
|
||||
M_TIME(
|
||||
status = OEMCrypto_GetNumberOfOpenSessions(
|
||||
requested_security_level_,
|
||||
&sessions_count),
|
||||
metrics_,
|
||||
oemcrypto_get_number_of_open_sessions_,
|
||||
status,
|
||||
requested_security_level_);
|
||||
OEMCryptoResult status = OEMCrypto_GetNumberOfOpenSessions(
|
||||
requested_security_level_, &sessions_count);
|
||||
|
||||
if (OEMCrypto_SUCCESS != status) {
|
||||
LOGW("OEMCrypto_GetNumberOfOpenSessions fails with %d", status);
|
||||
metrics_->oemcrypto_number_of_open_sessions_.SetError(status);
|
||||
return false;
|
||||
}
|
||||
|
||||
metrics_->oemcrypto_number_of_open_sessions_.Record(sessions_count);
|
||||
*count = sessions_count;
|
||||
return true;
|
||||
}
|
||||
@@ -1851,20 +1744,15 @@ bool CryptoSession::GetMaxNumberOfSessions(size_t* max) {
|
||||
}
|
||||
|
||||
size_t max_sessions;
|
||||
OEMCryptoResult status;
|
||||
M_TIME(
|
||||
status = OEMCrypto_GetMaxNumberOfSessions(
|
||||
requested_security_level_,
|
||||
&max_sessions),
|
||||
metrics_,
|
||||
oemcrypto_get_max_number_of_sessions_,
|
||||
status,
|
||||
requested_security_level_);
|
||||
|
||||
OEMCryptoResult status = OEMCrypto_GetMaxNumberOfSessions(
|
||||
requested_security_level_, &max_sessions);
|
||||
if (OEMCrypto_SUCCESS != status) {
|
||||
LOGW("OEMCrypto_GetMaxNumberOfSessions fails with %d", status);
|
||||
metrics_->oemcrypto_max_number_of_sessions_.SetError(status);
|
||||
return false;
|
||||
}
|
||||
|
||||
metrics_->oemcrypto_max_number_of_sessions_.Record(max_sessions);
|
||||
*max = max_sessions;
|
||||
return true;
|
||||
}
|
||||
@@ -2471,7 +2359,6 @@ OEMCryptoResult CryptoSession::CopyBufferInChunks(
|
||||
metrics_,
|
||||
oemcrypto_copy_buffer_,
|
||||
sts,
|
||||
requested_security_level_,
|
||||
metrics::Pow2Bucket(chunk_size));
|
||||
|
||||
if (sts != OEMCrypto_SUCCESS) {
|
||||
|
||||
Reference in New Issue
Block a user