Correct an error reported when a license is restored and then released

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

Now reports LICENSE_STATE_ERROR rather than ERROR_DRM_GENERIC_PLUGIN
to make the cause of failure and suggested action more clear for app
developers. Also added an additional error log.

Bug: 190645000
Test: WV unit/integration tests
Change-Id: Ib23ca628c590316f90f497d8fdfbab24fd644d6f
This commit is contained in:
Rahul Frias
2021-06-29 20:21:06 -07:00
parent 61218ec6cf
commit c882bd8230
6 changed files with 15 additions and 1 deletions

View File

@@ -420,6 +420,7 @@ enum CdmResponseType : int32_t {
CERT_PROVISIONING_RESPONSE_ERROR_9 = 365,
CERT_PROVISIONING_RESPONSE_ERROR_10 = 366,
CLIENT_TOKEN_NOT_SET = 367,
USAGE_ENTRY_ALREADY_LOADED = 368,
// Don't forget to add new values to
// * core/test/test_printers.cpp.
// * android/include/mapErrors-inl.h

View File

@@ -283,6 +283,11 @@ CdmResponseType CdmSession::RestoreOfflineSession(const CdmKeySetId& key_set_id,
CdmResponseType sts = usage_table_header_->LoadEntry(
crypto_session_.get(), usage_entry_, usage_entry_number_);
crypto_metrics_->usage_table_header_load_entry_.Increment(sts);
if (sts == LOAD_USAGE_ENTRY_INVALID_SESSION) {
LOGE("License loaded in different session: key_set_id = %s",
IdToString(key_set_id));
return USAGE_ENTRY_ALREADY_LOADED;
}
if (sts != NO_ERROR) {
LOGE("Failed to load usage entry: status = %d", static_cast<int>(sts));
return sts;

View File

@@ -887,6 +887,9 @@ void PrintTo(const enum CdmResponseType& value, ::std::ostream* os) {
case USAGE_ENTRY_NUMBER_MISMATCH:
*os << "USAGE_ENTRY_NUMBER_MISMATCH";
break;
case USAGE_ENTRY_ALREADY_LOADED:
*os << "USAGE_ENTRY_ALREADY_LOADED";
break;
case USAGE_GET_ENTRY_RETRIEVE_INVALID_STORAGE_TYPE:
*os << "USAGE_GET_ENTRY_RETRIEVE_INVALID_STORAGE_TYPE";
break;

View File

@@ -301,10 +301,11 @@ enum {
kCertProvisioningResponseError9 = ERROR_DRM_VENDOR_MIN + 316,
kCertProvisioningResponseError10 = ERROR_DRM_VENDOR_MIN + 317,
kClientTokenNotSet = ERROR_DRM_VENDOR_MIN + 318,
kUsageEntryAlreadyLoaded = ERROR_DRM_VENDOR_MIN + 319,
// This should always follow the last error code.
// The offset value should be updated each time a new error code is added.
kErrorWVDrmMaxErrorUsed = ERROR_DRM_VENDOR_MIN + 318,
kErrorWVDrmMaxErrorUsed = ERROR_DRM_VENDOR_MIN + 319,
// Used by crypto test mode
kErrorTestMode = ERROR_DRM_VENDOR_MAX,

View File

@@ -539,6 +539,8 @@ static android::status_t mapCdmResponseType(wvcdm::CdmResponseType res) {
return kUpdateUsageEntryUnknownError;
case wvcdm::USAGE_ENTRY_NUMBER_MISMATCH:
return kUsageEntryNumberMismatch;
case wvcdm::USAGE_ENTRY_ALREADY_LOADED:
return kUsageEntryAlreadyLoaded;
case wvcdm::USAGE_GET_ENTRY_RETRIEVE_INVALID_STORAGE_TYPE:
return kUsageGetEntryRetrieveInvalidStorageType;
case wvcdm::USAGE_GET_ENTRY_RETRIEVE_LICENSE_FAILED:

View File

@@ -361,6 +361,7 @@ static Status mapCdmResponseType_1_0(wvcdm::CdmResponseType res) {
case wvcdm::CERT_PROVISIONING_RESPONSE_ERROR_9:
case wvcdm::CERT_PROVISIONING_RESPONSE_ERROR_10:
case wvcdm::CLIENT_TOKEN_NOT_SET:
case wvcdm::USAGE_ENTRY_ALREADY_LOADED:
ALOGW("Returns UNKNOWN error for legacy status: %d", res);
return Status::ERROR_DRM_UNKNOWN;
@@ -617,6 +618,7 @@ static S mapCdmResponseType(wvcdm::CdmResponseType res) {
break;
case wvcdm::GET_RELEASED_LICENSE_ERROR:
case wvcdm::RESTORE_OFFLINE_LICENSE_ERROR_3:
case wvcdm::USAGE_ENTRY_ALREADY_LOADED:
err = ::drm::V1_4::Status::LICENSE_STATE_ERROR;
break;
case wvcdm::DEVICE_CERTIFICATE_ERROR_2: