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);
|
CdmSession(FileSystem* file_system, metrics::SessionMetrics* metrics);
|
||||||
virtual ~CdmSession();
|
virtual ~CdmSession();
|
||||||
|
|
||||||
void Close() { closed_ = true; }
|
void Close();
|
||||||
bool IsClosed() { return closed_; }
|
bool IsClosed() { return closed_; }
|
||||||
|
|
||||||
// Initializes this instance of CdmSession with the given property set.
|
// Initializes this instance of CdmSession with the given property set.
|
||||||
@@ -263,6 +263,9 @@ class CdmSession {
|
|||||||
bool mock_license_parser_in_use_;
|
bool mock_license_parser_in_use_;
|
||||||
bool mock_policy_engine_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);
|
CORE_DISALLOW_COPY_AND_ASSIGN(CdmSession);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -52,6 +52,9 @@ class CertificateProvisioning {
|
|||||||
video_widevine::SignedProvisioningMessage::ProtocolVersion
|
video_widevine::SignedProvisioningMessage::ProtocolVersion
|
||||||
GetProtocolVersion();
|
GetProtocolVersion();
|
||||||
|
|
||||||
|
bool GetProvisioningTokenType(
|
||||||
|
video_widevine::ClientIdentification::TokenType* token_type);
|
||||||
|
|
||||||
CryptoSession crypto_session_;
|
CryptoSession crypto_session_;
|
||||||
CdmCertificateType cert_type_;
|
CdmCertificateType cert_type_;
|
||||||
scoped_ptr<ServiceCertificate> service_certificate_;
|
scoped_ptr<ServiceCertificate> service_certificate_;
|
||||||
|
|||||||
@@ -333,6 +333,7 @@ enum CdmResponseType {
|
|||||||
GET_PROVISIONING_METHOD_ERROR = 289,
|
GET_PROVISIONING_METHOD_ERROR = 289,
|
||||||
SESSION_NOT_FOUND_17 = 290,
|
SESSION_NOT_FOUND_17 = 290,
|
||||||
SESSION_NOT_FOUND_18 = 291,
|
SESSION_NOT_FOUND_18 = 291,
|
||||||
|
SESSION_CLOSED_1 = 292,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum CdmKeyStatus {
|
enum CdmKeyStatus {
|
||||||
|
|||||||
@@ -66,6 +66,11 @@ CdmSession::~CdmSession() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CdmSession::Close() {
|
||||||
|
AutoLock lock(close_lock_);
|
||||||
|
closed_ = true;
|
||||||
|
}
|
||||||
|
|
||||||
CdmResponseType CdmSession::Init(
|
CdmResponseType CdmSession::Init(
|
||||||
CdmClientPropertySet* cdm_client_property_set) {
|
CdmClientPropertySet* cdm_client_property_set) {
|
||||||
return Init(cdm_client_property_set, NULL, NULL);
|
return Init(cdm_client_property_set, NULL, NULL);
|
||||||
@@ -567,10 +572,14 @@ CdmResponseType CdmSession::QueryOemCryptoSessionId(
|
|||||||
// Decrypt() - Accept encrypted buffer and return decrypted data.
|
// Decrypt() - Accept encrypted buffer and return decrypted data.
|
||||||
CdmResponseType CdmSession::Decrypt(const CdmDecryptionParameters& params) {
|
CdmResponseType CdmSession::Decrypt(const CdmDecryptionParameters& params) {
|
||||||
if (!initialized_) {
|
if (!initialized_) {
|
||||||
LOGE("CdmSession::Decrypt: not initialized");
|
|
||||||
return NOT_INITIALIZED_ERROR;
|
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
|
// Playback may not begin until either the start time passes or the license
|
||||||
// is updated, so we treat this Decrypt call as invalid.
|
// is updated, so we treat this Decrypt call as invalid.
|
||||||
if (params.is_encrypted) {
|
if (params.is_encrypted) {
|
||||||
|
|||||||
@@ -192,32 +192,51 @@ CdmResponseType CertificateProvisioning::GetProvisioningRequest(
|
|||||||
// Prepare device provisioning request.
|
// Prepare device provisioning request.
|
||||||
ProvisioningRequest 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;
|
wvcdm::ClientIdentification id;
|
||||||
status = id.Init(&crypto_session_);
|
status = id.Init(&crypto_session_);
|
||||||
if (status != NO_ERROR) return status;
|
if (status != NO_ERROR) return status;
|
||||||
|
|
||||||
video_widevine::ClientIdentification* client_id =
|
video_widevine::ClientIdentification* client_id =
|
||||||
provisioning_request.mutable_client_id();
|
provisioning_request.mutable_client_id();
|
||||||
CdmAppParameterMap app_parameter;
|
|
||||||
status = id.Prepare(app_parameter, client_id);
|
|
||||||
if (status != NO_ERROR) return status;
|
|
||||||
|
|
||||||
if (!service_certificate_->has_certificate()) {
|
if (token_type == video_widevine::ClientIdentification::KEYBOX) {
|
||||||
LOGE("CertificateProvisioning::GetProvisioningRequest: Service Certificate "
|
CdmAppParameterMap app_parameter;
|
||||||
"not staged");
|
status = id.Prepare(app_parameter, client_id);
|
||||||
return CERT_PROVISIONING_EMPTY_SERVICE_CERTIFICATE;
|
if (status != NO_ERROR) return status;
|
||||||
|
|
||||||
|
if (!service_certificate_->has_certificate()) {
|
||||||
|
LOGE("CertificateProvisioning::GetProvisioningRequest: Service "
|
||||||
|
"Certificate not staged");
|
||||||
|
return CERT_PROVISIONING_EMPTY_SERVICE_CERTIFICATE;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Encrypt client identification
|
||||||
|
EncryptedClientIdentification* encrypted_client_id =
|
||||||
|
provisioning_request.mutable_encrypted_client_id();
|
||||||
|
status = service_certificate_->EncryptClientId(&crypto_session_, client_id,
|
||||||
|
encrypted_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);
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO(rfrias): Uncomment when b/69427217 is addressed
|
|
||||||
/*
|
|
||||||
EncryptedClientIdentification* encrypted_client_id =
|
|
||||||
provisioning_request->mutable_encrypted_client_id();
|
|
||||||
CdmResponseType status =
|
|
||||||
service_certificate_->EncryptClientId(&crypto_session_, client_id,
|
|
||||||
encrypted_client_id);
|
|
||||||
provisioning_request->clear_client_id();
|
|
||||||
*/
|
|
||||||
|
|
||||||
uint32_t nonce;
|
uint32_t nonce;
|
||||||
if (!crypto_session_.GenerateNonce(&nonce)) {
|
if (!crypto_session_.GenerateNonce(&nonce)) {
|
||||||
LOGE("GetProvisioningRequest: fails to generate a nonce");
|
LOGE("GetProvisioningRequest: fails to generate a nonce");
|
||||||
@@ -405,4 +424,24 @@ CdmResponseType CertificateProvisioning::HandleProvisioningResponse(
|
|||||||
return NO_ERROR;
|
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
|
} // namespace wvcdm
|
||||||
|
|||||||
@@ -599,6 +599,8 @@ void PrintTo(const enum CdmResponseType& value, ::std::ostream* os) {
|
|||||||
break;
|
break;
|
||||||
case SESSION_NOT_FOUND_18: *os << "SESSION_NOT_FOUND_18";
|
case SESSION_NOT_FOUND_18: *os << "SESSION_NOT_FOUND_18";
|
||||||
break;
|
break;
|
||||||
|
case SESSION_CLOSED_1: *os << "SESSION_CLOSED_1";
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
*os << "Unknown CdmResponseType";
|
*os << "Unknown CdmResponseType";
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -4505,7 +4505,7 @@ TEST(VersionNumberTest, VersionNumberChangeCanary) {
|
|||||||
char release_number[PROPERTY_VALUE_MAX];
|
char release_number[PROPERTY_VALUE_MAX];
|
||||||
ASSERT_GT(property_get("ro.build.version.release", release_number, "Unknown"),
|
ASSERT_GT(property_get("ro.build.version.release", release_number, "Unknown"),
|
||||||
0);
|
0);
|
||||||
EXPECT_STREQ("P", release_number)
|
EXPECT_STREQ("9", release_number)
|
||||||
<< "The Android version number has changed. You need to update this test "
|
<< "The Android version number has changed. You need to update this test "
|
||||||
"and also possibly update the Widevine version number in "
|
"and also possibly update the Widevine version number in "
|
||||||
"properties_android.cpp.";
|
"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_10:
|
||||||
case wvcdm::SESSION_NOT_FOUND_17:
|
case wvcdm::SESSION_NOT_FOUND_17:
|
||||||
case wvcdm::SESSION_NOT_FOUND_18:
|
case wvcdm::SESSION_NOT_FOUND_18:
|
||||||
|
case wvcdm::SESSION_CLOSED_1:
|
||||||
return android::ERROR_DRM_SESSION_NOT_OPENED;
|
return android::ERROR_DRM_SESSION_NOT_OPENED;
|
||||||
case wvcdm::SESSION_KEYS_NOT_FOUND:
|
case wvcdm::SESSION_KEYS_NOT_FOUND:
|
||||||
return kSessionKeysNotFound;
|
return kSessionKeysNotFound;
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ static Status mapCdmResponseType(wvcdm::CdmResponseType res) {
|
|||||||
case wvcdm::SESSION_NOT_FOUND_10:
|
case wvcdm::SESSION_NOT_FOUND_10:
|
||||||
case wvcdm::SESSION_NOT_FOUND_17:
|
case wvcdm::SESSION_NOT_FOUND_17:
|
||||||
case wvcdm::SESSION_NOT_FOUND_18:
|
case wvcdm::SESSION_NOT_FOUND_18:
|
||||||
|
case wvcdm::SESSION_CLOSED_1:
|
||||||
return Status::ERROR_DRM_SESSION_NOT_OPENED;
|
return Status::ERROR_DRM_SESSION_NOT_OPENED;
|
||||||
|
|
||||||
case wvcdm::DECRYPT_ERROR:
|
case wvcdm::DECRYPT_ERROR:
|
||||||
|
|||||||
Reference in New Issue
Block a user