Add HDCP cap logging on HDCP-based failures.
[ Merge of http://go/wvgerrit/178872 ] [ Cherry-pick of http://ag/24047535 ] Partners have requested that we log HDCP information during certain operation: 1) Current and max HDCP capability when calls to decrypt or select key failure due to insufficient or mixed HDCP levels. 2) Current, desired and default HDCP level when video contraints are not met. To avoid spamming the logs, decrypt failures are only logged on their first occurrence, and unmet video constrains when one of the requirements change. Bug: 276686656 Test: license_keys_unittest Test: Android WVTS on oriole Change-Id: I98b18e66d7ce1c474a018ae83af4f1c0b03308df
This commit is contained in:
@@ -93,6 +93,8 @@ constexpr size_t kAes128BlockSize = 16;
|
||||
|
||||
constexpr int kMaxTerminateCountDown = 5;
|
||||
|
||||
constexpr char kUnavailableHdcpLevel[] = "<unavailable>";
|
||||
|
||||
const std::string kStringNotAvailable = "NA";
|
||||
|
||||
// TODO(b/174412779): Remove when b/170704368 is fixed.
|
||||
@@ -292,6 +294,37 @@ OEMCryptoCipherMode ToOEMCryptoCipherMode(CdmCipherMode cipher_mode) {
|
||||
: OEMCrypto_CipherMode_CBCS;
|
||||
}
|
||||
|
||||
// static
|
||||
const char* CryptoSession::HdcpCapabilityToString(HdcpCapability hdcp_level) {
|
||||
switch (hdcp_level) {
|
||||
case HDCP_NONE:
|
||||
return "None";
|
||||
case HDCP_V1: // Means v1.x
|
||||
return "v1.x";
|
||||
case HDCP_V2: // Means v2.0
|
||||
return "v2.0";
|
||||
case HDCP_V2_1:
|
||||
return "v2.1";
|
||||
case HDCP_V2_2:
|
||||
return "v2.2";
|
||||
case HDCP_V2_3:
|
||||
return "v2.3";
|
||||
case HDCP_V1_0:
|
||||
return "v1.0";
|
||||
case HDCP_V1_1:
|
||||
return "v1.1";
|
||||
case HDCP_V1_2:
|
||||
return "v1.2";
|
||||
case HDCP_V1_3:
|
||||
return "v1.3";
|
||||
case HDCP_V1_4:
|
||||
return "v1.4";
|
||||
case HDCP_NO_DIGITAL_OUTPUT:
|
||||
return "No-Digital-Output";
|
||||
}
|
||||
return UnknownEnumValueToString(static_cast<int>(hdcp_level));
|
||||
}
|
||||
|
||||
CryptoSession::CryptoSession(metrics::CryptoMetrics* metrics)
|
||||
: metrics_(metrics),
|
||||
system_id_(NULL_SYSTEM_ID),
|
||||
@@ -1513,6 +1546,35 @@ CdmResponseType CryptoSession::SelectKey(const std::string& key_id,
|
||||
return key_session_->SelectKey(key_id, cipher_mode);
|
||||
});
|
||||
|
||||
if (sts != last_select_key_error_) {
|
||||
// Only log errors on first occurrence. Calls to SelectKey from
|
||||
// the app are typically queued. If an error occurs, then it is
|
||||
// expected that multiple failures will occur before the app is
|
||||
// notified and stops queueing calls to the CDM.
|
||||
last_select_key_error_ = sts;
|
||||
if (sts == OEMCrypto_ERROR_INSUFFICIENT_HDCP ||
|
||||
sts == OEMCrypto_WARNING_MIXED_OUTPUT_PROTECTION) {
|
||||
const char* status_message = OemCryptoResultToString(sts);
|
||||
HdcpCapability current_hdcp_level;
|
||||
HdcpCapability max_hdcp_level;
|
||||
const CdmResponseType hdcp_status =
|
||||
GetHdcpCapabilities(¤t_hdcp_level, &max_hdcp_level);
|
||||
const char* current_hdcp_message = kUnavailableHdcpLevel;
|
||||
const char* max_hdcp_message = kUnavailableHdcpLevel;
|
||||
if (hdcp_status == NO_ERROR) {
|
||||
current_hdcp_message = HdcpCapabilityToString(current_hdcp_level);
|
||||
max_hdcp_message = HdcpCapabilityToString(max_hdcp_level);
|
||||
}
|
||||
LOGE(
|
||||
"oec_session_id = %u, security_level = %s, "
|
||||
"status = %s, current_hdcp_level = %s, "
|
||||
"max_hdcp_level = %s",
|
||||
oec_session_id_,
|
||||
RequestedSecurityLevelToString(requested_security_level_),
|
||||
status_message, current_hdcp_message, max_hdcp_message);
|
||||
}
|
||||
}
|
||||
|
||||
switch (sts) {
|
||||
// SelectKey errors.
|
||||
case OEMCrypto_SUCCESS:
|
||||
@@ -1791,11 +1853,26 @@ CdmResponseType CryptoSession::Decrypt(
|
||||
// the next call. The calling application may make several more
|
||||
// decrypt requests before the error is handled by the app.
|
||||
last_decrypt_error_ = sts;
|
||||
if (sts == OEMCrypto_WARNING_MIXED_OUTPUT_PROTECTION) {
|
||||
LOGW(
|
||||
"OEMCrypto_DecryptCENC is warning of mixed HDCP output protection: "
|
||||
"oec_session_id = %u",
|
||||
oec_session_id_);
|
||||
if (sts == OEMCrypto_WARNING_MIXED_OUTPUT_PROTECTION ||
|
||||
sts == OEMCrypto_ERROR_INSUFFICIENT_HDCP) {
|
||||
const char* status_message = OemCryptoResultToString(sts);
|
||||
HdcpCapability current_hdcp_level;
|
||||
HdcpCapability max_hdcp_level;
|
||||
const CdmResponseType hdcp_status =
|
||||
GetHdcpCapabilities(¤t_hdcp_level, &max_hdcp_level);
|
||||
const char* current_hdcp_message = kUnavailableHdcpLevel;
|
||||
const char* max_hdcp_message = kUnavailableHdcpLevel;
|
||||
if (hdcp_status == NO_ERROR) {
|
||||
current_hdcp_message = HdcpCapabilityToString(current_hdcp_level);
|
||||
max_hdcp_message = HdcpCapabilityToString(max_hdcp_level);
|
||||
}
|
||||
LOGE(
|
||||
"OEMCrypto_DecryptCENC failed: oec_session_id = %u, "
|
||||
"security_level = %s, status = %s, current_hdcp_level = %s, "
|
||||
"max_hdcp_level = %s",
|
||||
oec_session_id_,
|
||||
RequestedSecurityLevelToString(requested_security_level_),
|
||||
status_message, current_hdcp_message, max_hdcp_message);
|
||||
} else {
|
||||
LOGE(
|
||||
"OEMCrypto_DecryptCENC failed: oec_session_id = %u, "
|
||||
|
||||
Reference in New Issue
Block a user