Merge "Delete secure stops by key set ID."

This commit is contained in:
Alex Dale
2023-02-09 23:17:59 +00:00
committed by Android (Google) Code Review
6 changed files with 16 additions and 23 deletions

View File

@@ -199,7 +199,7 @@ class DeviceFiles {
std::string* provider_session_token); std::string* provider_session_token);
virtual bool DeleteUsageInfo(const std::string& usage_info_file_name, virtual bool DeleteUsageInfo(const std::string& usage_info_file_name,
const std::string& provider_session_token); const CdmKeySetId& key_set_id);
// Deletes a set of provider sessions from the specified usage info. // Deletes a set of provider sessions from the specified usage info.
// Sessions removed are based on the provided |key_set_ids|. If // Sessions removed are based on the provided |key_set_ids|. If

View File

@@ -1685,7 +1685,7 @@ CdmResponseType CdmEngine::RemoveAllUsageInfo(
} }
if (!handle.DeleteUsageInfo(DeviceFiles::GetUsageInfoFileName(app_id), if (!handle.DeleteUsageInfo(DeviceFiles::GetUsageInfoFileName(app_id),
usage_data[0].provider_session_token)) { usage_data[0].key_set_id)) {
LOGW("Failed to delete usage info"); LOGW("Failed to delete usage info");
break; break;
} }
@@ -1737,25 +1737,17 @@ CdmResponseType CdmEngine::RemoveUsageInfo(
new CdmSession(file_system_, metrics_->AddSession())); new CdmSession(file_system_, metrics_->AddSession()));
usage_session_->Init(usage_property_set_.get()); usage_session_->Init(usage_property_set_.get());
CdmKeyMessage license_request; DeviceFiles::CdmUsageData usage_data;
CdmKeyResponse license_response; if (!handle.RetrieveUsageInfo(DeviceFiles::GetUsageInfoFileName(app_id),
UsageEntry usage_entry; provider_session_token, &usage_data)) {
UsageEntryIndex usage_entry_index;
std::string drm_certificate;
CryptoWrappedKey wrapped_private_key;
if (!handle.RetrieveUsageInfo(
DeviceFiles::GetUsageInfoFileName(app_id), provider_session_token,
&license_request, &license_response, &usage_entry,
&usage_entry_index, &drm_certificate, &wrapped_private_key)) {
// Try other security level // Try other security level
continue; continue;
} }
if (usage_session_->SupportsUsageTable()) { if (usage_session_->SupportsUsageTable()) {
status = usage_session_->DeleteUsageEntry(usage_entry_index); status = usage_session_->DeleteUsageEntry(usage_data.usage_entry_index);
if (!handle.DeleteUsageInfo(DeviceFiles::GetUsageInfoFileName(app_id), if (!handle.DeleteUsageInfo(DeviceFiles::GetUsageInfoFileName(app_id),
provider_session_token)) { usage_data.key_set_id)) {
status = CdmResponseType(REMOVE_USAGE_INFO_ERROR_1); status = CdmResponseType(REMOVE_USAGE_INFO_ERROR_1);
} }
usage_session_.reset(); usage_session_.reset();

View File

@@ -1025,8 +1025,7 @@ bool CdmSession::DeleteLicenseFile() {
std::string app_id; std::string app_id;
GetApplicationId(&app_id); GetApplicationId(&app_id);
return file_handle_->DeleteUsageInfo( return file_handle_->DeleteUsageInfo(
DeviceFiles::GetUsageInfoFileName(app_id), DeviceFiles::GetUsageInfoFileName(app_id), key_set_id_);
license_parser_->provider_session_token());
} }
} }

View File

@@ -824,7 +824,7 @@ CdmResponseType CdmUsageTable::StoreEntry(UsageEntryIndex entry_index,
} }
device_files->DeleteUsageInfo( device_files->DeleteUsageInfo(
entry_info_list_[entry_index].usage_info_file_name, entry_info_list_[entry_index].usage_info_file_name,
provider_session_token); entry_info_list_[entry_index].key_set_id);
if (!device_files->StoreUsageInfo( if (!device_files->StoreUsageInfo(
provider_session_token, key_request, key_response, provider_session_token, key_request, key_response,
entry_info_list_[entry_index].usage_info_file_name, entry_info_list_[entry_index].usage_info_file_name,

View File

@@ -1128,7 +1128,7 @@ bool DeviceFiles::GetProviderSessionToken(const std::string& app_id,
} }
bool DeviceFiles::DeleteUsageInfo(const std::string& usage_info_file_name, bool DeviceFiles::DeleteUsageInfo(const std::string& usage_info_file_name,
const std::string& provider_session_token) { const CdmKeySetId& key_set_id) {
RETURN_FALSE_IF_UNINITIALIZED(); RETURN_FALSE_IF_UNINITIALIZED();
video_widevine_client::sdk::File file; video_widevine_client::sdk::File file;
if (RetrieveHashedFile(usage_info_file_name, &file) != kNoError) { if (RetrieveHashedFile(usage_info_file_name, &file) != kNoError) {
@@ -1140,17 +1140,19 @@ bool DeviceFiles::DeleteUsageInfo(const std::string& usage_info_file_name,
int index = 0; int index = 0;
bool found = false; bool found = false;
for (; index < usage_info->sessions_size(); ++index) { for (; index < usage_info->sessions_size(); ++index) {
if (usage_info->sessions(index).token() == provider_session_token) { const auto& session = usage_info->sessions(index);
if (session.key_set_id() == key_set_id) {
found = true; found = true;
break; break;
} }
} }
if (!found) { if (!found) {
LOGE("Unable to find provider session token: pst = %s", LOGE("Unable to find usage info: key_set_id = %s", IdToString(key_set_id));
wvutil::b2a_hex(provider_session_token).c_str());
return false; return false;
} }
LOGD("Deleting usage info: key_set_id = %s, pst = %s", IdToString(key_set_id),
wvutil::b2a_hex(usage_info->sessions(index).token()).c_str());
google::protobuf::RepeatedPtrField<UsageInfo_ProviderSession>* sessions = google::protobuf::RepeatedPtrField<UsageInfo_ProviderSession>* sessions =
usage_info->mutable_sessions(); usage_info->mutable_sessions();

View File

@@ -394,7 +394,7 @@ class MockDeviceFiles : public DeviceFiles {
MOCK_METHOD(bool, StoreUsageTableInfo, MOCK_METHOD(bool, StoreUsageTableInfo,
(const UsageTableHeader&, const std::vector<CdmUsageEntryInfo>&), (const UsageTableHeader&, const std::vector<CdmUsageEntryInfo>&),
(override)); (override));
MOCK_METHOD(bool, DeleteUsageInfo, (const std::string&, const std::string&), MOCK_METHOD(bool, DeleteUsageInfo, (const std::string&, const CdmKeySetId&),
(override)); (override));
MOCK_METHOD(bool, DeleteMultipleUsageInfoByKeySetIds, MOCK_METHOD(bool, DeleteMultipleUsageInfoByKeySetIds,
(const std::string&, const std::vector<std::string>&), (const std::string&, const std::vector<std::string>&),