Pass CdmIdentifier to UsageInfo Methods

The methods on WvContentDecryptionModule related to UsageInfo (Secure
Stops) do not work if kDefaultCdmIdentifier has not been provisioned.
This can occur if an app provisions and uses an origin without any app
on that device ever provisioning the default origin. More concerningly,
this will happen 100% of the time on SPOID-using devices, as there is no
way to provision the default identifier on these devices.

The fix is to pass the current identifier to these methods so that they
do not have to use kDefaultCdmIdentifier.

Test: build_and_run_all_unit_tests.sh
Test: WV GTS Tests
Bug: 62431478
Change-Id: I92a8b4acb69c964abe8129bccf2ff48a66c4a9e0
This commit is contained in:
John W. Bruce
2017-06-16 16:54:59 -07:00
parent c3cdb531d4
commit 43b8522b70
8 changed files with 144 additions and 65 deletions

View File

@@ -2540,7 +2540,8 @@ TEST_P(WvCdmUsageTest, WithClientId) {
uint32_t num_usage_info = 0;
CdmUsageInfo usage_info;
CdmUsageInfoReleaseMessage release_msg;
CdmResponseType status = decryptor_.GetUsageInfo(app_id, &usage_info);
CdmResponseType status = decryptor_.GetUsageInfo(
app_id, kDefaultCdmIdentifier, &usage_info);
EXPECT_EQ(usage_info.empty() ? NO_ERROR : KEY_MESSAGE, status);
// Validate signed renewal request
@@ -2571,7 +2572,8 @@ TEST_P(WvCdmUsageTest, WithClientId) {
release_msg =
GetUsageInfoResponse(g_license_server, g_client_auth, usage_info[0]);
EXPECT_EQ(NO_ERROR, decryptor_.ReleaseUsageInfo(release_msg));
EXPECT_EQ(NO_ERROR, decryptor_.ReleaseUsageInfo(release_msg,
kDefaultCdmIdentifier));
}
INSTANTIATE_TEST_CASE_P(
@@ -2622,20 +2624,23 @@ TEST_F(WvCdmRequestLicenseTest, UsageInfoRetryTest) {
uint32_t num_usage_info = 0;
CdmUsageInfo usage_info;
CdmUsageInfoReleaseMessage release_msg;
CdmResponseType status = decryptor_.GetUsageInfo(app_id, &usage_info);
CdmResponseType status = decryptor_.GetUsageInfo(
app_id, kDefaultCdmIdentifier, &usage_info);
EXPECT_EQ(usage_info.empty() ? NO_ERROR : KEY_MESSAGE, status);
// Discard and retry to verify usage reports can be generated multiple times
// before release.
status = decryptor_.GetUsageInfo(app_id, &usage_info);
status = decryptor_.GetUsageInfo(app_id, kDefaultCdmIdentifier, &usage_info);
EXPECT_EQ(usage_info.empty() ? NO_ERROR : KEY_MESSAGE, status);
while (usage_info.size() > 0) {
for (size_t i = 0; i < usage_info.size(); ++i) {
release_msg =
GetUsageInfoResponse(g_license_server, g_client_auth, usage_info[i]);
EXPECT_EQ(NO_ERROR, decryptor_.ReleaseUsageInfo(release_msg));
EXPECT_EQ(NO_ERROR, decryptor_.ReleaseUsageInfo(release_msg,
kDefaultCdmIdentifier));
}
status = decryptor_.GetUsageInfo(app_id, &usage_info);
status = decryptor_.GetUsageInfo(
app_id, kDefaultCdmIdentifier, &usage_info);
switch (status) {
case KEY_MESSAGE:
EXPECT_FALSE(usage_info.empty());
@@ -2718,15 +2723,19 @@ TEST_P(WvCdmUsageInfoTest, UsageInfo) {
CdmUsageInfo usage_info;
CdmUsageInfoReleaseMessage release_msg;
CdmResponseType status =
decryptor_.GetUsageInfo(usage_info_data->app_id, &usage_info);
decryptor_.GetUsageInfo(usage_info_data->app_id, kDefaultCdmIdentifier,
&usage_info);
EXPECT_EQ(usage_info.empty() ? NO_ERROR : KEY_MESSAGE, status);
while (usage_info.size() > 0) {
for (size_t i = 0; i < usage_info.size(); ++i) {
release_msg =
GetUsageInfoResponse(g_license_server, g_client_auth, usage_info[i]);
EXPECT_EQ(NO_ERROR, decryptor_.ReleaseUsageInfo(release_msg));
EXPECT_EQ(
NO_ERROR,
decryptor_.ReleaseUsageInfo(release_msg, kDefaultCdmIdentifier));
}
status = decryptor_.GetUsageInfo(usage_info_data->app_id, &usage_info);
status = decryptor_.GetUsageInfo(usage_info_data->app_id,
kDefaultCdmIdentifier, &usage_info);
EXPECT_EQ(usage_info.empty() ? NO_ERROR : KEY_MESSAGE, status);
}
}
@@ -2795,25 +2804,46 @@ TEST_F(WvCdmRequestLicenseTest, UsageReleaseAllTest) {
}
CdmUsageInfo usage_info;
EXPECT_EQ(KEY_MESSAGE, decryptor_.GetUsageInfo(app_id_empty, &usage_info));
EXPECT_EQ(
KEY_MESSAGE,
decryptor_.GetUsageInfo(app_id_empty, kDefaultCdmIdentifier,
&usage_info));
EXPECT_TRUE(usage_info.size() > 0);
EXPECT_EQ(KEY_MESSAGE,
decryptor_.GetUsageInfo(app_id_not_empty, &usage_info));
EXPECT_EQ(
KEY_MESSAGE,
decryptor_.GetUsageInfo(app_id_not_empty, kDefaultCdmIdentifier,
&usage_info));
EXPECT_TRUE(usage_info.size() > 0);
EXPECT_EQ(NO_ERROR, decryptor_.ReleaseAllUsageInfo(app_id_not_empty));
EXPECT_EQ(
NO_ERROR,
decryptor_.ReleaseAllUsageInfo(app_id_not_empty, kDefaultCdmIdentifier));
EXPECT_EQ(NO_ERROR, decryptor_.GetUsageInfo(app_id_not_empty, &usage_info));
EXPECT_EQ(
NO_ERROR,
decryptor_.GetUsageInfo(app_id_not_empty, kDefaultCdmIdentifier,
&usage_info));
EXPECT_TRUE(usage_info.empty());
EXPECT_EQ(KEY_MESSAGE, decryptor_.GetUsageInfo(app_id_empty, &usage_info));
EXPECT_EQ(
KEY_MESSAGE,
decryptor_.GetUsageInfo(app_id_empty, kDefaultCdmIdentifier,
&usage_info));
EXPECT_TRUE(usage_info.size() > 0);
EXPECT_EQ(NO_ERROR, decryptor_.ReleaseAllUsageInfo(app_id_empty));
EXPECT_EQ(
NO_ERROR,
decryptor_.ReleaseAllUsageInfo(app_id_empty, kDefaultCdmIdentifier));
EXPECT_EQ(NO_ERROR, decryptor_.GetUsageInfo(app_id_not_empty, &usage_info));
EXPECT_EQ(
NO_ERROR,
decryptor_.GetUsageInfo(app_id_not_empty, kDefaultCdmIdentifier,
&usage_info));
EXPECT_TRUE(usage_info.empty());
EXPECT_EQ(NO_ERROR, decryptor_.GetUsageInfo(app_id_empty, &usage_info));
EXPECT_EQ(
NO_ERROR,
decryptor_.GetUsageInfo(app_id_empty, kDefaultCdmIdentifier,
&usage_info));
EXPECT_TRUE(usage_info.empty());
}