Correct exception returned after RemoveKeys is called.
[ Merge of http://go/wvgerrit/47065 ] RemoveKeys now resets associated crypto and policy resources, rather than just closing the crypto session. This results in a MediaCodec.CryptoException with error code ERROR_NO_KEY rather than ERROR_SESSION_NOT_OPENED, if decrypt is called afterwards. Error SESSION_NOT_FOUND_FOR_DECRYPT is made unique. Error codes were also synchonized between various branches in the widevine repo. Bug: 77304819 Test: WV unit/integration tests, VtsHalDrmV1_0Target tests Change-Id: I6cba2a3e1ce466d58c7727cde2d8f81d9503d655
This commit is contained in:
@@ -145,12 +145,10 @@ class CdmSession {
|
||||
virtual CdmUsageSupportType get_usage_support_type()
|
||||
{ return usage_support_type_; }
|
||||
|
||||
// ReleaseCrypto() - Closes the underlying crypto session but leaves this
|
||||
// object alive. It is invalid to call any method that requires a crypto
|
||||
// session after calling this. Since calling this renders this object mostly
|
||||
// useless, it is preferable to simply delete this object (which will also
|
||||
// release the underlying crypto session) rather than call this method.
|
||||
virtual CdmResponseType ReleaseCrypto();
|
||||
// This method will remove keys by resetting crypto resources and
|
||||
// policy information. This renders the session mostly useless and it is
|
||||
// preferable to simply delete this object rather than call this method.
|
||||
virtual CdmResponseType RemoveKeys();
|
||||
|
||||
// Delete current license and matching usage record
|
||||
bool DeleteLicense();
|
||||
|
||||
@@ -324,7 +324,13 @@ enum CdmResponseType {
|
||||
REMOVE_USAGE_INFO_ERROR_1 = 282,
|
||||
REMOVE_USAGE_INFO_ERROR_2 = 283,
|
||||
REMOVE_USAGE_INFO_ERROR_3 = 284,
|
||||
GET_PROVISIONING_METHOD_ERROR = 285,
|
||||
INSUFFICIENT_CRYPTO_RESOURCES_6 = 285,
|
||||
NOT_AN_ENTITLEMENT_SESSION = 286,
|
||||
NO_MATCHING_ENTITLEMENT_KEY = 287,
|
||||
LOAD_ENTITLED_CONTENT_KEYS_ERROR = 288,
|
||||
GET_PROVISIONING_METHOD_ERROR = 289,
|
||||
SESSION_NOT_FOUND_17 = 290,
|
||||
SESSION_NOT_FOUND_18 = 291,
|
||||
};
|
||||
|
||||
enum CdmKeyStatus {
|
||||
|
||||
@@ -407,7 +407,7 @@ CdmResponseType CdmEngine::RemoveKeys(const CdmSessionId& session_id) {
|
||||
return SESSION_NOT_FOUND_5;
|
||||
}
|
||||
|
||||
session->ReleaseCrypto();
|
||||
session->RemoveKeys();
|
||||
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
@@ -875,8 +875,18 @@ bool CdmSession::StoreLicense(DeviceFiles::LicenseState state) {
|
||||
usage_entry_number_);
|
||||
}
|
||||
|
||||
CdmResponseType CdmSession::ReleaseCrypto() {
|
||||
crypto_session_->Close();
|
||||
CdmResponseType CdmSession::RemoveKeys() {
|
||||
CdmResponseType sts;
|
||||
crypto_session_.reset(new CryptoSession(crypto_metrics_));
|
||||
// Ignore errors
|
||||
M_TIME(
|
||||
sts = crypto_session_->Open(requested_security_level_),
|
||||
crypto_metrics_,
|
||||
crypto_session_open_,
|
||||
sts,
|
||||
requested_security_level_);
|
||||
policy_engine_.reset(new PolicyEngine(
|
||||
session_id_, NULL, crypto_session_.get()));
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
|
||||
@@ -1145,7 +1145,7 @@ CdmResponseType CryptoSession::Decrypt(const CdmDecryptionParameters& params) {
|
||||
case OEMCrypto_ERROR_KEY_EXPIRED:
|
||||
return NEED_KEY;
|
||||
case OEMCrypto_ERROR_INVALID_SESSION:
|
||||
return SESSION_NOT_FOUND_FOR_DECRYPT;
|
||||
return SESSION_NOT_FOUND_17;
|
||||
case OEMCrypto_ERROR_DECRYPT_FAILED:
|
||||
case OEMCrypto_ERROR_UNKNOWN_FAILURE:
|
||||
return DECRYPT_ERROR;
|
||||
|
||||
@@ -581,8 +581,22 @@ void PrintTo(const enum CdmResponseType& value, ::std::ostream* os) {
|
||||
break;
|
||||
case REMOVE_USAGE_INFO_ERROR_3: *os << "REMOVE_USAGE_INFO_ERROR_3";
|
||||
break;
|
||||
case INSUFFICIENT_CRYPTO_RESOURCES_6:
|
||||
*os << "INSUFFICIENT_CRYPTO_RESOURCES_6";
|
||||
break;
|
||||
case NOT_AN_ENTITLEMENT_SESSION: *os << "NOT_AN_ENTITLEMENT_SESSION";
|
||||
break;
|
||||
case NO_MATCHING_ENTITLEMENT_KEY: *os << "NO_MATCHING_ENTITLEMENT_KEY";
|
||||
break;
|
||||
case LOAD_ENTITLED_CONTENT_KEYS_ERROR:
|
||||
*os << "LOAD_ENTITLED_CONTENT_KEYS_ERROR";
|
||||
break;
|
||||
case GET_PROVISIONING_METHOD_ERROR: *os << "GET_PROVISIONING_METHOD_ERROR";
|
||||
break;
|
||||
case SESSION_NOT_FOUND_17: *os << "SESSION_NOT_FOUND_17";
|
||||
break;
|
||||
case SESSION_NOT_FOUND_18: *os << "SESSION_NOT_FOUND_18";
|
||||
break;
|
||||
default:
|
||||
*os << "Unknown CdmResponseType";
|
||||
break;
|
||||
|
||||
Reference in New Issue
Block a user