Replace event notification from when openSession fails

Merge of https://widevine-internal-review.googlesource.com/#/c/7280/1
from the Widevine CDM repo.

bug: 10396953
Change-Id: I085b60e01292f37379d19d059b39ac7a7f299012
This commit is contained in:
Jeff Tinker
2013-08-19 17:27:44 -07:00
parent a2e15186e5
commit 2fa6b63292
2 changed files with 39 additions and 1 deletions

View File

@@ -59,7 +59,7 @@ status_t WVDrmPlugin::openSession(Vector<uint8_t>& sessionId) {
&cdmSessionId);
if (!isCdmResponseTypeSuccess(res)) {
return mapCdmResponseType(res);
return mapAndNotifyOfCdmResponseType(sessionId, res);
}
bool success = false;

View File

@@ -11,6 +11,7 @@
#include "gtest/gtest.h"
#include "media/stagefright/foundation/ABase.h"
#include "media/stagefright/foundation/AString.h"
#include "media/stagefright/MediaErrors.h"
#include "wv_cdm_constants.h"
#include "wv_cdm_types.h"
#include "wv_content_decryption_module.h"
@@ -1102,6 +1103,43 @@ TEST_F(WVDrmPluginTest, MarshalsEvents) {
plugin.onEvent(cdmSessionId, LICENSE_RENEWAL_NEEDED_EVENT);
}
TEST_F(WVDrmPluginTest, GeneratesProvisioningNeededEvent) {
StrictMock<MockCDM> cdm;
StrictMock<MockCrypto> crypto;
WVDrmPlugin plugin(&cdm, &crypto);
sp<MockDrmPluginListener> listener = new MockDrmPluginListener();
EXPECT_CALL(*listener, sendEvent(DrmPlugin::kDrmPluginEventProvisionRequired, 0,
Pointee(ElementsAreArray(sessionIdRaw,
kSessionIdSize)),
NULL))
.Times(1);
// Provide expected behavior to support session creation
EXPECT_CALL(cdm, OpenSession(StrEq("com.widevine"), _, _))
.Times(AtLeast(1))
.WillRepeatedly(DoAll(SetArgPointee<2>(cdmSessionId),
Return(wvcdm::NEED_PROVISIONING)));
// Let gMock know these calls will happen but we aren't interested in them.
EXPECT_CALL(cdm, AttachEventListener(_, _))
.Times(AtLeast(0));
EXPECT_CALL(cdm, DetachEventListener(_, _))
.Times(AtLeast(0));
EXPECT_CALL(cdm, CloseSession(_))
.Times(AtLeast(0));
status_t res = plugin.setListener(listener);
ASSERT_EQ(OK, res);
res = plugin.openSession(sessionId);
ASSERT_EQ(ERROR_DRM_NOT_PROVISIONED, res);
}
TEST_F(WVDrmPluginTest, ProvidesExpectedDefaultPropertiesToCdm) {
StrictMock<MockCDM> cdm;
StrictMock<MockCrypto> crypto;