Implement Cdm::listStoredLicenses()
[ Merge of http://go/wvgerrit/23600 ] This adds a new entry to IStorage:: - bool list(std::vector<std::string> file_names) It returns the name of each file in the (origin-specific) file system. b/34628115 Uses the current file system (origin-specific) bound to the CDM. Returns the list of stored licenses (key_set_ids) in vector output parameter. Test: verified by unittests on angler. Change-Id: I988556b27c2a4b75f52b59bcd78cfeaddd649acd
This commit is contained in:
@@ -299,6 +299,39 @@ bool DeviceFiles::DeleteLicense(const std::string& key_set_id) {
|
||||
return RemoveFile(key_set_id + kLicenseFileNameExt);
|
||||
}
|
||||
|
||||
bool DeviceFiles::ListLicenses(std::vector<std::string>* key_set_ids) {
|
||||
if (!initialized_) {
|
||||
LOGW("DeviceFiles::ListLicenses: not initialized");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (key_set_ids == NULL) {
|
||||
LOGW("DeviceFiles::ListLicenses: key_set_ids parameter not provided");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Get list of filenames
|
||||
std::vector<std::string> filenames;
|
||||
if (!ListFiles(&filenames)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// 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++) {
|
||||
std::string* name = &filenames[i];
|
||||
std::size_t pos = name->find(kLicenseFileNameExt);
|
||||
if (pos == std::string::npos) {
|
||||
// Skip this file - extension does not match
|
||||
continue;
|
||||
}
|
||||
// Store filename (minus extension). This should be a key set ID.
|
||||
key_set_ids->push_back(name->substr(0, pos));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DeviceFiles::DeleteAllLicenses() {
|
||||
if (!initialized_) {
|
||||
LOGW("DeviceFiles::DeleteAllLicenses: not initialized");
|
||||
@@ -821,7 +854,7 @@ bool DeviceFiles::RetrieveHashedFile(
|
||||
|
||||
std::string path;
|
||||
if (!Properties::GetDeviceFilesBasePath(security_level_, &path)) {
|
||||
LOGW("DeviceFiles::StoreFileWithHash: Unable to get base path");
|
||||
LOGW("DeviceFiles::RetrieveHashedFile: Unable to get base path");
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -898,6 +931,15 @@ bool DeviceFiles::FileExists(const std::string& name) {
|
||||
return file_system_->Exists(path);
|
||||
}
|
||||
|
||||
bool DeviceFiles::ListFiles(std::vector<std::string>* names) {
|
||||
std::string path;
|
||||
if (!Properties::GetDeviceFilesBasePath(security_level_, &path)) {
|
||||
LOGW("DeviceFiles::RemoveFile: Unable to get base path");
|
||||
return false;
|
||||
}
|
||||
return file_system_->List(path, names);
|
||||
}
|
||||
|
||||
bool DeviceFiles::RemoveFile(const std::string& name) {
|
||||
std::string path;
|
||||
if (!Properties::GetDeviceFilesBasePath(security_level_, &path)) {
|
||||
|
||||
Reference in New Issue
Block a user