Fixes for usage table upgrades
[ Merge of http://go/wvgerrit/34060 ] License were not being upgraded successfully from usage tables to usage table headers and entries (big usage tables). Bug: 65730713 Test: WV unit/integration tests Test: GTSMediaDrmTests Test: Playback using netflix and play movies Test: Manual upgrade from N (L3) Change-Id: I7ef127204104fa36dd1ee385bc80ed6a81172b4b
This commit is contained in:
@@ -586,24 +586,25 @@ CdmResponseType CryptoSession::Open(SecurityLevel requested_security_level) {
|
||||
CdmSecurityLevel security_level = GetSecurityLevel();
|
||||
if (security_level == kSecurityLevelL1 ||
|
||||
security_level == kSecurityLevelL3) {
|
||||
UsageTableHeader* header = security_level == kSecurityLevelL1 ?
|
||||
usage_table_header_l1_ : usage_table_header_l3_;
|
||||
if (header == NULL) {
|
||||
header = new UsageTableHeader();
|
||||
UsageTableHeader** header = security_level == kSecurityLevelL1 ?
|
||||
&usage_table_header_l1_ : &usage_table_header_l3_;
|
||||
if (*header == NULL) {
|
||||
*header = new UsageTableHeader();
|
||||
// Ignore errors since we do not know when a session is opened,
|
||||
// if it is intended to be used for offline/usage session related
|
||||
// or otherwise.
|
||||
if (!header->Init(security_level, this)) {
|
||||
delete header;
|
||||
crypto_lock_.Release();
|
||||
bool is_usage_table_header_inited =
|
||||
(*header)->Init(security_level, this);
|
||||
crypto_lock_.Acquire();
|
||||
if (!is_usage_table_header_inited) {
|
||||
delete *header;
|
||||
*header = NULL;
|
||||
usage_table_header_ = NULL;
|
||||
return NO_ERROR;
|
||||
}
|
||||
if (security_level == kSecurityLevelL1)
|
||||
usage_table_header_l1_ = header;
|
||||
else
|
||||
usage_table_header_l3_ = header;
|
||||
}
|
||||
usage_table_header_ = header;
|
||||
usage_table_header_ = *header;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2262,6 +2263,55 @@ CdmResponseType CryptoSession::MoveUsageEntry(uint32_t new_entry_number) {
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
bool CryptoSession::CreateOldUsageEntry(
|
||||
uint64_t time_since_license_received,
|
||||
uint64_t time_since_first_decrypt,
|
||||
uint64_t time_since_last_decrypt,
|
||||
UsageDurationStatus usage_duration_status,
|
||||
const std::string& server_mac_key,
|
||||
const std::string& client_mac_key,
|
||||
const std::string& provider_session_token) {
|
||||
LOGV("CreateOldUsageEntry: Lock");
|
||||
AutoLock auto_lock(crypto_lock_);
|
||||
|
||||
if (server_mac_key.size() < MAC_KEY_SIZE ||
|
||||
client_mac_key.size() < MAC_KEY_SIZE) {
|
||||
LOGE("CreateOldUsageEntry: Invalid mac key size: server mac key size %d, "
|
||||
"client mac key size: %d", server_mac_key.size(),
|
||||
client_mac_key.size());
|
||||
return false;
|
||||
}
|
||||
|
||||
OEMCrypto_Usage_Entry_Status status;
|
||||
switch (usage_duration_status) {
|
||||
case kUsageDurationsInvalid: status = kUnused; break;
|
||||
case kUsageDurationPlaybackNotBegun: status = kInactiveUnused; break;
|
||||
case kUsageDurationsValid: status = kActive; break;
|
||||
default:
|
||||
LOGE("CreateOldUsageEntry: Unrecognized usage entry status: %d", status);
|
||||
status = kUnused;
|
||||
return false;
|
||||
}
|
||||
|
||||
OEMCryptoResult result =
|
||||
OEMCrypto_CreateOldUsageEntry(
|
||||
requested_security_level_, time_since_license_received,
|
||||
time_since_first_decrypt, time_since_last_decrypt, status,
|
||||
reinterpret_cast<uint8_t*>(
|
||||
const_cast<char*>(server_mac_key.data())),
|
||||
reinterpret_cast<uint8_t*>(
|
||||
const_cast<char*>(client_mac_key.data())),
|
||||
reinterpret_cast<const uint8_t*>(provider_session_token.data()),
|
||||
provider_session_token.size());
|
||||
|
||||
if (result != OEMCrypto_SUCCESS) {
|
||||
LOGE("CreateOldUsageEntry: OEMCrypto_CreateOldUsageEntry error: %d",
|
||||
result);
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
CdmResponseType CryptoSession::CopyOldUsageEntry(
|
||||
const std::string& provider_session_token) {
|
||||
LOGV("CopyOldUsageEntry: id=%ld", (uint32_t)oec_session_id_);
|
||||
|
||||
Reference in New Issue
Block a user