From 151a0e1a760fdba77baff65f73052f7ae75ad902 Mon Sep 17 00:00:00 2001 From: Alex Dale Date: Wed, 25 Oct 2023 16:58:39 -0700 Subject: [PATCH] Include client_version in license requests. "client_version" is an optional, information field in the protocol for license requests. It was requested that the CE CDM includes this information in the license request. It does not hurt to include this information in the Android license requests too. If, for some reason, the client cannot provide this information, the request is still sent out as normal. No reason to prevent an otherwise valid license request due to a missing optional field. Note: This field is directly in the LicenseRequest message and not the ClientIdentification message. Bug: 253013596 Test: license_unittest Change-Id: I9dc342301fffdc174122088af39406150b34562e --- libwvdrmengine/cdm/core/src/license.cpp | 15 +++++++++++---- libwvdrmengine/cdm/core/test/license_unittest.cpp | 2 ++ 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/libwvdrmengine/cdm/core/src/license.cpp b/libwvdrmengine/cdm/core/src/license.cpp index 6f44a625..ceeb21d3 100644 --- a/libwvdrmengine/cdm/core/src/license.cpp +++ b/libwvdrmengine/cdm/core/src/license.cpp @@ -1026,13 +1026,20 @@ CdmResponseType CdmLicense::PrepareClientId( license_request->mutable_encrypted_client_id(); status = service_certificate_.EncryptClientId(crypto_session_, client_id, encrypted_client_id); - if (NO_ERROR == status) { - license_request->clear_client_id(); - } else { + if (status != NO_ERROR) { + LOGE("Failed to encrypt client ID: status = %s", + status.ToString().c_str()); license_request->clear_encrypted_client_id(); + return status; } - return status; + license_request->clear_client_id(); } + + std::string client_version; + if (Properties::GetWVCdmVersion(&client_version)) { + license_request->set_client_version(std::move(client_version)); + } + return CdmResponseType(NO_ERROR); } diff --git a/libwvdrmengine/cdm/core/test/license_unittest.cpp b/libwvdrmengine/cdm/core/test/license_unittest.cpp index c45804a0..23655695 100644 --- a/libwvdrmengine/cdm/core/test/license_unittest.cpp +++ b/libwvdrmengine/cdm/core/test/license_unittest.cpp @@ -427,6 +427,7 @@ TEST_F(CdmLicenseTest, PrepareKeyRequestValidation) { EXPECT_EQ(kLicenseStartTime, license_request.request_time()); EXPECT_EQ(video_widevine::VERSION_2_1, license_request.protocol_version()); EXPECT_EQ(kNonce, license_request.key_control_nonce()); + EXPECT_FALSE(license_request.client_version().empty()); } TEST_F(CdmLicenseTest, PrepareKeyRequestValidationV15) { @@ -561,6 +562,7 @@ TEST_F(CdmLicenseTest, PrepareKeyRequestValidationV15) { EXPECT_EQ(kLicenseStartTime, license_request.request_time()); EXPECT_EQ(video_widevine::VERSION_2_1, license_request.protocol_version()); EXPECT_EQ(kNonce, license_request.key_control_nonce()); + EXPECT_FALSE(license_request.client_version().empty()); } struct EntitledKeyVariant {