Correctly handle local display only for SRM version.

[ Merge of http://go/wvgerrit/105343 ]

If a device only supports local display (eliminating the need for an
SRM version), then the CDM should treat this as no SRM version.

Bug: 166009716
Test: License request integration test
Change-Id: I2d9c3f98735563df6d7c7a287abab41bf0a8c513
This commit is contained in:
Alex Dale
2020-08-28 12:55:21 -07:00
parent e929a5dcdd
commit b96b58628c
7 changed files with 46 additions and 26 deletions

View File

@@ -415,6 +415,7 @@ enum CdmResponseType : int32_t {
LICENSE_USAGE_ENTRY_MISSING = 360, LICENSE_USAGE_ENTRY_MISSING = 360,
LOAD_USAGE_ENTRY_INVALID_SESSION = 361, LOAD_USAGE_ENTRY_INVALID_SESSION = 361,
RESTORE_OFFLINE_LICENSE_ERROR_3 = 362, RESTORE_OFFLINE_LICENSE_ERROR_3 = 362,
NO_SRM_VERSION = 363,
// Don't forget to add new values to // Don't forget to add new values to
// * core/test/test_printers.cpp. // * core/test/test_printers.cpp.
// * android/include/mapErrors-inl.h // * android/include/mapErrors-inl.h

View File

@@ -617,17 +617,22 @@ CdmResponseType CdmEngine::QueryStatus(SecurityLevel security_level,
} else if (query_token == QUERY_KEY_CURRENT_SRM_VERSION) { } else if (query_token == QUERY_KEY_CURRENT_SRM_VERSION) {
uint16_t current_srm_version; uint16_t current_srm_version;
status = crypto_session->GetSrmVersion(&current_srm_version); status = crypto_session->GetSrmVersion(&current_srm_version);
if (status == NOT_IMPLEMENTED_ERROR) { switch (status) {
case NO_ERROR: {
*query_response = std::to_string(current_srm_version);
return NO_ERROR;
}
case NO_SRM_VERSION: {
// SRM is not supported or not applicable (ex. local display only).
*query_response = QUERY_VALUE_NONE; *query_response = QUERY_VALUE_NONE;
return NO_ERROR; return NO_ERROR;
} else if (status != NO_ERROR) { }
default: {
LOGW("GetCurrentSRMVersion failed: status = %d", LOGW("GetCurrentSRMVersion failed: status = %d",
static_cast<int>(status)); static_cast<int>(status));
return status; return status;
} }
}
*query_response = std::to_string(current_srm_version);
return NO_ERROR;
} else if (query_token == QUERY_KEY_SRM_UPDATE_SUPPORT) { } else if (query_token == QUERY_KEY_SRM_UPDATE_SUPPORT) {
bool is_srm_update_supported = crypto_session->IsSrmUpdateSupported(); bool is_srm_update_supported = crypto_session->IsSrmUpdateSupported();
*query_response = *query_response =

View File

@@ -1913,25 +1913,33 @@ CdmResponseType CryptoSession::GetSrmVersion(uint16_t* srm_version) {
RETURN_IF_UNINITIALIZED(CRYPTO_SESSION_NOT_INITIALIZED); RETURN_IF_UNINITIALIZED(CRYPTO_SESSION_NOT_INITIALIZED);
RETURN_IF_NULL(srm_version, PARAMETER_NULL); RETURN_IF_NULL(srm_version, PARAMETER_NULL);
OEMCryptoResult status; const OEMCryptoResult status = WithOecReadLock("GetSrmVersion", [&] {
WithOecReadLock("GetSrmVersion", [&] { return OEMCrypto_GetCurrentSRMVersion(srm_version);
status = OEMCrypto_GetCurrentSRMVersion(srm_version);
}); });
// SRM is an optional feature. Whether it is implemented is up to the // SRM is an optional feature. Whether it is implemented is up to the
// discretion of OEMs // discretion of OEMs. OEMs may implement this method, but SRM is not
if (status == OEMCrypto_ERROR_NOT_IMPLEMENTED) { // required if there is only a local display, as such no SRM version
LOGV("OEMCrypto_GetCurrentSRMVersion not implemented"); // is available/reportable. |srm_version| is only set if SUCCESS is
return NOT_IMPLEMENTED_ERROR; // returned.
} switch (status) {
case OEMCrypto_SUCCESS:
return NO_ERROR;
case OEMCrypto_LOCAL_DISPLAY_ONLY:
LOGD("No SRM: Local display only");
return NO_SRM_VERSION;
case OEMCrypto_ERROR_NOT_IMPLEMENTED:
LOGD("No SRM: Not implemented");
return NO_SRM_VERSION;
default:
return MapOEMCryptoResult(status, GET_SRM_VERSION_ERROR, return MapOEMCryptoResult(status, GET_SRM_VERSION_ERROR,
"GetCurrentSRMVersion"); "GetCurrentSRMVersion");
} }
}
bool CryptoSession::IsSrmUpdateSupported() { bool CryptoSession::IsSrmUpdateSupported() {
LOGV("Checking if SRM update is supported"); LOGV("Checking if SRM update is supported");
if (!IsInitialized()) return false; RETURN_IF_UNINITIALIZED(false);
return WithOecReadLock("IsSrmUpdateSupported", return WithOecReadLock("IsSrmUpdateSupported",
[&] { return OEMCrypto_IsSRMUpdateSupported(); }); [&] { return OEMCrypto_IsSRMUpdateSupported(); });
} }
@@ -1944,9 +1952,8 @@ CdmResponseType CryptoSession::LoadSrm(const std::string& srm) {
return INVALID_SRM_LIST; return INVALID_SRM_LIST;
} }
OEMCryptoResult status; const OEMCryptoResult status = WithOecWriteLock("LoadSrm", [&] {
WithOecWriteLock("LoadSrm", [&] { return OEMCrypto_LoadSRM(reinterpret_cast<const uint8_t*>(srm.data()),
status = OEMCrypto_LoadSRM(reinterpret_cast<const uint8_t*>(srm.data()),
srm.size()); srm.size());
}); });

View File

@@ -596,6 +596,9 @@ void PrintTo(const enum CdmResponseType& value, ::std::ostream* os) {
case NO_MATCHING_ENTITLEMENT_KEY: case NO_MATCHING_ENTITLEMENT_KEY:
*os << "NO_MATCHING_ENTITLEMENT_KEY"; *os << "NO_MATCHING_ENTITLEMENT_KEY";
break; break;
case NO_SRM_VERSION:
*os << "NO_SRM_VERSION";
break;
case NONCE_GENERATION_ERROR: case NONCE_GENERATION_ERROR:
*os << "NONCE_GENERATION_ERROR"; *os << "NONCE_GENERATION_ERROR";
break; break;

View File

@@ -297,10 +297,11 @@ enum {
kLicenseUsageEntryMissing = ERROR_DRM_VENDOR_MIN + 312, kLicenseUsageEntryMissing = ERROR_DRM_VENDOR_MIN + 312,
kLoadUsageEntryInvalidSession = ERROR_DRM_VENDOR_MIN + 313, kLoadUsageEntryInvalidSession = ERROR_DRM_VENDOR_MIN + 313,
kRestoreOfflineLicenseError3 = ERROR_DRM_VENDOR_MIN + 314, kRestoreOfflineLicenseError3 = ERROR_DRM_VENDOR_MIN + 314,
kNoSrmVersion = ERROR_DRM_VENDOR_MIN + 315,
// This should always follow the last error code. // This should always follow the last error code.
// The offset value should be updated each time a new error code is added. // The offset value should be updated each time a new error code is added.
kErrorWVDrmMaxErrorUsed = ERROR_DRM_VENDOR_MIN + 314, kErrorWVDrmMaxErrorUsed = ERROR_DRM_VENDOR_MIN + 315,
// Used by crypto test mode // Used by crypto test mode
kErrorTestMode = ERROR_DRM_VENDOR_MAX, kErrorTestMode = ERROR_DRM_VENDOR_MAX,

View File

@@ -402,6 +402,8 @@ static android::status_t mapCdmResponseType(wvcdm::CdmResponseType res) {
return kNoContentKey2; return kNoContentKey2;
case wvcdm::NO_DEVICE_KEY_1: case wvcdm::NO_DEVICE_KEY_1:
return kNoDeviceKey1; return kNoDeviceKey1;
case wvcdm::NO_SRM_VERSION:
return kNoSrmVersion;
case wvcdm::NO_USAGE_ENTRIES: case wvcdm::NO_USAGE_ENTRIES:
return kNoUsageEntries; return kNoUsageEntries;
case wvcdm::OFFLINE_LICENSE_PROHIBITED: case wvcdm::OFFLINE_LICENSE_PROHIBITED:

View File

@@ -356,6 +356,7 @@ static Status mapCdmResponseType(wvcdm::CdmResponseType res) {
case wvcdm::SHRINK_USAGE_TABLE_HEADER_ENTRY_IN_USE: case wvcdm::SHRINK_USAGE_TABLE_HEADER_ENTRY_IN_USE:
case wvcdm::LICENSE_USAGE_ENTRY_MISSING: case wvcdm::LICENSE_USAGE_ENTRY_MISSING:
case wvcdm::PROVISIONING_NOT_ALLOWED_FOR_ATSC: case wvcdm::PROVISIONING_NOT_ALLOWED_FOR_ATSC:
case wvcdm::NO_SRM_VERSION:
ALOGW("Returns UNKNOWN error for legacy status: %d", res); ALOGW("Returns UNKNOWN error for legacy status: %d", res);
return Status::ERROR_DRM_UNKNOWN; return Status::ERROR_DRM_UNKNOWN;