Snap for 4739962 from e3e437a6eb to pi-release
am: 0ecd120cb8
Change-Id: I5c2630d17a1bcde4b3f744176a7c15cbb39800a2
This commit is contained in:
committed by
android-build-merger
commit
d9b29a68df
@@ -37,7 +37,7 @@ class CdmSession {
|
||||
CdmSession(FileSystem* file_system, metrics::SessionMetrics* metrics);
|
||||
virtual ~CdmSession();
|
||||
|
||||
void Close() { closed_ = true; }
|
||||
void Close();
|
||||
bool IsClosed() { return closed_; }
|
||||
|
||||
// Initializes this instance of CdmSession with the given property set.
|
||||
@@ -263,6 +263,9 @@ class CdmSession {
|
||||
bool mock_license_parser_in_use_;
|
||||
bool mock_policy_engine_in_use_;
|
||||
|
||||
// Lock to avoid race conditions between Close() and Decrypt()
|
||||
Lock close_lock_;
|
||||
|
||||
CORE_DISALLOW_COPY_AND_ASSIGN(CdmSession);
|
||||
};
|
||||
|
||||
|
||||
@@ -52,6 +52,9 @@ class CertificateProvisioning {
|
||||
video_widevine::SignedProvisioningMessage::ProtocolVersion
|
||||
GetProtocolVersion();
|
||||
|
||||
bool GetProvisioningTokenType(
|
||||
video_widevine::ClientIdentification::TokenType* token_type);
|
||||
|
||||
CryptoSession crypto_session_;
|
||||
CdmCertificateType cert_type_;
|
||||
scoped_ptr<ServiceCertificate> service_certificate_;
|
||||
|
||||
@@ -333,6 +333,7 @@ enum CdmResponseType {
|
||||
GET_PROVISIONING_METHOD_ERROR = 289,
|
||||
SESSION_NOT_FOUND_17 = 290,
|
||||
SESSION_NOT_FOUND_18 = 291,
|
||||
SESSION_CLOSED_1 = 292,
|
||||
};
|
||||
|
||||
enum CdmKeyStatus {
|
||||
|
||||
@@ -66,6 +66,11 @@ CdmSession::~CdmSession() {
|
||||
}
|
||||
}
|
||||
|
||||
void CdmSession::Close() {
|
||||
AutoLock lock(close_lock_);
|
||||
closed_ = true;
|
||||
}
|
||||
|
||||
CdmResponseType CdmSession::Init(
|
||||
CdmClientPropertySet* cdm_client_property_set) {
|
||||
return Init(cdm_client_property_set, NULL, NULL);
|
||||
@@ -567,10 +572,14 @@ CdmResponseType CdmSession::QueryOemCryptoSessionId(
|
||||
// Decrypt() - Accept encrypted buffer and return decrypted data.
|
||||
CdmResponseType CdmSession::Decrypt(const CdmDecryptionParameters& params) {
|
||||
if (!initialized_) {
|
||||
LOGE("CdmSession::Decrypt: not initialized");
|
||||
return NOT_INITIALIZED_ERROR;
|
||||
}
|
||||
|
||||
AutoLock lock(close_lock_);
|
||||
if (IsClosed()) {
|
||||
return SESSION_CLOSED_1;
|
||||
}
|
||||
|
||||
// Playback may not begin until either the start time passes or the license
|
||||
// is updated, so we treat this Decrypt call as invalid.
|
||||
if (params.is_encrypted) {
|
||||
|
||||
@@ -192,31 +192,50 @@ CdmResponseType CertificateProvisioning::GetProvisioningRequest(
|
||||
// Prepare device provisioning request.
|
||||
ProvisioningRequest provisioning_request;
|
||||
|
||||
video_widevine::ClientIdentification::TokenType token_type;
|
||||
if (!GetProvisioningTokenType(&token_type)) {
|
||||
LOGE("GetProvisioningRequest: failure getting provisioning token type");
|
||||
return CLIENT_IDENTIFICATION_TOKEN_ERROR_1;
|
||||
}
|
||||
|
||||
wvcdm::ClientIdentification id;
|
||||
status = id.Init(&crypto_session_);
|
||||
if (status != NO_ERROR) return status;
|
||||
|
||||
video_widevine::ClientIdentification* client_id =
|
||||
provisioning_request.mutable_client_id();
|
||||
|
||||
if (token_type == video_widevine::ClientIdentification::KEYBOX) {
|
||||
CdmAppParameterMap app_parameter;
|
||||
status = id.Prepare(app_parameter, client_id);
|
||||
if (status != NO_ERROR) return status;
|
||||
|
||||
if (!service_certificate_->has_certificate()) {
|
||||
LOGE("CertificateProvisioning::GetProvisioningRequest: Service Certificate "
|
||||
"not staged");
|
||||
LOGE("CertificateProvisioning::GetProvisioningRequest: Service "
|
||||
"Certificate not staged");
|
||||
return CERT_PROVISIONING_EMPTY_SERVICE_CERTIFICATE;
|
||||
}
|
||||
|
||||
// TODO(rfrias): Uncomment when b/69427217 is addressed
|
||||
/*
|
||||
// Encrypt client identification
|
||||
EncryptedClientIdentification* encrypted_client_id =
|
||||
provisioning_request->mutable_encrypted_client_id();
|
||||
CdmResponseType status =
|
||||
service_certificate_->EncryptClientId(&crypto_session_, client_id,
|
||||
provisioning_request.mutable_encrypted_client_id();
|
||||
status = service_certificate_->EncryptClientId(&crypto_session_, client_id,
|
||||
encrypted_client_id);
|
||||
provisioning_request->clear_client_id();
|
||||
*/
|
||||
provisioning_request.clear_client_id();
|
||||
} else {
|
||||
// TODO(rfrias,juce,b/78303730) provide encrypted client identification
|
||||
// for devices whose root of trust is OEM_DEVICE_CERTIFICATES.
|
||||
// Prerequisite is that apps need to transition to sending the
|
||||
// provisioning request in the HTTP POST body.
|
||||
client_id->set_type(token_type);
|
||||
|
||||
std::string token;
|
||||
if (!crypto_session_.GetProvisioningToken(&token)) {
|
||||
LOGE("GetProvisioningRequest: failure getting provisioning token");
|
||||
return CLIENT_IDENTIFICATION_TOKEN_ERROR_2;
|
||||
}
|
||||
client_id->set_token(token);
|
||||
}
|
||||
|
||||
uint32_t nonce;
|
||||
if (!crypto_session_.GenerateNonce(&nonce)) {
|
||||
@@ -405,4 +424,24 @@ CdmResponseType CertificateProvisioning::HandleProvisioningResponse(
|
||||
return NO_ERROR;
|
||||
}
|
||||
|
||||
bool CertificateProvisioning::GetProvisioningTokenType(
|
||||
video_widevine::ClientIdentification::TokenType* token_type) {
|
||||
CdmClientTokenType token = crypto_session_.GetPreProvisionTokenType();
|
||||
switch (token) {
|
||||
case kClientTokenKeybox:
|
||||
*token_type = video_widevine::ClientIdentification::KEYBOX;
|
||||
return true;
|
||||
case kClientTokenOemCert:
|
||||
*token_type =
|
||||
video_widevine::ClientIdentification::OEM_DEVICE_CERTIFICATE;
|
||||
return true;
|
||||
case kClientTokenDrmCert:
|
||||
default:
|
||||
// shouldn't happen
|
||||
LOGE("CertificateProvisioning::GetProvisioningTokenType: unexpected "
|
||||
"provisioning type: %d", token);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
} // namespace wvcdm
|
||||
|
||||
@@ -599,6 +599,8 @@ void PrintTo(const enum CdmResponseType& value, ::std::ostream* os) {
|
||||
break;
|
||||
case SESSION_NOT_FOUND_18: *os << "SESSION_NOT_FOUND_18";
|
||||
break;
|
||||
case SESSION_CLOSED_1: *os << "SESSION_CLOSED_1";
|
||||
break;
|
||||
default:
|
||||
*os << "Unknown CdmResponseType";
|
||||
break;
|
||||
|
||||
@@ -4505,7 +4505,7 @@ TEST(VersionNumberTest, VersionNumberChangeCanary) {
|
||||
char release_number[PROPERTY_VALUE_MAX];
|
||||
ASSERT_GT(property_get("ro.build.version.release", release_number, "Unknown"),
|
||||
0);
|
||||
EXPECT_STREQ("P", release_number)
|
||||
EXPECT_STREQ("9", release_number)
|
||||
<< "The Android version number has changed. You need to update this test "
|
||||
"and also possibly update the Widevine version number in "
|
||||
"properties_android.cpp.";
|
||||
|
||||
@@ -230,6 +230,7 @@ static android::status_t mapCdmResponseType(wvcdm::CdmResponseType res) {
|
||||
case wvcdm::SESSION_NOT_FOUND_10:
|
||||
case wvcdm::SESSION_NOT_FOUND_17:
|
||||
case wvcdm::SESSION_NOT_FOUND_18:
|
||||
case wvcdm::SESSION_CLOSED_1:
|
||||
return android::ERROR_DRM_SESSION_NOT_OPENED;
|
||||
case wvcdm::SESSION_KEYS_NOT_FOUND:
|
||||
return kSessionKeysNotFound;
|
||||
|
||||
@@ -58,6 +58,7 @@ static Status mapCdmResponseType(wvcdm::CdmResponseType res) {
|
||||
case wvcdm::SESSION_NOT_FOUND_10:
|
||||
case wvcdm::SESSION_NOT_FOUND_17:
|
||||
case wvcdm::SESSION_NOT_FOUND_18:
|
||||
case wvcdm::SESSION_CLOSED_1:
|
||||
return Status::ERROR_DRM_SESSION_NOT_OPENED;
|
||||
|
||||
case wvcdm::DECRYPT_ERROR:
|
||||
|
||||
Reference in New Issue
Block a user