Merge "Usage Table Failure Creates Broken CryptoSession"
This commit is contained in:
@@ -674,6 +674,7 @@ CdmResponseType CryptoSession::Open(SecurityLevel requested_security_level) {
|
|||||||
return LOAD_SYSTEM_ID_ERROR;
|
return LOAD_SYSTEM_ID_ERROR;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set up request ID
|
||||||
uint64_t request_id_base;
|
uint64_t request_id_base;
|
||||||
OEMCryptoResult random_sts;
|
OEMCryptoResult random_sts;
|
||||||
WithOecReadLock("Open() calling OEMCrypto_GetRandom", [&] {
|
WithOecReadLock("Open() calling OEMCrypto_GetRandom", [&] {
|
||||||
@@ -688,6 +689,22 @@ CdmResponseType CryptoSession::Open(SecurityLevel requested_security_level) {
|
|||||||
HexEncode(reinterpret_cast<uint8_t*>(&request_id_index),
|
HexEncode(reinterpret_cast<uint8_t*>(&request_id_index),
|
||||||
sizeof(request_id_index));
|
sizeof(request_id_index));
|
||||||
|
|
||||||
|
// Initialize key session
|
||||||
|
WithOecSessionLock("Open() calling key_session_.reset()", [&] {
|
||||||
|
key_session_.reset(new ContentKeySession(oec_session_id_, metrics_));
|
||||||
|
});
|
||||||
|
|
||||||
|
// Set up Usage Table support
|
||||||
|
//
|
||||||
|
// This MUST be the last thing in the function because it contains the
|
||||||
|
// successful return paths of the function. It will attempt to initialize
|
||||||
|
// usage tables. However, whether they are employed is determined by
|
||||||
|
// information in the license, which will not be received until later. In case
|
||||||
|
// usage tables are not even needed, initialization errors here are ignored by
|
||||||
|
// returning successfully.
|
||||||
|
//
|
||||||
|
// TODO(b/141350978): Refactor this code so that it does not have this
|
||||||
|
// problem.
|
||||||
if (!GetApiVersion(&api_version_)) {
|
if (!GetApiVersion(&api_version_)) {
|
||||||
LOGE("Failed to get API version");
|
LOGE("Failed to get API version");
|
||||||
return USAGE_SUPPORT_GET_API_FAILED;
|
return USAGE_SUPPORT_GET_API_FAILED;
|
||||||
@@ -735,9 +752,12 @@ CdmResponseType CryptoSession::Open(SecurityLevel requested_security_level) {
|
|||||||
metrics_->oemcrypto_usage_table_support_.SetError(result);
|
metrics_->oemcrypto_usage_table_support_.SetError(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
WithOecSessionLock("Open() calling key_session_.reset()", [&] {
|
// Do not add logic after this point as it may never get exercised. In the
|
||||||
key_session_.reset(new ContentKeySession(oec_session_id_, metrics_));
|
// event of errors initializing the usage tables, the code will return early,
|
||||||
});
|
// never reaching this point. See the comment above the "Set up Usage Table
|
||||||
|
// support" section for details.
|
||||||
|
//
|
||||||
|
// TODO(b/139973602): Refactor this code.
|
||||||
|
|
||||||
return NO_ERROR;
|
return NO_ERROR;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user