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:
@@ -261,7 +261,7 @@ CdmResponseType CdmLicense::PrepareKeyRequest(
|
||||
CdmKeyMessage* signed_request, std::string* server_url) {
|
||||
if (!initialized_) {
|
||||
LOGE("CdmLicense not initialized");
|
||||
return LICENSE_PARSER_NOT_INITIALIZED_4;
|
||||
return CdmResponseType(LICENSE_PARSER_NOT_INITIALIZED_4);
|
||||
}
|
||||
client_token_ = client_token;
|
||||
if (init_data.IsEmpty() && stored_init_data_) {
|
||||
@@ -273,19 +273,19 @@ CdmResponseType CdmLicense::PrepareKeyRequest(
|
||||
wrapped_keys_ = init_data.ExtractWrappedKeys();
|
||||
if (!init_data.is_supported()) {
|
||||
LOGE("Unsupported init data type: type = %s", init_data.type().c_str());
|
||||
return INVALID_PARAMETERS_LIC_3;
|
||||
return CdmResponseType(INVALID_PARAMETERS_LIC_3);
|
||||
}
|
||||
if (init_data.IsEmpty()) {
|
||||
LOGE("Init data is empty");
|
||||
return INVALID_PARAMETERS_LIC_4;
|
||||
return CdmResponseType(INVALID_PARAMETERS_LIC_4);
|
||||
}
|
||||
if (signed_request == nullptr) {
|
||||
LOGE("Output parameter |signed_request| not provided");
|
||||
return INVALID_PARAMETERS_LIC_6;
|
||||
return CdmResponseType(INVALID_PARAMETERS_LIC_6);
|
||||
}
|
||||
if (server_url == nullptr) {
|
||||
LOGE("Output parameter |server_url| not provided");
|
||||
return INVALID_PARAMETERS_LIC_7;
|
||||
return CdmResponseType(INVALID_PARAMETERS_LIC_7);
|
||||
}
|
||||
|
||||
// If privacy mode and no service certificate, depending on platform
|
||||
@@ -293,17 +293,18 @@ CdmResponseType CdmLicense::PrepareKeyRequest(
|
||||
if (use_privacy_mode_ && !service_certificate_.has_certificate()) {
|
||||
if (!Properties::allow_service_certificate_requests()) {
|
||||
LOGE("Privacy mode failure: No service certificate");
|
||||
return PRIVACY_MODE_ERROR_1;
|
||||
return CdmResponseType(PRIVACY_MODE_ERROR_1);
|
||||
}
|
||||
|
||||
stored_init_data_.reset(new InitializationData(init_data));
|
||||
|
||||
if (!ServiceCertificate::GetRequest(signed_request)) {
|
||||
LOGE("Failed to prepare service certificated request");
|
||||
return LICENSE_REQUEST_SERVICE_CERTIFICATE_GENERATION_ERROR;
|
||||
return CdmResponseType(
|
||||
LICENSE_REQUEST_SERVICE_CERTIFICATE_GENERATION_ERROR);
|
||||
}
|
||||
|
||||
return KEY_MESSAGE;
|
||||
return CdmResponseType(KEY_MESSAGE);
|
||||
}
|
||||
|
||||
const std::string& request_id = crypto_session_->request_id();
|
||||
@@ -325,14 +326,14 @@ CdmResponseType CdmLicense::PrepareKeyRequest(
|
||||
// of the license response.
|
||||
status = crypto_session_->GenerateNonce(&license_nonce_);
|
||||
|
||||
switch (status) {
|
||||
switch (status.Enum()) {
|
||||
case NO_ERROR:
|
||||
break;
|
||||
case SESSION_LOST_STATE_ERROR:
|
||||
case SYSTEM_INVALIDATED_ERROR:
|
||||
return status;
|
||||
default:
|
||||
return LICENSE_REQUEST_NONCE_GENERATION_ERROR;
|
||||
return CdmResponseType(LICENSE_REQUEST_NONCE_GENERATION_ERROR);
|
||||
}
|
||||
license_request.set_key_control_nonce(license_nonce_);
|
||||
license_request.set_protocol_version(video_widevine::VERSION_2_1);
|
||||
@@ -358,7 +359,7 @@ CdmResponseType CdmLicense::PrepareKeyRequest(
|
||||
if (license_request_signature.empty()) {
|
||||
LOGE("License request signature is empty");
|
||||
signed_request->clear();
|
||||
return EMPTY_LICENSE_REQUEST;
|
||||
return CdmResponseType(EMPTY_LICENSE_REQUEST);
|
||||
}
|
||||
|
||||
// Put serialized license request and signature together
|
||||
@@ -371,7 +372,7 @@ CdmResponseType CdmLicense::PrepareKeyRequest(
|
||||
signed_message.SerializeToString(signed_request);
|
||||
|
||||
*server_url = server_url_;
|
||||
return KEY_MESSAGE;
|
||||
return CdmResponseType(KEY_MESSAGE);
|
||||
}
|
||||
|
||||
// TODO(b/166007195): Remove this.
|
||||
@@ -381,7 +382,7 @@ CdmResponseType CdmLicense::PrepareKeyUpdateReload(CdmSession* cdm_session) {
|
||||
LOGW("Unknown API Version");
|
||||
api_version = 16;
|
||||
}
|
||||
if (api_version != 16) return NO_ERROR;
|
||||
if (api_version != 16) return CdmResponseType(NO_ERROR);
|
||||
// To work around b/166010609, we ask OEMCrypto to prepare an unused renewal
|
||||
// request. This lets the ODK library update its clock saying when the renewal
|
||||
// was signed.
|
||||
@@ -399,26 +400,26 @@ CdmResponseType CdmLicense::PrepareKeyUpdateRequest(
|
||||
std::string* server_url) {
|
||||
if (!initialized_) {
|
||||
LOGE("CdmLicense not initialized");
|
||||
return LICENSE_PARSER_NOT_INITIALIZED_1;
|
||||
return CdmResponseType(LICENSE_PARSER_NOT_INITIALIZED_1);
|
||||
}
|
||||
if (signed_request == nullptr) {
|
||||
LOGE("Output parameter |signed_request| not provided");
|
||||
return INVALID_PARAMETERS_LIC_1;
|
||||
return CdmResponseType(INVALID_PARAMETERS_LIC_1);
|
||||
}
|
||||
if (server_url == nullptr) {
|
||||
LOGE("Output parameter |server_url| not provided");
|
||||
return INVALID_PARAMETERS_LIC_2;
|
||||
return CdmResponseType(INVALID_PARAMETERS_LIC_2);
|
||||
}
|
||||
|
||||
if (is_renewal && !policy_engine_->CanRenew()) {
|
||||
LOGE("License renewal prohibited");
|
||||
return LICENSE_RENEWAL_PROHIBITED;
|
||||
return CdmResponseType(LICENSE_RENEWAL_PROHIBITED);
|
||||
}
|
||||
|
||||
if (renew_with_client_id_) {
|
||||
if (use_privacy_mode_ && !service_certificate_.has_certificate()) {
|
||||
LOGE("Privacy mode failure: No service certificate");
|
||||
return PRIVACY_MODE_ERROR_2;
|
||||
return CdmResponseType(PRIVACY_MODE_ERROR_2);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -465,7 +466,7 @@ CdmResponseType CdmLicense::PrepareKeyUpdateRequest(
|
||||
if (NO_ERROR == status)
|
||||
current_license->set_session_usage_table_entry(usage_report);
|
||||
else
|
||||
return GENERATE_USAGE_REPORT_ERROR;
|
||||
return CdmResponseType(GENERATE_USAGE_REPORT_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -495,7 +496,7 @@ CdmResponseType CdmLicense::PrepareKeyUpdateRequest(
|
||||
|
||||
if (license_request_signature.empty()) {
|
||||
LOGE("License request signature is empty");
|
||||
return EMPTY_LICENSE_RENEWAL;
|
||||
return CdmResponseType(EMPTY_LICENSE_RENEWAL);
|
||||
}
|
||||
|
||||
// Put serialize license request and signature together
|
||||
@@ -507,27 +508,27 @@ CdmResponseType CdmLicense::PrepareKeyUpdateRequest(
|
||||
|
||||
signed_message.SerializeToString(signed_request);
|
||||
*server_url = server_url_;
|
||||
return KEY_MESSAGE;
|
||||
return CdmResponseType(KEY_MESSAGE);
|
||||
}
|
||||
|
||||
CdmResponseType CdmLicense::HandleKeyResponse(
|
||||
bool is_restore, const CdmKeyResponse& license_response) {
|
||||
if (!initialized_) {
|
||||
LOGE("CdmLicense not initialized");
|
||||
return LICENSE_PARSER_NOT_INITIALIZED_2;
|
||||
return CdmResponseType(LICENSE_PARSER_NOT_INITIALIZED_2);
|
||||
}
|
||||
// Clear the latest service version when we receive a new response.
|
||||
latest_service_version_.Clear();
|
||||
|
||||
if (license_response.empty()) {
|
||||
LOGE("License response is empty");
|
||||
return EMPTY_LICENSE_RESPONSE_1;
|
||||
return CdmResponseType(EMPTY_LICENSE_RESPONSE_1);
|
||||
}
|
||||
|
||||
SignedMessage signed_response;
|
||||
if (!signed_response.ParseFromString(license_response)) {
|
||||
LOGE("Unable to parse signed license response");
|
||||
return INVALID_LICENSE_RESPONSE;
|
||||
return CdmResponseType(INVALID_LICENSE_RESPONSE);
|
||||
}
|
||||
|
||||
latest_service_version_ = signed_response.service_version_info();
|
||||
@@ -540,7 +541,7 @@ CdmResponseType CdmLicense::HandleKeyResponse(
|
||||
if (status != NO_ERROR) return status;
|
||||
|
||||
status = service_certificate_.Init(signed_certificate);
|
||||
return (status == NO_ERROR) ? NEED_KEY : status;
|
||||
return (status == NO_ERROR) ? CdmResponseType(NEED_KEY) : status;
|
||||
}
|
||||
|
||||
if (signed_response.type() == SignedMessage::ERROR_RESPONSE)
|
||||
@@ -549,12 +550,12 @@ CdmResponseType CdmLicense::HandleKeyResponse(
|
||||
if (signed_response.type() != SignedMessage::LICENSE) {
|
||||
LOGE("Unrecognized signed message type: type = %d",
|
||||
static_cast<int>(signed_response.type()));
|
||||
return INVALID_LICENSE_TYPE;
|
||||
return CdmResponseType(INVALID_LICENSE_TYPE);
|
||||
}
|
||||
|
||||
if (!signed_response.has_signature()) {
|
||||
LOGE("License response is not signed");
|
||||
return LICENSE_RESPONSE_NOT_SIGNED;
|
||||
return CdmResponseType(LICENSE_RESPONSE_NOT_SIGNED);
|
||||
}
|
||||
|
||||
const std::string& signed_message = signed_response.msg();
|
||||
@@ -564,12 +565,12 @@ CdmResponseType CdmLicense::HandleKeyResponse(
|
||||
License license;
|
||||
if (!license.ParseFromString(signed_message)) {
|
||||
LOGE("Unable to parse license response");
|
||||
return LICENSE_RESPONSE_PARSE_ERROR_1;
|
||||
return CdmResponseType(LICENSE_RESPONSE_PARSE_ERROR_1);
|
||||
}
|
||||
|
||||
if (!signed_response.has_session_key()) {
|
||||
LOGE("Signed response has no session keys present");
|
||||
return SESSION_KEYS_NOT_FOUND;
|
||||
return CdmResponseType(SESSION_KEYS_NOT_FOUND);
|
||||
}
|
||||
CdmResponseType status = crypto_session_->GenerateDerivedKeys(
|
||||
key_request_, signed_response.session_key());
|
||||
@@ -597,7 +598,7 @@ CdmResponseType CdmLicense::HandleKeyResponse(
|
||||
"MAC key/IV size error: expected = %zu/%zu, "
|
||||
"actual = %zu/%zu (key/iv)",
|
||||
kLicenseMacKeySize, KEY_IV_SIZE, mac_keys.size(), mac_key_iv.size());
|
||||
return KEY_SIZE_ERROR_1;
|
||||
return CdmResponseType(KEY_SIZE_ERROR_1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -614,7 +615,7 @@ CdmResponseType CdmLicense::HandleKeyResponse(
|
||||
}
|
||||
if (key_array.empty()) {
|
||||
LOGE("No content keys");
|
||||
return NO_CONTENT_KEY;
|
||||
return CdmResponseType(NO_CONTENT_KEY);
|
||||
}
|
||||
license_key_type_ = key_type;
|
||||
|
||||
@@ -645,7 +646,7 @@ CdmResponseType CdmLicense::HandleKeyResponse(
|
||||
crypto_session_->UseSecondaryKey(signed_response.using_secondary_key());
|
||||
if (status != NO_ERROR) return status;
|
||||
|
||||
CdmResponseType resp = NO_CONTENT_KEY;
|
||||
CdmResponseType resp(NO_CONTENT_KEY);
|
||||
if (kLicenseKeyTypeEntitlement == key_type) {
|
||||
resp =
|
||||
HandleEntitlementKeyResponse(is_restore, signed_message, core_message,
|
||||
@@ -661,17 +662,17 @@ CdmResponseType CdmLicense::HandleKeyUpdateResponse(
|
||||
bool is_renewal, bool is_restore, const CdmKeyResponse& license_response) {
|
||||
if (!initialized_) {
|
||||
LOGE("CdmLicense not initialized");
|
||||
return LICENSE_PARSER_NOT_INITIALIZED_3;
|
||||
return CdmResponseType(LICENSE_PARSER_NOT_INITIALIZED_3);
|
||||
}
|
||||
if (license_response.empty()) {
|
||||
LOGE("License response is empty");
|
||||
return EMPTY_LICENSE_RESPONSE_2;
|
||||
return CdmResponseType(EMPTY_LICENSE_RESPONSE_2);
|
||||
}
|
||||
|
||||
SignedMessage signed_response;
|
||||
if (!signed_response.ParseFromString(license_response)) {
|
||||
LOGE("Unable to parse signed message");
|
||||
return LICENSE_RESPONSE_PARSE_ERROR_2;
|
||||
return CdmResponseType(LICENSE_RESPONSE_PARSE_ERROR_2);
|
||||
}
|
||||
|
||||
switch (signed_response.type()) {
|
||||
@@ -682,7 +683,7 @@ CdmResponseType CdmLicense::HandleKeyUpdateResponse(
|
||||
default:
|
||||
LOGE("Unrecognized signed message type: type = %d",
|
||||
static_cast<int>(signed_response.type()));
|
||||
return INVALID_LICENSE_TYPE;
|
||||
return CdmResponseType(INVALID_LICENSE_TYPE);
|
||||
}
|
||||
|
||||
const std::string& signed_message = signed_response.msg();
|
||||
@@ -691,23 +692,23 @@ CdmResponseType CdmLicense::HandleKeyUpdateResponse(
|
||||
|
||||
if (is_renewal && core_message.empty()) {
|
||||
LOGE("Renewal response is missing |core_message| field");
|
||||
return CORE_MESSAGE_NOT_FOUND;
|
||||
return CdmResponseType(CORE_MESSAGE_NOT_FOUND);
|
||||
}
|
||||
|
||||
if (signature.empty()) {
|
||||
LOGE("Update key response is missing signature");
|
||||
return SIGNATURE_NOT_FOUND;
|
||||
return CdmResponseType(SIGNATURE_NOT_FOUND);
|
||||
}
|
||||
|
||||
License license;
|
||||
if (!license.ParseFromString(signed_message)) {
|
||||
LOGE("Unable to parse license from signed message");
|
||||
return LICENSE_RESPONSE_PARSE_ERROR_3;
|
||||
return CdmResponseType(LICENSE_RESPONSE_PARSE_ERROR_3);
|
||||
}
|
||||
|
||||
if (!license.has_id()) {
|
||||
LOGE("License ID not present");
|
||||
return LICENSE_ID_NOT_FOUND;
|
||||
return CdmResponseType(LICENSE_ID_NOT_FOUND);
|
||||
}
|
||||
|
||||
if (license.policy().has_always_include_client_id()) {
|
||||
@@ -715,9 +716,10 @@ CdmResponseType CdmLicense::HandleKeyUpdateResponse(
|
||||
}
|
||||
|
||||
if (!is_renewal) {
|
||||
if (!license.id().has_provider_session_token()) return KEY_ADDED;
|
||||
if (!license.id().has_provider_session_token())
|
||||
return CdmResponseType(KEY_ADDED);
|
||||
provider_session_token_ = license.id().provider_session_token();
|
||||
return KEY_ADDED;
|
||||
return CdmResponseType(KEY_ADDED);
|
||||
}
|
||||
|
||||
if (license.policy().has_renewal_server_url() &&
|
||||
@@ -753,12 +755,12 @@ CdmResponseType CdmLicense::RestoreOfflineLicense(
|
||||
CdmSession* cdm_session) {
|
||||
if (license_request.empty()) {
|
||||
LOGE("License request is empty");
|
||||
return EMPTY_LICENSE_REQUEST_2;
|
||||
return CdmResponseType(EMPTY_LICENSE_REQUEST_2);
|
||||
}
|
||||
|
||||
if (license_response.empty()) {
|
||||
LOGE("License response is empty");
|
||||
return EMPTY_LICENSE_RESPONSE_3;
|
||||
return CdmResponseType(EMPTY_LICENSE_RESPONSE_3);
|
||||
}
|
||||
|
||||
client_token_ = client_token;
|
||||
@@ -766,14 +768,14 @@ CdmResponseType CdmLicense::RestoreOfflineLicense(
|
||||
SignedMessage signed_request;
|
||||
if (!signed_request.ParseFromString(license_request)) {
|
||||
LOGE("Failed to parse license request");
|
||||
return PARSE_REQUEST_ERROR_1;
|
||||
return CdmResponseType(PARSE_REQUEST_ERROR_1);
|
||||
}
|
||||
|
||||
if (signed_request.type() != SignedMessage::LICENSE_REQUEST) {
|
||||
LOGE("Unexpected license request type: expected = %d, actual = %d",
|
||||
static_cast<int>(SignedMessage::LICENSE_REQUEST),
|
||||
static_cast<int>(signed_request.type()));
|
||||
return INVALID_LICENSE_REQUEST_TYPE_1;
|
||||
return CdmResponseType(INVALID_LICENSE_REQUEST_TYPE_1);
|
||||
}
|
||||
|
||||
key_request_ = signed_request.msg();
|
||||
@@ -832,7 +834,7 @@ CdmResponseType CdmLicense::RestoreOfflineLicense(
|
||||
|
||||
policy_engine_->RestorePlaybackTimes(playback_start_time, last_playback_time,
|
||||
grace_period_end_time);
|
||||
return NO_ERROR;
|
||||
return CdmResponseType(NO_ERROR);
|
||||
}
|
||||
|
||||
CdmResponseType CdmLicense::RestoreLicenseForRelease(
|
||||
@@ -840,12 +842,12 @@ CdmResponseType CdmLicense::RestoreLicenseForRelease(
|
||||
const CdmKeyResponse& license_response) {
|
||||
if (license_request.empty()) {
|
||||
LOGE("License request is empty");
|
||||
return EMPTY_LICENSE_REQUEST_3;
|
||||
return CdmResponseType(EMPTY_LICENSE_REQUEST_3);
|
||||
}
|
||||
|
||||
if (license_response.empty()) {
|
||||
LOGE("License response is empty");
|
||||
return EMPTY_LICENSE_RESPONSE_4;
|
||||
return CdmResponseType(EMPTY_LICENSE_RESPONSE_4);
|
||||
}
|
||||
|
||||
client_token_ = client_token;
|
||||
@@ -853,14 +855,14 @@ CdmResponseType CdmLicense::RestoreLicenseForRelease(
|
||||
SignedMessage signed_request;
|
||||
if (!signed_request.ParseFromString(license_request)) {
|
||||
LOGE("Failed to parse signed license request");
|
||||
return PARSE_REQUEST_ERROR_2;
|
||||
return CdmResponseType(PARSE_REQUEST_ERROR_2);
|
||||
}
|
||||
|
||||
if (signed_request.type() != SignedMessage::LICENSE_REQUEST) {
|
||||
LOGE("Unexpected signed license request type: expected = %d, actual = %d",
|
||||
static_cast<int>(SignedMessage::LICENSE_REQUEST),
|
||||
static_cast<int>(signed_request.type()));
|
||||
return INVALID_LICENSE_REQUEST_TYPE_2;
|
||||
return CdmResponseType(INVALID_LICENSE_REQUEST_TYPE_2);
|
||||
}
|
||||
|
||||
key_request_ = signed_request.msg();
|
||||
@@ -868,30 +870,30 @@ CdmResponseType CdmLicense::RestoreLicenseForRelease(
|
||||
SignedMessage signed_response;
|
||||
if (!signed_response.ParseFromString(license_response)) {
|
||||
LOGE("Failed to parse signed license response");
|
||||
return LICENSE_RESPONSE_PARSE_ERROR_4;
|
||||
return CdmResponseType(LICENSE_RESPONSE_PARSE_ERROR_4);
|
||||
}
|
||||
|
||||
if (SignedMessage::LICENSE != signed_response.type()) {
|
||||
LOGE("Unexpected signed license response type: expected = %d, actual = %d",
|
||||
static_cast<int>(SignedMessage::LICENSE),
|
||||
static_cast<int>(signed_response.type()));
|
||||
return INVALID_LICENSE_TYPE_2;
|
||||
return CdmResponseType(INVALID_LICENSE_TYPE_2);
|
||||
}
|
||||
|
||||
if (!signed_response.has_signature()) {
|
||||
LOGE("License response is not signed");
|
||||
return SIGNATURE_NOT_FOUND_2;
|
||||
return CdmResponseType(SIGNATURE_NOT_FOUND_2);
|
||||
}
|
||||
|
||||
if (!signed_response.has_oemcrypto_core_message()) {
|
||||
LOGE("License response is missing core message");
|
||||
return CORE_MESSAGE_NOT_FOUND;
|
||||
return CdmResponseType(CORE_MESSAGE_NOT_FOUND);
|
||||
}
|
||||
|
||||
License license;
|
||||
if (!license.ParseFromString(signed_response.msg())) {
|
||||
LOGE("Failed to parse license response");
|
||||
return LICENSE_RESPONSE_PARSE_ERROR_5;
|
||||
return CdmResponseType(LICENSE_RESPONSE_PARSE_ERROR_5);
|
||||
}
|
||||
|
||||
if (license.has_provider_client_token())
|
||||
@@ -905,12 +907,12 @@ CdmResponseType CdmLicense::RestoreLicenseForRelease(
|
||||
|
||||
if (!signed_response.has_session_key()) {
|
||||
LOGE("No session keys present");
|
||||
return SESSION_KEYS_NOT_FOUND_2;
|
||||
return CdmResponseType(SESSION_KEYS_NOT_FOUND_2);
|
||||
}
|
||||
|
||||
if (!license.id().has_provider_session_token()) {
|
||||
CdmResponseType result = HandleKeyResponse(false, license_response);
|
||||
return result == KEY_ADDED ? NO_ERROR : result;
|
||||
return result == KEY_ADDED ? CdmResponseType(NO_ERROR) : result;
|
||||
}
|
||||
|
||||
if (license.policy().has_renewal_server_url())
|
||||
@@ -919,7 +921,7 @@ CdmResponseType CdmLicense::RestoreLicenseForRelease(
|
||||
// If the policy engine already has keys, they will now expire.
|
||||
// If the policy engine does not already have keys, this will not add any.
|
||||
policy_engine_->SetLicenseForRelease(license);
|
||||
return NO_ERROR;
|
||||
return CdmResponseType(NO_ERROR);
|
||||
}
|
||||
|
||||
bool CdmLicense::IsKeyLoaded(const KeyId& key_id) {
|
||||
@@ -967,19 +969,20 @@ CdmResponseType CdmLicense::HandleKeyErrorResponse(
|
||||
LicenseError license_error;
|
||||
if (!license_error.ParseFromString(signed_message.msg())) {
|
||||
LOGE("Failed to parse license error response");
|
||||
return KEY_ERROR;
|
||||
return CdmResponseType(KEY_ERROR);
|
||||
}
|
||||
|
||||
// TODO(b/261185349) Add new field in CdmResponseType to handle license_error
|
||||
switch (license_error.error_code()) {
|
||||
case LicenseError::INVALID_DRM_DEVICE_CERTIFICATE:
|
||||
return NEED_PROVISIONING;
|
||||
return CdmResponseType(NEED_PROVISIONING);
|
||||
case LicenseError::REVOKED_DRM_DEVICE_CERTIFICATE:
|
||||
return DEVICE_REVOKED;
|
||||
return CdmResponseType(DEVICE_REVOKED);
|
||||
case LicenseError::SERVICE_UNAVAILABLE:
|
||||
default:
|
||||
LOGW("Unknown error type: error_code = %d",
|
||||
static_cast<int>(license_error.error_code()));
|
||||
return KEY_ERROR;
|
||||
return CdmResponseType(KEY_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -989,7 +992,7 @@ CdmResponseType CdmLicense::PrepareClientId(
|
||||
wvcdm::ClientIdentification id;
|
||||
if (client_token_.empty()) {
|
||||
LOGE("Client token not set when preparing client ID");
|
||||
return CLIENT_TOKEN_NOT_SET;
|
||||
return CdmResponseType(CLIENT_TOKEN_NOT_SET);
|
||||
}
|
||||
|
||||
CdmResponseType status =
|
||||
@@ -1004,7 +1007,7 @@ CdmResponseType CdmLicense::PrepareClientId(
|
||||
if (Properties::UsePrivacyMode(session_id_)) {
|
||||
if (!service_certificate_.has_certificate()) {
|
||||
LOGE("Service certificate not staged");
|
||||
return PRIVACY_MODE_ERROR_3;
|
||||
return CdmResponseType(PRIVACY_MODE_ERROR_3);
|
||||
}
|
||||
EncryptedClientIdentification* encrypted_client_id =
|
||||
license_request->mutable_encrypted_client_id();
|
||||
@@ -1017,7 +1020,7 @@ CdmResponseType CdmLicense::PrepareClientId(
|
||||
}
|
||||
return status;
|
||||
}
|
||||
return NO_ERROR;
|
||||
return CdmResponseType(NO_ERROR);
|
||||
}
|
||||
|
||||
CdmResponseType CdmLicense::PrepareContentId(
|
||||
@@ -1035,11 +1038,11 @@ CdmResponseType CdmLicense::PrepareContentId(
|
||||
widevine_pssh_data->add_pssh_data(init_data.data());
|
||||
} else {
|
||||
LOGE("ISO-CENC init data not available");
|
||||
return CENC_INIT_DATA_UNAVAILABLE;
|
||||
return CdmResponseType(CENC_INIT_DATA_UNAVAILABLE);
|
||||
}
|
||||
|
||||
if (!SetTypeAndId(license_type, request_id, widevine_pssh_data)) {
|
||||
return PREPARE_CENC_CONTENT_ID_FAILED;
|
||||
return CdmResponseType(PREPARE_CENC_CONTENT_ID_FAILED);
|
||||
}
|
||||
} else if (init_data.is_webm()) {
|
||||
LicenseRequest_ContentIdentification_WebmKeyId* webm_key_id =
|
||||
@@ -1049,17 +1052,17 @@ CdmResponseType CdmLicense::PrepareContentId(
|
||||
webm_key_id->set_header(init_data.data());
|
||||
} else {
|
||||
LOGE("WebM init data not available");
|
||||
return WEBM_INIT_DATA_UNAVAILABLE;
|
||||
return CdmResponseType(WEBM_INIT_DATA_UNAVAILABLE);
|
||||
}
|
||||
|
||||
if (!SetTypeAndId(license_type, request_id, webm_key_id)) {
|
||||
return PREPARE_WEBM_CONTENT_ID_FAILED;
|
||||
return CdmResponseType(PREPARE_WEBM_CONTENT_ID_FAILED);
|
||||
}
|
||||
} else {
|
||||
LOGE("Unsupported init data type: type = %s", init_data.type().c_str());
|
||||
return UNSUPPORTED_INIT_DATA_FORMAT;
|
||||
return CdmResponseType(UNSUPPORTED_INIT_DATA_FORMAT);
|
||||
}
|
||||
return NO_ERROR;
|
||||
return CdmResponseType(NO_ERROR);
|
||||
}
|
||||
|
||||
CdmResponseType CdmLicense::HandleContentKeyResponse(
|
||||
@@ -1068,7 +1071,7 @@ CdmResponseType CdmLicense::HandleContentKeyResponse(
|
||||
const video_widevine::License& license) {
|
||||
if (key_array.empty()) {
|
||||
LOGE("No content keys provided");
|
||||
return NO_CONTENT_KEY;
|
||||
return CdmResponseType(NO_CONTENT_KEY);
|
||||
}
|
||||
const CdmResponseType resp = crypto_session_->LoadLicense(
|
||||
msg, core_message, signature, kLicenseKeyTypeContent);
|
||||
@@ -1088,7 +1091,7 @@ CdmResponseType CdmLicense::HandleEntitlementKeyResponse(
|
||||
const video_widevine::License& license) {
|
||||
if (key_array.empty()) {
|
||||
LOGE("No entitlement keys provided");
|
||||
return NO_CONTENT_KEY;
|
||||
return CdmResponseType(NO_CONTENT_KEY);
|
||||
}
|
||||
const CdmResponseType resp = crypto_session_->LoadLicense(
|
||||
msg, core_message, signature, kLicenseKeyTypeEntitlement);
|
||||
@@ -1120,7 +1123,7 @@ CdmResponseType CdmLicense::HandleNewEntitledKeys(
|
||||
"Entitled content key too small: "
|
||||
"expected = %zu, actual = %zu (bytes)",
|
||||
CONTENT_KEY_SIZE, content_key.size());
|
||||
return KEY_SIZE_ERROR_2;
|
||||
return CdmResponseType(KEY_SIZE_ERROR_2);
|
||||
} else if (content_key.size() > CONTENT_KEY_SIZE) {
|
||||
content_key.resize(CONTENT_KEY_SIZE);
|
||||
}
|
||||
@@ -1142,7 +1145,7 @@ CdmResponseType CdmLicense::HandleNewEntitledKeys(
|
||||
loaded_keys_.insert(wk.key_id());
|
||||
}
|
||||
policy_engine_->SetEntitledLicenseKeys(wrapped_keys);
|
||||
return KEY_ADDED;
|
||||
return CdmResponseType(KEY_ADDED);
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
||||
Reference in New Issue
Block a user