Add usage support query method

[ Merge of http://go/wvgerrit/23522 ]

A helper method has been added to CryptoSession to determine whether the
TEE supports usage tables, usage table headers+entries or does not
provide any support for persistent licenses.

In addition
* CryptoSession now supports deletion of multiple
  usage entries rather than a single one.
* Typedefs have been added for usage table headers and entries

b/34327459

Test: Verified by unit/integration tests on angler.

Change-Id: I634d3b7b81ce94d1deccd2a7aaf26b9efde414a8
This commit is contained in:
Rahul Frias
2017-02-06 17:49:37 -08:00
parent 6d617e2be4
commit db6df99db1
8 changed files with 125 additions and 43 deletions

View File

@@ -177,7 +177,7 @@ bool DeviceFiles::StoreLicense(
const std::string& release_server_url, int64_t playback_start_time,
int64_t last_playback_time, int64_t grace_period_end_time,
const CdmAppParameterMap& app_parameters,
const std::string& usage_entry) {
const CdmUsageEntry& usage_entry) {
if (!initialized_) {
LOGW("DeviceFiles::StoreLicense: not initialized");
return false;
@@ -233,7 +233,7 @@ bool DeviceFiles::RetrieveLicense(
CdmKeyMessage* license_renewal_request, CdmKeyResponse* license_renewal,
std::string* release_server_url, int64_t* playback_start_time,
int64_t* last_playback_time, int64_t* grace_period_end_time,
CdmAppParameterMap* app_parameters, std::string* usage_entry) {
CdmAppParameterMap* app_parameters, CdmUsageEntry* usage_entry) {
if (!initialized_) {
LOGW("DeviceFiles::RetrieveLicense: not initialized");
return false;
@@ -319,7 +319,7 @@ bool DeviceFiles::ListLicenses(std::vector<std::string>* key_set_ids) {
// Scan list of returned filenames, remove extension, and return
// as a list of key_set_ids.
key_set_ids->clear();
for (int i = 0; i < filenames.size(); i++) {
for (size_t i = 0; i < filenames.size(); i++) {
std::string* name = &filenames[i];
std::size_t pos = name->find(kLicenseFileNameExt);
if (pos == std::string::npos) {
@@ -384,7 +384,7 @@ bool DeviceFiles::StoreUsageInfo(const std::string& provider_session_token,
const CdmKeyResponse& key_response,
const std::string& app_id,
const std::string& key_set_id,
const std::string& usage_entry) {
const CdmUsageEntry& usage_entry) {
if (!initialized_) {
LOGW("DeviceFiles::StoreUsageInfo: not initialized");
return false;
@@ -525,7 +525,7 @@ bool DeviceFiles::RetrieveUsageInfo(const std::string& app_id,
const std::string& provider_session_token,
CdmKeyMessage* license_request,
CdmKeyResponse* license_response,
std::string* usage_entry) {
CdmUsageEntry* usage_entry) {
if (!initialized_) {
LOGW("DeviceFiles::RetrieveUsageInfo: not initialized");
return false;
@@ -555,7 +555,7 @@ bool DeviceFiles::RetrieveUsageInfoByKeySetId(
const std::string& key_set_id,
CdmKeyMessage* license_request,
CdmKeyResponse* license_response,
std::string* usage_entry) {
CdmUsageEntry* usage_entry) {
if (!initialized_) {
LOGW("DeviceFiles::RetrieveUsageInfoByKeySetId: not initialized");
return false;
@@ -678,7 +678,7 @@ bool DeviceFiles::DeleteHlsAttributes(const std::string& key_set_id) {
}
bool DeviceFiles::StoreUsageTableInfo(
const std::string& usage_table_header,
const CdmUsageTableHeader& usage_table_header,
const std::vector<DeviceFiles::UsageEntryInfo>& usage_entry_info) {
if (!initialized_) {
LOGW("DeviceFiles::StoreUsageTableHeader: not initialized");
@@ -723,7 +723,7 @@ bool DeviceFiles::StoreUsageTableInfo(
}
bool DeviceFiles::RetrieveUsageTableInfo(
std::string* usage_table_header,
CdmUsageTableHeader* usage_table_header,
std::vector<DeviceFiles::UsageEntryInfo>* usage_entry_info) {
if (!initialized_) {
LOGW("DeviceFiles::RetrieveUsageTableInfo: not initialized");