Merge changes Ie4a63ac2,I8523ef28 into pi-dev

* changes:
  Recovery from usage info corruption
  Correct segfault in WvCdmRequestLicenseTest.UsageRemoveSecureStopTest
This commit is contained in:
Rahul Frias
2018-04-03 18:12:34 +00:00
committed by Android (Google) Code Review
8 changed files with 300 additions and 18 deletions

View File

@@ -289,7 +289,7 @@ enum CdmResponseType {
USAGE_STORE_LICENSE_FAILED = 247,
USAGE_STORE_USAGE_INFO_FAILED = 248,
USAGE_INVALID_LOAD_ENTRY = 249,
REMOVE_ALL_USAGE_INFO_ERROR_4 = 250,
/* previously REMOVE_ALL_USAGE_INFO_ERROR_4 = 250, */
REMOVE_ALL_USAGE_INFO_ERROR_5 = 251,
RELEASE_USAGE_INFO_FAILED = 252,
INCORRECT_USAGE_SUPPORT_TYPE_1 = 253,

View File

@@ -1223,24 +1223,29 @@ CdmResponseType CdmEngine::RemoveAllUsageInfo(const std::string& app_id) {
if (!handle.RetrieveUsageInfo(
DeviceFiles::GetUsageInfoFileName(app_id),
&usage_data)) {
status = REMOVE_ALL_USAGE_INFO_ERROR_4;
LOGW("CdmEngine::RemoveAllUsageInfo: failed to retrieve usage info");
break;
}
if (usage_data.empty()) break;
status = usage_session_->DeleteUsageEntry(
CdmResponseType res = usage_session_->DeleteUsageEntry(
usage_data[0].usage_entry_number);
if (status != NO_ERROR) break;
if (res != NO_ERROR) {
LOGW("CdmEngine::RemoveAllUsageInfo: failed to delete usage "
"entry: error: %d", res);
break;
}
if (!handle.DeleteUsageInfo(
DeviceFiles::GetUsageInfoFileName(app_id),
usage_data[0].provider_session_token)) {
status = REMOVE_ALL_USAGE_INFO_ERROR_6;
LOGW("CdmEngine::RemoveAllUsageInfo: failed to delete usage "
"info");
break;
}
} while (status == NO_ERROR && !usage_data.empty());
} while (!usage_data.empty());
std::vector<std::string> provider_session_tokens;
if (!handle.DeleteAllUsageInfoForApp(
@@ -1315,8 +1320,7 @@ CdmResponseType CdmEngine::RemoveUsageInfo(
switch (usage_session_->get_usage_support_type()) {
case kUsageEntrySupport: {
status = usage_session_->DeleteUsageEntry(
usage_data[0].usage_entry_number);
status = usage_session_->DeleteUsageEntry(usage_entry_number);
if (!handle.DeleteUsageInfo(
DeviceFiles::GetUsageInfoFileName(app_id),

View File

@@ -841,6 +841,25 @@ CdmResponseType CdmSession::StoreLicense() {
key_set_id_, usage_entry_,
usage_entry_number_)) {
LOGE("CdmSession::StoreLicense: Unable to store usage info");
// Usage info file is corrupt. Delete current usage entry and file.
switch (usage_support_type_) {
case kUsageEntrySupport:
DeleteUsageEntry(usage_entry_number_);
break;
case kUsageTableSupport:
crypto_session_->DeleteUsageInformation(provider_session_token);
crypto_session_->UpdateUsageInformation();
break;
default:
LOGW("CdmSession::StoreLicense: unexpected usage support type: %d",
usage_support_type_);
break;
}
std::vector<std::string> provider_session_tokens;
file_handle_->DeleteAllUsageInfoForApp(
DeviceFiles::GetUsageInfoFileName(app_id),
&provider_session_tokens);
return STORE_USAGE_INFO_ERROR;
}
return NO_ERROR;

View File

@@ -227,9 +227,6 @@ void PrintTo(const enum CdmResponseType& value, ::std::ostream* os) {
case REMOVE_ALL_USAGE_INFO_ERROR_2:
*os << "REMOVE_ALL_USAGE_INFO_ERROR_2";
break;
case REMOVE_ALL_USAGE_INFO_ERROR_4:
*os << "REMOVE_ALL_USAGE_INFO_ERROR_4";
break;
case REMOVE_ALL_USAGE_INFO_ERROR_5:
*os << "REMOVE_ALL_USAGE_INFO_ERROR_5";
break;