New CDM error codes for usage table errors.

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

There are three situtations where error codes from a usage table
operations were not being mapped to unique CDM response types.  These
particular errors provide useful information for the CDM during table
defragging.

Also fixed misspelled error code.

Bug: 150890014
Bug: 150891685
Test: Linux unit tests and Android build
Change-Id: I683abdd5fc0871317eede960ea36cfafac7e7f49
This commit is contained in:
Alex Dale
2020-03-05 23:06:56 -08:00
parent 8c1f8f1469
commit c9e4dd2495
7 changed files with 62 additions and 27 deletions

View File

@@ -281,7 +281,7 @@ enum CdmResponseType {
/* previsouly INVALID_PARAMETERS_ENG_20 = 227, */
UPDATE_USAGE_ENTRY_UNKNOWN_ERROR = 228,
/* previously INVALID_PARAMETERS_ENG_21 = 229, */
SHRINK_USAGE_TABLER_HEADER_UNKNOWN_ERROR = 230,
SHRINK_USAGE_TABLE_HEADER_UNKNOWN_ERROR = 230,
MOVE_USAGE_ENTRY_UNKNOWN_ERROR = 231,
COPY_OLD_USAGE_ENTRY_UNKNOWN_ERROR = 232,
INVALID_PARAMETERS_ENG_22 = 233,
@@ -408,6 +408,9 @@ enum CdmResponseType {
CANNOT_DECRYPT_ZERO_SUBSAMPLES = 354,
SAMPLE_AND_SUBSAMPLE_SIZE_MISMATCH = 355,
INVALID_IV_SIZE = 356,
LOAD_USAGE_ENTRY_INVALID_SESSION = 357,
MOVE_USAGE_ENTRY_DESTINATION_IN_USE = 358,
SHRINK_USAGE_TABLE_HEADER_ENTRY_IN_USE = 359,
// Don't forget to add new values to
// * core/test/test_printers.cpp.
// * android/include/mapErrors-inl.h

View File

@@ -2476,18 +2476,19 @@ CdmResponseType CryptoSession::LoadUsageEntry(
case OEMCrypto_SUCCESS:
case OEMCrypto_WARNING_GENERATION_SKEW:
return NO_ERROR;
case OEMCrypto_ERROR_INVALID_SESSION:
// This case is special, as it could imply that the provided
// session ID is invalid (CDM internal bug), or that the entry
// being loaded is already in use in a different session.
// It is up to the caller to handle this.
return LOAD_USAGE_ENTRY_INVALID_SESSION;
case OEMCrypto_ERROR_GENERATION_SKEW:
return LOAD_USAGE_ENTRY_GENERATION_SKEW;
case OEMCrypto_ERROR_SIGNATURE_FAILURE:
return LOAD_USAGE_ENTRY_SIGNATURE_FAILURE;
case OEMCrypto_ERROR_INSUFFICIENT_RESOURCES:
return INSUFFICIENT_CRYPTO_RESOURCES_3;
case OEMCrypto_ERROR_SESSION_LOST_STATE:
return SESSION_LOST_STATE_ERROR;
case OEMCrypto_ERROR_SYSTEM_INVALIDATED:
return SYSTEM_INVALIDATED_ERROR;
default:
return LOAD_USAGE_ENTRY_UNKNOWN_ERROR;
return MapOEMCryptoResult(result, LOAD_USAGE_ENTRY_UNKNOWN_ERROR,
"LoadUsageEntry");
}
}
@@ -2561,13 +2562,17 @@ CdmResponseType CryptoSession::ShrinkUsageTableHeader(
});
}
if (result == OEMCrypto_SUCCESS) {
switch (result) {
case OEMCrypto_SUCCESS:
usage_table_header->resize(usage_table_header_len);
}
return MapOEMCryptoResult(result, SHRINK_USAGE_TABLER_HEADER_UNKNOWN_ERROR,
return NO_ERROR;
case OEMCrypto_ERROR_ENTRY_IN_USE:
return SHRINK_USAGE_TABLE_HEADER_ENTRY_IN_USE;
default:
return MapOEMCryptoResult(result, SHRINK_USAGE_TABLE_HEADER_UNKNOWN_ERROR,
"ShrinkUsageTableHeader");
}
}
CdmResponseType CryptoSession::MoveUsageEntry(uint32_t new_entry_number) {
LOGV("Moving usage entry: id = %u", oec_session_id_);
@@ -2578,9 +2583,16 @@ CdmResponseType CryptoSession::MoveUsageEntry(uint32_t new_entry_number) {
metrics_->oemcrypto_move_entry_.Increment(result);
});
switch (result) {
case OEMCrypto_ERROR_ENTRY_IN_USE:
LOGW("OEMCrypto_MoveEntry failed: Destination index in use: index = %u",
new_entry_number);
return MOVE_USAGE_ENTRY_DESTINATION_IN_USE;
default:
return MapOEMCryptoResult(result, MOVE_USAGE_ENTRY_UNKNOWN_ERROR,
"MoveUsageEntry");
}
}
bool CryptoSession::GetAnalogOutputCapabilities(bool* can_support_output,
bool* can_disable_output,

View File

@@ -560,6 +560,9 @@ void PrintTo(const enum CdmResponseType& value, ::std::ostream* os) {
case LOAD_USAGE_ENTRY_GENERATION_SKEW:
*os << "LOAD_USAGE_ENTRY_GENERATION_SKEW";
break;
case LOAD_USAGE_ENTRY_INVALID_SESSION:
*os << "LOAD_USAGE_ENTRY_INVALID_SESSION";
break;
case LOAD_USAGE_ENTRY_SIGNATURE_FAILURE:
*os << "LOAD_USAGE_ENTRY_SIGNATURE_FAILURE";
break;
@@ -578,6 +581,9 @@ void PrintTo(const enum CdmResponseType& value, ::std::ostream* os) {
case LOAD_USAGE_HEADER_UNKNOWN_ERROR:
*os << "LOAD_USAGE_HEADER_UNKNOWN_ERROR";
break;
case MOVE_USAGE_ENTRY_DESTINATION_IN_USE:
*os << "MOVE_USAGE_ENTRY_DESTINATION_IN_USE";
break;
case MOVE_USAGE_ENTRY_UNKNOWN_ERROR:
*os << "MOVE_USAGE_ENTRY_UNKNOWN_ERROR";
break;
@@ -818,8 +824,11 @@ void PrintTo(const enum CdmResponseType& value, ::std::ostream* os) {
case SET_DECRYPT_HASH_ERROR:
*os << "SET_DECRYPT_HASH_ERROR";
break;
case SHRINK_USAGE_TABLER_HEADER_UNKNOWN_ERROR:
*os << "SHRINK_USAGE_TABLER_HEADER_UNKNOWN_ERROR";
case SHRINK_USAGE_TABLE_HEADER_ENTRY_IN_USE:
*os << "SHRINK_USAGE_TABLE_HEADER_ENTRY_IN_USE";
break;
case SHRINK_USAGE_TABLE_HEADER_UNKNOWN_ERROR:
*os << "SHRINK_USAGE_TABLE_HEADER_UNKNOWN_ERROR";
break;
case SIGNATURE_NOT_FOUND:
*os << "SIGNATURE_NOT_FOUND";

View File

@@ -740,10 +740,9 @@ TEST_P(UsageTableHeaderInitializationTest,
Open(security_level))
.Times(2)
.WillRepeatedly(Return(NO_ERROR));
EXPECT_CALL(
*crypto_session_,
EXPECT_CALL(*crypto_session_,
ShrinkUsageTableHeader(usage_entries_202.size() - 1, NotNull()))
.WillOnce(Return(SHRINK_USAGE_TABLER_HEADER_UNKNOWN_ERROR));
.WillOnce(Return(SHRINK_USAGE_TABLE_HEADER_UNKNOWN_ERROR));
EXPECT_TRUE(usage_table_header_->Init(GetParam(), crypto_session_));
}
@@ -1306,7 +1305,7 @@ TEST_F(UsageTableHeaderTest, DeleteEntry_CryptoSessionError) {
EXPECT_CALL(
*crypto_session_,
ShrinkUsageTableHeader(usage_entry_info_vector.size() - 1, NotNull()))
.WillOnce(Return(SHRINK_USAGE_TABLER_HEADER_UNKNOWN_ERROR));
.WillOnce(Return(SHRINK_USAGE_TABLE_HEADER_UNKNOWN_ERROR));
EXPECT_NE(NO_ERROR,
usage_table_header_->DeleteEntry(usage_entry_number_to_be_deleted,

View File

@@ -206,7 +206,7 @@ enum {
kLoadUsageEntrySignatureFailure = ERROR_DRM_VENDOR_MIN + 218,
kLoadUsageEntryUnknownError = ERROR_DRM_VENDOR_MIN + 219,
kUpdateUsageEntryUnknownError = ERROR_DRM_VENDOR_MIN + 222,
kShrinkUsageTablerHeaderUnknownError = ERROR_DRM_VENDOR_MIN + 224,
kShrinkUsageTableHeaderUnknownError = ERROR_DRM_VENDOR_MIN + 224,
kMoveUsageEntryUnknownError = ERROR_DRM_VENDOR_MIN + 225,
kCopyOldUsageEntryUnknownError = ERROR_DRM_VENDOR_MIN + 226,
kInvalidParametersEng22 = ERROR_DRM_VENDOR_MIN + 227,
@@ -289,10 +289,13 @@ enum {
kCannotDecryptZeroSubsamples = ERROR_DRM_VENDOR_MIN + 306,
kSampleAndSubsampleSizeMismatch = ERROR_DRM_VENDOR_MIN + 307,
kInvalidIvSize = ERROR_DRM_VENDOR_MIN + 308,
kLoadUsageEntryInvalidSession = ERROR_DRM_VENDOR_MIN + 309,
kMoveUsageEntryDestinationInUse = ERROR_DRM_VENDOR_MIN + 310,
kShrinkUsageTableHeaderEntryInUse = ERROR_DRM_VENDOR_MIN + 311,
// 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 + 308,
kErrorWVDrmMaxErrorUsed = ERROR_DRM_VENDOR_MIN + 311,
// Used by crypto test mode
kErrorTestMode = ERROR_DRM_VENDOR_MAX,

View File

@@ -378,6 +378,8 @@ static android::status_t mapCdmResponseType(wvcdm::CdmResponseType res) {
return kLoadSystemIdError;
case wvcdm::LOAD_USAGE_ENTRY_GENERATION_SKEW:
return kLoadUsageEntryGenerationSkew;
case wvcdm::LOAD_USAGE_ENTRY_INVALID_SESSION:
return kLoadUsageEntryInvalidSession;
case wvcdm::LOAD_USAGE_ENTRY_SIGNATURE_FAILURE:
return kLoadUsageEntrySignatureFailure;
case wvcdm::LOAD_USAGE_ENTRY_UNKNOWN_ERROR:
@@ -394,6 +396,8 @@ static android::status_t mapCdmResponseType(wvcdm::CdmResponseType res) {
return kLoadUsageInfoFileError;
case wvcdm::LOAD_USAGE_INFO_MISSING:
return kLoadUsageInfoMissing;
case wvcdm::MOVE_USAGE_ENTRY_DESTINATION_IN_USE:
return kMoveUsageEntryDestinationInUse;
case wvcdm::MOVE_USAGE_ENTRY_UNKNOWN_ERROR:
return kMoveUsageEntryUnknownError;
case wvcdm::NOT_AN_ENTITLEMENT_SESSION:
@@ -492,8 +496,10 @@ static android::status_t mapCdmResponseType(wvcdm::CdmResponseType res) {
return kSessionNotFound16;
case wvcdm::SET_DECRYPT_HASH_ERROR:
return kSetDecryptHashError;
case wvcdm::SHRINK_USAGE_TABLER_HEADER_UNKNOWN_ERROR:
return kShrinkUsageTablerHeaderUnknownError;
case wvcdm::SHRINK_USAGE_TABLE_HEADER_ENTRY_IN_USE:
return kShrinkUsageTableHeaderEntryInUse;
case wvcdm::SHRINK_USAGE_TABLE_HEADER_UNKNOWN_ERROR:
return kShrinkUsageTableHeaderUnknownError;
case wvcdm::SIGNATURE_NOT_FOUND:
return kSignatureNotFound;
case wvcdm::SIGNATURE_NOT_FOUND_2:

View File

@@ -246,7 +246,7 @@ static Status mapCdmResponseType(wvcdm::CdmResponseType res) {
case wvcdm::LOAD_USAGE_ENTRY_SIGNATURE_FAILURE:
case wvcdm::LOAD_USAGE_ENTRY_UNKNOWN_ERROR:
case wvcdm::UPDATE_USAGE_ENTRY_UNKNOWN_ERROR:
case wvcdm::SHRINK_USAGE_TABLER_HEADER_UNKNOWN_ERROR:
case wvcdm::SHRINK_USAGE_TABLE_HEADER_UNKNOWN_ERROR:
case wvcdm::MOVE_USAGE_ENTRY_UNKNOWN_ERROR:
case wvcdm::COPY_OLD_USAGE_ENTRY_UNKNOWN_ERROR:
case wvcdm::INVALID_PARAMETERS_ENG_22:
@@ -355,6 +355,9 @@ static Status mapCdmResponseType(wvcdm::CdmResponseType res) {
case wvcdm::CANNOT_DECRYPT_ZERO_SUBSAMPLES:
case wvcdm::SAMPLE_AND_SUBSAMPLE_SIZE_MISMATCH:
case wvcdm::INVALID_IV_SIZE:
case wvcdm::LOAD_USAGE_ENTRY_INVALID_SESSION:
case wvcdm::MOVE_USAGE_ENTRY_DESTINATION_IN_USE:
case wvcdm::SHRINK_USAGE_TABLE_HEADER_ENTRY_IN_USE:
ALOGW("Returns UNKNOWN error for legacy status: %d", res);
return Status::ERROR_DRM_UNKNOWN;