Rename method CanUseKey for clarity

[ Merge of http://go/wvgerrit/60240 ]

Since the method is not a general purpose check and only verifies that
the key can be used for a given security level the method
has been renamed PolicyEngine::CanUseKeyForSecurityLevel.

Bug: 115701771
Test: WV unit/integration tests
Change-Id: Icd6789538bb709d2a48c67bbd7bc810f4b000e14
This commit is contained in:
Rahul Frias
2018-09-13 23:42:24 -07:00
parent ba3e8933c8
commit adfc0093f5
4 changed files with 14 additions and 8 deletions

View File

@@ -45,7 +45,8 @@ class PolicyEngine {
// Verifies whether the policy allows use of the specified key of // Verifies whether the policy allows use of the specified key of
// a given security level for content decryption. // a given security level for content decryption.
virtual bool CanUseKey(const KeyId& key_id, CdmSecurityLevel security_level); virtual bool CanUseKeyForSecurityLevel(const KeyId& key_id,
CdmSecurityLevel security_level);
// OnTimerEvent is called when a timer fires. It notifies the Policy Engine // OnTimerEvent is called when a timer fires. It notifies the Policy Engine
// that the timer has fired and dispatches the relevant events through // that the timer has fired and dispatches the relevant events through

View File

@@ -588,7 +588,8 @@ CdmResponseType CdmSession::Decrypt(const CdmDecryptionParameters& params) {
return INSUFFICIENT_OUTPUT_PROTECTION; return INSUFFICIENT_OUTPUT_PROTECTION;
return NEED_KEY; return NEED_KEY;
} }
if (!policy_engine_->CanUseKey(*params.key_id, security_level_)) { if (!policy_engine_->CanUseKeyForSecurityLevel(*params.key_id,
security_level_)) {
return KEY_PROHIBITED_FOR_SECURITY_LEVEL; return KEY_PROHIBITED_FOR_SECURITY_LEVEL;
} }
} }

View File

@@ -314,7 +314,7 @@ CdmResponseType PolicyEngine::QueryKeyAllowedUsage(
return KEY_NOT_FOUND_1; return KEY_NOT_FOUND_1;
} }
bool PolicyEngine::CanUseKey( bool PolicyEngine::CanUseKeyForSecurityLevel(
const KeyId& key_id, const KeyId& key_id,
CdmSecurityLevel security_level) { CdmSecurityLevel security_level) {

View File

@@ -1672,7 +1672,7 @@ class PolicyEngineKeySecurityLevelTest
: public PolicyEngineTest, : public PolicyEngineTest,
public ::testing::WithParamInterface<KeySecurityLevelParams*> {}; public ::testing::WithParamInterface<KeySecurityLevelParams*> {};
TEST_P(PolicyEngineKeySecurityLevelTest, CanUseKey) { TEST_P(PolicyEngineKeySecurityLevelTest, CanUseKeyForSecurityLevel) {
KeySecurityLevelParams* param = GetParam(); KeySecurityLevelParams* param = GetParam();
@@ -1693,13 +1693,17 @@ TEST_P(PolicyEngineKeySecurityLevelTest, CanUseKey) {
policy_engine_->SetLicense(license_); policy_engine_->SetLicense(license_);
EXPECT_EQ(param->expect_can_L1_use_key, EXPECT_EQ(param->expect_can_L1_use_key,
policy_engine_->CanUseKey(kKeyId, kSecurityLevelL1)); policy_engine_->CanUseKeyForSecurityLevel(kKeyId,
kSecurityLevelL1));
EXPECT_EQ(param->expect_can_L2_use_key, EXPECT_EQ(param->expect_can_L2_use_key,
policy_engine_->CanUseKey(kKeyId, kSecurityLevelL2)); policy_engine_->CanUseKeyForSecurityLevel(kKeyId,
kSecurityLevelL2));
EXPECT_EQ(param->expect_can_L3_use_key, EXPECT_EQ(param->expect_can_L3_use_key,
policy_engine_->CanUseKey(kKeyId, kSecurityLevelL3)); policy_engine_->CanUseKeyForSecurityLevel(kKeyId,
kSecurityLevelL3));
EXPECT_EQ(param->expect_can_level_unknown_use_key, EXPECT_EQ(param->expect_can_level_unknown_use_key,
policy_engine_->CanUseKey(kKeyId, kSecurityLevelUnknown)); policy_engine_->CanUseKeyForSecurityLevel(kKeyId,
kSecurityLevelUnknown));
} }
INSTANTIATE_TEST_CASE_P( INSTANTIATE_TEST_CASE_P(