Upgrade widevine HIDL service to v1.1.

Merged from http://go/wvgerrit/44803.

Upgrade HIDL service to v1.1 and implements new 1.1 media API.

Test: Netflix and Play Movies & TV
  streaming and offline playback

Test: GTS WidevineH264PlaybackTests test
  e.g. ANDROID_BUILD_TOP= ./android-gts/tools/gts-tradefed run gts -m GtsMediaTestCases
  --test com.google.android.media.gts.WidevineH264PlaybackTests#testL1With480P30

Test: GTS MediaDrmTest tests
  e.g. ANDROID_BUILD_TOP= ./android-gts/tools/gts-tradefed run gts -m GtsMediaTestCases
  --test com.google.android.media.gts.MediaDrmTest#testWidevineApi28

Test: unit tests

bug: 69674645
Change-Id: I91e7e43f9178b61a531e846beffb5f5c17050a3c
This commit is contained in:
Edwin Wong
2018-02-06 10:53:10 -08:00
parent efc008c5a1
commit bc66aebfe2
24 changed files with 447 additions and 89 deletions

View File

@@ -90,6 +90,7 @@ LOCAL_STATIC_LIBRARIES := \
LOCAL_SHARED_LIBRARIES := \
android.hardware.drm@1.0 \
android.hardware.drm@1.1 \
android.hidl.memory@1.0 \
libbinder \
libcutils \

View File

@@ -5,9 +5,9 @@
#define LOG_TAG "WVDrmPluginTest"
#include <utils/Log.h>
#include <android/hardware/drm/1.0/types.h>
#include <android/hardware/drm/1.0/IDrmPlugin.h>
#include <android/hardware/drm/1.0/IDrmPluginListener.h>
#include <android/hardware/drm/1.1/IDrmPlugin.h>
#include <android/hardware/drm/1.1/types.h>
#include <stdio.h>
#include <ostream>
@@ -30,14 +30,14 @@
namespace wvdrm {
namespace hardware {
namespace drm {
namespace V1_0 {
namespace V1_1 {
namespace widevine {
using ::android::hardware::drm::V1_0::EventType;
using ::android::hardware::drm::V1_0::KeyStatus;
using ::android::hardware::drm::V1_0::KeyStatusType;
using ::android::hardware::drm::V1_0::Status;
using ::android::hardware::drm::V1_0::widevine::toHidlVec;
using ::android::hardware::drm::V1_1::widevine::toHidlVec;
using ::android::hardware::hidl_vec;
using ::testing::_;
@@ -55,6 +55,7 @@ using ::testing::NotNull;
using ::testing::Pointee;
using ::testing::SaveArg;
using ::testing::SetArgPointee;
using ::testing::SetArrayArgument;
using ::testing::StrictMock;
using ::testing::StrEq;
using ::testing::Test;
@@ -107,7 +108,6 @@ using wvcdm::QUERY_KEY_SYSTEM_ID;
using wvcdm::QUERY_KEY_WVCDM_VERSION;
using wvcdm::QUERY_VALUE_SECURITY_LEVEL_L1;
using wvcdm::QUERY_VALUE_SECURITY_LEVEL_L3;
using wvcdm::SecurityLevel;
using wvcdm::SESSION_ID_PREFIX;
using wvcdm::WvCdmEventListener;
@@ -159,7 +159,7 @@ class MockCDM : public WvContentDecryptionModule {
MOCK_METHOD2(RestoreKey, CdmResponseType(const CdmSessionId&,
const CdmKeySetId&));
MOCK_METHOD3(QueryStatus, CdmResponseType(SecurityLevel, const std::string&,
MOCK_METHOD3(QueryStatus, CdmResponseType(wvcdm::SecurityLevel, const std::string&,
std::string*));
MOCK_METHOD2(QueryKeyStatus, CdmResponseType(const CdmSessionId&,
@@ -309,7 +309,7 @@ TEST_F(WVDrmPluginTest, OpensSessions) {
.WillOnce(DoAll(SetArgPointee<4>(cdmSessionId),
testing::Return(wvcdm::NO_ERROR)));
// Provide expected behavior when plugin requests session control info
// Provide expected mock behavior
EXPECT_CALL(*cdm, QueryOemCryptoSessionId(cdmSessionId, _))
.Times(AtLeast(1))
.WillRepeatedly(Invoke(setSessionIdOnMap<4>));
@@ -326,6 +326,51 @@ TEST_F(WVDrmPluginTest, OpensSessions) {
});
EXPECT_THAT(sessionId, ElementsAreArray(sessionIdRaw, kSessionIdSize));
Status status = plugin.closeSession(toHidlVec(sessionId));
ASSERT_EQ(Status::OK, status);
}
TEST_F(WVDrmPluginTest, OpensSessions_1_1) {
android::sp<StrictMock<MockCDM>> cdm = new StrictMock<MockCDM>();
StrictMock<MockCrypto> crypto;
std::string appPackageName;
const CdmClientPropertySet* propertySet = NULL;
// Provide expected mock behavior
EXPECT_CALL(*cdm, QueryStatus(_, QUERY_KEY_SECURITY_LEVEL, _))
.WillOnce(DoAll(SetArgPointee<2>(QUERY_VALUE_SECURITY_LEVEL_L1),
testing::Return(wvcdm::NO_ERROR)))
.WillOnce(DoAll(SetArgPointee<2>(QUERY_VALUE_SECURITY_LEVEL_L3),
testing::Return(wvcdm::NO_ERROR)));
EXPECT_CALL(*cdm, OpenSession(_, _, _, _, _))
.WillRepeatedly(DoAll(SetArgPointee<4>(cdmSessionId),
SaveArg<1>(&propertySet),
testing::Return(wvcdm::NO_ERROR)));
EXPECT_CALL(*cdm, QueryOemCryptoSessionId(cdmSessionId, _))
.WillRepeatedly(Invoke(setSessionIdOnMap<4>));
EXPECT_CALL(*cdm, CloseSession(_))
.Times(AtLeast(0));
WVDrmPlugin plugin(cdm.get(), appPackageName, &crypto, false);
Status status = plugin.setPropertyString(hidl_string("securityLevel"), hidl_string("L1"));
ASSERT_EQ(Status::OK, status);
plugin.openSession_1_1(android::hardware::drm::V1_1::SecurityLevel::SW_SECURE_CRYPTO,
[&](Status status, hidl_vec<uint8_t> hSessionId) {
ASSERT_EQ(Status::OK, status);
sessionId.clear();
sessionId.assign(hSessionId.data(), hSessionId.data() + hSessionId.size());
});
ASSERT_THAT(propertySet, NotNull());
EXPECT_THAT(sessionId, ElementsAreArray(sessionIdRaw, kSessionIdSize));
status = plugin.closeSession(toHidlVec(sessionId));
ASSERT_EQ(Status::OK, status);
}
TEST_F(WVDrmPluginTest, ClosesSessions) {
@@ -2453,7 +2498,7 @@ TEST_F(WVDrmPluginTest, AllowsStoringOfSessionSharingId) {
}
} // namespace widevine
} // namespace V1_0
} // namespace V1_1
} // namespace drm
} // namespace hardware
} // namespace wvdrm