Reworked DeleteEntry() into InvalidateEntry().
[ Merge of http://go/wvgerrit/95406 ] There was an issue with DeleteEntry() where it would result in an invalid table state if shrinking the usage table when the number of sessions is at its max. This required changing how the usage table invalidates entries. Now, after invalidating an entry (marking an entry as kStorageTypeUnknown) the table is defragmented if specified to. Defragmentation involves: 1) Move valid entries near the end of the table to the position of invalid entries near the front of the table. 2) Shrinking the table to cut off trailing invalid entries. This change updates the existing tests to pass, but still needs new tests for some of the edge cases. Bug: 150887808 Bug: 149100568 Test: Linux unit tests and Android unit tests Change-Id: I70c7b296e5e4b367746fcdaabbf0f12dcfb39230
This commit is contained in:
@@ -532,16 +532,18 @@ CdmResponseType CdmSession::AddKeyInternal(const CdmKeyResponse& key_response) {
|
||||
metrics_->license_sdk_version_.Record(
|
||||
version_info.license_service_version());
|
||||
|
||||
// Update or delete entry if usage table header+entries are supported
|
||||
// Update or invalidate entry if usage table header+entries are supported
|
||||
if (usage_support_type_ == kUsageEntrySupport &&
|
||||
!provider_session_token.empty() && usage_table_header_ != nullptr) {
|
||||
if (sts != KEY_ADDED) {
|
||||
CdmResponseType delete_sts = usage_table_header_->DeleteEntry(
|
||||
usage_entry_number_, file_handle_.get(), crypto_metrics_);
|
||||
crypto_metrics_->usage_table_header_delete_entry_.Increment(delete_sts);
|
||||
if (delete_sts != NO_ERROR) {
|
||||
LOGW("Delete usage entry failed: status = %d",
|
||||
static_cast<int>(delete_sts));
|
||||
const CdmResponseType invalidate_sts =
|
||||
usage_table_header_->InvalidateEntry(
|
||||
usage_entry_number_, true, file_handle_.get(), crypto_metrics_);
|
||||
crypto_metrics_->usage_table_header_delete_entry_.Increment(
|
||||
invalidate_sts);
|
||||
if (invalidate_sts != NO_ERROR) {
|
||||
LOGW("Invalidate usage entry failed: status = %d",
|
||||
static_cast<int>(invalidate_sts));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -827,8 +829,8 @@ CdmResponseType CdmSession::DeleteUsageEntry(uint32_t usage_entry_number) {
|
||||
return INCORRECT_USAGE_SUPPORT_TYPE_1;
|
||||
}
|
||||
|
||||
sts = usage_table_header_->DeleteEntry(usage_entry_number, file_handle_.get(),
|
||||
crypto_metrics_);
|
||||
sts = usage_table_header_->InvalidateEntry(
|
||||
usage_entry_number, true, file_handle_.get(), crypto_metrics_);
|
||||
crypto_metrics_->usage_table_header_delete_entry_.Increment(sts);
|
||||
return sts;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user