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:
@@ -96,7 +96,7 @@ class CryptoSession {
|
||||
|
||||
// Usage related methods
|
||||
virtual bool UsageInformationSupport(bool* has_support);
|
||||
virtual CdmResponseType UpdateUsageInformation();
|
||||
virtual CdmResponseType UpdateUsageInformation(); // only for OEMCrypto v9-12
|
||||
virtual CdmResponseType DeactivateUsageInformation(
|
||||
const std::string& provider_session_token);
|
||||
virtual CdmResponseType GenerateUsageReport(
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -671,6 +671,11 @@ bool DeviceFiles::RetrieveUsageInfo(const std::string& usage_info_file_name,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (usage_data == NULL) {
|
||||
LOGW("DeviceFiles::RetrieveUsageInfo: usage_data not provided");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!FileExists(usage_info_file_name) ||
|
||||
GetFileSize(usage_info_file_name) == 0) {
|
||||
usage_data->resize(0);
|
||||
@@ -706,6 +711,11 @@ bool DeviceFiles::RetrieveUsageInfo(const std::string& usage_info_file_name,
|
||||
return false;
|
||||
}
|
||||
|
||||
if (usage_data == NULL) {
|
||||
LOGW("DeviceFiles::RetrieveUsageInfo: usage_data not provided");
|
||||
return false;
|
||||
}
|
||||
|
||||
video_widevine_client::sdk::File file;
|
||||
if (!RetrieveHashedFile(usage_info_file_name, &file)) {
|
||||
return false;
|
||||
|
||||
Reference in New Issue
Block a user