Improve query performance

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

Android mediaDrm allows callers to serially query status information through a
property API. CDM however retrieves all status information in a map and
filters out all but the relevent one. This leads to delays in Netflix app
startup. Rewriting the CDM interface to return only the queried value.

b/24181894

Change-Id: Ie9ed6288524e3a7e03b83aa55ef3531dd52a0dfb
This commit is contained in:
Rahul Frias
2015-10-05 15:22:20 -07:00
parent dfe644da56
commit e5dfb83e03
7 changed files with 270 additions and 217 deletions

View File

@@ -60,7 +60,8 @@ class MockCDM : public WvContentDecryptionModule {
MOCK_METHOD2(RestoreKey, CdmResponseType(const CdmSessionId&,
const CdmKeySetId&));
MOCK_METHOD2(QueryStatus, CdmResponseType(SecurityLevel, CdmQueryMap*));
MOCK_METHOD3(QueryStatus, CdmResponseType(SecurityLevel, const std::string&,
std::string*));
MOCK_METHOD2(QueryKeyStatus, CdmResponseType(const CdmSessionId&,
CdmQueryMap*));
@@ -808,45 +809,40 @@ TEST_F(WVDrmPluginTest, ReturnsExpectedPropertyValues) {
l3Map[QUERY_KEY_SECURITY_LEVEL] = QUERY_VALUE_SECURITY_LEVEL_L3;
static const string uniqueId = "The Universe";
CdmQueryMap deviceIDMap;
deviceIDMap[QUERY_KEY_DEVICE_ID] = uniqueId;
static const string systemId = "42";
CdmQueryMap systemIDMap;
systemIDMap[QUERY_KEY_SYSTEM_ID] = systemId;
static const string provisioningId("Life\0&Everything", 16);
CdmQueryMap provisioningIDMap;
provisioningIDMap[QUERY_KEY_PROVISIONING_ID] = provisioningId;
static const string openSessions = "15";
CdmQueryMap openSessionsMap;
openSessionsMap[QUERY_KEY_NUMBER_OF_OPEN_SESSIONS] = openSessions;
static const string maxSessions = "18";
CdmQueryMap maxSessionsMap;
maxSessionsMap[QUERY_KEY_MAX_NUMBER_OF_SESSIONS] = maxSessions;
static const string oemCryptoApiVersion = "10";
CdmQueryMap oemCryptoApiVersionMap;
oemCryptoApiVersionMap[QUERY_KEY_OEMCRYPTO_API_VERSION] = oemCryptoApiVersion;
EXPECT_CALL(*cdm, QueryStatus(_, _))
.WillOnce(DoAll(SetArgPointee<1>(l1Map),
EXPECT_CALL(*cdm, QueryStatus(_, QUERY_KEY_SECURITY_LEVEL, _))
.WillOnce(DoAll(SetArgPointee<2>(QUERY_VALUE_SECURITY_LEVEL_L1),
Return(wvcdm::NO_ERROR)))
.WillOnce(DoAll(SetArgPointee<1>(l3Map),
Return(wvcdm::NO_ERROR)))
.WillOnce(DoAll(SetArgPointee<1>(deviceIDMap),
Return(wvcdm::NO_ERROR)))
.WillOnce(DoAll(SetArgPointee<1>(systemIDMap),
Return(wvcdm::NO_ERROR)))
.WillOnce(DoAll(SetArgPointee<1>(provisioningIDMap),
Return(wvcdm::NO_ERROR)))
.WillOnce(DoAll(SetArgPointee<1>(openSessionsMap),
Return(wvcdm::NO_ERROR)))
.WillOnce(DoAll(SetArgPointee<1>(maxSessionsMap),
Return(wvcdm::NO_ERROR)))
.WillOnce(DoAll(SetArgPointee<1>(oemCryptoApiVersionMap),
.WillOnce(DoAll(SetArgPointee<2>(QUERY_VALUE_SECURITY_LEVEL_L3),
Return(wvcdm::NO_ERROR)));
EXPECT_CALL(*cdm, QueryStatus(_, QUERY_KEY_DEVICE_ID, _))
.WillOnce(DoAll(SetArgPointee<2>(uniqueId),
Return(wvcdm::NO_ERROR)));
EXPECT_CALL(*cdm, QueryStatus(_, QUERY_KEY_SYSTEM_ID, _))
.WillOnce(DoAll(SetArgPointee<2>(systemId),
Return(wvcdm::NO_ERROR)));
EXPECT_CALL(*cdm, QueryStatus(_, QUERY_KEY_PROVISIONING_ID, _))
.WillOnce(DoAll(SetArgPointee<2>(provisioningId),
Return(wvcdm::NO_ERROR)));
EXPECT_CALL(*cdm, QueryStatus(_, QUERY_KEY_NUMBER_OF_OPEN_SESSIONS, _))
.WillOnce(DoAll(SetArgPointee<2>(openSessions),
Return(wvcdm::NO_ERROR)));
EXPECT_CALL(*cdm, QueryStatus(_, QUERY_KEY_MAX_NUMBER_OF_SESSIONS, _))
.WillOnce(DoAll(SetArgPointee<2>(maxSessions),
Return(wvcdm::NO_ERROR)));
EXPECT_CALL(*cdm, QueryStatus(_, QUERY_KEY_OEMCRYPTO_API_VERSION, _))
.WillOnce(DoAll(SetArgPointee<2>(oemCryptoApiVersion),
Return(wvcdm::NO_ERROR)));
String8 stringResult;
@@ -1475,9 +1471,6 @@ TEST_F(WVDrmPluginTest, CanSetAppId) {
const CdmClientPropertySet* propertySet = NULL;
CdmQueryMap l3Map;
l3Map[QUERY_KEY_SECURITY_LEVEL] = QUERY_VALUE_SECURITY_LEVEL_L3;
// Provide expected mock behavior
{
// Provide expected behavior in response to OpenSession and store the
@@ -1488,8 +1481,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<1>(l3Map),
EXPECT_CALL(*cdm, QueryStatus(_, QUERY_KEY_SECURITY_LEVEL, _))
.WillRepeatedly(DoAll(SetArgPointee<2>(QUERY_VALUE_SECURITY_LEVEL_L3),
Return(wvcdm::NO_ERROR)));
// Provide expected behavior when plugin requests session control info
@@ -1564,16 +1557,10 @@ TEST_F(WVDrmPluginTest, CanSetSecurityLevel) {
const CdmClientPropertySet* propertySet = NULL;
CdmQueryMap l1Map;
l1Map[QUERY_KEY_SECURITY_LEVEL] = QUERY_VALUE_SECURITY_LEVEL_L1;
CdmQueryMap l3Map;
l3Map[QUERY_KEY_SECURITY_LEVEL] = QUERY_VALUE_SECURITY_LEVEL_L3;
EXPECT_CALL(*cdm, QueryStatus(_, _))
.WillOnce(DoAll(SetArgPointee<1>(l3Map),
EXPECT_CALL(*cdm, QueryStatus(_, QUERY_KEY_SECURITY_LEVEL, _))
.WillOnce(DoAll(SetArgPointee<2>(QUERY_VALUE_SECURITY_LEVEL_L3),
Return(wvcdm::NO_ERROR)))
.WillOnce(DoAll(SetArgPointee<1>(l1Map),
.WillOnce(DoAll(SetArgPointee<2>(QUERY_VALUE_SECURITY_LEVEL_L1),
Return(wvcdm::NO_ERROR)));
// Provide expected mock behavior