Integrate OnExpirationUpdate and OnSessionKeysChange with Android

Also removes OnSessionExpiration which is no longer needed with
OnSessionKeysChange.

Bug: 19771612
Bug: 19771431

Merged from Widevine CDM repo:
https://widevine-internal-review.googlesource.com/#/c/13951/

Change-Id: I0603e808e8d50ff7bb1fb1d5e44fabd8d268ee8a
This commit is contained in:
Kongqun Yang
2015-04-01 15:02:38 -07:00
parent 4621028434
commit f7c449e93a
8 changed files with 142 additions and 102 deletions

View File

@@ -113,6 +113,9 @@ class MockDrmPluginListener : public DrmPluginListener {
public:
MOCK_METHOD4(sendEvent, void(DrmPlugin::EventType, int,
const Vector<uint8_t>*, const Vector<uint8_t>*));
MOCK_METHOD2(sendExpirationUpdate, void(const Vector<uint8_t>*, int64_t));
MOCK_METHOD3(sendKeysChange, void(const Vector<uint8_t>*,
const Vector<DrmPlugin::KeyStatus>*, bool));
};
template <uint8_t DIGIT>
@@ -1181,27 +1184,77 @@ TEST_F(WVDrmPluginTest, MarshalsEvents) {
sp<StrictMock<MockDrmPluginListener> > listener =
new StrictMock<MockDrmPluginListener>();
const int64_t kExpiryTimeInSeconds = 123456789012LL;
const char kKeyId1[] = "Testing Key1 Id ";
const char kKeyId2[] = "Testing Key2 Id ";
const char kKeyId3[] = "Testing Key3 Id ";
const char kKeyId4[] = "Testing Key4 Id ";
{
InSequence calls;
EXPECT_CALL(*listener, sendEvent(DrmPlugin::kDrmPluginEventKeyExpired, 0,
Pointee(ElementsAreArray(sessionIdRaw,
kSessionIdSize)),
NULL))
.Times(1);
EXPECT_CALL(*listener, sendEvent(DrmPlugin::kDrmPluginEventKeyNeeded, 0,
Pointee(ElementsAreArray(sessionIdRaw,
kSessionIdSize)),
NULL))
.Times(1);
EXPECT_CALL(*listener,
sendKeysChange(
Pointee(ElementsAreArray(sessionIdRaw, kSessionIdSize)),
Pointee(UnorderedElementsAre(AllOf(
Field(&DrmPlugin::KeyStatus::mKeyId,
ElementsAreArray(kKeyId1, sizeof(kKeyId1) - 1)),
Field(&DrmPlugin::KeyStatus::mType,
DrmPlugin::kKeyStatusType_Expired)))),
false));
EXPECT_CALL(
*listener,
sendEvent(DrmPlugin::kDrmPluginEventKeyExpired, 0,
Pointee(ElementsAreArray(sessionIdRaw, kSessionIdSize)),
NULL));
EXPECT_CALL(
*listener,
sendEvent(DrmPlugin::kDrmPluginEventKeyNeeded, 0,
Pointee(ElementsAreArray(sessionIdRaw, kSessionIdSize)),
NULL));
EXPECT_CALL(*listener,
sendExpirationUpdate(
Pointee(ElementsAreArray(sessionIdRaw, kSessionIdSize)),
kExpiryTimeInSeconds * 1000));
EXPECT_CALL(
*listener,
sendKeysChange(
Pointee(ElementsAreArray(sessionIdRaw, kSessionIdSize)),
Pointee(UnorderedElementsAre(
AllOf(Field(&DrmPlugin::KeyStatus::mKeyId,
ElementsAreArray(kKeyId1, sizeof(kKeyId1) - 1)),
Field(&DrmPlugin::KeyStatus::mType,
DrmPlugin::kKeyStatusType_Usable)),
AllOf(Field(&DrmPlugin::KeyStatus::mKeyId,
ElementsAreArray(kKeyId2, sizeof(kKeyId2) - 1)),
Field(&DrmPlugin::KeyStatus::mType,
DrmPlugin::kKeyStatusType_OutputNotAllowed)),
AllOf(Field(&DrmPlugin::KeyStatus::mKeyId,
ElementsAreArray(kKeyId3, sizeof(kKeyId3) - 1)),
Field(&DrmPlugin::KeyStatus::mType,
DrmPlugin::kKeyStatusType_InternalError)),
AllOf(Field(&DrmPlugin::KeyStatus::mKeyId,
ElementsAreArray(kKeyId4, sizeof(kKeyId4) - 1)),
Field(&DrmPlugin::KeyStatus::mType,
DrmPlugin::kKeyStatusType_StatusPending)))),
true));
}
status_t res = plugin.setListener(listener);
ASSERT_EQ(OK, res);
plugin.OnSessionExpiration(cdmSessionId);
CdmKeyStatusMap cdmKeysStatus;
cdmKeysStatus[kKeyId1] = kKeyStatusExpired;
plugin.OnSessionKeysChange(cdmSessionId, cdmKeysStatus, false);
plugin.OnSessionRenewalNeeded(cdmSessionId);
plugin.OnExpirationUpdate(cdmSessionId, kExpiryTimeInSeconds);
cdmKeysStatus[kKeyId1] = kKeyStatusUsable;
cdmKeysStatus[kKeyId2] = kKeyStatusOutputNotAllowed;
cdmKeysStatus[kKeyId3] = kKeyStatusInternalError;
cdmKeysStatus[kKeyId4] = kKeyStatusPending;
plugin.OnSessionKeysChange(cdmSessionId, cdmKeysStatus, true);
}
TEST_F(WVDrmPluginTest, GeneratesProvisioningNeededEvent) {