Consolidate update usage table calls

[ Merge of http://go/wvgerrit/24147 ]

In OEMCrypto version 13, usage information is updated by calls to
OEMCrypto_UpdateUsageEntry. In previous versions calls were made to
OEMCrypto_UpdateUsageTable instead. Both need to be supported as the
OEMCrypto version may vary by device.

This consolidates calls to OEMCrypto_UpdateUsageTable so that they
can be disabled if OEMCrypto version >= 13. No functional changes other
than disabling by OEMCrypto version were introduced in this section.

Helper routines have been added to device files as well.

Bug: 34327459

Test: WV unit/integration tests
Change-Id: I223b0a947c21b8b7ba3c8f345b0206747eb50984
This commit is contained in:
Rahul Frias
2018-01-04 10:59:05 -08:00
parent 17ccdcf351
commit e34f83cdce
3 changed files with 26 additions and 9 deletions

View File

@@ -633,7 +633,8 @@ void CryptoSession::Close() {
open_ = false;
update_usage_table = update_usage_table_after_close_session_;
}
if (close_sts == OEMCrypto_SUCCESS && update_usage_table) {
if (close_sts == OEMCrypto_SUCCESS && update_usage_table &&
usage_support_type_ == kUsageTableSupport) {
UpdateUsageInformation();
}
}
@@ -826,8 +827,10 @@ CdmResponseType CryptoSession::LoadKeys(
// Leaving critical section
crypto_lock_.Release();
if (!provider_session_token.empty())
if (!provider_session_token.empty() &&
usage_support_type_ == kUsageTableSupport) {
UpdateUsageInformation();
}
return result;
}
@@ -1240,7 +1243,7 @@ bool CryptoSession::UsageInformationSupport(bool* has_support) {
}
CdmResponseType CryptoSession::UpdateUsageInformation() {
LOGV("UpdateUsageInformation: id=%ld", (uint32_t)oec_session_id_);
LOGV("CryptoSession::UpdateUsageInformation: id=%ld", (uint32_t)oec_session_id_);
AutoLock auto_lock(crypto_lock_);
if (!initialized_) return UNKNOWN_ERROR;
@@ -1252,7 +1255,7 @@ CdmResponseType CryptoSession::UpdateUsageInformation() {
OEMCryptoResult status = OEMCrypto_UpdateUsageTable();
metrics_->oemcrypto_update_usage_table_.Increment(status);
if (status != OEMCrypto_SUCCESS) {
LOGE("CryptoSession::UsageUsageInformation: error=%ld", status);
LOGE("CryptoSession::UpdateUsageInformation: error=%ld", status);
return UNKNOWN_ERROR;
}
return NO_ERROR;
@@ -1406,7 +1409,8 @@ CdmResponseType CryptoSession::ReleaseUsageInformation(
}
}
UpdateUsageInformation();
if (usage_support_type_ == kUsageTableSupport)
UpdateUsageInformation();
return NO_ERROR;
}
@@ -1427,7 +1431,8 @@ CdmResponseType CryptoSession::DeleteUsageInformation(
response = UNKNOWN_ERROR;
}
}
UpdateUsageInformation();
if (usage_support_type_ == kUsageTableSupport)
UpdateUsageInformation();
return response;
}
@@ -1449,7 +1454,8 @@ CdmResponseType CryptoSession::DeleteMultipleUsageInformation(
}
}
}
UpdateUsageInformation();
if (usage_support_type_ == kUsageTableSupport)
UpdateUsageInformation();
return response;
}
@@ -1466,7 +1472,8 @@ CdmResponseType CryptoSession::DeleteAllUsageReports() {
}
}
UpdateUsageInformation();
if (usage_support_type_ == kUsageTableSupport)
UpdateUsageInformation();
return NO_ERROR;
}