Address CE CDM test failures and code review comments
The android CL ag/13947818 was submitted before some CE CDM test failures were noticed and code review comments were received. Bug: 184813991 Test: WV unit/integration test Change-Id: Ic31ca5bc5e46994e01eca56248e6bdffedd779f3
This commit is contained in:
@@ -172,6 +172,9 @@ CdmResponseType CdmSession::Init(CdmClientPropertySet* cdm_client_property_set,
|
||||
if (cdm_client_property_set != nullptr)
|
||||
atsc_mode_enabled_ = cdm_client_property_set->use_atsc_mode();
|
||||
|
||||
// If a DRM certificate does not exist, indicate that provisioning is needed.
|
||||
// The actual validation and loading of a certificate will happen when
|
||||
// a key request is generated or an offline license is loaded.
|
||||
if (!file_handle_->HasCertificate(atsc_mode_enabled_))
|
||||
return NEED_PROVISIONING;
|
||||
|
||||
@@ -1251,31 +1254,14 @@ CdmResponseType CdmSession::LoadPrivateKey() {
|
||||
return NEED_PROVISIONING;
|
||||
}
|
||||
|
||||
CdmResponseType status = LoadPrivateKey(private_key);
|
||||
|
||||
if (status == NO_ERROR) {
|
||||
drm_certificate_ = drm_certificate;
|
||||
wrapped_private_key_.set_type(private_key.type());
|
||||
wrapped_private_key_.set_key(private_key.key());
|
||||
}
|
||||
|
||||
return status;
|
||||
return LoadPrivateKey(drm_certificate, private_key);
|
||||
}
|
||||
|
||||
CdmResponseType CdmSession::LoadPrivateOrLegacyKey(
|
||||
const std::string& certificate, const CryptoWrappedKey& private_key) {
|
||||
// Use provided key if valid
|
||||
if (!certificate.empty() && private_key.IsValid()) {
|
||||
CdmResponseType status = LoadPrivateKey(private_key);
|
||||
|
||||
if (status == NO_ERROR) {
|
||||
drm_certificate_ = certificate;
|
||||
wrapped_private_key_.set_type(private_key.type());
|
||||
wrapped_private_key_.set_key(private_key.key());
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
if (!certificate.empty() && private_key.IsValid())
|
||||
return LoadPrivateKey(certificate, private_key);
|
||||
|
||||
// Otherwise use key from legacy certificate
|
||||
std::string drm_certificate;
|
||||
@@ -1285,19 +1271,11 @@ CdmResponseType CdmSession::LoadPrivateOrLegacyKey(
|
||||
DeviceFiles::kCertificateValid)
|
||||
return NEED_PROVISIONING;
|
||||
|
||||
CdmResponseType status = LoadPrivateKey(wrapped_private_key);
|
||||
|
||||
if (status == NO_ERROR) {
|
||||
drm_certificate_ = drm_certificate;
|
||||
wrapped_private_key_.set_type(wrapped_private_key.type());
|
||||
wrapped_private_key_.set_key(wrapped_private_key.key());
|
||||
}
|
||||
|
||||
return status;
|
||||
return LoadPrivateKey(drm_certificate, wrapped_private_key);
|
||||
}
|
||||
|
||||
CdmResponseType CdmSession::LoadPrivateKey(
|
||||
const CryptoWrappedKey& private_key) {
|
||||
const std::string& drm_certificate, const CryptoWrappedKey& private_key) {
|
||||
CdmResponseType load_cert_sts;
|
||||
M_TIME(
|
||||
load_cert_sts = crypto_session_->LoadCertificatePrivateKey(private_key),
|
||||
@@ -1308,6 +1286,9 @@ CdmResponseType CdmSession::LoadPrivateKey(
|
||||
case NO_ERROR:
|
||||
metrics_->drm_certificate_key_type_.Record(
|
||||
DrmKeyTypeToMetricValue(private_key.type()));
|
||||
|
||||
drm_certificate_ = drm_certificate;
|
||||
wrapped_private_key_ = std::move(private_key);
|
||||
return NO_ERROR;
|
||||
case SESSION_LOST_STATE_ERROR:
|
||||
case SYSTEM_INVALIDATED_ERROR:
|
||||
|
||||
@@ -127,8 +127,8 @@ bool ExtractFromDeviceCertificate(const DeviceCertificate& device_certificate,
|
||||
RETURN_FALSE_IF_NULL(certificate);
|
||||
RETURN_FALSE_IF_NULL(private_key);
|
||||
|
||||
bool has_certificate = device_certificate.has_certificate();
|
||||
bool has_key = device_certificate.has_wrapped_private_key();
|
||||
const bool has_certificate = device_certificate.has_certificate();
|
||||
const bool has_key = device_certificate.has_wrapped_private_key();
|
||||
|
||||
// If no certificate information, nothing to be done. DeviceCertificate
|
||||
// is a legacy DRM certificate
|
||||
|
||||
Reference in New Issue
Block a user