Secure stop API related changes
[ Merge of http://go/wvgerrit/44921 ] * Added the ability to remove a single usage information record. * Added a method to retrieve all secure stop Ids. Bug: 69674645 Test: WV unit, integration tests Change-Id: I04ac8224b4bdda69541e61ff1103af3836138228
This commit is contained in:
@@ -464,22 +464,25 @@ bool DeviceFiles::StoreUsageInfo(const std::string& provider_session_token,
|
||||
return StoreFileWithHash(usage_info_file_name, serialized_file);
|
||||
}
|
||||
|
||||
bool DeviceFiles::ListUsageRecords(const std::string& app_id,
|
||||
std::vector<std::string>* ksids) {
|
||||
bool DeviceFiles::ListUsageIds(
|
||||
const std::string& app_id,
|
||||
std::vector<std::string>* ksids,
|
||||
std::vector<std::string>* provider_session_tokens) {
|
||||
if (!initialized_) {
|
||||
LOGW("DeviceFiles::ListUsageRecords: not initialized");
|
||||
LOGW("DeviceFiles::ListUsageIds: not initialized");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (ksids == NULL) {
|
||||
LOGW("DeviceFiles::ListUsageRecords: return parameter not provided");
|
||||
if (ksids == NULL && provider_session_tokens == NULL) {
|
||||
LOGW("DeviceFiles::ListUsageIds: ksids or pst parameter not provided");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Empty or non-existent file == no usage records.
|
||||
std::string file_name = GetUsageInfoFileName(app_id);
|
||||
if (!FileExists(file_name) || GetFileSize(file_name) == 0) {
|
||||
ksids->clear();
|
||||
if (ksids != NULL) ksids->clear();
|
||||
if (provider_session_tokens != NULL) provider_session_tokens->clear();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -489,13 +492,19 @@ bool DeviceFiles::ListUsageRecords(const std::string& app_id,
|
||||
return false;
|
||||
}
|
||||
|
||||
ksids->clear();
|
||||
if (ksids != NULL) ksids->clear();
|
||||
if (provider_session_tokens != NULL) provider_session_tokens->clear();
|
||||
|
||||
size_t num_records = file.usage_info().sessions_size();
|
||||
for (size_t i = 0; i < num_records; ++i) {
|
||||
if (!file.usage_info().sessions(i).key_set_id().empty()) {
|
||||
if ((ksids != NULL) &&
|
||||
!file.usage_info().sessions(i).key_set_id().empty()) {
|
||||
ksids->push_back(file.usage_info().sessions(i).key_set_id());
|
||||
}
|
||||
if ((provider_session_tokens != NULL) &&
|
||||
!file.usage_info().sessions(i).token().empty()) {
|
||||
provider_session_tokens->push_back(file.usage_info().sessions(i).token());
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user