Log cleanup and reformatting for core/ (part 1)
Merge from Widevine repo of http://go/wvgerrit/81265 Types of cleanup: - Removed function / class prefixes from the logs. - Fixed log string format options to match the types passed - Added static_cast conversion on enumerations - _Tried_ to make the log format more consistent (open to feedback) - Corrected small spelling mistakes This set of changes is very large, splitting change across several submissions. This change: - core/src/buffer_reader.cpp - core/src/cdm_engine.cpp - core/src/cdm_session.cpp Test: WV linux unittests Bug: 134460638 Change-Id: I16c3297b8e94a99c2b8650b129d0f9e8d96b177f
This commit is contained in:
@@ -11,16 +11,12 @@ namespace wvcdm {
|
|||||||
|
|
||||||
bool BufferReader::Read1(uint8_t* v) {
|
bool BufferReader::Read1(uint8_t* v) {
|
||||||
if (v == NULL) {
|
if (v == NULL) {
|
||||||
LOGE(
|
LOGE("Parse failure: Null output parameter when expecting non-null");
|
||||||
"BufferReader::Read1 : Failure during parse: Null output parameter "
|
|
||||||
"when expecting non-null");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!HasBytes(1)) {
|
if (!HasBytes(1)) {
|
||||||
LOGV(
|
LOGV("Parse failure: No bytes available");
|
||||||
"BufferReader::Read1 : Failure while parsing: "
|
|
||||||
"Not enough bytes (1)");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -32,18 +28,13 @@ bool BufferReader::Read1(uint8_t* v) {
|
|||||||
template <typename T>
|
template <typename T>
|
||||||
bool BufferReader::Read(T* v) {
|
bool BufferReader::Read(T* v) {
|
||||||
if (v == NULL) {
|
if (v == NULL) {
|
||||||
LOGE(
|
LOGE("Parse failure: Null output parameter when expecting non-null (%s)",
|
||||||
"BufferReader::Read<T> : Failure during parse: Null output parameter "
|
__PRETTY_FUNCTION__);
|
||||||
"when expecting non-null (%s)",
|
|
||||||
__PRETTY_FUNCTION__);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!HasBytes(sizeof(T))) {
|
if (!HasBytes(sizeof(T))) {
|
||||||
LOGV(
|
LOGV("Parse failure: Not enough bytes (%zu)", sizeof(T));
|
||||||
"BufferReader::Read<T> : Failure during parse: "
|
|
||||||
"Not enough bytes (%u)",
|
|
||||||
sizeof(T));
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -65,17 +56,12 @@ bool BufferReader::Read8s(int64_t* v) { return Read(v); }
|
|||||||
|
|
||||||
bool BufferReader::ReadString(std::string* str, size_t count) {
|
bool BufferReader::ReadString(std::string* str, size_t count) {
|
||||||
if (str == NULL) {
|
if (str == NULL) {
|
||||||
LOGE(
|
LOGE("Parse failure: Null output parameter when expecting non-null");
|
||||||
"BufferReader::ReadString : Failure during parse: Null output "
|
|
||||||
"parameter when expecting non-null");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!HasBytes(count)) {
|
if (!HasBytes(count)) {
|
||||||
LOGV(
|
LOGV("Parse failure: Not enough bytes (%zu)", count);
|
||||||
"BufferReader::ReadString : Parse Failure: "
|
|
||||||
"Not enough bytes (%d)",
|
|
||||||
count);
|
|
||||||
return false;
|
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) {
|
bool BufferReader::ReadVec(std::vector<uint8_t>* vec, size_t count) {
|
||||||
if (vec == NULL) {
|
if (vec == NULL) {
|
||||||
LOGE(
|
LOGE("Parse failure: Null output parameter when expecting non-null");
|
||||||
"BufferReader::ReadVec : Failure during parse: Null output parameter "
|
|
||||||
"when expecting non-null");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!HasBytes(count)) {
|
if (!HasBytes(count)) {
|
||||||
LOGV(
|
LOGV("Parse failure: Not enough bytes (%zu)", count);
|
||||||
"BufferReader::ReadVec : Parse Failure: "
|
|
||||||
"Not enough bytes (%d)",
|
|
||||||
count);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -108,10 +89,7 @@ bool BufferReader::ReadVec(std::vector<uint8_t>* vec, size_t count) {
|
|||||||
|
|
||||||
bool BufferReader::SkipBytes(size_t bytes) {
|
bool BufferReader::SkipBytes(size_t bytes) {
|
||||||
if (!HasBytes(bytes)) {
|
if (!HasBytes(bytes)) {
|
||||||
LOGV(
|
LOGV("Parse failure: Not enough bytes (%zu)", bytes);
|
||||||
"BufferReader::SkipBytes : Parse Failure: "
|
|
||||||
"Not enough bytes (%d)",
|
|
||||||
bytes);
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,9 +99,7 @@ bool BufferReader::SkipBytes(size_t bytes) {
|
|||||||
|
|
||||||
bool BufferReader::Read4Into8(uint64_t* v) {
|
bool BufferReader::Read4Into8(uint64_t* v) {
|
||||||
if (v == NULL) {
|
if (v == NULL) {
|
||||||
LOGE(
|
LOGE("Parse failure: Null output parameter when expecting non-null");
|
||||||
"BufferReader::Read4Into8 : Failure during parse: Null output "
|
|
||||||
"parameter when expecting non-null");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -137,9 +113,7 @@ bool BufferReader::Read4Into8(uint64_t* v) {
|
|||||||
|
|
||||||
bool BufferReader::Read4sInto8s(int64_t* v) {
|
bool BufferReader::Read4sInto8s(int64_t* v) {
|
||||||
if (v == NULL) {
|
if (v == NULL) {
|
||||||
LOGE(
|
LOGE("Parse failure: Null output parameter when expecting non-null");
|
||||||
"BufferReader::Read4sInto8s : Failure during parse: Null output "
|
|
||||||
"parameter when expecting non-null");
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -89,7 +89,7 @@ CdmResponseType CdmSession::Init(CdmClientPropertySet* cdm_client_property_set,
|
|||||||
const CdmSessionId* forced_session_id,
|
const CdmSessionId* forced_session_id,
|
||||||
WvCdmEventListener* event_listener) {
|
WvCdmEventListener* event_listener) {
|
||||||
if (initialized_) {
|
if (initialized_) {
|
||||||
LOGE("CdmSession::Init: Failed due to previous initialization");
|
LOGE("Failed due to previous initialization");
|
||||||
return REINIT_ERROR;
|
return REINIT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -114,7 +114,7 @@ CdmResponseType CdmSession::Init(CdmClientPropertySet* cdm_client_property_set,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!file_handle_->Init(security_level_)) {
|
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;
|
return SESSION_FILE_HANDLE_INIT_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -178,7 +178,7 @@ CdmResponseType CdmSession::Init(CdmClientPropertySet* cdm_client_property_set,
|
|||||||
metrics_->SetSessionId(session_id_);
|
metrics_->SetSessionId(session_id_);
|
||||||
|
|
||||||
if (session_id_.empty()) {
|
if (session_id_.empty()) {
|
||||||
LOGE("CdmSession::Init: empty session ID");
|
LOGE("Empty session ID");
|
||||||
return EMPTY_SESSION_ID;
|
return EMPTY_SESSION_ID;
|
||||||
}
|
}
|
||||||
if (cdm_client_property_set)
|
if (cdm_client_property_set)
|
||||||
@@ -211,7 +211,7 @@ CdmResponseType CdmSession::RestoreOfflineSession(const CdmKeySetId& key_set_id,
|
|||||||
CdmLicenseType license_type,
|
CdmLicenseType license_type,
|
||||||
int* error_detail) {
|
int* error_detail) {
|
||||||
if (!initialized_) {
|
if (!initialized_) {
|
||||||
LOGE("CdmSession::RestoreOfflineSession: not initialized");
|
LOGE("CDM session not initialized");
|
||||||
return NOT_INITIALIZED_ERROR;
|
return NOT_INITIALIZED_ERROR;
|
||||||
}
|
}
|
||||||
if (!key_set_id_.empty()) {
|
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,
|
&playback_start_time, &last_playback_time, &grace_period_end_time,
|
||||||
&app_parameters_, &usage_entry_, &usage_entry_number_,
|
&app_parameters_, &usage_entry_, &usage_entry_number_,
|
||||||
&sub_error_code)) {
|
&sub_error_code)) {
|
||||||
LOGE(
|
LOGE("Failed to retrieve license: sub_error_code = %d, key_set_id = %s",
|
||||||
"CdmSession::RestoreOfflineSession: failed to retrieve license. "
|
static_cast<int>(sub_error_code), key_set_id.c_str());
|
||||||
"sub error: %d, key set id = %s",
|
|
||||||
sub_error_code, key_set_id.c_str());
|
|
||||||
SetErrorDetail(error_detail, sub_error_code);
|
SetErrorDetail(error_detail, sub_error_code);
|
||||||
return sub_error_code == DeviceFiles::kFileNotFound ? KEYSET_ID_NOT_FOUND_4
|
return sub_error_code == DeviceFiles::kFileNotFound ? KEYSET_ID_NOT_FOUND_4
|
||||||
: GET_LICENSE_ERROR;
|
: GET_LICENSE_ERROR;
|
||||||
@@ -251,10 +249,8 @@ CdmResponseType CdmSession::RestoreOfflineSession(const CdmKeySetId& key_set_id,
|
|||||||
// retry.
|
// retry.
|
||||||
if (!(license_type == kLicenseTypeRelease ||
|
if (!(license_type == kLicenseTypeRelease ||
|
||||||
license_state == DeviceFiles::kLicenseStateActive)) {
|
license_state == DeviceFiles::kLicenseStateActive)) {
|
||||||
LOGE(
|
LOGE("Invalid offline license state: license_state = %d, license_type = %d",
|
||||||
"CdmSession::RestoreOfflineSession: invalid offline license state = "
|
static_cast<int>(license_state), static_cast<int>(license_type));
|
||||||
"%d, type = %d",
|
|
||||||
license_state, license_type);
|
|
||||||
return GET_RELEASED_LICENSE_ERROR;
|
return GET_RELEASED_LICENSE_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -269,10 +265,7 @@ CdmResponseType CdmSession::RestoreOfflineSession(const CdmKeySetId& key_set_id,
|
|||||||
crypto_session_.get(), usage_entry_, usage_entry_number_);
|
crypto_session_.get(), usage_entry_, usage_entry_number_);
|
||||||
crypto_metrics_->usage_table_header_load_entry_.Increment(sts);
|
crypto_metrics_->usage_table_header_load_entry_.Increment(sts);
|
||||||
if (sts != NO_ERROR) {
|
if (sts != NO_ERROR) {
|
||||||
LOGE(
|
LOGE("Failed to load usage entry: status = %d", static_cast<int>(sts));
|
||||||
"CdmSession::RestoreOfflineSession: failed to load usage entry = "
|
|
||||||
"%d",
|
|
||||||
sts);
|
|
||||||
return sts;
|
return sts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -302,16 +295,11 @@ CdmResponseType CdmSession::RestoreOfflineSession(const CdmKeySetId& key_set_id,
|
|||||||
CdmResponseType sts =
|
CdmResponseType sts =
|
||||||
usage_table_header_->UpdateEntry(crypto_session_.get(), &usage_entry_);
|
usage_table_header_->UpdateEntry(crypto_session_.get(), &usage_entry_);
|
||||||
if (sts != NO_ERROR) {
|
if (sts != NO_ERROR) {
|
||||||
LOGE(
|
LOGE("Failed to update usage entry: status = %d", static_cast<int>(sts));
|
||||||
"CdmSession::RestoreOfflineSession failed to update usage entry = "
|
|
||||||
"%d",
|
|
||||||
sts);
|
|
||||||
return sts;
|
return sts;
|
||||||
}
|
}
|
||||||
if (!StoreLicense(license_state, error_detail)) {
|
if (!StoreLicense(license_state, error_detail)) {
|
||||||
LOGW(
|
LOGW("Unable to save updated usage info");
|
||||||
"CdmSession::RestoreUsageSession: unable to save updated usage "
|
|
||||||
"info");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -324,7 +312,7 @@ CdmResponseType CdmSession::RestoreOfflineSession(const CdmKeySetId& key_set_id,
|
|||||||
CdmResponseType CdmSession::RestoreUsageSession(
|
CdmResponseType CdmSession::RestoreUsageSession(
|
||||||
const DeviceFiles::CdmUsageData& usage_data, int* error_detail) {
|
const DeviceFiles::CdmUsageData& usage_data, int* error_detail) {
|
||||||
if (!initialized_) {
|
if (!initialized_) {
|
||||||
LOGE("CdmSession::RestoreUsageSession: not initialized");
|
LOGE("CDM session not initialized");
|
||||||
return NOT_INITIALIZED_ERROR;
|
return NOT_INITIALIZED_ERROR;
|
||||||
}
|
}
|
||||||
if (!key_set_id_.empty()) {
|
if (!key_set_id_.empty()) {
|
||||||
@@ -344,8 +332,7 @@ CdmResponseType CdmSession::RestoreUsageSession(
|
|||||||
usage_entry_number_);
|
usage_entry_number_);
|
||||||
crypto_metrics_->usage_table_header_load_entry_.Increment(sts);
|
crypto_metrics_->usage_table_header_load_entry_.Increment(sts);
|
||||||
if (sts != NO_ERROR) {
|
if (sts != NO_ERROR) {
|
||||||
LOGE("CdmSession::RestoreUsageSession: failed to load usage entry = %d",
|
LOGE("Failed to load usage entry: status = %d", static_cast<int>(sts));
|
||||||
sts);
|
|
||||||
return sts;
|
return sts;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -362,14 +349,11 @@ CdmResponseType CdmSession::RestoreUsageSession(
|
|||||||
sts =
|
sts =
|
||||||
usage_table_header_->UpdateEntry(crypto_session_.get(), &usage_entry_);
|
usage_table_header_->UpdateEntry(crypto_session_.get(), &usage_entry_);
|
||||||
if (sts != NO_ERROR) {
|
if (sts != NO_ERROR) {
|
||||||
LOGE("CdmSession::RestoreUsageSession: failed to update usage entry: %d",
|
LOGE("Failed to update usage entry: status = %d", static_cast<int>(sts));
|
||||||
sts);
|
|
||||||
return sts;
|
return sts;
|
||||||
}
|
}
|
||||||
if (!UpdateUsageInfo()) {
|
if (!UpdateUsageInfo()) {
|
||||||
LOGW(
|
LOGW("Unable to save updated usage info");
|
||||||
"CdmSession::RestoreUsageSession: unable to save updated usage "
|
|
||||||
"info");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -399,12 +383,12 @@ CdmResponseType CdmSession::GenerateKeyRequestInternal(
|
|||||||
const InitializationData& init_data, CdmLicenseType license_type,
|
const InitializationData& init_data, CdmLicenseType license_type,
|
||||||
const CdmAppParameterMap& app_parameters, CdmKeyRequest* key_request) {
|
const CdmAppParameterMap& app_parameters, CdmKeyRequest* key_request) {
|
||||||
if (!initialized_) {
|
if (!initialized_) {
|
||||||
LOGE("CdmSession::GenerateKeyRequest: not initialized");
|
LOGE("CDM session not initialized");
|
||||||
return NOT_INITIALIZED_ERROR;
|
return NOT_INITIALIZED_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!key_request) {
|
if (!key_request) {
|
||||||
LOGE("CdmSession::GenerateKeyRequest: No output destination provided");
|
LOGE("No output destination provided");
|
||||||
return PARAMETER_NULL;
|
return PARAMETER_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -430,8 +414,7 @@ CdmResponseType CdmSession::GenerateKeyRequestInternal(
|
|||||||
case kLicenseTypeEmbeddedKeyData:
|
case kLicenseTypeEmbeddedKeyData:
|
||||||
return license_parser_->HandleEmbeddedKeyData(init_data);
|
return license_parser_->HandleEmbeddedKeyData(init_data);
|
||||||
default:
|
default:
|
||||||
LOGE("CdmSession::GenerateKeyRequest: unrecognized license type: %ld",
|
LOGE("Unrecognized license type: %d", static_cast<int>(license_type));
|
||||||
license_type);
|
|
||||||
return INVALID_LICENSE_TYPE;
|
return INVALID_LICENSE_TYPE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -452,16 +435,15 @@ CdmResponseType CdmSession::GenerateKeyRequestInternal(
|
|||||||
key_request->type = kKeyRequestTypeInitial;
|
key_request->type = kKeyRequestTypeInitial;
|
||||||
|
|
||||||
if (!init_data.is_supported()) {
|
if (!init_data.is_supported()) {
|
||||||
LOGW("CdmSession::GenerateKeyRequest: unsupported init data type (%s)",
|
LOGW("Unsupported init data type: %s", init_data.type().c_str());
|
||||||
init_data.type().c_str());
|
|
||||||
return UNSUPPORTED_INIT_DATA;
|
return UNSUPPORTED_INIT_DATA;
|
||||||
}
|
}
|
||||||
if (init_data.IsEmpty() && !license_parser_->HasInitData()) {
|
if (init_data.IsEmpty() && !license_parser_->HasInitData()) {
|
||||||
LOGW("CdmSession::GenerateKeyRequest: init data absent");
|
LOGW("Init data absent");
|
||||||
return INIT_DATA_NOT_FOUND;
|
return INIT_DATA_NOT_FOUND;
|
||||||
}
|
}
|
||||||
if (is_offline_ && key_set_id_.empty()) {
|
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;
|
return KEY_REQUEST_ERROR_1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -490,7 +472,7 @@ CdmResponseType CdmSession::AddKey(const CdmKeyResponse& key_response) {
|
|||||||
// AddKeyInternal() - Accept license response and extract key info.
|
// AddKeyInternal() - Accept license response and extract key info.
|
||||||
CdmResponseType CdmSession::AddKeyInternal(const CdmKeyResponse& key_response) {
|
CdmResponseType CdmSession::AddKeyInternal(const CdmKeyResponse& key_response) {
|
||||||
if (!initialized_) {
|
if (!initialized_) {
|
||||||
LOGE("CdmSession::AddKey: not initialized");
|
LOGE("Not initialized");
|
||||||
return NOT_INITIALIZED_ERROR;
|
return NOT_INITIALIZED_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -535,8 +517,8 @@ CdmResponseType CdmSession::AddKeyInternal(const CdmKeyResponse& key_response) {
|
|||||||
usage_entry_number_, file_handle_.get(), crypto_metrics_);
|
usage_entry_number_, file_handle_.get(), crypto_metrics_);
|
||||||
crypto_metrics_->usage_table_header_delete_entry_.Increment(delete_sts);
|
crypto_metrics_->usage_table_header_delete_entry_.Increment(delete_sts);
|
||||||
if (delete_sts != NO_ERROR) {
|
if (delete_sts != NO_ERROR) {
|
||||||
LOGW("CdmSession::AddKey: Delete usage entry failed = %d",
|
LOGW("Delete usage entry failed: status = %d",
|
||||||
delete_sts);
|
static_cast<int>(delete_sts));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -546,9 +528,9 @@ CdmResponseType CdmSession::AddKeyInternal(const CdmKeyResponse& key_response) {
|
|||||||
license_received_ = true;
|
license_received_ = true;
|
||||||
key_response_ = key_response;
|
key_response_ = key_response;
|
||||||
|
|
||||||
LOGV("AddKey: provider_session_token (size=%d) =%s",
|
LOGV("Key added: provider_session_token = %s (size = %zu)",
|
||||||
license_parser_->provider_session_token().size(),
|
license_parser_->provider_session_token().c_str(),
|
||||||
license_parser_->provider_session_token().c_str());
|
license_parser_->provider_session_token().size());
|
||||||
|
|
||||||
if (is_offline_ || has_provider_session_token()) {
|
if (is_offline_ || has_provider_session_token()) {
|
||||||
if (has_provider_session_token() &&
|
if (has_provider_session_token() &&
|
||||||
@@ -571,7 +553,7 @@ CdmResponseType CdmSession::AddKeyInternal(const CdmKeyResponse& key_response) {
|
|||||||
|
|
||||||
CdmResponseType CdmSession::QueryStatus(CdmQueryMap* query_response) {
|
CdmResponseType CdmSession::QueryStatus(CdmQueryMap* query_response) {
|
||||||
if (!initialized_) {
|
if (!initialized_) {
|
||||||
LOGE("CdmSession::QueryStatus: not initialized");
|
LOGE("CDM session not initialized");
|
||||||
return NOT_INITIALIZED_ERROR;
|
return NOT_INITIALIZED_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -611,7 +593,7 @@ CdmResponseType CdmSession::QueryKeyAllowedUsage(
|
|||||||
CdmResponseType CdmSession::QueryOemCryptoSessionId(
|
CdmResponseType CdmSession::QueryOemCryptoSessionId(
|
||||||
CdmQueryMap* query_response) {
|
CdmQueryMap* query_response) {
|
||||||
if (!initialized_) {
|
if (!initialized_) {
|
||||||
LOGE("CdmSession::QueryOemCryptoSessionId: not initialized");
|
LOGE("Not initialized");
|
||||||
return NOT_INITIALIZED_ERROR;
|
return NOT_INITIALIZED_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -668,7 +650,7 @@ CdmResponseType CdmSession::Decrypt(const CdmDecryptionParameters& params) {
|
|||||||
// session keys.
|
// session keys.
|
||||||
CdmResponseType CdmSession::GenerateRenewalRequest(CdmKeyRequest* key_request) {
|
CdmResponseType CdmSession::GenerateRenewalRequest(CdmKeyRequest* key_request) {
|
||||||
if (!initialized_) {
|
if (!initialized_) {
|
||||||
LOGE("CdmSession::GenerateRenewalRequest: not initialized");
|
LOGE("CDM session not initialized");
|
||||||
return NOT_INITIALIZED_ERROR;
|
return NOT_INITIALIZED_ERROR;
|
||||||
}
|
}
|
||||||
CdmResponseType status = license_parser_->PrepareKeyUpdateRequest(
|
CdmResponseType status = license_parser_->PrepareKeyUpdateRequest(
|
||||||
@@ -689,7 +671,7 @@ CdmResponseType CdmSession::GenerateRenewalRequest(CdmKeyRequest* key_request) {
|
|||||||
// RenewKey() - Accept renewal response and update key info.
|
// RenewKey() - Accept renewal response and update key info.
|
||||||
CdmResponseType CdmSession::RenewKey(const CdmKeyResponse& key_response) {
|
CdmResponseType CdmSession::RenewKey(const CdmKeyResponse& key_response) {
|
||||||
if (!initialized_) {
|
if (!initialized_) {
|
||||||
LOGE("CdmSession::RenewKey: not initialized");
|
LOGE("CDM session not initialized");
|
||||||
return NOT_INITIALIZED_ERROR;
|
return NOT_INITIALIZED_ERROR;
|
||||||
}
|
}
|
||||||
CdmResponseType sts =
|
CdmResponseType sts =
|
||||||
@@ -711,7 +693,7 @@ CdmResponseType CdmSession::RenewKey(const CdmKeyResponse& key_response) {
|
|||||||
|
|
||||||
CdmResponseType CdmSession::GenerateReleaseRequest(CdmKeyRequest* key_request) {
|
CdmResponseType CdmSession::GenerateReleaseRequest(CdmKeyRequest* key_request) {
|
||||||
if (!initialized_) {
|
if (!initialized_) {
|
||||||
LOGE("CdmSession::GenerateReleaseRequest: not initialized");
|
LOGE("CDM session not initialized");
|
||||||
return NOT_INITIALIZED_ERROR;
|
return NOT_INITIALIZED_ERROR;
|
||||||
}
|
}
|
||||||
is_release_ = true;
|
is_release_ = true;
|
||||||
@@ -730,10 +712,7 @@ CdmResponseType CdmSession::GenerateReleaseRequest(CdmKeyRequest* key_request) {
|
|||||||
usage_table_header_->UpdateEntry(crypto_session_.get(), &usage_entry_);
|
usage_table_header_->UpdateEntry(crypto_session_.get(), &usage_entry_);
|
||||||
|
|
||||||
if (status != NO_ERROR) {
|
if (status != NO_ERROR) {
|
||||||
LOGE(
|
LOGE("Update usage entry failed: status = %d", static_cast<int>(status));
|
||||||
"CdmSession::GenerateReleaseRequest: Update usage entry failed = "
|
|
||||||
"%d",
|
|
||||||
status);
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -756,7 +735,7 @@ CdmResponseType CdmSession::GenerateReleaseRequest(CdmKeyRequest* key_request) {
|
|||||||
// ReleaseKey() - Accept release response and release license.
|
// ReleaseKey() - Accept release response and release license.
|
||||||
CdmResponseType CdmSession::ReleaseKey(const CdmKeyResponse& key_response) {
|
CdmResponseType CdmSession::ReleaseKey(const CdmKeyResponse& key_response) {
|
||||||
if (!initialized_) {
|
if (!initialized_) {
|
||||||
LOGE("CdmSession::ReleaseKey: not initialized");
|
LOGE("CDM session not initialized");
|
||||||
return NOT_INITIALIZED_ERROR;
|
return NOT_INITIALIZED_ERROR;
|
||||||
}
|
}
|
||||||
CdmResponseType sts =
|
CdmResponseType sts =
|
||||||
@@ -771,12 +750,12 @@ CdmResponseType CdmSession::ReleaseKey(const CdmKeyResponse& key_response) {
|
|||||||
|
|
||||||
CdmResponseType CdmSession::DeleteUsageEntry(uint32_t usage_entry_number) {
|
CdmResponseType CdmSession::DeleteUsageEntry(uint32_t usage_entry_number) {
|
||||||
if (!initialized_) {
|
if (!initialized_) {
|
||||||
LOGE("CdmSession::DeleteUsageEntry: not initialized");
|
LOGE("CDM session not initialized");
|
||||||
return NOT_INITIALIZED_ERROR;
|
return NOT_INITIALIZED_ERROR;
|
||||||
}
|
}
|
||||||
if (usage_support_type_ != kUsageEntrySupport) {
|
if (usage_support_type_ != kUsageEntrySupport) {
|
||||||
LOGE("CdmSession::DeleteUsageEntry: Unexpected usage type supported: %d",
|
LOGE("Unexpected usage support type: %d",
|
||||||
usage_support_type_);
|
static_cast<int>(usage_support_type_));
|
||||||
return INCORRECT_USAGE_SUPPORT_TYPE_1;
|
return INCORRECT_USAGE_SUPPORT_TYPE_1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -799,7 +778,7 @@ CdmResponseType CdmSession::DeleteUsageEntry(uint32_t usage_entry_number) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (usage_table_header_ == NULL) {
|
if (usage_table_header_ == NULL) {
|
||||||
LOGE("CdmSession::DeleteUsageEntry: Usage table header unavailable");
|
LOGE("Usage table header unavailable");
|
||||||
return INCORRECT_USAGE_SUPPORT_TYPE_1;
|
return INCORRECT_USAGE_SUPPORT_TYPE_1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -825,7 +804,7 @@ CdmSessionId CdmSession::GenerateSessionId() {
|
|||||||
|
|
||||||
bool CdmSession::GenerateKeySetId(CdmKeySetId* key_set_id) {
|
bool CdmSession::GenerateKeySetId(CdmKeySetId* key_set_id) {
|
||||||
if (!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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -852,23 +831,23 @@ bool CdmSession::GenerateKeySetId(CdmKeySetId* key_set_id) {
|
|||||||
|
|
||||||
CdmResponseType CdmSession::StoreLicense() {
|
CdmResponseType CdmSession::StoreLicense() {
|
||||||
if (is_temporary_) {
|
if (is_temporary_) {
|
||||||
LOGE("CdmSession::StoreLicense: Session type prohibits storage.");
|
LOGE("Session type prohibits storage");
|
||||||
return STORAGE_PROHIBITED;
|
return STORAGE_PROHIBITED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_offline_) {
|
if (is_offline_) {
|
||||||
if (key_set_id_.empty()) {
|
if (key_set_id_.empty()) {
|
||||||
LOGE("CdmSession::StoreLicense: No key set ID");
|
LOGE("No key set ID");
|
||||||
return EMPTY_KEYSET_ID;
|
return EMPTY_KEYSET_ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!license_parser_->is_offline()) {
|
if (!license_parser_->is_offline()) {
|
||||||
LOGE("CdmSession::StoreLicense: License policy prohibits storage.");
|
LOGE("License policy prohibits storage");
|
||||||
return OFFLINE_LICENSE_PROHIBITED;
|
return OFFLINE_LICENSE_PROHIBITED;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!StoreLicense(DeviceFiles::kLicenseStateActive, nullptr)) {
|
if (!StoreLicense(DeviceFiles::kLicenseStateActive, nullptr)) {
|
||||||
LOGE("CdmSession::StoreLicense: Unable to store license");
|
LOGE("Unable to store license");
|
||||||
return STORE_LICENSE_ERROR_1;
|
return STORE_LICENSE_ERROR_1;
|
||||||
}
|
}
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
@@ -877,7 +856,7 @@ CdmResponseType CdmSession::StoreLicense() {
|
|||||||
std::string provider_session_token =
|
std::string provider_session_token =
|
||||||
license_parser_->provider_session_token();
|
license_parser_->provider_session_token();
|
||||||
if (provider_session_token.empty()) {
|
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;
|
return STORE_LICENSE_ERROR_2;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -887,7 +866,7 @@ CdmResponseType CdmSession::StoreLicense() {
|
|||||||
provider_session_token, key_request_, key_response_,
|
provider_session_token, key_request_, key_response_,
|
||||||
DeviceFiles::GetUsageInfoFileName(app_id), key_set_id_, usage_entry_,
|
DeviceFiles::GetUsageInfoFileName(app_id), key_set_id_, usage_entry_,
|
||||||
usage_entry_number_)) {
|
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.
|
// Usage info file is corrupt. Delete current usage entry and file.
|
||||||
switch (usage_support_type_) {
|
switch (usage_support_type_) {
|
||||||
case kUsageEntrySupport:
|
case kUsageEntrySupport:
|
||||||
@@ -898,8 +877,8 @@ CdmResponseType CdmSession::StoreLicense() {
|
|||||||
crypto_session_->UpdateUsageInformation();
|
crypto_session_->UpdateUsageInformation();
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
LOGW("CdmSession::StoreLicense: unexpected usage support type: %d",
|
LOGW("Unexpected usage support type: %d",
|
||||||
usage_support_type_);
|
static_cast<int>(usage_support_type_));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
std::vector<std::string> provider_session_tokens;
|
std::vector<std::string> provider_session_tokens;
|
||||||
@@ -1030,10 +1009,10 @@ CdmResponseType CdmSession::UpdateUsageEntryInformation() {
|
|||||||
if (usage_support_type_ != kUsageEntrySupport ||
|
if (usage_support_type_ != kUsageEntrySupport ||
|
||||||
!has_provider_session_token() || usage_table_header_ == NULL) {
|
!has_provider_session_token() || usage_table_header_ == NULL) {
|
||||||
LOGE(
|
LOGE(
|
||||||
"CdmSession::UpdateUsageEntryInformation: Unexpected state, "
|
"Unexpected state: usage support type = %d, PST present = %s, "
|
||||||
"usage support type: %d, PST present: %s, usage table header available"
|
"usage table header available = %s",
|
||||||
": %s",
|
static_cast<int>(usage_support_type_),
|
||||||
usage_support_type_, has_provider_session_token() ? "yes" : "no",
|
has_provider_session_token() ? "yes" : "no",
|
||||||
usage_table_header_ == NULL ? "no" : "yes");
|
usage_table_header_ == NULL ? "no" : "yes");
|
||||||
return INCORRECT_USAGE_SUPPORT_TYPE_2;
|
return INCORRECT_USAGE_SUPPORT_TYPE_2;
|
||||||
}
|
}
|
||||||
@@ -1064,7 +1043,7 @@ CdmResponseType CdmSession::GenericEncrypt(const std::string& in_buffer,
|
|||||||
CdmEncryptionAlgorithm algorithm,
|
CdmEncryptionAlgorithm algorithm,
|
||||||
std::string* out_buffer) {
|
std::string* out_buffer) {
|
||||||
if (!out_buffer) {
|
if (!out_buffer) {
|
||||||
LOGE("CdmSession::GenericEncrypt: No output destination provided");
|
LOGE("No output destination provided");
|
||||||
return PARAMETER_NULL;
|
return PARAMETER_NULL;
|
||||||
}
|
}
|
||||||
CdmResponseType sts;
|
CdmResponseType sts;
|
||||||
@@ -1081,7 +1060,7 @@ CdmResponseType CdmSession::GenericDecrypt(const std::string& in_buffer,
|
|||||||
CdmEncryptionAlgorithm algorithm,
|
CdmEncryptionAlgorithm algorithm,
|
||||||
std::string* out_buffer) {
|
std::string* out_buffer) {
|
||||||
if (!out_buffer) {
|
if (!out_buffer) {
|
||||||
LOGE("CdmSession::GenericDecrypt: No output destination provided");
|
LOGE("No output destination provided");
|
||||||
return PARAMETER_NULL;
|
return PARAMETER_NULL;
|
||||||
}
|
}
|
||||||
CdmResponseType sts;
|
CdmResponseType sts;
|
||||||
@@ -1097,7 +1076,7 @@ CdmResponseType CdmSession::GenericSign(const std::string& message,
|
|||||||
CdmSigningAlgorithm algorithm,
|
CdmSigningAlgorithm algorithm,
|
||||||
std::string* signature) {
|
std::string* signature) {
|
||||||
if (!signature) {
|
if (!signature) {
|
||||||
LOGE("CdmSession::GenericSign: No output destination provided");
|
LOGE("No output destination provided");
|
||||||
return PARAMETER_NULL;
|
return PARAMETER_NULL;
|
||||||
}
|
}
|
||||||
CdmResponseType sts;
|
CdmResponseType sts;
|
||||||
|
|||||||
Reference in New Issue
Block a user