Check if license exists before calling remove.
[ Merge of http://go/wvgerrit/187610 ] [ Partial cherry-pick of http://ag/25096962 ] The removeOfflineLicense() API in the Media DRM plug would attempt to remove the specified license from L1, then retry L3 if L1 failed for any reason. This causes error emitted by L1 to be masked by errors emitted from L3. In particular, if an internal error occurs on L1 when removing the license, because the plugin would then try L3 which does not contain the license, the app will receive either a "does not exist" or "needs provisioning" error from L3. This CL changes the plugin to first determines which security level the license exists for. Then only attempts removal on that security level. Bug: 301910628 Bug: 291181955 Bug: 296300842 Bug: 302612540 Test: MediaDrmParameterizedTests GTS on oriole Change-Id: I5fbb6805e598650f9b384a3b0e8d67f1c2a0f78d
This commit is contained in:
@@ -2971,13 +2971,78 @@ TEST_F(WVDrmPluginHalTest, GetOfflineLicenseState) {
|
||||
ASSERT_EQ(OfflineLicenseState::UNKNOWN, result);
|
||||
}
|
||||
|
||||
TEST_F(WVDrmPluginHalTest, RemoveOfflineLicense) {
|
||||
EXPECT_CALL(
|
||||
*mCdm, RemoveOfflineLicense(_, kSecurityLevelL1, HasOrigin(EMPTY_ORIGIN)))
|
||||
.Times(1);
|
||||
TEST_F(WVDrmPluginHalTest, RemoveOfflineLicense_L1) {
|
||||
// Key set to remove.
|
||||
const CdmKeySetId cdmKeySetId = "ksidDEADBEAF";
|
||||
const KeySetId keySetId{
|
||||
std::vector<uint8_t>(cdmKeySetId.begin(), cdmKeySetId.end())};
|
||||
// Desired key set ID found in L1.
|
||||
const std::vector<CdmKeySetId> cdmKeySetIdsL1 = {"ksid1234", "ksid9876",
|
||||
"ksid9999", cdmKeySetId,
|
||||
"ksidBAD", "ksidCAFEB0BA"};
|
||||
|
||||
auto ret = mPlugin->removeOfflineLicense(keySetId);
|
||||
EXPECT_TRUE(ret.isOk());
|
||||
EXPECT_CALL(*mCdm, ListStoredLicenses(kSecurityLevelL1, _, NotNull()))
|
||||
.WillOnce(DoAll(SetArgPointee<2>(cdmKeySetIdsL1),
|
||||
testing::Return(CdmResponseType(wvcdm::NO_ERROR))));
|
||||
// Only call L1.
|
||||
EXPECT_CALL(*mCdm, RemoveOfflineLicense(cdmKeySetId, kSecurityLevelL1, _))
|
||||
.WillOnce(testing::Return(CdmResponseType(wvcdm::NO_ERROR)));
|
||||
EXPECT_CALL(*mCdm, RemoveOfflineLicense(_, kSecurityLevelL3, _)).Times(0);
|
||||
|
||||
const auto status = mPlugin->removeOfflineLicense(keySetId);
|
||||
ASSERT_TRUE(status.isOk());
|
||||
}
|
||||
|
||||
TEST_F(WVDrmPluginHalTest, RemoveOfflineLicense_L3) {
|
||||
// Key set to remove.
|
||||
const CdmKeySetId cdmKeySetId = "ksidDEADBEAF";
|
||||
const KeySetId keySetId{
|
||||
std::vector<uint8_t>(cdmKeySetId.begin(), cdmKeySetId.end())};
|
||||
// Desired key set ID is not found in L1.
|
||||
const std::vector<CdmKeySetId> cdmKeySetIdsL1 = {"ksid1234", "ksid9876",
|
||||
"ksid9999"};
|
||||
// Desired key set ID found in L3.
|
||||
const std::vector<CdmKeySetId> cdmKeySetIdsL3 = {
|
||||
"ksidDEADC0DE", "ksid1337", cdmKeySetId, "ksidBAD", "ksidCAFEB0BA"};
|
||||
|
||||
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))));
|
||||
// Only call L3.
|
||||
EXPECT_CALL(*mCdm, RemoveOfflineLicense(_, kSecurityLevelL1, _)).Times(0);
|
||||
EXPECT_CALL(*mCdm, RemoveOfflineLicense(cdmKeySetId, kSecurityLevelL3, _))
|
||||
.WillOnce(testing::Return(CdmResponseType(wvcdm::NO_ERROR)));
|
||||
|
||||
const auto status = mPlugin->removeOfflineLicense(keySetId);
|
||||
ASSERT_TRUE(status.isOk());
|
||||
}
|
||||
|
||||
TEST_F(WVDrmPluginHalTest, RemoveOfflineLicense_NotFound) {
|
||||
// Key set to remove.
|
||||
const CdmKeySetId cdmKeySetId = "ksidDEADBEAF";
|
||||
const KeySetId keySetId{
|
||||
std::vector<uint8_t>(cdmKeySetId.begin(), cdmKeySetId.end())};
|
||||
// Desired key set ID is not found in L1.
|
||||
const std::vector<CdmKeySetId> cdmKeySetIdsL1 = {"ksid1234", "ksid9876",
|
||||
"ksid9999"};
|
||||
// Desired key set ID is not found in L3.
|
||||
const std::vector<CdmKeySetId> cdmKeySetIdsL3 = {"ksidDEADC0DE", "ksid1337",
|
||||
"ksidBAD", "ksidCAFEB0BA"};
|
||||
|
||||
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))));
|
||||
// No call to RemoveOfflineLicense should be made.
|
||||
EXPECT_CALL(*mCdm, RemoveOfflineLicense(_, _, _)).Times(0);
|
||||
|
||||
const auto status = mPlugin->removeOfflineLicense(keySetId);
|
||||
ASSERT_FALSE(status.isOk());
|
||||
}
|
||||
|
||||
TEST_F(WVDrmPluginHalTest, CanStoreAtscLicense) {
|
||||
|
||||
Reference in New Issue
Block a user