Added CDM support for production readiness reporting. am: cd5afa88a6 am: cce550d006

Original change: https://googleplex-android-review.googlesource.com/c/platform/vendor/widevine/+/18195696

Change-Id: Ib68038545cfc302f34eabe52264188b3e7ff356b
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
Alex Dale
2022-05-10 22:04:13 +00:00
committed by Automerger Merge Worker
13 changed files with 112 additions and 10 deletions

View File

@@ -221,6 +221,11 @@ class CryptoSession {
RequestedSecurityLevel requested_security_level,
CdmWatermarkingSupport* support);
virtual bool GetProductionReadiness(CdmProductionReadiness* readiness);
virtual bool GetProductionReadiness(
RequestedSecurityLevel requested_security_level,
CdmProductionReadiness* readiness);
virtual bool GetMaximumUsageTableEntries(
RequestedSecurityLevel security_level, size_t* number_of_entries);

View File

@@ -72,6 +72,7 @@ OEMCryptoResult OEMCrypto_GetOEMPublicCertificate(uint8_t* public_cert,
RequestedSecurityLevel level);
OEMCrypto_WatermarkingSupport OEMCrypto_GetWatermarkingSupport(
RequestedSecurityLevel level);
OEMCryptoResult OEMCrypto_ProductionReady(RequestedSecurityLevel level);
} // namespace wvcdm
/* The following functions are deprecated in OEMCrypto v13. They are defined

View File

@@ -112,6 +112,7 @@ static const std::string QUERY_KEY_ANALOG_OUTPUT_CAPABILITIES =
static const std::string QUERY_KEY_CAN_DISABLE_ANALOG_OUTPUT =
"CanDisableAnalogOutput";
static const std::string QUERY_KEY_WATERMARKING_SUPPORT = "WatermarkingSupport";
static const std::string QUERY_KEY_PRODUCTION_READY = "ProductionReady";
static const std::string QUERY_VALUE_TRUE = "True";
static const std::string QUERY_VALUE_FALSE = "False";

View File

@@ -599,6 +599,12 @@ enum CdmWatermarkingSupport : int32_t {
kWatermarkingAlwaysOn
};
enum CdmProductionReadiness : int32_t {
kProductionReadinessUnknown,
kProductionReadinessTrue,
kProductionReadinessFalse,
};
class CdmKeyAllowedUsage {
public:
CdmKeyAllowedUsage() { Clear(); }
@@ -842,6 +848,7 @@ const char* CdmUsageEntryStorageTypeToString(CdmUsageEntryStorageType type);
const char* RequestedSecurityLevelToString(
RequestedSecurityLevel security_level);
const char* CdmWatermarkingSupportToString(CdmWatermarkingSupport support);
const char* CdmProductionReadinessToString(CdmProductionReadiness readiness);
// Converts a generic, unknown enum value to a string representation
// containing its numeric value.
// The pointer returned from this function is thread_local.

View File

@@ -817,6 +817,28 @@ CdmResponseType CdmEngine::QueryStatus(RequestedSecurityLevel security_level,
}
return NO_ERROR;
}
if (query_token == QUERY_KEY_PRODUCTION_READY) {
CdmProductionReadiness readiness;
if (!crypto_session->GetProductionReadiness(security_level, &readiness)) {
LOGW("GetProductionReadiness failed");
return UNKNOWN_ERROR;
}
switch (readiness) {
case kProductionReadinessUnknown:
*query_response = QUERY_VALUE_UNKNOWN;
break;
case kProductionReadinessTrue:
*query_response = QUERY_VALUE_TRUE;
break;
case kProductionReadinessFalse:
*query_response = QUERY_VALUE_FALSE;
break;
default:
LOGW("Unknown readiness: %d", static_cast<int>(readiness));
return UNKNOWN_ERROR;
}
return NO_ERROR;
}
CdmResponseType status;
M_TIME(status = crypto_session->Open(security_level),

View File

@@ -2350,6 +2350,34 @@ bool CryptoSession::GetWatermarkingSupport(
return true;
}
bool CryptoSession::GetProductionReadiness(CdmProductionReadiness* readiness) {
RETURN_IF_NOT_OPEN(false);
return GetProductionReadiness(requested_security_level_, readiness);
}
bool CryptoSession::GetProductionReadiness(
RequestedSecurityLevel security_level, CdmProductionReadiness* readiness) {
LOGV("security_level = %s", RequestedSecurityLevelToString(security_level));
RETURN_IF_UNINITIALIZED(false);
RETURN_IF_NULL(readiness, false);
const OEMCryptoResult result = WithOecReadLock("GetProductionReadiness", [&] {
return OEMCrypto_ProductionReady(security_level);
});
switch (result) {
case OEMCrypto_SUCCESS:
*readiness = kProductionReadinessTrue;
break;
case OEMCrypto_ERROR_NOT_IMPLEMENTED:
*readiness = kProductionReadinessUnknown;
break;
case OEMCrypto_ERROR_UNKNOWN_FAILURE:
default: // Other vendor-defined codes indicate not production ready.
*readiness = kProductionReadinessFalse;
break;
}
return true;
}
bool CryptoSession::GetMaximumUsageTableEntries(
RequestedSecurityLevel security_level, size_t* number_of_entries) {
LOGV("Getting maximum usage table entries: security_level = %s",

View File

@@ -1912,6 +1912,15 @@ OEMCrypto_WatermarkingSupport OEMCrypto_GetWatermarkingSupport(
return OEMCrypto_WatermarkingError;
return fcn->GetWatermarkingSupport();
}
OEMCryptoResult OEMCrypto_ProductionReady(wvcdm::RequestedSecurityLevel level) {
if (!gAdapter) return OEMCrypto_ERROR_UNKNOWN_FAILURE;
const FunctionPointers* fcn = gAdapter->GetFunctionPointers(level);
if (!fcn) return OEMCrypto_ERROR_NOT_IMPLEMENTED;
if (fcn->version < 17) return OEMCrypto_ERROR_NOT_IMPLEMENTED;
if (fcn->ProductionReady == nullptr) return OEMCrypto_ERROR_NOT_IMPLEMENTED;
return fcn->ProductionReady();
}
} // namespace wvcdm
extern "C" OEMCryptoResult OEMCrypto_SetSandbox(const uint8_t* sandbox_id,
@@ -3310,15 +3319,6 @@ extern "C" OEMCryptoResult OEMCrypto_LoadCasECMKeys(
odd_key);
}
extern "C" OEMCryptoResult OEMCrypto_ProductionReady() {
if (!gAdapter) return OEMCrypto_ERROR_UNKNOWN_FAILURE;
const FunctionPointers* fcn = gAdapter->GetFunctionPointers(kLevelDefault);
if (!fcn) return OEMCrypto_ERROR_NOT_IMPLEMENTED;
if (fcn->version < 17) return OEMCrypto_ERROR_NOT_IMPLEMENTED;
if (fcn->ProductionReady == nullptr) return OEMCrypto_ERROR_NOT_IMPLEMENTED;
return fcn->ProductionReady();
}
extern "C" OEMCryptoResult OEMCrypto_OPK_SerializationVersion(
uint32_t* ree_major, uint32_t* ree_minor, uint32_t* tee_major,
uint32_t* tee_minor) {
@@ -3423,3 +3423,7 @@ extern "C" OEMCrypto_WatermarkingSupport OEMCrypto_GetWatermarkingSupport(
void) {
return wvcdm::OEMCrypto_GetWatermarkingSupport(kLevelDefault);
}
extern "C" OEMCryptoResult OEMCrypto_ProductionReady(void) {
return wvcdm::OEMCrypto_ProductionReady(kLevelDefault);
}

View File

@@ -131,6 +131,18 @@ const char* CdmWatermarkingSupportToString(CdmWatermarkingSupport support) {
return UnknownValueRep(support);
}
const char* CdmProductionReadinessToString(CdmProductionReadiness readiness) {
switch (readiness) {
case kProductionReadinessUnknown:
return QUERY_VALUE_UNKNOWN.c_str();
case kProductionReadinessTrue:
return QUERY_VALUE_TRUE.c_str();
case kProductionReadinessFalse:
return QUERY_VALUE_FALSE.c_str();
}
return UnknownValueRep(readiness);
}
const char* UnknownEnumValueToString(int value) {
snprintf(tl_unknown_rep_buf, sizeof(tl_unknown_rep_buf), "<unknown(%d)>",
value);