Merges to android Pi release (part 4)
These are a set of CLs merged from the wv cdm repo to the android repo. * Correct RELEASE_ALL_USAGE_INFO_ERRORs Author: Rahul Frias <rfrias@google.com> [ Merge of http://go/wvgerrit/28742 ] RELEASE_ALL_USAGE_INFO_ERROR_4 and 5 were introduced and made use of in http://go/wvgerrit/24022 (branch: oc-dev). The error code definitions were merged over in http://go/wvgerrit/24602. When http://go/wvgerrit/24622 from cdm_partners_3.2 was merged to master (http://go/wvgerrit/27723) there was conflict in error codes. The error codes were adjusted to RELEASE_ALL_USAGE_INFO_ERROR_3 and 4 and were made use of. To avoid renaming the errors between oc-dev and master, new errors RELEASE_ALL_USAGE_INFO_ERROR_6 and 7 have been added to handle the scenarios noted in the merge from cdm_partner_3.2. The other errors have been reverted back to RELEASE_ALL_USAGE_INFO_ERROR_4 and 5. They will be used when http://go/wvgerrit/24602 is merged. * Address compilation issues Author: Rahul Frias <rfrias@google.com> [ Merge of http://go/wvgerrit/28740 ] These changes enable compilation of most of the cdm code on android expect for OEMCrypto unit tests (b/62739406) on wv master. * Add property for binary/base64 provisioning msgs. Author: Gene Morgan <gmorgan@google.com> [ Merge of http://go/wvgerrit/28074 ] Property is "provisioning_messages_are_binary". Its default setting is false in the CE CDM, but it can be overridden by integrators. Added section to integration guide that discusses Provisioning Server message formats and the new property. Link: https://docs.google.com/document/d/1cBVbhgrajLpDe2W3_vzLzUqzpdDt73chvm4_sZlZlS8/edit#heading=h.hgxw53ddw7jo BUG: 71650075 Test: Not currently passing. Will be addressed in a subsequent commit in the chain. Change-Id: I9168193819974d1ff65d9a94dbd762e45ecc43ca
This commit is contained in:
@@ -55,7 +55,7 @@ const char kUsageInfoFileNamePrefix[] = "usage";
|
||||
const char kUsageInfoFileNameExt[] = ".bin";
|
||||
const char kLicenseFileNameExt[] = ".lic";
|
||||
const char kEmptyFileName[] = "";
|
||||
const char kUsageTableFileName[] = "usagetable.bin";
|
||||
const char kUsageTableFileName[] = "usgtable.bin";
|
||||
const char kWildcard[] = "*";
|
||||
|
||||
bool Hash(const std::string& data, std::string* hash) {
|
||||
@@ -734,14 +734,65 @@ bool DeviceFiles::StoreUsageInfo(const std::string& usage_info_file_name,
|
||||
return StoreFileWithHash(usage_info_file_name, serialized_file);
|
||||
}
|
||||
|
||||
bool DeviceFiles::UpdateUsageInfo(const std::string& usage_info_file_name,
|
||||
const std::string& provider_session_token,
|
||||
const CdmUsageData& usage_data) {
|
||||
if (!initialized_) {
|
||||
LOGW("DeviceFiles::UpdateUsageInfo: not initialized");
|
||||
return false;
|
||||
}
|
||||
|
||||
video_widevine_client::sdk::File file;
|
||||
if (!FileExists(usage_info_file_name)) {
|
||||
LOGW("DeviceFiles::UpdateUsageInfo: Usage file does not exist");
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if (!RetrieveHashedFile(usage_info_file_name, &file)) {
|
||||
LOGW("DeviceFiles::UpdateUsageInfo: Unable to parse file");
|
||||
return false;
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
for (; index < file.usage_info().sessions_size(); ++index) {
|
||||
if (file.usage_info().sessions(index).token() == provider_session_token) {
|
||||
UsageInfo* usage_info = file.mutable_usage_info();
|
||||
UsageInfo_ProviderSession* provider_session =
|
||||
usage_info->mutable_sessions(index);
|
||||
provider_session->set_license_request(usage_data.license_request);
|
||||
provider_session->set_license(usage_data.license);
|
||||
provider_session->set_key_set_id(usage_data.key_set_id);
|
||||
provider_session->set_usage_entry(usage_data.usage_entry);
|
||||
provider_session->set_usage_entry_number(usage_data.usage_entry_number);
|
||||
|
||||
std::string serialized_file;
|
||||
file.SerializeToString(&serialized_file);
|
||||
return StoreFileWithHash(usage_info_file_name, serialized_file);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool DeviceFiles::RetrieveUsageInfo(const std::string& usage_info_file_name,
|
||||
std::vector<CdmUsageData>* usage_data) {
|
||||
|
||||
if (!initialized_) {
|
||||
LOGW("DeviceFiles::RetrieveUsageInfo: not initialized");
|
||||
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);
|
||||
return true;
|
||||
}
|
||||
|
||||
video_widevine_client::sdk::File file;
|
||||
if (!RetrieveHashedFile(usage_info_file_name, &file)) {
|
||||
return false;
|
||||
@@ -760,6 +811,43 @@ bool DeviceFiles::RetrieveUsageInfo(const std::string& usage_info_file_name,
|
||||
file.usage_info().sessions(i).usage_entry_number();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DeviceFiles::RetrieveUsageInfo(const std::string& usage_info_file_name,
|
||||
const std::string& provider_session_token,
|
||||
CdmUsageData* usage_data) {
|
||||
if (!initialized_) {
|
||||
LOGW("DeviceFiles::RetrieveUsageInfo: not initialized");
|
||||
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;
|
||||
}
|
||||
|
||||
int index = 0;
|
||||
for (; index < file.usage_info().sessions_size(); ++index) {
|
||||
if (file.usage_info().sessions(index).token() == provider_session_token) {
|
||||
usage_data->provider_session_token =
|
||||
file.usage_info().sessions(index).token();
|
||||
usage_data->license_request =
|
||||
file.usage_info().sessions(index).license_request();
|
||||
usage_data->license = file.usage_info().sessions(index).license();
|
||||
usage_data->key_set_id = file.usage_info().sessions(index).key_set_id();
|
||||
usage_data->usage_entry = file.usage_info().sessions(index).usage_entry();
|
||||
usage_data->usage_entry_number =
|
||||
file.usage_info().sessions(index).usage_entry_number();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user