Respect Client Properties when reporting CDM Status

[ Merge from go/wvgerrit/14286 ]

CDM now reports status information associated with the specified security level.
Earlier information would be reported from the default security level.

b/18709693

Change-Id: I7a01e8ea9773b56951c207437ce85e567fd32b09
This commit is contained in:
Rahul Frias
2015-05-07 10:26:07 -07:00
parent 1c6b675f0c
commit d2e91faf8e
12 changed files with 110 additions and 30 deletions

View File

@@ -254,7 +254,11 @@ class WVDrmPlugin : public android::DrmPlugin,
map<CdmSessionId, CryptoSession> mCryptoSessions;
status_t queryProperty(const std::string& property,
std::string& string_value) const;
std::string& stringValue) const;
status_t queryProperty(wvcdm::SecurityLevel securityLevel,
const std::string& property,
std::string& stringValue) const;
status_t queryProperty(const std::string& property,
String8& string8_value) const;

View File

@@ -537,7 +537,8 @@ status_t WVDrmPlugin::setPropertyString(const String8& name,
// We must be sure we CAN set the security level to L1.
std::string current_security_level;
status_t status =
queryProperty(QUERY_KEY_SECURITY_LEVEL, current_security_level);
queryProperty(kLevelDefault, QUERY_KEY_SECURITY_LEVEL,
current_security_level);
if (status != android::OK) return status;
if (current_security_level != QUERY_VALUE_SECURITY_LEVEL_L1) {
@@ -880,9 +881,20 @@ void WVDrmPlugin::OnExpirationUpdate(const CdmSessionId& cdmSessionId,
}
status_t WVDrmPlugin::queryProperty(const std::string& property,
std::string& string_value) const {
std::string& stringValue) const {
SecurityLevel securityLevel =
mPropertySet.security_level().compare(QUERY_VALUE_SECURITY_LEVEL_L3) == 0
? kLevel3
: kLevelDefault;
return queryProperty(securityLevel, property, stringValue);
}
status_t WVDrmPlugin::queryProperty(SecurityLevel securityLevel,
const std::string& property,
std::string& stringValue) const {
CdmQueryMap status;
CdmResponseType res = mCDM->QueryStatus(&status);
CdmResponseType res = mCDM->QueryStatus(securityLevel, &status);
if (res != wvcdm::NO_ERROR) {
ALOGE("Error querying CDM status: %u", res);
return mapCdmResponseType(res);
@@ -890,7 +902,7 @@ status_t WVDrmPlugin::queryProperty(const std::string& property,
ALOGE("CDM did not report %s", property.c_str());
return kErrorCDMGeneric;
}
string_value = status[property];
stringValue = status[property];
return android::OK;
}

View File

@@ -60,7 +60,7 @@ class MockCDM : public WvContentDecryptionModule {
MOCK_METHOD2(RestoreKey, CdmResponseType(const CdmSessionId&,
const CdmKeySetId&));
MOCK_METHOD1(QueryStatus, CdmResponseType(CdmQueryMap*));
MOCK_METHOD2(QueryStatus, CdmResponseType(SecurityLevel, CdmQueryMap*));
MOCK_METHOD2(QueryKeyStatus, CdmResponseType(const CdmSessionId&,
CdmQueryMap*));
@@ -812,20 +812,20 @@ TEST_F(WVDrmPluginTest, ReturnsExpectedPropertyValues) {
CdmQueryMap maxSessionsMap;
maxSessionsMap[QUERY_KEY_MAX_NUMBER_OF_SESSIONS] = maxSessions;
EXPECT_CALL(cdm, QueryStatus(_))
.WillOnce(DoAll(SetArgPointee<0>(l1Map),
EXPECT_CALL(cdm, QueryStatus(_, _))
.WillOnce(DoAll(SetArgPointee<1>(l1Map),
Return(wvcdm::NO_ERROR)))
.WillOnce(DoAll(SetArgPointee<0>(l3Map),
.WillOnce(DoAll(SetArgPointee<1>(l3Map),
Return(wvcdm::NO_ERROR)))
.WillOnce(DoAll(SetArgPointee<0>(deviceIDMap),
.WillOnce(DoAll(SetArgPointee<1>(deviceIDMap),
Return(wvcdm::NO_ERROR)))
.WillOnce(DoAll(SetArgPointee<0>(systemIDMap),
.WillOnce(DoAll(SetArgPointee<1>(systemIDMap),
Return(wvcdm::NO_ERROR)))
.WillOnce(DoAll(SetArgPointee<0>(provisioningIDMap),
.WillOnce(DoAll(SetArgPointee<1>(provisioningIDMap),
Return(wvcdm::NO_ERROR)))
.WillOnce(DoAll(SetArgPointee<0>(openSessionsMap),
.WillOnce(DoAll(SetArgPointee<1>(openSessionsMap),
Return(wvcdm::NO_ERROR)))
.WillOnce(DoAll(SetArgPointee<0>(maxSessionsMap),
.WillOnce(DoAll(SetArgPointee<1>(maxSessionsMap),
Return(wvcdm::NO_ERROR)));
String8 stringResult;
@@ -1457,8 +1457,8 @@ TEST_F(WVDrmPluginTest, CanSetAppId) {
Return(wvcdm::NO_ERROR)));
// Provide expected behavior when plugin queries for the security level
EXPECT_CALL(cdm, QueryStatus(_))
.WillRepeatedly(DoAll(SetArgPointee<0>(l3Map),
EXPECT_CALL(cdm, QueryStatus(_, _))
.WillRepeatedly(DoAll(SetArgPointee<1>(l3Map),
Return(wvcdm::NO_ERROR)));
// Provide expected behavior when plugin requests session control info
@@ -1539,10 +1539,10 @@ TEST_F(WVDrmPluginTest, CanSetSecurityLevel) {
CdmQueryMap l3Map;
l3Map[QUERY_KEY_SECURITY_LEVEL] = QUERY_VALUE_SECURITY_LEVEL_L3;
EXPECT_CALL(cdm, QueryStatus(_))
.WillOnce(DoAll(SetArgPointee<0>(l3Map),
EXPECT_CALL(cdm, QueryStatus(_, _))
.WillOnce(DoAll(SetArgPointee<1>(l3Map),
Return(wvcdm::NO_ERROR)))
.WillOnce(DoAll(SetArgPointee<0>(l1Map),
.WillOnce(DoAll(SetArgPointee<1>(l1Map),
Return(wvcdm::NO_ERROR)));
// Provide expected mock behavior