Log cleanup and reformatting for core/ (Part 2-6)
[ Merge of http://go/wvgerrit/83423 ] [ Merge of http://go/wvgerrit/83424 ] [ Merge of http://go/wvgerrit/83425 ] [ Merge of http://go/wvgerrit/83426 ] [ Merge of http://go/wvgerrit/83427 ] Types of cleanup: - Removed function / class prefixes from the logs. - Fixed log string format options to match the types passed - Corrected small spelling mistakes / typos - _Tried_ to make the log format more consistent - Added static_cast<int> conversion on enumerations when logged - Changed several LOGE to LOGW and vice versa - Used LOGE if the triggering condition stops the method/function from completing its task - Used LOGW if the triggering condition changes the expected outcome but does not stop the rest of the method/function's task - Changed several instances of `NULL` to `nullptr` - Ran clang-format on files after cleanup This is part of a larger code quality effort in Widevine DRM. Test: WV linux unittests and WV Android unit tests Bug: 134460638 Bug: 134365840 Bug: 136123217 Change-Id: I958ec70ef99eef95c38dbebd7a1acd62ef304145
This commit is contained in:
@@ -68,7 +68,7 @@ void ExtractAndDecodeSignedMessage(const std::string& provisioning_response,
|
||||
|
||||
if (start == provisioning_response.npos) {
|
||||
// Message is not properly wrapped - reject it.
|
||||
LOGE("ExtractAndDecodeSignedMessage: cannot locate start substring");
|
||||
LOGE("Cannot locate start substring");
|
||||
result->clear();
|
||||
return;
|
||||
} else {
|
||||
@@ -76,7 +76,7 @@ void ExtractAndDecodeSignedMessage(const std::string& provisioning_response,
|
||||
size_t end = provisioning_response.find(json_end_substr,
|
||||
start + json_start_substr.length());
|
||||
if (end == provisioning_response.npos) {
|
||||
LOGE("ExtractAndDecodeSignedMessage: cannot locate end substring");
|
||||
LOGE("Cannot locate end substring");
|
||||
result->clear();
|
||||
return;
|
||||
}
|
||||
@@ -86,7 +86,7 @@ void ExtractAndDecodeSignedMessage(const std::string& provisioning_response,
|
||||
}
|
||||
|
||||
if (message_string.empty()) {
|
||||
LOGE("ExtractAndDecodeSignedMessage: CdmProvisioningResponse is empty");
|
||||
LOGE("CDM provisioning response is empty");
|
||||
result->clear();
|
||||
return;
|
||||
}
|
||||
@@ -127,9 +127,7 @@ CdmResponseType CertificateProvisioning::SetSpoidParameter(
|
||||
const std::string& origin, const std::string& spoid,
|
||||
ProvisioningRequest* request) {
|
||||
if (!request) {
|
||||
LOGE(
|
||||
"CertificateProvisioning::SetSpoidParameter: No request buffer "
|
||||
"passed to method.");
|
||||
LOGE("Output parameter |request| is not provided");
|
||||
return PARAMETER_NULL;
|
||||
}
|
||||
if (!spoid.empty()) {
|
||||
@@ -140,8 +138,8 @@ CdmResponseType CertificateProvisioning::SetSpoidParameter(
|
||||
request->set_provider_id(service_certificate_->provider_id());
|
||||
} else {
|
||||
LOGE(
|
||||
"CertificateProvisioning::SetSpoidParameter: Failure getting "
|
||||
"provider ID");
|
||||
"Failed to set provider ID: "
|
||||
"Service certificate provider ID is empty");
|
||||
return SERVICE_CERTIFICATE_PROVIDER_ID_EMPTY;
|
||||
}
|
||||
} else if (origin != EMPTY_ORIGIN) {
|
||||
@@ -151,9 +149,8 @@ CdmResponseType CertificateProvisioning::SetSpoidParameter(
|
||||
crypto_session_->GetInternalDeviceUniqueId(&device_unique_id);
|
||||
|
||||
if (status != NO_ERROR) {
|
||||
LOGE(
|
||||
"CertificateProvisioning::SetSpoidParameter: Failure getting "
|
||||
"device unique ID");
|
||||
LOGE("Failed to get device unique ID: status = %d",
|
||||
static_cast<int>(status));
|
||||
return status;
|
||||
}
|
||||
request->set_stable_id(device_unique_id + origin);
|
||||
@@ -186,7 +183,7 @@ CdmResponseType CertificateProvisioning::GetProvisioningRequest(
|
||||
const std::string& spoid, CdmProvisioningRequest* request,
|
||||
std::string* default_url) {
|
||||
if (!default_url) {
|
||||
LOGE("GetProvisioningRequest: pointer for returning URL is NULL");
|
||||
LOGE("Output parameter |default_url| is not provided");
|
||||
return CERT_PROVISIONING_REQUEST_ERROR_1;
|
||||
}
|
||||
|
||||
@@ -194,7 +191,8 @@ CdmResponseType CertificateProvisioning::GetProvisioningRequest(
|
||||
|
||||
CdmResponseType status = crypto_session_->Open(requested_security_level);
|
||||
if (NO_ERROR != status) {
|
||||
LOGE("GetProvisioningRequest: fails to create a crypto session");
|
||||
LOGE("Failed to create a crypto session: status = %d",
|
||||
static_cast<int>(status));
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -213,9 +211,7 @@ CdmResponseType CertificateProvisioning::GetProvisioningRequest(
|
||||
if (status != NO_ERROR) return status;
|
||||
|
||||
if (!service_certificate_->has_certificate()) {
|
||||
LOGE(
|
||||
"CertificateProvisioning::GetProvisioningRequest: Service "
|
||||
"Certificate not staged");
|
||||
LOGE("Service certificate not staged");
|
||||
return CERT_PROVISIONING_EMPTY_SERVICE_CERTIFICATE;
|
||||
}
|
||||
|
||||
@@ -230,7 +226,7 @@ CdmResponseType CertificateProvisioning::GetProvisioningRequest(
|
||||
status = crypto_session_->GenerateNonce(&nonce);
|
||||
|
||||
if (status != NO_ERROR) {
|
||||
LOGE("GetProvisioningRequest: fails to generate a nonce: %d", status);
|
||||
LOGE("Failed to generate a nonce: status = %d", static_cast<int>(status));
|
||||
return status == NONCE_GENERATION_ERROR
|
||||
? CERT_PROVISIONING_NONCE_GENERATION_ERROR
|
||||
: status;
|
||||
@@ -252,7 +248,7 @@ CdmResponseType CertificateProvisioning::GetProvisioningRequest(
|
||||
video_widevine::ProvisioningOptions_CertificateType_X509);
|
||||
break;
|
||||
default:
|
||||
LOGE("GetProvisioningRequest: unknown certificate type %ld", cert_type);
|
||||
LOGE("Unknown certificate type: %d", static_cast<int>(cert_type));
|
||||
return CERT_PROVISIONING_INVALID_CERT_TYPE;
|
||||
}
|
||||
|
||||
@@ -271,12 +267,13 @@ CdmResponseType CertificateProvisioning::GetProvisioningRequest(
|
||||
&request_signature);
|
||||
|
||||
if (status != NO_ERROR) {
|
||||
LOGE("GetProvisioningRequest: fails to prepare request");
|
||||
LOGE("Failed to prepare provisioning request: status = %d",
|
||||
static_cast<int>(status));
|
||||
return status;
|
||||
}
|
||||
|
||||
if (request_signature.empty()) {
|
||||
LOGE("GetProvisioningRequest: request signature is empty");
|
||||
LOGE("Request signature is empty");
|
||||
return CERT_PROVISIONING_REQUEST_ERROR_4;
|
||||
}
|
||||
|
||||
@@ -310,7 +307,7 @@ CdmResponseType CertificateProvisioning::HandleProvisioningResponse(
|
||||
FileSystem* file_system, const CdmProvisioningResponse& response_message,
|
||||
std::string* cert, std::string* wrapped_key) {
|
||||
if (response_message.empty()) {
|
||||
LOGE("HandleProvisioningResponse: response message is empty.");
|
||||
LOGE("Provisioning response message is empty");
|
||||
return CERT_PROVISIONING_RESPONSE_ERROR_1;
|
||||
}
|
||||
|
||||
@@ -322,9 +319,7 @@ CdmResponseType CertificateProvisioning::HandleProvisioningResponse(
|
||||
// Extract it and decode it. On error return an empty string.
|
||||
ExtractAndDecodeSignedMessage(response_message, &response);
|
||||
if (response.empty()) {
|
||||
LOGE(
|
||||
"HandleProvisioningResponse: response message is "
|
||||
"an invalid JSON/base64 string.");
|
||||
LOGE("Provisioning response message is an invalid JSON/base64 string");
|
||||
return CERT_PROVISIONING_RESPONSE_ERROR_1;
|
||||
}
|
||||
}
|
||||
@@ -334,18 +329,18 @@ CdmResponseType CertificateProvisioning::HandleProvisioningResponse(
|
||||
// stores private device RSA key and certificate.
|
||||
SignedProvisioningMessage signed_response;
|
||||
if (!signed_response.ParseFromString(response)) {
|
||||
LOGE("HandleProvisioningResponse: fails to parse signed response");
|
||||
LOGE("Failed to parse signed provisioining response");
|
||||
return CERT_PROVISIONING_RESPONSE_ERROR_2;
|
||||
}
|
||||
|
||||
bool error = false;
|
||||
if (!signed_response.has_signature()) {
|
||||
LOGE("HandleProvisioningResponse: signature not found");
|
||||
LOGE("Signed response does not have signature");
|
||||
error = true;
|
||||
}
|
||||
|
||||
if (!signed_response.has_message()) {
|
||||
LOGE("HandleProvisioningResponse: message not found");
|
||||
LOGE("Signed response does not have message");
|
||||
error = true;
|
||||
}
|
||||
|
||||
@@ -356,12 +351,12 @@ CdmResponseType CertificateProvisioning::HandleProvisioningResponse(
|
||||
ProvisioningResponse provisioning_response;
|
||||
|
||||
if (!provisioning_response.ParseFromString(signed_message)) {
|
||||
LOGE("HandleProvisioningResponse: Fails to parse signed message");
|
||||
LOGE("Failed to parse provisioning response");
|
||||
return CERT_PROVISIONING_RESPONSE_ERROR_4;
|
||||
}
|
||||
|
||||
if (!provisioning_response.has_device_rsa_key()) {
|
||||
LOGE("HandleProvisioningResponse: key not found");
|
||||
LOGE("Provisioning response does not have RSA key");
|
||||
return CERT_PROVISIONING_RESPONSE_ERROR_5;
|
||||
}
|
||||
|
||||
@@ -371,7 +366,7 @@ CdmResponseType CertificateProvisioning::HandleProvisioningResponse(
|
||||
if (service_certificate_->VerifySignedMessage(signed_message, signature) !=
|
||||
NO_ERROR) {
|
||||
// TODO(b/69562876): if the cert is bad, request a new one.
|
||||
LOGE("HandleProvisioningResponse: message not properly signed");
|
||||
LOGE("Provisioning response message not properly signed");
|
||||
return CERT_PROVISIONING_RESPONSE_ERROR_6;
|
||||
}
|
||||
}
|
||||
@@ -391,7 +386,7 @@ CdmResponseType CertificateProvisioning::HandleProvisioningResponse(
|
||||
&wrapped_private_key);
|
||||
|
||||
if (status != NO_ERROR) {
|
||||
LOGE("HandleProvisioningResponse: RewrapCertificate fails");
|
||||
LOGE("RewrapCertificate failed: status = %d", static_cast<int>(status));
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -412,11 +407,11 @@ CdmResponseType CertificateProvisioning::HandleProvisioningResponse(
|
||||
|
||||
DeviceFiles handle(file_system);
|
||||
if (!handle.Init(security_level)) {
|
||||
LOGE("HandleProvisioningResponse: failed to init DeviceFiles");
|
||||
LOGE("Failed to initialize DeviceFiles");
|
||||
return CERT_PROVISIONING_RESPONSE_ERROR_7;
|
||||
}
|
||||
if (!handle.StoreCertificate(device_certificate, wrapped_private_key)) {
|
||||
LOGE("HandleProvisioningResponse: failed to save provisioning certificate");
|
||||
LOGE("Failed to store provisioning certificate");
|
||||
return CERT_PROVISIONING_RESPONSE_ERROR_8;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user