Add recoverable errors
[ Merge of http://go/wvgerrit/71326 ] Nonce flood, frame size, session and system invalidation errors will now bubble up to the app. OEMCrypto v15 returns OEMCrypto_ERROR_BUFFER_TOO_LARGE, OEMCrypto_ERROR_SESSION_LOST_STATE, OEMCrypto_ERROR_SYSTEM_INVALIDATED and a variety of nonce errors. These will be reported to HIDL as OUTPUT_TOO_LARGE_ERROR, ERROR_DRM_SESSION_LOST_STATE, ERROR_DRM_INVALID_STATE and ERROR_DRM_RESOURCE_CONTENTION. Bug: 120572706 Test: Unit/Integration tests Change-Id: Ida177300046327ce81592a273028ef6c3a0d9fd9
This commit is contained in:
@@ -565,10 +565,12 @@ CdmResponseType CdmEngine::QueryStatus(SecurityLevel security_level,
|
||||
query_token == QUERY_KEY_MAX_HDCP_LEVEL) {
|
||||
CryptoSession::HdcpCapability current_hdcp;
|
||||
CryptoSession::HdcpCapability max_hdcp;
|
||||
if (!crypto_session->GetHdcpCapabilities(security_level, ¤t_hdcp,
|
||||
&max_hdcp)) {
|
||||
LOGW("CdmEngine::QueryStatus: GetHdcpCapabilities failed");
|
||||
return UNKNOWN_ERROR;
|
||||
status = crypto_session->GetHdcpCapabilities(security_level, ¤t_hdcp,
|
||||
&max_hdcp);
|
||||
|
||||
if (status != NO_ERROR) {
|
||||
LOGW("CdmEngine::QueryStatus: GetHdcpCapabilities failed: %d", status);
|
||||
return status;
|
||||
}
|
||||
*query_response =
|
||||
MapHdcpVersion(query_token == QUERY_KEY_CURRENT_HDCP_LEVEL ?
|
||||
@@ -594,20 +596,26 @@ CdmResponseType CdmEngine::QueryStatus(SecurityLevel security_level,
|
||||
return NO_ERROR;
|
||||
} else if (query_token == QUERY_KEY_NUMBER_OF_OPEN_SESSIONS) {
|
||||
size_t number_of_open_sessions;
|
||||
if (!crypto_session->GetNumberOfOpenSessions(security_level,
|
||||
&number_of_open_sessions)) {
|
||||
LOGW("CdmEngine::QueryStatus: GetNumberOfOpenSessions failed");
|
||||
return UNKNOWN_ERROR;
|
||||
status = crypto_session->GetNumberOfOpenSessions(security_level,
|
||||
&number_of_open_sessions);
|
||||
if (status != NO_ERROR) {
|
||||
LOGW("CdmEngine::QueryStatus: GetNumberOfOpenSessions failed: %d",
|
||||
status);
|
||||
return status;
|
||||
}
|
||||
|
||||
*query_response = std::to_string(number_of_open_sessions);
|
||||
return NO_ERROR;
|
||||
} else if (query_token == QUERY_KEY_MAX_NUMBER_OF_SESSIONS) {
|
||||
size_t maximum_number_of_sessions = 0;
|
||||
if (!crypto_session->GetMaxNumberOfSessions(security_level,
|
||||
&maximum_number_of_sessions)) {
|
||||
LOGW("CdmEngine::QueryStatus: GetMaxNumberOfOpenSessions failed");
|
||||
return UNKNOWN_ERROR;
|
||||
status =
|
||||
crypto_session->GetMaxNumberOfSessions(security_level,
|
||||
&maximum_number_of_sessions);
|
||||
|
||||
if (status != NO_ERROR) {
|
||||
LOGW("CdmEngine::QueryStatus: GetMaxNumberOfOpenSessions failed: %d",
|
||||
status);
|
||||
return status;
|
||||
}
|
||||
|
||||
*query_response = std::to_string(maximum_number_of_sessions);
|
||||
@@ -623,9 +631,10 @@ CdmResponseType CdmEngine::QueryStatus(SecurityLevel security_level,
|
||||
return NO_ERROR;
|
||||
} else if (query_token == QUERY_KEY_CURRENT_SRM_VERSION) {
|
||||
uint16_t current_srm_version;
|
||||
if (!crypto_session->GetSrmVersion(¤t_srm_version)) {
|
||||
LOGW("CdmEngine::QueryStatus: GetCurrentSRMVersion failed");
|
||||
return UNKNOWN_ERROR;
|
||||
status = crypto_session->GetSrmVersion(¤t_srm_version);
|
||||
if (status != NO_ERROR) {
|
||||
LOGW("CdmEngine::QueryStatus: GetCurrentSRMVersion failed: %d", status);
|
||||
return status;
|
||||
}
|
||||
|
||||
*query_response = std::to_string(current_srm_version);
|
||||
@@ -672,19 +681,16 @@ CdmResponseType CdmEngine::QueryStatus(SecurityLevel security_level,
|
||||
crypto_session_open_,
|
||||
status,
|
||||
security_level);
|
||||
if (status != NO_ERROR)
|
||||
return status;
|
||||
|
||||
if (status != NO_ERROR) return status;
|
||||
|
||||
// Add queries here, that need an open session before they can be answered
|
||||
if (query_token == QUERY_KEY_DEVICE_ID) {
|
||||
std::string deviceId;
|
||||
bool got_id = crypto_session->GetExternalDeviceUniqueId(&deviceId);
|
||||
status = crypto_session->GetExternalDeviceUniqueId(&deviceId);
|
||||
metrics_.GetCryptoMetrics()->crypto_session_get_device_unique_id_
|
||||
.Increment(got_id);
|
||||
if (!got_id) {
|
||||
LOGW("CdmEngine::QueryStatus: QUERY_KEY_DEVICE_ID unknown failure");
|
||||
return UNKNOWN_ERROR;
|
||||
}
|
||||
.Increment(status);
|
||||
if (status != NO_ERROR) return status;
|
||||
|
||||
*query_response = deviceId;
|
||||
} else if (query_token == QUERY_KEY_SYSTEM_ID) {
|
||||
@@ -698,9 +704,10 @@ CdmResponseType CdmEngine::QueryStatus(SecurityLevel security_level,
|
||||
*query_response = std::to_string(system_id);
|
||||
} else if (query_token == QUERY_KEY_PROVISIONING_ID) {
|
||||
std::string provisioning_id;
|
||||
if (!crypto_session->GetProvisioningId(&provisioning_id)) {
|
||||
LOGW("CdmEngine::QueryStatus: GetProvisioningId failed");
|
||||
return UNKNOWN_ERROR;
|
||||
status = crypto_session->GetProvisioningId(&provisioning_id);
|
||||
if (status != NO_ERROR) {
|
||||
LOGW("CdmEngine::QueryStatus: GetProvisioningId failed: %d", status);
|
||||
return status;
|
||||
}
|
||||
|
||||
*query_response = provisioning_id;
|
||||
|
||||
Reference in New Issue
Block a user