Update license holder to handle Android license releases

Since the CDM engine handles license releases for CE CDM and Android
differently, this changes the license release test to accomodate for
that.

Bug: 348712053
Change-Id: Ibc768e5d5c31ef8c2226b63dc622ffabfc0591fe
This commit is contained in:
Vicky Min
2024-08-14 21:59:54 +00:00
committed by Rahul Frias
parent 1a036457ee
commit e642847b81
2 changed files with 46 additions and 5 deletions

View File

@@ -7,6 +7,7 @@
#include "license_request.h"
#include "message_dumper.h"
#include "oec_device_features.h"
#include "properties.h"
#include "test_base.h"
namespace wvcdm {
@@ -126,10 +127,27 @@ void LicenseHolder::GenerateAndPostReleaseRequest(
const std::string init_data_string = MakePSSH(pssh);
const InitializationData init_data(kCencMimeType, init_data_string);
init_data.DumpToLogs();
const CdmResponseType result = cdm_engine_->GenerateKeyRequest(
session_id_, key_set_id_, init_data, kLicenseTypeRelease,
CdmSessionId session_id;
CdmKeySetId key_set_id;
CdmResponseType result;
// For Android when key set IDs are used, the key set ID passed in should have
// a value and the session ID should be empty.
if (!Properties::AlwaysUseKeySetIds()) {
key_set_id = key_set_id_;
result = cdm_engine_->OpenKeySetSession(key_set_id_, nullptr, nullptr);
ASSERT_EQ(NO_ERROR, result) << "Failed for " << content_id();
// For CE CDM, we only need the session ID to be valid.
} else {
session_id = session_id_;
}
result = cdm_engine_->GenerateKeyRequest(session_id, key_set_id, init_data,
kLicenseTypeRelease,
empty_app_parameters, &request);
ASSERT_EQ(KEY_MESSAGE, result) << "Failed for " << content_id();
if (!Properties::AlwaysUseKeySetIds()) {
cdm_engine_->CloseKeySetSession(key_set_id_);
}
if (config_.dump_golden_data()) {
// TODO (b/295956275) vickymin: write DumpReleaseRequest function
// MessageDumper::DumpReleaseRequest(request);

View File

@@ -19,6 +19,7 @@
#include "license_holder.h"
#include "log.h"
#include "oec_device_features.h"
#include "properties.h"
#include "provisioning_holder.h"
#include "test_base.h"
#include "test_printers.h"
@@ -193,13 +194,24 @@ TEST_F(CorePIGTest, LicenseRelease1) {
ASSERT_NO_FATAL_FAILURE(holder.FetchLicense());
ASSERT_NO_FATAL_FAILURE(holder.LoadLicense());
EXPECT_EQ(NO_ERROR, holder.Decrypt(key_id));
// For Android where AlwaysUseKeySetIds() is false, the CDM engine generates
// a session separately. Thus, we close the session and only for CE CDM reopen
// it for the license release.
ASSERT_NO_FATAL_FAILURE(holder.CloseSession());
if (Properties::AlwaysUseKeySetIds()) {
ASSERT_NO_FATAL_FAILURE(holder.OpenSession());
ASSERT_NO_FATAL_FAILURE(holder.ReloadLicense());
}
ASSERT_NO_FATAL_FAILURE(holder.GenerateAndPostReleaseRequest(
"CDM_UnlimitedStreaming_can_persist"));
EXPECT_NE(NO_ERROR, holder.Decrypt(key_id));
ASSERT_NO_FATAL_FAILURE(holder.FetchRelease());
ASSERT_NO_FATAL_FAILURE(holder.LoadRelease());
EXPECT_NE(NO_ERROR, holder.Decrypt(key_id));
// For CE CDM, we can close the session after we have gotten the release.
if (Properties::AlwaysUseKeySetIds()) {
ASSERT_NO_FATAL_FAILURE(holder.CloseSession());
}
}
/**
@@ -219,11 +231,22 @@ TEST_F(CorePIGTest, LicenseRelease2) {
ASSERT_NO_FATAL_FAILURE(holder.FetchLicense());
ASSERT_NO_FATAL_FAILURE(holder.LoadLicense());
wvutil::TestSleep::Sleep(10);
// For Android where AlwaysUseKeySetIds() is false, the CDM engine generates
// a session separately. Thus, we close the session and only for CE CDM reopen
// it for the license release.
ASSERT_NO_FATAL_FAILURE(holder.CloseSession());
if (Properties::AlwaysUseKeySetIds()) {
ASSERT_NO_FATAL_FAILURE(holder.OpenSession());
ASSERT_NO_FATAL_FAILURE(holder.ReloadLicense());
}
ASSERT_NO_FATAL_FAILURE(holder.GenerateAndPostReleaseRequest(
"CDM_UnlimitedStreaming_can_persist"));
ASSERT_NO_FATAL_FAILURE(holder.FetchRelease());
ASSERT_NO_FATAL_FAILURE(holder.LoadRelease());
// For CE CDM, we can close the session after we have gotten the release.
if (Properties::AlwaysUseKeySetIds()) {
ASSERT_NO_FATAL_FAILURE(holder.CloseSession());
}
}
TEST_F(CorePIGTest, CastReceiverProvisioningUsingCdm) {