Merge "Log cleanup and reformatting for core/ (part 1)"

This commit is contained in:
Alex Dale
2019-07-10 01:26:16 +00:00
committed by Android (Google) Code Review
3 changed files with 277 additions and 369 deletions

View File

@@ -11,16 +11,12 @@ namespace wvcdm {
bool BufferReader::Read1(uint8_t* v) {
if (v == NULL) {
LOGE(
"BufferReader::Read1 : Failure during parse: Null output parameter "
"when expecting non-null");
LOGE("Parse failure: Null output parameter when expecting non-null");
return false;
}
if (!HasBytes(1)) {
LOGV(
"BufferReader::Read1 : Failure while parsing: "
"Not enough bytes (1)");
LOGV("Parse failure: No bytes available");
return false;
}
@@ -32,18 +28,13 @@ bool BufferReader::Read1(uint8_t* v) {
template <typename T>
bool BufferReader::Read(T* v) {
if (v == NULL) {
LOGE(
"BufferReader::Read<T> : Failure during parse: Null output parameter "
"when expecting non-null (%s)",
__PRETTY_FUNCTION__);
LOGE("Parse failure: Null output parameter when expecting non-null (%s)",
__PRETTY_FUNCTION__);
return false;
}
if (!HasBytes(sizeof(T))) {
LOGV(
"BufferReader::Read<T> : Failure during parse: "
"Not enough bytes (%u)",
sizeof(T));
LOGV("Parse failure: Not enough bytes (%zu)", sizeof(T));
return false;
}
@@ -65,17 +56,12 @@ bool BufferReader::Read8s(int64_t* v) { return Read(v); }
bool BufferReader::ReadString(std::string* str, size_t count) {
if (str == NULL) {
LOGE(
"BufferReader::ReadString : Failure during parse: Null output "
"parameter when expecting non-null");
LOGE("Parse failure: Null output parameter when expecting non-null");
return false;
}
if (!HasBytes(count)) {
LOGV(
"BufferReader::ReadString : Parse Failure: "
"Not enough bytes (%d)",
count);
LOGV("Parse failure: Not enough bytes (%zu)", count);
return false;
}
@@ -86,17 +72,12 @@ bool BufferReader::ReadString(std::string* str, size_t count) {
bool BufferReader::ReadVec(std::vector<uint8_t>* vec, size_t count) {
if (vec == NULL) {
LOGE(
"BufferReader::ReadVec : Failure during parse: Null output parameter "
"when expecting non-null");
LOGE("Parse failure: Null output parameter when expecting non-null");
return false;
}
if (!HasBytes(count)) {
LOGV(
"BufferReader::ReadVec : Parse Failure: "
"Not enough bytes (%d)",
count);
LOGV("Parse failure: Not enough bytes (%zu)", count);
return false;
}
@@ -108,10 +89,7 @@ bool BufferReader::ReadVec(std::vector<uint8_t>* vec, size_t count) {
bool BufferReader::SkipBytes(size_t bytes) {
if (!HasBytes(bytes)) {
LOGV(
"BufferReader::SkipBytes : Parse Failure: "
"Not enough bytes (%d)",
bytes);
LOGV("Parse failure: Not enough bytes (%zu)", bytes);
return false;
}
@@ -121,9 +99,7 @@ bool BufferReader::SkipBytes(size_t bytes) {
bool BufferReader::Read4Into8(uint64_t* v) {
if (v == NULL) {
LOGE(
"BufferReader::Read4Into8 : Failure during parse: Null output "
"parameter when expecting non-null");
LOGE("Parse failure: Null output parameter when expecting non-null");
return false;
}
@@ -137,9 +113,7 @@ bool BufferReader::Read4Into8(uint64_t* v) {
bool BufferReader::Read4sInto8s(int64_t* v) {
if (v == NULL) {
LOGE(
"BufferReader::Read4sInto8s : Failure during parse: Null output "
"parameter when expecting non-null");
LOGE("Parse failure: Null output parameter when expecting non-null");
return false;
}

File diff suppressed because it is too large Load Diff

View File

@@ -89,7 +89,7 @@ CdmResponseType CdmSession::Init(CdmClientPropertySet* cdm_client_property_set,
const CdmSessionId* forced_session_id,
WvCdmEventListener* event_listener) {
if (initialized_) {
LOGE("CdmSession::Init: Failed due to previous initialization");
LOGE("Failed due to previous initialization");
return REINIT_ERROR;
}
@@ -114,7 +114,7 @@ CdmResponseType CdmSession::Init(CdmClientPropertySet* cdm_client_property_set,
}
if (!file_handle_->Init(security_level_)) {
LOGE("CdmSession::Init: Unable to initialize file handle");
LOGE("Unable to initialize file handle");
return SESSION_FILE_HANDLE_INIT_ERROR;
}
@@ -178,7 +178,7 @@ CdmResponseType CdmSession::Init(CdmClientPropertySet* cdm_client_property_set,
metrics_->SetSessionId(session_id_);
if (session_id_.empty()) {
LOGE("CdmSession::Init: empty session ID");
LOGE("Empty session ID");
return EMPTY_SESSION_ID;
}
if (cdm_client_property_set)
@@ -211,7 +211,7 @@ CdmResponseType CdmSession::RestoreOfflineSession(const CdmKeySetId& key_set_id,
CdmLicenseType license_type,
int* error_detail) {
if (!initialized_) {
LOGE("CdmSession::RestoreOfflineSession: not initialized");
LOGE("CDM session not initialized");
return NOT_INITIALIZED_ERROR;
}
if (!key_set_id_.empty()) {
@@ -232,10 +232,8 @@ CdmResponseType CdmSession::RestoreOfflineSession(const CdmKeySetId& key_set_id,
&playback_start_time, &last_playback_time, &grace_period_end_time,
&app_parameters_, &usage_entry_, &usage_entry_number_,
&sub_error_code)) {
LOGE(
"CdmSession::RestoreOfflineSession: failed to retrieve license. "
"sub error: %d, key set id = %s",
sub_error_code, key_set_id.c_str());
LOGE("Failed to retrieve license: sub_error_code = %d, key_set_id = %s",
static_cast<int>(sub_error_code), key_set_id.c_str());
SetErrorDetail(error_detail, sub_error_code);
return sub_error_code == DeviceFiles::kFileNotFound ? KEYSET_ID_NOT_FOUND_4
: GET_LICENSE_ERROR;
@@ -253,10 +251,8 @@ CdmResponseType CdmSession::RestoreOfflineSession(const CdmKeySetId& key_set_id,
// retry.
if (!(license_type == kLicenseTypeRelease ||
license_state == DeviceFiles::kLicenseStateActive)) {
LOGE(
"CdmSession::RestoreOfflineSession: invalid offline license state = "
"%d, type = %d",
license_state, license_type);
LOGE("Invalid offline license state: license_state = %d, license_type = %d",
static_cast<int>(license_state), static_cast<int>(license_type));
return GET_RELEASED_LICENSE_ERROR;
}
@@ -271,10 +267,7 @@ CdmResponseType CdmSession::RestoreOfflineSession(const CdmKeySetId& key_set_id,
crypto_session_.get(), usage_entry_, usage_entry_number_);
crypto_metrics_->usage_table_header_load_entry_.Increment(sts);
if (sts != NO_ERROR) {
LOGE(
"CdmSession::RestoreOfflineSession: failed to load usage entry = "
"%d",
sts);
LOGE("Failed to load usage entry: status = %d", static_cast<int>(sts));
return sts;
}
}
@@ -304,16 +297,11 @@ CdmResponseType CdmSession::RestoreOfflineSession(const CdmKeySetId& key_set_id,
CdmResponseType sts =
usage_table_header_->UpdateEntry(crypto_session_.get(), &usage_entry_);
if (sts != NO_ERROR) {
LOGE(
"CdmSession::RestoreOfflineSession failed to update usage entry = "
"%d",
sts);
LOGE("Failed to update usage entry: status = %d", static_cast<int>(sts));
return sts;
}
if (!StoreLicense(license_state, error_detail)) {
LOGW(
"CdmSession::RestoreUsageSession: unable to save updated usage "
"info");
LOGW("Unable to save updated usage info");
}
}
@@ -326,7 +314,7 @@ CdmResponseType CdmSession::RestoreOfflineSession(const CdmKeySetId& key_set_id,
CdmResponseType CdmSession::RestoreUsageSession(
const DeviceFiles::CdmUsageData& usage_data, int* error_detail) {
if (!initialized_) {
LOGE("CdmSession::RestoreUsageSession: not initialized");
LOGE("CDM session not initialized");
return NOT_INITIALIZED_ERROR;
}
if (!key_set_id_.empty()) {
@@ -346,8 +334,7 @@ CdmResponseType CdmSession::RestoreUsageSession(
usage_entry_number_);
crypto_metrics_->usage_table_header_load_entry_.Increment(sts);
if (sts != NO_ERROR) {
LOGE("CdmSession::RestoreUsageSession: failed to load usage entry = %d",
sts);
LOGE("Failed to load usage entry: status = %d", static_cast<int>(sts));
return sts;
}
}
@@ -364,14 +351,11 @@ CdmResponseType CdmSession::RestoreUsageSession(
sts =
usage_table_header_->UpdateEntry(crypto_session_.get(), &usage_entry_);
if (sts != NO_ERROR) {
LOGE("CdmSession::RestoreUsageSession: failed to update usage entry: %d",
sts);
LOGE("Failed to update usage entry: status = %d", static_cast<int>(sts));
return sts;
}
if (!UpdateUsageInfo()) {
LOGW(
"CdmSession::RestoreUsageSession: unable to save updated usage "
"info");
LOGW("Unable to save updated usage info");
}
}
@@ -401,12 +385,12 @@ CdmResponseType CdmSession::GenerateKeyRequestInternal(
const InitializationData& init_data, CdmLicenseType license_type,
const CdmAppParameterMap& app_parameters, CdmKeyRequest* key_request) {
if (!initialized_) {
LOGE("CdmSession::GenerateKeyRequest: not initialized");
LOGE("CDM session not initialized");
return NOT_INITIALIZED_ERROR;
}
if (!key_request) {
LOGE("CdmSession::GenerateKeyRequest: No output destination provided");
LOGE("No output destination provided");
return PARAMETER_NULL;
}
@@ -432,8 +416,7 @@ CdmResponseType CdmSession::GenerateKeyRequestInternal(
case kLicenseTypeEmbeddedKeyData:
return license_parser_->HandleEmbeddedKeyData(init_data);
default:
LOGE("CdmSession::GenerateKeyRequest: unrecognized license type: %ld",
license_type);
LOGE("Unrecognized license type: %d", static_cast<int>(license_type));
return INVALID_LICENSE_TYPE;
}
@@ -454,16 +437,15 @@ CdmResponseType CdmSession::GenerateKeyRequestInternal(
key_request->type = kKeyRequestTypeInitial;
if (!init_data.is_supported()) {
LOGW("CdmSession::GenerateKeyRequest: unsupported init data type (%s)",
init_data.type().c_str());
LOGW("Unsupported init data type: %s", init_data.type().c_str());
return UNSUPPORTED_INIT_DATA;
}
if (init_data.IsEmpty() && !license_parser_->HasInitData()) {
LOGW("CdmSession::GenerateKeyRequest: init data absent");
LOGW("Init data absent");
return INIT_DATA_NOT_FOUND;
}
if (is_offline_ && key_set_id_.empty()) {
LOGE("CdmSession::GenerateKeyRequest: Unable to generate key set ID");
LOGE("Unable to generate key set ID");
return KEY_REQUEST_ERROR_1;
}
@@ -492,7 +474,7 @@ CdmResponseType CdmSession::AddKey(const CdmKeyResponse& key_response) {
// AddKeyInternal() - Accept license response and extract key info.
CdmResponseType CdmSession::AddKeyInternal(const CdmKeyResponse& key_response) {
if (!initialized_) {
LOGE("CdmSession::AddKey: not initialized");
LOGE("Not initialized");
return NOT_INITIALIZED_ERROR;
}
@@ -537,8 +519,8 @@ CdmResponseType CdmSession::AddKeyInternal(const CdmKeyResponse& key_response) {
usage_entry_number_, file_handle_.get(), crypto_metrics_);
crypto_metrics_->usage_table_header_delete_entry_.Increment(delete_sts);
if (delete_sts != NO_ERROR) {
LOGW("CdmSession::AddKey: Delete usage entry failed = %d",
delete_sts);
LOGW("Delete usage entry failed: status = %d",
static_cast<int>(delete_sts));
}
}
}
@@ -548,9 +530,9 @@ CdmResponseType CdmSession::AddKeyInternal(const CdmKeyResponse& key_response) {
license_received_ = true;
key_response_ = key_response;
LOGV("AddKey: provider_session_token (size=%d) =%s",
license_parser_->provider_session_token().size(),
license_parser_->provider_session_token().c_str());
LOGV("Key added: provider_session_token = %s (size = %zu)",
license_parser_->provider_session_token().c_str(),
license_parser_->provider_session_token().size());
if (is_offline_ || has_provider_session_token()) {
if (has_provider_session_token() &&
@@ -573,7 +555,7 @@ CdmResponseType CdmSession::AddKeyInternal(const CdmKeyResponse& key_response) {
CdmResponseType CdmSession::QueryStatus(CdmQueryMap* query_response) {
if (!initialized_) {
LOGE("CdmSession::QueryStatus: not initialized");
LOGE("CDM session not initialized");
return NOT_INITIALIZED_ERROR;
}
@@ -613,7 +595,7 @@ CdmResponseType CdmSession::QueryKeyAllowedUsage(
CdmResponseType CdmSession::QueryOemCryptoSessionId(
CdmQueryMap* query_response) {
if (!initialized_) {
LOGE("CdmSession::QueryOemCryptoSessionId: not initialized");
LOGE("Not initialized");
return NOT_INITIALIZED_ERROR;
}
@@ -670,7 +652,7 @@ CdmResponseType CdmSession::Decrypt(const CdmDecryptionParameters& params) {
// session keys.
CdmResponseType CdmSession::GenerateRenewalRequest(CdmKeyRequest* key_request) {
if (!initialized_) {
LOGE("CdmSession::GenerateRenewalRequest: not initialized");
LOGE("CDM session not initialized");
return NOT_INITIALIZED_ERROR;
}
CdmResponseType status = license_parser_->PrepareKeyUpdateRequest(
@@ -691,7 +673,7 @@ CdmResponseType CdmSession::GenerateRenewalRequest(CdmKeyRequest* key_request) {
// RenewKey() - Accept renewal response and update key info.
CdmResponseType CdmSession::RenewKey(const CdmKeyResponse& key_response) {
if (!initialized_) {
LOGE("CdmSession::RenewKey: not initialized");
LOGE("CDM session not initialized");
return NOT_INITIALIZED_ERROR;
}
CdmResponseType sts =
@@ -713,7 +695,7 @@ CdmResponseType CdmSession::RenewKey(const CdmKeyResponse& key_response) {
CdmResponseType CdmSession::GenerateReleaseRequest(CdmKeyRequest* key_request) {
if (!initialized_) {
LOGE("CdmSession::GenerateReleaseRequest: not initialized");
LOGE("CDM session not initialized");
return NOT_INITIALIZED_ERROR;
}
is_release_ = true;
@@ -732,10 +714,7 @@ CdmResponseType CdmSession::GenerateReleaseRequest(CdmKeyRequest* key_request) {
usage_table_header_->UpdateEntry(crypto_session_.get(), &usage_entry_);
if (status != NO_ERROR) {
LOGE(
"CdmSession::GenerateReleaseRequest: Update usage entry failed = "
"%d",
status);
LOGE("Update usage entry failed: status = %d", static_cast<int>(status));
return status;
}
}
@@ -758,7 +737,7 @@ CdmResponseType CdmSession::GenerateReleaseRequest(CdmKeyRequest* key_request) {
// ReleaseKey() - Accept release response and release license.
CdmResponseType CdmSession::ReleaseKey(const CdmKeyResponse& key_response) {
if (!initialized_) {
LOGE("CdmSession::ReleaseKey: not initialized");
LOGE("CDM session not initialized");
return NOT_INITIALIZED_ERROR;
}
CdmResponseType sts =
@@ -773,12 +752,12 @@ CdmResponseType CdmSession::ReleaseKey(const CdmKeyResponse& key_response) {
CdmResponseType CdmSession::DeleteUsageEntry(uint32_t usage_entry_number) {
if (!initialized_) {
LOGE("CdmSession::DeleteUsageEntry: not initialized");
LOGE("CDM session not initialized");
return NOT_INITIALIZED_ERROR;
}
if (usage_support_type_ != kUsageEntrySupport) {
LOGE("CdmSession::DeleteUsageEntry: Unexpected usage type supported: %d",
usage_support_type_);
LOGE("Unexpected usage support type: %d",
static_cast<int>(usage_support_type_));
return INCORRECT_USAGE_SUPPORT_TYPE_1;
}
@@ -801,7 +780,7 @@ CdmResponseType CdmSession::DeleteUsageEntry(uint32_t usage_entry_number) {
}
if (usage_table_header_ == NULL) {
LOGE("CdmSession::DeleteUsageEntry: Usage table header unavailable");
LOGE("Usage table header unavailable");
return INCORRECT_USAGE_SUPPORT_TYPE_1;
}
@@ -827,7 +806,7 @@ CdmSessionId CdmSession::GenerateSessionId() {
bool CdmSession::GenerateKeySetId(CdmKeySetId* key_set_id) {
if (!key_set_id) {
LOGW("CdmSession::GenerateKeySetId: key set id destination not provided");
LOGW("Key set ID destination not provided");
return false;
}
@@ -854,23 +833,23 @@ bool CdmSession::GenerateKeySetId(CdmKeySetId* key_set_id) {
CdmResponseType CdmSession::StoreLicense() {
if (is_temporary_) {
LOGE("CdmSession::StoreLicense: Session type prohibits storage.");
LOGE("Session type prohibits storage");
return STORAGE_PROHIBITED;
}
if (is_offline_) {
if (key_set_id_.empty()) {
LOGE("CdmSession::StoreLicense: No key set ID");
LOGE("No key set ID");
return EMPTY_KEYSET_ID;
}
if (!license_parser_->is_offline()) {
LOGE("CdmSession::StoreLicense: License policy prohibits storage.");
LOGE("License policy prohibits storage");
return OFFLINE_LICENSE_PROHIBITED;
}
if (!StoreLicense(DeviceFiles::kLicenseStateActive, nullptr)) {
LOGE("CdmSession::StoreLicense: Unable to store license");
LOGE("Unable to store license");
return STORE_LICENSE_ERROR_1;
}
return NO_ERROR;
@@ -879,7 +858,7 @@ CdmResponseType CdmSession::StoreLicense() {
std::string provider_session_token =
license_parser_->provider_session_token();
if (provider_session_token.empty()) {
LOGE("CdmSession::StoreLicense: No provider session token and not offline");
LOGE("No provider session token and not offline");
return STORE_LICENSE_ERROR_2;
}
@@ -889,7 +868,7 @@ CdmResponseType CdmSession::StoreLicense() {
provider_session_token, key_request_, key_response_,
DeviceFiles::GetUsageInfoFileName(app_id), key_set_id_, usage_entry_,
usage_entry_number_)) {
LOGE("CdmSession::StoreLicense: Unable to store usage info");
LOGE("Unable to store usage info");
// Usage info file is corrupt. Delete current usage entry and file.
switch (usage_support_type_) {
case kUsageEntrySupport:
@@ -900,8 +879,8 @@ CdmResponseType CdmSession::StoreLicense() {
crypto_session_->UpdateUsageInformation();
break;
default:
LOGW("CdmSession::StoreLicense: unexpected usage support type: %d",
usage_support_type_);
LOGW("Unexpected usage support type: %d",
static_cast<int>(usage_support_type_));
break;
}
std::vector<std::string> provider_session_tokens;
@@ -1032,10 +1011,10 @@ CdmResponseType CdmSession::UpdateUsageEntryInformation() {
if (usage_support_type_ != kUsageEntrySupport ||
!has_provider_session_token() || usage_table_header_ == NULL) {
LOGE(
"CdmSession::UpdateUsageEntryInformation: Unexpected state, "
"usage support type: %d, PST present: %s, usage table header available"
": %s",
usage_support_type_, has_provider_session_token() ? "yes" : "no",
"Unexpected state: usage support type = %d, PST present = %s, "
"usage table header available = %s",
static_cast<int>(usage_support_type_),
has_provider_session_token() ? "yes" : "no",
usage_table_header_ == NULL ? "no" : "yes");
return INCORRECT_USAGE_SUPPORT_TYPE_2;
}
@@ -1066,7 +1045,7 @@ CdmResponseType CdmSession::GenericEncrypt(const std::string& in_buffer,
CdmEncryptionAlgorithm algorithm,
std::string* out_buffer) {
if (!out_buffer) {
LOGE("CdmSession::GenericEncrypt: No output destination provided");
LOGE("No output destination provided");
return PARAMETER_NULL;
}
CdmResponseType sts;
@@ -1083,7 +1062,7 @@ CdmResponseType CdmSession::GenericDecrypt(const std::string& in_buffer,
CdmEncryptionAlgorithm algorithm,
std::string* out_buffer) {
if (!out_buffer) {
LOGE("CdmSession::GenericDecrypt: No output destination provided");
LOGE("No output destination provided");
return PARAMETER_NULL;
}
CdmResponseType sts;
@@ -1099,7 +1078,7 @@ CdmResponseType CdmSession::GenericSign(const std::string& message,
CdmSigningAlgorithm algorithm,
std::string* signature) {
if (!signature) {
LOGE("CdmSession::GenericSign: No output destination provided");
LOGE("No output destination provided");
return PARAMETER_NULL;
}
CdmResponseType sts;