Add more CdmResponseType to help with debugging in the field.
The errors in the range ERROR_DRM_VENDOR_MIN to ERROR_DRM_VENDOR_MAX are reflected in the message that is reported to the app, which is MediaDrmStateException.getDiagnosticInfo(). Many errors map to kErrorCDMGeneric, especially KEY_ERROR is used as a generic error in CDM. This fix defines more specific error codes in the CDM for places where KEY_ERROR is returned. Merge from http://go/wvgerrit/14071 bug: 19244061 Change-Id: I688bf32828f997000fea041dd29567dde18ac677
This commit is contained in:
@@ -466,15 +466,15 @@ CdmResponseType CdmLicense::PrepareKeyUpdateRequest(
|
||||
bool is_renewal, CdmKeyMessage* signed_request, std::string* server_url) {
|
||||
if (!initialized_) {
|
||||
LOGE("CdmLicense::PrepareKeyUpdateRequest: not initialized");
|
||||
return UNKNOWN_ERROR;
|
||||
return LICENSE_PARSER_NOT_INITIALIZED_1;
|
||||
}
|
||||
if (!signed_request) {
|
||||
LOGE("CdmLicense::PrepareKeyUpdateRequest: No signed request provided");
|
||||
return UNKNOWN_ERROR;
|
||||
return INVALID_PARAMETERS_LIC_1;
|
||||
}
|
||||
if (!server_url) {
|
||||
LOGE("CdmLicense::PrepareKeyUpdateRequest: No server url provided");
|
||||
return UNKNOWN_ERROR;
|
||||
return INVALID_PARAMETERS_LIC_2;
|
||||
}
|
||||
|
||||
LicenseRequest license_request;
|
||||
@@ -508,7 +508,7 @@ CdmResponseType CdmLicense::PrepareKeyUpdateRequest(
|
||||
if (NO_ERROR == status)
|
||||
current_license->set_session_usage_table_entry(usage_report);
|
||||
else
|
||||
return KEY_ERROR;
|
||||
return GENERATE_USAGE_REPORT_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -527,7 +527,7 @@ CdmResponseType CdmLicense::PrepareKeyUpdateRequest(
|
||||
// of the license response.
|
||||
uint32_t nonce;
|
||||
if (!session_->GenerateNonce(&nonce)) {
|
||||
return KEY_ERROR;
|
||||
return GENERATE_NONCE_ERROR;
|
||||
}
|
||||
license_request.set_key_control_nonce(nonce);
|
||||
LOGD("PrepareKeyUpdateRequest: nonce=%u", nonce);
|
||||
@@ -541,13 +541,13 @@ CdmResponseType CdmLicense::PrepareKeyUpdateRequest(
|
||||
std::string license_request_signature;
|
||||
if (!session_->PrepareRenewalRequest(serialized_license_req,
|
||||
&license_request_signature))
|
||||
return KEY_ERROR;
|
||||
return RENEWAL_REQUEST_ERROR;
|
||||
|
||||
if (license_request_signature.empty()) {
|
||||
LOGE(
|
||||
"CdmLicense::PrepareKeyUpdateRequest: empty license request"
|
||||
" signature");
|
||||
return KEY_ERROR;
|
||||
return EMPTY_LICENSE_REQUEST;
|
||||
}
|
||||
|
||||
// Put serialize license request and signature together
|
||||
@@ -565,11 +565,11 @@ CdmResponseType CdmLicense::HandleKeyResponse(
|
||||
const CdmKeyResponse& license_response) {
|
||||
if (!initialized_) {
|
||||
LOGE("CdmLicense::HandleKeyResponse: not initialized");
|
||||
return KEY_ERROR;
|
||||
return LICENSE_PARSER_NOT_INITIALIZED_2;
|
||||
}
|
||||
if (license_response.empty()) {
|
||||
LOGE("CdmLicense::HandleKeyResponse: empty license response");
|
||||
return KEY_ERROR;
|
||||
return EMPTY_LICENSE_RESPONSE_1;
|
||||
}
|
||||
|
||||
SignedMessage signed_response;
|
||||
@@ -577,7 +577,7 @@ CdmResponseType CdmLicense::HandleKeyResponse(
|
||||
LOGE(
|
||||
"CdmLicense::HandleKeyResponse: unable to parse signed license"
|
||||
" response");
|
||||
return KEY_ERROR;
|
||||
return INVALID_LICENSE_RESPONSE;
|
||||
}
|
||||
|
||||
switch (signed_response.type()) {
|
||||
@@ -591,29 +591,29 @@ CdmResponseType CdmLicense::HandleKeyResponse(
|
||||
LOGE(
|
||||
"CdmLicense::HandleKeyResponse: unrecognized signed message type: %d",
|
||||
signed_response.type());
|
||||
return KEY_ERROR;
|
||||
return INVALID_LICENSE_TYPE;
|
||||
}
|
||||
|
||||
if (!signed_response.has_signature()) {
|
||||
LOGE("CdmLicense::HandleKeyResponse: license response is not signed");
|
||||
return KEY_ERROR;
|
||||
return LICENSE_RESPONSE_NOT_SIGNED;
|
||||
}
|
||||
|
||||
License license;
|
||||
if (!license.ParseFromString(signed_response.msg())) {
|
||||
LOGE("CdmLicense::HandleKeyResponse: unable to parse license response");
|
||||
return KEY_ERROR;
|
||||
return LICENSE_RESPONSE_PARSE_ERROR_1;
|
||||
}
|
||||
|
||||
if (Properties::use_certificates_as_identification()) {
|
||||
if (!signed_response.has_session_key()) {
|
||||
LOGE("CdmLicense::HandleKeyResponse: no session keys present");
|
||||
return KEY_ERROR;
|
||||
return SESSION_KEYS_NOT_FOUND;
|
||||
}
|
||||
|
||||
if (!session_->GenerateDerivedKeys(key_request_,
|
||||
signed_response.session_key()))
|
||||
return KEY_ERROR;
|
||||
return GENERATE_DERIVED_KEYS_ERROR;
|
||||
}
|
||||
|
||||
// Extract mac key
|
||||
@@ -634,14 +634,14 @@ CdmResponseType CdmLicense::HandleKeyResponse(
|
||||
"CdmLicense::HandleKeyResponse: mac key/iv size error"
|
||||
"(key/iv size expected: %d/%d, actual: %d/%d",
|
||||
MAC_KEY_SIZE, KEY_IV_SIZE, mac_key.size(), mac_key_iv.size());
|
||||
return KEY_ERROR;
|
||||
return KEY_SIZE_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
std::vector<CryptoKey> key_array = ExtractContentKeys(license);
|
||||
if (!key_array.size()) {
|
||||
LOGE("CdmLicense::HandleKeyResponse : No content keys.");
|
||||
return KEY_ERROR;
|
||||
return NO_CONTENT_KEY;
|
||||
}
|
||||
|
||||
if (license.id().has_provider_session_token())
|
||||
@@ -671,17 +671,17 @@ CdmResponseType CdmLicense::HandleKeyUpdateResponse(
|
||||
bool is_renewal, const CdmKeyResponse& license_response) {
|
||||
if (!initialized_) {
|
||||
LOGE("CdmLicense::HandleKeyUpdateResponse: not initialized");
|
||||
return KEY_ERROR;
|
||||
return LICENSE_PARSER_NOT_INITIALIZED_3;
|
||||
}
|
||||
if (license_response.empty()) {
|
||||
LOGE("CdmLicense::HandleKeyUpdateResponse : Empty license response.");
|
||||
return KEY_ERROR;
|
||||
return EMPTY_LICENSE_RESPONSE_2;
|
||||
}
|
||||
|
||||
SignedMessage signed_response;
|
||||
if (!signed_response.ParseFromString(license_response)) {
|
||||
LOGE("CdmLicense::HandleKeyUpdateResponse: Unable to parse signed message");
|
||||
return KEY_ERROR;
|
||||
return LICENSE_RESPONSE_PARSE_ERROR_2;
|
||||
}
|
||||
|
||||
if (signed_response.type() == SignedMessage::ERROR_RESPONSE) {
|
||||
@@ -690,7 +690,7 @@ CdmResponseType CdmLicense::HandleKeyUpdateResponse(
|
||||
|
||||
if (!signed_response.has_signature()) {
|
||||
LOGE("CdmLicense::HandleKeyUpdateResponse: signature missing");
|
||||
return KEY_ERROR;
|
||||
return SIGNATURE_NOT_FOUND;
|
||||
}
|
||||
|
||||
License license;
|
||||
@@ -698,12 +698,12 @@ CdmResponseType CdmLicense::HandleKeyUpdateResponse(
|
||||
LOGE(
|
||||
"CdmLicense::HandleKeyUpdateResponse: Unable to parse license"
|
||||
" from signed message");
|
||||
return KEY_ERROR;
|
||||
return LICENSE_RESPONSE_PARSE_ERROR_3;
|
||||
}
|
||||
|
||||
if (!license.has_id()) {
|
||||
LOGE("CdmLicense::HandleKeyUpdateResponse: license id not present");
|
||||
return KEY_ERROR;
|
||||
return LICENSE_ID_NOT_FOUND;
|
||||
}
|
||||
|
||||
policy_engine_->UpdateLicense(license);
|
||||
@@ -729,7 +729,7 @@ CdmResponseType CdmLicense::HandleKeyUpdateResponse(
|
||||
key_array.size(), &key_array[0])) {
|
||||
return KEY_ADDED;
|
||||
} else {
|
||||
return KEY_ERROR;
|
||||
return REFRESH_KEYS_ERROR;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -928,7 +928,7 @@ CdmResponseType CdmLicense::HandleServiceCertificateResponse(
|
||||
LOGE(
|
||||
"CdmLicense::HandleServiceCertificateResponse: unable to parse"
|
||||
"signed device certificate");
|
||||
return KEY_ERROR;
|
||||
return DEVICE_CERTIFICATE_ERROR_1;
|
||||
}
|
||||
|
||||
RsaPublicKey root_ca_key;
|
||||
@@ -939,7 +939,7 @@ CdmResponseType CdmLicense::HandleServiceCertificateResponse(
|
||||
LOGE(
|
||||
"CdmLicense::HandleServiceCertificateResponse: public key "
|
||||
"initialization failed");
|
||||
return KEY_ERROR;
|
||||
return DEVICE_CERTIFICATE_ERROR_2;
|
||||
}
|
||||
|
||||
if (!root_ca_key.VerifySignature(
|
||||
@@ -948,7 +948,7 @@ CdmResponseType CdmLicense::HandleServiceCertificateResponse(
|
||||
LOGE(
|
||||
"CdmLicense::HandleServiceCertificateResponse: service "
|
||||
"certificate verification failed");
|
||||
return KEY_ERROR;
|
||||
return DEVICE_CERTIFICATE_ERROR_3;
|
||||
}
|
||||
|
||||
DeviceCertificate service_certificate;
|
||||
@@ -957,7 +957,7 @@ CdmResponseType CdmLicense::HandleServiceCertificateResponse(
|
||||
LOGE(
|
||||
"CdmLicense::HandleServiceCertificateResponse: unable to parse "
|
||||
"retrieved service certificate");
|
||||
return KEY_ERROR;
|
||||
return DEVICE_CERTIFICATE_ERROR_4;
|
||||
}
|
||||
|
||||
if (service_certificate.type() !=
|
||||
@@ -966,7 +966,7 @@ CdmResponseType CdmLicense::HandleServiceCertificateResponse(
|
||||
"CdmLicense::HandleServiceCertificateResponse: certificate not of type"
|
||||
" service, %d",
|
||||
service_certificate.type());
|
||||
return KEY_ERROR;
|
||||
return INVALID_DEVICE_CERTIFICATE_TYPE;
|
||||
}
|
||||
|
||||
service_certificate_ = signed_service_certificate.device_certificate();
|
||||
|
||||
Reference in New Issue
Block a user