Refactor WvCdmEventListener and some cleanups

Bug: 19771437

It is a merge of below CLs from Widevine CDM repo:

Clean up CdmSession and PolicyEngine testing injection
https://widevine-internal-review.googlesource.com/#/c/13700

Refactor WvCdmEventListener handling
https://widevine-internal-review.googlesource.com/#/c/13702

Change-Id: I356b90000c056113d394926862b859aab380d305
This commit is contained in:
KongQun Yang
2015-03-16 19:46:11 -07:00
parent 69d7ffb22d
commit fddbc89136
16 changed files with 237 additions and 494 deletions

View File

@@ -42,13 +42,6 @@ WVDrmPlugin::~WVDrmPlugin() {
for (mapIterator iter = mCryptoSessions.begin();
iter != mCryptoSessions.end();
++iter) {
bool bRes = mCDM->DetachEventListener(iter->first, this);
if (!bRes) {
ALOGE("Received failure when trying to detach WVDrmPlugin as an event "
"listener.");
}
CdmResponseType res = mCDM->CloseSession(iter->first);
if (!isCdmResponseTypeSuccess(res)) {
ALOGE("Failed to close session while destroying WVDrmPlugin");
@@ -59,8 +52,8 @@ WVDrmPlugin::~WVDrmPlugin() {
status_t WVDrmPlugin::openSession(Vector<uint8_t>& sessionId) {
CdmSessionId cdmSessionId;
CdmResponseType res = mCDM->OpenSession("com.widevine", &mPropertySet,
&cdmSessionId);
CdmResponseType res =
mCDM->OpenSession("com.widevine", &mPropertySet, this, &cdmSessionId);
if (!isCdmResponseTypeSuccess(res)) {
return mapAndNotifyOfCdmResponseType(sessionId, res);
@@ -68,32 +61,23 @@ status_t WVDrmPlugin::openSession(Vector<uint8_t>& sessionId) {
bool success = false;
// Register for events
bool listenerAttached = mCDM->AttachEventListener(cdmSessionId, this);
// Construct a CryptoSession
CdmQueryMap info;
res = mCDM->QueryKeyControlInfo(cdmSessionId, &info);
if (listenerAttached) {
// Construct a CryptoSession
CdmQueryMap info;
if (isCdmResponseTypeSuccess(res) &&
info.count(QUERY_KEY_OEMCRYPTO_SESSION_ID)) {
OEMCrypto_SESSION oecSessionId;
istringstream(info[QUERY_KEY_OEMCRYPTO_SESSION_ID]) >> oecSessionId;
res = mCDM->QueryKeyControlInfo(cdmSessionId, &info);
if (isCdmResponseTypeSuccess(res) &&
info.count(QUERY_KEY_OEMCRYPTO_SESSION_ID)) {
OEMCrypto_SESSION oecSessionId;
istringstream(info[QUERY_KEY_OEMCRYPTO_SESSION_ID]) >> oecSessionId;
{
Mutex::Autolock lock(mCryptoSessionsMutex);
mCryptoSessions[cdmSessionId] = CryptoSession(oecSessionId);
}
success = true;
} else {
ALOGE("Unable to query key control info.");
{
Mutex::Autolock lock(mCryptoSessionsMutex);
mCryptoSessions[cdmSessionId] = CryptoSession(oecSessionId);
}
success = true;
} else {
ALOGE("Received failure when trying to attach WVDrmPlugin as an event"
"listener.");
ALOGE("Unable to query key control info.");
}
if (success) {
@@ -104,10 +88,6 @@ status_t WVDrmPlugin::openSession(Vector<uint8_t>& sessionId) {
return android::OK;
} else {
if (listenerAttached) {
mCDM->DetachEventListener(cdmSessionId, this);
}
mCDM->CloseSession(cdmSessionId);
if (!isCdmResponseTypeSuccess(res)) {