Squashed merge 3 CLs.

1. "Change CdmResponseType from enum into a struct"
Merged from http://go/wvgerrit/163199
Bug: 253271674

2. "Log request information when server returns 401"
Bug: 260760387
Bug: 186031735
Merged from http://go/wvgerrit/162798

3. "Specify server version on the command line"
Bug: 251599048
Merged from http://go/wvgerrit/158897

Test: build android.hardware.drm-service.widevine
Test: Netflix and Play Movies & TV
Test: build_and_run_all_unit_tests.sh

Bug: 253271674
Change-Id: I70c950acce070609ee0343920ec68e66b058bc23
This commit is contained in:
Robert Shih
2022-11-16 10:02:18 -08:00
committed by Edwin Wong
parent ac9641ae13
commit 096b0eda5a
46 changed files with 1726 additions and 1443 deletions

View File

@@ -29,7 +29,7 @@
#define RETURN_STATUS_IF_NULL(PARAM) \
if ((PARAM) == nullptr) { \
LOGE("Output parameter |" STRINGIFY(PARAM) "| not provided"); \
return PARAMETER_NULL; \
return CdmResponseType(PARAMETER_NULL); \
}
#define RETURN_FALSE_IF_NULL(PARAM) \
@@ -46,7 +46,7 @@ const size_t kKeySetIdLength = 14;
template <typename T>
void SetErrorDetail(int* error_detail, T error_code) {
if (error_detail != nullptr) {
*error_detail = error_code;
*error_detail = static_cast<int>(error_code);
}
}
@@ -118,7 +118,7 @@ CdmResponseType CdmSession::Init(CdmClientPropertySet* cdm_client_property_set,
bool forced_level3) {
if (initialized_) {
LOGE("Failed due to previous initialization");
return REINIT_ERROR;
return CdmResponseType(REINIT_ERROR);
}
if ((cdm_client_property_set && cdm_client_property_set->security_level() ==
@@ -144,7 +144,7 @@ CdmResponseType CdmSession::Init(CdmClientPropertySet* cdm_client_property_set,
if (!file_handle_->Init(security_level_)) {
LOGE("Unable to initialize file handle");
return SESSION_FILE_HANDLE_INIT_ERROR;
return CdmResponseType(SESSION_FILE_HANDLE_INIT_ERROR);
}
bool has_support = false;
@@ -159,7 +159,7 @@ CdmResponseType CdmSession::Init(CdmClientPropertySet* cdm_client_property_set,
// The actual validation and loading of a certificate will happen when
// a key request is generated or an offline license is loaded.
if (!file_handle_->HasCertificate(atsc_mode_enabled_))
return NEED_PROVISIONING;
return CdmResponseType(NEED_PROVISIONING);
if (forced_session_id) {
key_set_id_ = *forced_session_id;
@@ -178,7 +178,7 @@ CdmResponseType CdmSession::Init(CdmClientPropertySet* cdm_client_property_set,
if (session_id_.empty()) {
LOGE("Empty session ID");
return EMPTY_SESSION_ID;
return CdmResponseType(EMPTY_SESSION_ID);
}
if (cdm_client_property_set)
Properties::AddSessionPropertySet(session_id_, cdm_client_property_set);
@@ -196,13 +196,13 @@ CdmResponseType CdmSession::Init(CdmClientPropertySet* cdm_client_property_set,
if (!license_parser_->Init(Properties::UsePrivacyMode(session_id_),
service_certificate, crypto_session_.get(),
policy_engine_.get()))
return LICENSE_PARSER_INIT_ERROR;
return CdmResponseType(LICENSE_PARSER_INIT_ERROR);
license_received_ = false;
is_initial_decryption_ = true;
initialized_ = true;
closed_ = false;
return NO_ERROR;
return CdmResponseType(NO_ERROR);
}
CdmResponseType CdmSession::RestoreOfflineSession(const CdmKeySetId& key_set_id,
@@ -210,7 +210,7 @@ CdmResponseType CdmSession::RestoreOfflineSession(const CdmKeySetId& key_set_id,
int* error_detail) {
if (!initialized_) {
LOGE("CDM session not initialized");
return NOT_INITIALIZED_ERROR;
return CdmResponseType(NOT_INITIALIZED_ERROR);
}
if (!key_set_id_.empty()) {
file_handle_->UnreserveLicenseId(key_set_id_);
@@ -219,7 +219,7 @@ CdmResponseType CdmSession::RestoreOfflineSession(const CdmKeySetId& key_set_id,
LOGE(
"Disallow multiple offline license restores or restoring a license if "
"a license has already been loaded");
return RESTORE_OFFLINE_LICENSE_ERROR_3;
return CdmResponseType(RESTORE_OFFLINE_LICENSE_ERROR_3);
}
key_set_id_ = key_set_id;
@@ -233,8 +233,9 @@ CdmResponseType CdmSession::RestoreOfflineSession(const CdmKeySetId& key_set_id,
DeviceFiles::ResponseTypeToString(sub_error_code),
IdToString(key_set_id));
SetErrorDetail(error_detail, sub_error_code);
return sub_error_code == DeviceFiles::kFileNotFound ? KEYSET_ID_NOT_FOUND_4
: GET_LICENSE_ERROR;
return sub_error_code == DeviceFiles::kFileNotFound
? CdmResponseType(KEYSET_ID_NOT_FOUND_4)
: CdmResponseType(GET_LICENSE_ERROR);
}
offline_init_data_ = std::move(license_data.pssh_data);
key_request_ = std::move(license_data.license_request);
@@ -266,7 +267,7 @@ CdmResponseType CdmSession::RestoreOfflineSession(const CdmKeySetId& key_set_id,
LOGE("Invalid offline license state: state = %s, license_type = %s",
CdmOfflineLicenseStateToString(license_data.state),
CdmLicenseTypeToString(license_type));
return GET_RELEASED_LICENSE_ERROR;
return CdmResponseType(GET_RELEASED_LICENSE_ERROR);
}
std::string provider_session_token;
@@ -278,7 +279,7 @@ CdmResponseType CdmSession::RestoreOfflineSession(const CdmKeySetId& key_set_id,
sign_fake_request = true; // TODO(b/169483174): remove this line.
} else if (!VerifyOfflineUsageEntry()) {
LOGE("License usage entry is invalid, cannot restore");
return LICENSE_USAGE_ENTRY_MISSING;
return CdmResponseType(LICENSE_USAGE_ENTRY_MISSING);
} else {
CdmResponseType sts = usage_table_header_->LoadEntry(
crypto_session_.get(), usage_entry_, usage_entry_number_);
@@ -286,7 +287,7 @@ CdmResponseType CdmSession::RestoreOfflineSession(const CdmKeySetId& key_set_id,
if (sts == LOAD_USAGE_ENTRY_INVALID_SESSION) {
LOGE("License loaded in different session: key_set_id = %s",
IdToString(key_set_id));
return USAGE_ENTRY_ALREADY_LOADED;
return CdmResponseType(USAGE_ENTRY_ALREADY_LOADED);
}
if (sts != NO_ERROR) {
LOGE("Failed to load usage entry: status = %d", static_cast<int>(sts));
@@ -317,8 +318,8 @@ CdmResponseType CdmSession::RestoreOfflineSession(const CdmKeySetId& key_set_id,
license_data.drm_certificate, key_request_, key_response_);
if (result != NO_ERROR) {
SetErrorDetail(error_detail, result);
return RELEASE_LICENSE_ERROR_1;
SetErrorDetail(error_detail, result.Enum());
return CdmResponseType(RELEASE_LICENSE_ERROR_1);
}
} else {
result = license_parser_->RestoreOfflineLicense(
@@ -327,8 +328,8 @@ CdmResponseType CdmSession::RestoreOfflineSession(const CdmKeySetId& key_set_id,
license_data.last_playback_time, license_data.grace_period_end_time,
this);
if (result != NO_ERROR) {
SetErrorDetail(error_detail, result);
return RESTORE_OFFLINE_LICENSE_ERROR_2;
SetErrorDetail(error_detail, result.Enum());
return CdmResponseType(RESTORE_OFFLINE_LICENSE_ERROR_2);
}
}
@@ -348,14 +349,14 @@ CdmResponseType CdmSession::RestoreOfflineSession(const CdmKeySetId& key_set_id,
is_offline_ = true;
is_release_ = license_type == kLicenseTypeRelease;
has_license_been_restored_ = true;
return KEY_ADDED;
return CdmResponseType(KEY_ADDED);
}
CdmResponseType CdmSession::RestoreUsageSession(
const DeviceFiles::CdmUsageData& usage_data, int* error_detail) {
if (!initialized_) {
LOGE("CDM session not initialized");
return NOT_INITIALIZED_ERROR;
return CdmResponseType(NOT_INITIALIZED_ERROR);
}
if (!key_set_id_.empty()) {
file_handle_->UnreserveLicenseId(key_set_id_);
@@ -371,7 +372,7 @@ CdmResponseType CdmSession::RestoreUsageSession(
usage_data.drm_certificate, usage_data.wrapped_private_key);
if (status != NO_ERROR) return status;
CdmResponseType sts = NO_ERROR;
CdmResponseType sts(NO_ERROR);
if (supports_usage_info()) {
sts = usage_table_header_->LoadEntry(crypto_session_.get(), usage_entry_,
usage_entry_number_);
@@ -387,7 +388,7 @@ CdmResponseType CdmSession::RestoreUsageSession(
if (sts != NO_ERROR) {
SetErrorDetail(error_detail, sts);
return RELEASE_LICENSE_ERROR_2;
return CdmResponseType(RELEASE_LICENSE_ERROR_2);
}
if (supports_usage_info()) {
@@ -405,7 +406,7 @@ CdmResponseType CdmSession::RestoreUsageSession(
license_received_ = true;
is_offline_ = false;
is_release_ = true;
return KEY_ADDED;
return CdmResponseType(KEY_ADDED);
}
// This is a thin wrapper that initiates the latency metric.
@@ -429,7 +430,7 @@ CdmResponseType CdmSession::GenerateKeyRequestInternal(
const CdmAppParameterMap& app_parameters, CdmKeyRequest* key_request) {
if (!initialized_) {
LOGE("CDM session not initialized");
return NOT_INITIALIZED_ERROR;
return CdmResponseType(NOT_INITIALIZED_ERROR);
}
RETURN_STATUS_IF_NULL(key_request);
@@ -457,7 +458,7 @@ CdmResponseType CdmSession::GenerateKeyRequestInternal(
return license_parser_->HandleEmbeddedKeyData(init_data);
default:
LOGE("Unrecognized license type: %d", static_cast<int>(license_type));
return INVALID_LICENSE_TYPE;
return CdmResponseType(INVALID_LICENSE_TYPE);
}
if (is_release_) {
@@ -479,15 +480,15 @@ CdmResponseType CdmSession::GenerateKeyRequestInternal(
if (!init_data.is_supported()) {
LOGW("Unsupported init data type: %s", init_data.type().c_str());
return UNSUPPORTED_INIT_DATA;
return CdmResponseType(UNSUPPORTED_INIT_DATA);
}
if (init_data.IsEmpty() && !license_parser_->HasInitData()) {
LOGW("Init data absent");
return INIT_DATA_NOT_FOUND;
return CdmResponseType(INIT_DATA_NOT_FOUND);
}
if (is_offline_ && key_set_id_.empty()) {
LOGE("Key set ID not set");
return KEY_REQUEST_ERROR_1;
return CdmResponseType(KEY_REQUEST_ERROR_1);
}
// Attempt to load provisioned private key if available.
CdmResponseType status = LoadPrivateKey();
@@ -504,7 +505,7 @@ CdmResponseType CdmSession::GenerateKeyRequestInternal(
offline_init_data_ = init_data.data();
offline_release_server_url_ = key_request->url;
}
return KEY_MESSAGE;
return CdmResponseType(KEY_MESSAGE);
}
// This thin wrapper allows us to update metrics.
@@ -518,12 +519,12 @@ CdmResponseType CdmSession::AddKey(const CdmKeyResponse& key_response) {
CdmResponseType CdmSession::AddKeyInternal(const CdmKeyResponse& key_response) {
if (!initialized_) {
LOGE("Not initialized");
return NOT_INITIALIZED_ERROR;
return CdmResponseType(NOT_INITIALIZED_ERROR);
}
if (is_release_) {
const CdmResponseType sts = ReleaseKey(key_response);
return (sts == NO_ERROR) ? KEY_ADDED : sts;
return (sts == NO_ERROR) ? CdmResponseType(KEY_ADDED) : sts;
}
if (license_received_) { // renewal
return RenewKey(key_response);
@@ -571,7 +572,8 @@ CdmResponseType CdmSession::AddKeyInternal(const CdmKeyResponse& key_response) {
}
}
if (sts != KEY_ADDED) return (sts == KEY_ERROR) ? ADD_KEY_ERROR : sts;
if (sts != KEY_ADDED)
return (sts == KEY_ERROR) ? CdmResponseType(ADD_KEY_ERROR) : sts;
license_received_ = true;
key_response_ = key_response;
@@ -594,13 +596,13 @@ CdmResponseType CdmSession::AddKeyInternal(const CdmKeyResponse& key_response) {
}
has_license_been_loaded_ = true;
return KEY_ADDED;
return CdmResponseType(KEY_ADDED);
}
CdmResponseType CdmSession::QueryStatus(CdmQueryMap* query_response) {
if (!initialized_) {
LOGE("CDM session not initialized");
return NOT_INITIALIZED_ERROR;
return CdmResponseType(NOT_INITIALIZED_ERROR);
}
RETURN_STATUS_IF_NULL(query_response);
@@ -623,9 +625,9 @@ CdmResponseType CdmSession::QueryStatus(CdmQueryMap* query_response) {
QUERY_VALUE_SECURITY_LEVEL_UNKNOWN;
break;
default:
return INVALID_QUERY_KEY;
return CdmResponseType(INVALID_QUERY_KEY);
}
return NO_ERROR;
return CdmResponseType(NO_ERROR);
}
CdmResponseType CdmSession::SetServiceCertificate(
@@ -646,19 +648,19 @@ CdmResponseType CdmSession::QueryOemCryptoSessionId(
CdmQueryMap* query_response) {
if (!initialized_) {
LOGE("CDM session not initialized");
return NOT_INITIALIZED_ERROR;
return CdmResponseType(NOT_INITIALIZED_ERROR);
}
RETURN_STATUS_IF_NULL(query_response);
(*query_response)[QUERY_KEY_OEMCRYPTO_SESSION_ID] =
std::to_string(crypto_session_->oec_session_id());
return NO_ERROR;
return CdmResponseType(NO_ERROR);
}
// Decrypt() - Accept encrypted buffer and return decrypted data.
CdmResponseType CdmSession::Decrypt(const CdmDecryptionParametersV16& params) {
if (!initialized_) {
return NOT_INITIALIZED_ERROR;
return CdmResponseType(NOT_INITIALIZED_ERROR);
}
bool is_protected = std::any_of(
@@ -677,18 +679,19 @@ CdmResponseType CdmSession::Decrypt(const CdmDecryptionParametersV16& params) {
// the security level is not high enough yet.
if (is_protected) {
if (!policy_engine_->CanDecryptContent(params.key_id)) {
if (policy_engine_->IsLicenseForFuture()) return DECRYPT_NOT_READY;
if (policy_engine_->IsLicenseForFuture())
return CdmResponseType(DECRYPT_NOT_READY);
if (!policy_engine_->IsSufficientOutputProtection(params.key_id)) {
LOGE("Key use prohibited as HDCP or resolution requirements not met");
return INSUFFICIENT_OUTPUT_PROTECTION;
return CdmResponseType(INSUFFICIENT_OUTPUT_PROTECTION);
}
return NEED_KEY;
return CdmResponseType(NEED_KEY);
}
if (!policy_engine_->CanUseKeyForSecurityLevel(params.key_id)) {
LOGE(
"Key use prohibited as security level requirements in the policy"
" not met");
return KEY_PROHIBITED_FOR_SECURITY_LEVEL;
return CdmResponseType(KEY_PROHIBITED_FOR_SECURITY_LEVEL);
}
}
@@ -715,7 +718,7 @@ CdmResponseType CdmSession::Decrypt(const CdmDecryptionParametersV16& params) {
const int64_t current_time = clock.GetCurrentTime();
if (policy_engine_->HasLicenseOrRentalOrPlaybackDurationExpired(
current_time)) {
return NEED_KEY;
return CdmResponseType(NEED_KEY);
}
}
@@ -728,7 +731,7 @@ CdmResponseType CdmSession::Decrypt(const CdmDecryptionParametersV16& params) {
CdmResponseType CdmSession::GenerateRenewalRequest(CdmKeyRequest* key_request) {
if (!initialized_) {
LOGE("CDM session not initialized");
return NOT_INITIALIZED_ERROR;
return CdmResponseType(NOT_INITIALIZED_ERROR);
}
RETURN_STATUS_IF_NULL(key_request);
@@ -744,14 +747,14 @@ CdmResponseType CdmSession::GenerateRenewalRequest(CdmKeyRequest* key_request) {
}
key_request_type_ = key_request->type;
license_request_latency_.Start(); // Start or restart timer.
return KEY_MESSAGE;
return CdmResponseType(KEY_MESSAGE);
}
// RenewKey() - Accept renewal response and update key info.
CdmResponseType CdmSession::RenewKey(const CdmKeyResponse& key_response) {
if (!initialized_) {
LOGE("CDM session not initialized");
return NOT_INITIALIZED_ERROR;
return CdmResponseType(NOT_INITIALIZED_ERROR);
}
CdmResponseType sts = license_parser_->HandleKeyUpdateResponse(
/* is renewal */ true,
@@ -760,20 +763,21 @@ CdmResponseType CdmSession::RenewKey(const CdmKeyResponse& key_response) {
// Record the timing on success.
UpdateRequestLatencyTiming(sts);
if (sts != KEY_ADDED) return (sts == KEY_ERROR) ? RENEW_KEY_ERROR_1 : sts;
if (sts != KEY_ADDED)
return (sts == KEY_ERROR) ? CdmResponseType(RENEW_KEY_ERROR_1) : sts;
if (is_offline_) {
offline_key_renewal_response_ = key_response;
if (!StoreLicense(kLicenseStateActive, nullptr /* error_detail */))
return RENEW_KEY_ERROR_2;
return CdmResponseType(RENEW_KEY_ERROR_2);
}
return KEY_ADDED;
return CdmResponseType(KEY_ADDED);
}
CdmResponseType CdmSession::GenerateReleaseRequest(CdmKeyRequest* key_request) {
if (!initialized_) {
LOGE("CDM session not initialized");
return NOT_INITIALIZED_ERROR;
return CdmResponseType(NOT_INITIALIZED_ERROR);
}
RETURN_STATUS_IF_NULL(key_request);
is_release_ = true;
@@ -798,24 +802,24 @@ CdmResponseType CdmSession::GenerateReleaseRequest(CdmKeyRequest* key_request) {
if (is_offline_) { // Mark license as being released
if (!StoreLicense(kLicenseStateReleasing, nullptr))
return RELEASE_KEY_REQUEST_ERROR;
return CdmResponseType(RELEASE_KEY_REQUEST_ERROR);
} else if (!usage_provider_session_token_.empty()) {
if (supports_usage_info()) {
if (!UpdateUsageInfo()) return RELEASE_USAGE_INFO_FAILED;
if (!UpdateUsageInfo()) return CdmResponseType(RELEASE_USAGE_INFO_FAILED);
}
}
key_request_type_ = key_request->type;
license_request_latency_.Start(); // Start or restart timer.
return KEY_MESSAGE;
return CdmResponseType(KEY_MESSAGE);
}
// ReleaseKey() - Accept release response and release license.
CdmResponseType CdmSession::ReleaseKey(const CdmKeyResponse& key_response) {
if (!initialized_) {
LOGE("CDM session not initialized");
return NOT_INITIALIZED_ERROR;
return CdmResponseType(NOT_INITIALIZED_ERROR);
}
CdmResponseType sts = license_parser_->HandleKeyUpdateResponse(
/* is renewal */ false,
@@ -823,7 +827,8 @@ CdmResponseType CdmSession::ReleaseKey(const CdmKeyResponse& key_response) {
// Record the timing on success.
UpdateRequestLatencyTiming(sts);
if (sts != KEY_ADDED) return (sts == KEY_ERROR) ? RELEASE_KEY_ERROR : sts;
if (sts != KEY_ADDED)
return (sts == KEY_ERROR) ? CdmResponseType(RELEASE_KEY_ERROR) : sts;
return RemoveLicense();
}
@@ -831,11 +836,11 @@ CdmResponseType CdmSession::ReleaseKey(const CdmKeyResponse& key_response) {
CdmResponseType CdmSession::DeleteUsageEntry(uint32_t usage_entry_number) {
if (!initialized_) {
LOGE("CDM session not initialized");
return NOT_INITIALIZED_ERROR;
return CdmResponseType(NOT_INITIALIZED_ERROR);
}
if (!supports_usage_info()) {
LOGE("Cannot delete entry, usage table not supported");
return INCORRECT_USAGE_SUPPORT_TYPE_1;
return CdmResponseType(INCORRECT_USAGE_SUPPORT_TYPE_1);
}
// The usage entry cannot be deleted if it has a crypto session handling
@@ -856,7 +861,7 @@ CdmResponseType CdmSession::DeleteUsageEntry(uint32_t usage_entry_number) {
if (usage_table_header_ == nullptr) {
LOGE("Usage table header unavailable");
return INCORRECT_USAGE_SUPPORT_TYPE_1;
return CdmResponseType(INCORRECT_USAGE_SUPPORT_TYPE_1);
}
sts = usage_table_header_->InvalidateEntry(
@@ -910,32 +915,32 @@ bool CdmSession::GenerateKeySetId(bool atsc_mode_enabled,
CdmResponseType CdmSession::StoreLicense() {
if (is_temporary_) {
LOGE("Session type prohibits storage");
return STORAGE_PROHIBITED;
return CdmResponseType(STORAGE_PROHIBITED);
}
if (is_offline_) {
if (key_set_id_.empty()) {
LOGE("No key set ID");
return EMPTY_KEYSET_ID;
return CdmResponseType(EMPTY_KEYSET_ID);
}
if (!license_parser_->is_offline()) {
LOGE("License policy prohibits storage");
return OFFLINE_LICENSE_PROHIBITED;
return CdmResponseType(OFFLINE_LICENSE_PROHIBITED);
}
if (!StoreLicense(kLicenseStateActive, nullptr)) {
LOGE("Unable to store license");
return STORE_LICENSE_ERROR_1;
return CdmResponseType(STORE_LICENSE_ERROR_1);
}
return NO_ERROR;
return CdmResponseType(NO_ERROR);
} // if (is_offline_)
std::string provider_session_token =
license_parser_->provider_session_token();
if (provider_session_token.empty()) {
LOGE("No provider session token and not offline");
return STORE_LICENSE_ERROR_2;
return CdmResponseType(STORE_LICENSE_ERROR_2);
}
std::string app_id;
@@ -955,9 +960,9 @@ CdmResponseType CdmSession::StoreLicense() {
file_handle_->DeleteAllUsageInfoForApp(
DeviceFiles::GetUsageInfoFileName(app_id), &provider_session_tokens);
return STORE_USAGE_INFO_ERROR;
return CdmResponseType(STORE_USAGE_INFO_ERROR);
}
return NO_ERROR;
return CdmResponseType(NO_ERROR);
}
bool CdmSession::StoreLicense(CdmOfflineLicenseState state, int* error_detail) {
@@ -995,7 +1000,7 @@ CdmResponseType CdmSession::RemoveKeys() {
crypto_metrics_, crypto_session_open_, sts, requested_security_level_);
policy_engine_.reset(
new PolicyEngine(session_id_, nullptr, crypto_session_.get()));
return NO_ERROR;
return CdmResponseType(NO_ERROR);
}
CdmResponseType CdmSession::RemoveLicense() {
@@ -1005,7 +1010,7 @@ CdmResponseType CdmSession::RemoveLicense() {
}
DeleteLicenseFile();
}
return NO_ERROR;
return CdmResponseType(NO_ERROR);
}
bool CdmSession::DeleteLicenseFile() {
@@ -1054,10 +1059,10 @@ CdmResponseType CdmSession::UpdateUsageEntryInformation() {
LOGE("Unexpected state: usage_support = %s, PST present = %s, ",
supports_usage_info() ? "true" : "false",
has_provider_session_token() ? "yes" : "no");
return INCORRECT_USAGE_SUPPORT_TYPE_2;
return CdmResponseType(INCORRECT_USAGE_SUPPORT_TYPE_2);
}
CdmResponseType sts = NO_ERROR;
CdmResponseType sts(NO_ERROR);
// TODO(blueeyes): Add measurements to all UpdateEntry calls in a way that
// allos us to isolate this particular use case within
// UpdateUsageEntryInformation.
@@ -1073,7 +1078,7 @@ CdmResponseType CdmSession::UpdateUsageEntryInformation() {
else if (!usage_provider_session_token_.empty())
UpdateUsageInfo();
return NO_ERROR;
return CdmResponseType(NO_ERROR);
}
CdmResponseType CdmSession::GenericEncrypt(const std::string& in_buffer,
@@ -1190,7 +1195,7 @@ CdmResponseType CdmSession::LoadPrivateKey() {
if (file_handle_->RetrieveCertificate(atsc_mode_enabled_, &drm_certificate,
&private_key, nullptr, &system_id) !=
DeviceFiles::kCertificateValid) {
return NEED_PROVISIONING;
return CdmResponseType(NEED_PROVISIONING);
}
return LoadPrivateKey(drm_certificate, private_key);
@@ -1208,7 +1213,7 @@ CdmResponseType CdmSession::LoadPrivateOrLegacyKey(
if (file_handle_->RetrieveLegacyCertificate(
&drm_certificate, &wrapped_private_key, nullptr, nullptr) !=
DeviceFiles::kCertificateValid)
return NEED_PROVISIONING;
return CdmResponseType(NEED_PROVISIONING);
return LoadPrivateKey(drm_certificate, wrapped_private_key);
}
@@ -1221,19 +1226,19 @@ CdmResponseType CdmSession::LoadPrivateKey(
crypto_metrics_, crypto_session_load_certificate_private_key_,
load_cert_sts);
switch (load_cert_sts) {
switch (load_cert_sts.Enum()) {
case NO_ERROR:
metrics_->drm_certificate_key_type_.Record(
DrmKeyTypeToMetricValue(private_key.type()));
drm_certificate_ = drm_certificate;
wrapped_private_key_ = std::move(private_key);
return NO_ERROR;
return CdmResponseType(NO_ERROR);
case SESSION_LOST_STATE_ERROR:
case SYSTEM_INVALIDATED_ERROR:
return load_cert_sts;
default:
return NEED_PROVISIONING;
return CdmResponseType(NEED_PROVISIONING);
}
}