getOfflineLicenseKeySetIds() respects plugin security level.
[ Merge of http://go/wvgerrit/208155 ] The MediaDrm plugin API getOfflineLicenseKeySetIds() was listing both L1 and L3 offline licenses. While this is generally acceptable, apps might force set L3 via the setStringProperty(), which should cause the DRM plugin to behave as if it is L3 only. This change will cause the WVDrmPlugin list L3 only if the app had set the security level to L3. Bug: 357863269 Bug: 372105842 Test: DRM Compliance ATP via ABTD Test: libwvdrmdrmplugin_hal_test on Oriole Change-Id: I1a6e10b7eb880eef4ba36ed31b12ebfe8617f002
This commit is contained in:
@@ -2884,6 +2884,8 @@ TEST_F(WVDrmPluginHalTest, GetOfflineLicenseKeySetIds_NonAtscMode) {
|
||||
std::vector<KeySetId> offlineKeySetIds;
|
||||
const auto ret = mPlugin->getOfflineLicenseKeySetIds(&offlineKeySetIds);
|
||||
ASSERT_TRUE(ret.isOk());
|
||||
|
||||
// Transform back into CDM types.
|
||||
std::vector<CdmKeySetId> offlineCdmKeySetIds;
|
||||
for (const auto &keySetId : offlineKeySetIds) {
|
||||
offlineCdmKeySetIds.emplace_back(keySetId.keySetId.begin(),
|
||||
@@ -2929,6 +2931,8 @@ TEST_F(WVDrmPluginHalTest, GetOfflineLicenseKeySetIds_AtscMode) {
|
||||
std::vector<KeySetId> offlineKeySetIds;
|
||||
const auto ret = mPlugin->getOfflineLicenseKeySetIds(&offlineKeySetIds);
|
||||
ASSERT_TRUE(ret.isOk());
|
||||
|
||||
// Transform back into CDM types.
|
||||
std::vector<CdmKeySetId> offlineCdmKeySetIds;
|
||||
for (const auto &keySetId : offlineKeySetIds) {
|
||||
offlineCdmKeySetIds.emplace_back(keySetId.keySetId.begin(),
|
||||
@@ -2939,6 +2943,72 @@ TEST_F(WVDrmPluginHalTest, GetOfflineLicenseKeySetIds_AtscMode) {
|
||||
EXPECT_EQ(expectedCdmKeySetIds, offlineCdmKeySetIds);
|
||||
}
|
||||
|
||||
TEST_F(WVDrmPluginHalTest, GetOfflineLicenseKeySetIds_L1AndL3) {
|
||||
const std::vector<CdmKeySetId> cdmKeySetIdsL1 = {"ksid1111", "ksid2222",
|
||||
"ksid3333", "ksid4444"};
|
||||
const std::vector<CdmKeySetId> cdmKeySetIdsL3 = {"ksid5555", "ksid6666",
|
||||
"ksid7777", "ksid8888"};
|
||||
// Expected key set IDs are the combination of both L1 and L3.
|
||||
std::vector<CdmKeySetId> cdmKeySetIds = cdmKeySetIdsL1;
|
||||
cdmKeySetIds.insert(cdmKeySetIds.end(), cdmKeySetIdsL3.begin(),
|
||||
cdmKeySetIdsL3.end());
|
||||
|
||||
EXPECT_CALL(*mCdm, ListStoredLicenses(kSecurityLevelL1, _, NotNull()))
|
||||
.WillOnce(DoAll(SetArgPointee<2>(cdmKeySetIdsL1),
|
||||
testing::Return(CdmResponseType(wvcdm::NO_ERROR))));
|
||||
EXPECT_CALL(*mCdm, ListStoredLicenses(kSecurityLevelL3, _, NotNull()))
|
||||
.WillOnce(DoAll(SetArgPointee<2>(cdmKeySetIdsL3),
|
||||
testing::Return(CdmResponseType(wvcdm::NO_ERROR))));
|
||||
|
||||
// In if security level is default, then both L1 and L3
|
||||
// offline licenses should be returned.
|
||||
mPlugin->setPropertyString("securityLevel",
|
||||
wvcdm::QUERY_VALUE_SECURITY_LEVEL_DEFAULT);
|
||||
|
||||
std::vector<KeySetId> offlineKeySetIds;
|
||||
const auto ret = mPlugin->getOfflineLicenseKeySetIds(&offlineKeySetIds);
|
||||
ASSERT_TRUE(ret.isOk());
|
||||
|
||||
// Transform back into CDM types.
|
||||
std::vector<CdmKeySetId> offlineCdmKeySetIds;
|
||||
for (const auto &keySetId : offlineKeySetIds) {
|
||||
offlineCdmKeySetIds.emplace_back(keySetId.keySetId.begin(),
|
||||
keySetId.keySetId.end());
|
||||
}
|
||||
|
||||
EXPECT_EQ(cdmKeySetIds.size(), offlineCdmKeySetIds.size());
|
||||
EXPECT_EQ(cdmKeySetIds, offlineCdmKeySetIds);
|
||||
}
|
||||
|
||||
TEST_F(WVDrmPluginHalTest, GetOfflineLicenseKeySetIds_L3Only) {
|
||||
const std::vector<CdmKeySetId> cdmKeySetIdsL3 = {"ksid1111", "ksid2222",
|
||||
"ksid3333", "ksid4444"};
|
||||
|
||||
EXPECT_CALL(*mCdm, ListStoredLicenses(kSecurityLevelL1, _, NotNull()))
|
||||
.Times(0);
|
||||
EXPECT_CALL(*mCdm, ListStoredLicenses(kSecurityLevelL3, _, NotNull()))
|
||||
.WillOnce(DoAll(SetArgPointee<2>(cdmKeySetIdsL3),
|
||||
testing::Return(CdmResponseType(wvcdm::NO_ERROR))));
|
||||
|
||||
// After setting L3 mode, only L3 key set IDs should be returned.
|
||||
mPlugin->setPropertyString("securityLevel",
|
||||
wvcdm::QUERY_VALUE_SECURITY_LEVEL_L3);
|
||||
|
||||
std::vector<KeySetId> offlineKeySetIds;
|
||||
const auto ret = mPlugin->getOfflineLicenseKeySetIds(&offlineKeySetIds);
|
||||
ASSERT_TRUE(ret.isOk());
|
||||
|
||||
// Transform back into CDM types.
|
||||
std::vector<CdmKeySetId> offlineCdmKeySetIds;
|
||||
for (const auto &keySetId : offlineKeySetIds) {
|
||||
offlineCdmKeySetIds.emplace_back(keySetId.keySetId.begin(),
|
||||
keySetId.keySetId.end());
|
||||
}
|
||||
|
||||
EXPECT_EQ(cdmKeySetIdsL3.size(), offlineCdmKeySetIds.size());
|
||||
EXPECT_EQ(cdmKeySetIdsL3, offlineCdmKeySetIds);
|
||||
}
|
||||
|
||||
TEST_F(WVDrmPluginHalTest, GetOfflineLicenseState) {
|
||||
EXPECT_CALL(*mCdm, QueryStatus(_, QUERY_KEY_SECURITY_LEVEL, _))
|
||||
.WillRepeatedly(DoAll(SetArgPointee<2>(QUERY_VALUE_SECURITY_LEVEL_L1),
|
||||
|
||||
Reference in New Issue
Block a user