Merge "make descrambler test optional since it may be provided through tuner module since cas@1.2"

This commit is contained in:
Henry Fang 2021-01-12 01:37:27 +00:00 committed by Android (Google) Code Review
commit 24dedfeb3c
5 changed files with 244 additions and 217 deletions

View file

@ -20,6 +20,8 @@ cc_test {
srcs: ["VtsHalCasV1_0TargetTest.cpp"],
static_libs: [
"android.hardware.cas@1.0",
"android.hardware.cas@1.1",
"android.hardware.cas@1.2",
"android.hardware.cas.native@1.0",
"android.hidl.allocator@1.0",
"android.hidl.memory@1.0",

View file

@ -22,6 +22,7 @@
#include <android/hardware/cas/1.0/IDescramblerBase.h>
#include <android/hardware/cas/1.0/IMediaCasService.h>
#include <android/hardware/cas/1.0/types.h>
#include <android/hardware/cas/1.2/IMediaCasService.h>
#include <android/hardware/cas/native/1.0/IDescrambler.h>
#include <android/hardware/cas/native/1.0/types.h>
#include <binder/MemoryDealer.h>
@ -212,6 +213,10 @@ void MediaCasListener::testEventEcho(sp<ICas>& mediaCas, int32_t& event, int32_t
class MediaCasHidlTest : public testing::TestWithParam<std::string> {
public:
virtual void SetUp() override {
if (android::hardware::cas::V1_2::IMediaCasService::getService(GetParam()) == nullptr) {
ALOGI("Descrambler is need to be tested before cas@1.2.");
mIsTestDescrambler = true;
}
mService = IMediaCasService::getService(GetParam());
ASSERT_NE(mService, nullptr);
}
@ -226,6 +231,7 @@ class MediaCasHidlTest : public testing::TestWithParam<std::string> {
sp<ICas> mMediaCas;
sp<IDescramblerBase> mDescramblerBase;
sp<MediaCasListener> mCasListener;
bool mIsTestDescrambler = false;
typedef struct _OobInputTestParams {
const SubSample* subSamples;
uint32_t numSubSamples;
@ -270,8 +276,14 @@ class MediaCasHidlTest : public testing::TestWithParam<std::string> {
auto descramblerStatus = mService->createDescrambler(caSystemId);
if (!descramblerStatus.isOk()) {
return ::testing::AssertionFailure();
if (mIsTestDescrambler) {
return ::testing::AssertionFailure();
} else {
ALOGI("Skip Descrambler test since it's not required in cas@1.2.");
return ::testing::AssertionSuccess();
}
}
mIsTestDescrambler = true;
mDescramblerBase = descramblerStatus;
return ::testing::AssertionResult(mDescramblerBase != nullptr);
}
@ -494,14 +506,15 @@ TEST_P(MediaCasHidlTest, TestClearKeyApis) {
returnStatus = mMediaCas->setSessionPrivateData(streamSessionId, hidlPvtData);
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
if (mIsTestDescrambler) {
returnStatus = mDescramblerBase->setMediaCasSession(sessionId);
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
returnStatus = mDescramblerBase->setMediaCasSession(sessionId);
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
returnStatus = mDescramblerBase->setMediaCasSession(streamSessionId);
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
returnStatus = mDescramblerBase->setMediaCasSession(streamSessionId);
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
}
hidl_vec<uint8_t> hidlNullPtr;
hidlNullPtr.setToExternal(static_cast<uint8_t*>(nullptr), 0);
@ -543,29 +556,32 @@ TEST_P(MediaCasHidlTest, TestClearKeyApis) {
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
EXPECT_FALSE(mDescramblerBase->requiresSecureDecoderComponent("video/avc"));
if (mIsTestDescrambler) {
EXPECT_FALSE(mDescramblerBase->requiresSecureDecoderComponent("video/avc"));
sp<IDescrambler> descrambler;
descrambler = IDescrambler::castFrom(mDescramblerBase);
ASSERT_NE(descrambler, nullptr);
sp<IDescrambler> descrambler;
descrambler = IDescrambler::castFrom(mDescramblerBase);
ASSERT_NE(descrambler, nullptr);
Status descrambleStatus = Status::OK;
sp<IMemory> dataMemory;
Status descrambleStatus = Status::OK;
sp<IMemory> dataMemory;
ASSERT_TRUE(descrambleTestInputBuffer(descrambler, &descrambleStatus, &dataMemory));
EXPECT_EQ(Status::OK, descrambleStatus);
ASSERT_TRUE(descrambleTestInputBuffer(descrambler, &descrambleStatus, &dataMemory));
EXPECT_EQ(Status::OK, descrambleStatus);
ASSERT_NE(nullptr, dataMemory.get());
uint8_t* opBuffer = static_cast<uint8_t*>(static_cast<void*>(dataMemory->unsecurePointer()));
ASSERT_NE(nullptr, dataMemory.get());
uint8_t* opBuffer =
static_cast<uint8_t*>(static_cast<void*>(dataMemory->unsecurePointer()));
int compareResult =
memcmp(static_cast<const void*>(opBuffer), static_cast<const void*>(kOutRefBinaryBuffer),
sizeof(kOutRefBinaryBuffer));
EXPECT_EQ(0, compareResult);
int compareResult =
memcmp(static_cast<const void*>(opBuffer),
static_cast<const void*>(kOutRefBinaryBuffer), sizeof(kOutRefBinaryBuffer));
EXPECT_EQ(0, compareResult);
returnStatus = mDescramblerBase->release();
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
returnStatus = mDescramblerBase->release();
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
}
returnStatus = mMediaCas->release();
EXPECT_TRUE(returnStatus.isOk());
@ -590,13 +606,15 @@ TEST_P(MediaCasHidlTest, TestClearKeySessionClosedAfterRelease) {
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
returnStatus = mDescramblerBase->setMediaCasSession(sessionId);
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::ERROR_CAS_SESSION_NOT_OPENED, returnStatus);
if (mIsTestDescrambler) {
returnStatus = mDescramblerBase->setMediaCasSession(sessionId);
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::ERROR_CAS_SESSION_NOT_OPENED, returnStatus);
returnStatus = mDescramblerBase->setMediaCasSession(streamSessionId);
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::ERROR_CAS_SESSION_NOT_OPENED, returnStatus);
returnStatus = mDescramblerBase->setMediaCasSession(streamSessionId);
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::ERROR_CAS_SESSION_NOT_OPENED, returnStatus);
}
}
TEST_P(MediaCasHidlTest, TestClearKeyErrors) {
@ -654,38 +672,40 @@ TEST_P(MediaCasHidlTest, TestClearKeyErrors) {
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::ERROR_CAS_UNKNOWN, returnStatus);
/*
* Test MediaDescrambler error codes
*/
// setMediaCasSession should fail with an invalid session id
returnStatus = mDescramblerBase->setMediaCasSession(invalidSessionId);
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::ERROR_CAS_SESSION_NOT_OPENED, returnStatus);
if (mIsTestDescrambler) {
/*
* Test MediaDescrambler error codes
*/
// setMediaCasSession should fail with an invalid session id
returnStatus = mDescramblerBase->setMediaCasSession(invalidSessionId);
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::ERROR_CAS_SESSION_NOT_OPENED, returnStatus);
// descramble should fail without a valid session
sp<IDescrambler> descrambler;
descrambler = IDescrambler::castFrom(mDescramblerBase);
ASSERT_NE(descrambler, nullptr);
// descramble should fail without a valid session
sp<IDescrambler> descrambler;
descrambler = IDescrambler::castFrom(mDescramblerBase);
ASSERT_NE(descrambler, nullptr);
Status descrambleStatus = Status::OK;
sp<IMemory> dataMemory;
Status descrambleStatus = Status::OK;
sp<IMemory> dataMemory;
ASSERT_TRUE(descrambleTestInputBuffer(descrambler, &descrambleStatus, &dataMemory));
EXPECT_EQ(Status::ERROR_CAS_DECRYPT_UNIT_NOT_INITIALIZED, descrambleStatus);
ASSERT_TRUE(descrambleTestInputBuffer(descrambler, &descrambleStatus, &dataMemory));
EXPECT_EQ(Status::ERROR_CAS_DECRYPT_UNIT_NOT_INITIALIZED, descrambleStatus);
// Now set a valid session, should still fail because no valid ecm is processed
returnStatus = mDescramblerBase->setMediaCasSession(sessionId);
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
// Now set a valid session, should still fail because no valid ecm is processed
returnStatus = mDescramblerBase->setMediaCasSession(sessionId);
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
ASSERT_TRUE(descrambleTestInputBuffer(descrambler, &descrambleStatus, &dataMemory));
EXPECT_EQ(Status::ERROR_CAS_DECRYPT, descrambleStatus);
ASSERT_TRUE(descrambleTestInputBuffer(descrambler, &descrambleStatus, &dataMemory));
EXPECT_EQ(Status::ERROR_CAS_DECRYPT, descrambleStatus);
// Verify that requiresSecureDecoderComponent handles empty mime
EXPECT_FALSE(mDescramblerBase->requiresSecureDecoderComponent(""));
// Verify that requiresSecureDecoderComponent handles empty mime
EXPECT_FALSE(mDescramblerBase->requiresSecureDecoderComponent(""));
// Verify that requiresSecureDecoderComponent handles invalid mime
EXPECT_FALSE(mDescramblerBase->requiresSecureDecoderComponent("bad"));
// Verify that requiresSecureDecoderComponent handles invalid mime
EXPECT_FALSE(mDescramblerBase->requiresSecureDecoderComponent("bad"));
}
}
TEST_P(MediaCasHidlTest, TestClearKeyOobFails) {
@ -700,9 +720,11 @@ TEST_P(MediaCasHidlTest, TestClearKeyOobFails) {
std::vector<uint8_t> sessionId;
ASSERT_TRUE(openCasSession(&sessionId));
returnStatus = mDescramblerBase->setMediaCasSession(sessionId);
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
if (mIsTestDescrambler) {
returnStatus = mDescramblerBase->setMediaCasSession(sessionId);
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
}
hidl_vec<uint8_t> hidlEcm;
hidlEcm.setToExternal(const_cast<uint8_t*>(kEcmBinaryBuffer), sizeof(kEcmBinaryBuffer));
@ -710,126 +732,104 @@ TEST_P(MediaCasHidlTest, TestClearKeyOobFails) {
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
sp<IDescrambler> descrambler = IDescrambler::castFrom(mDescramblerBase);
ASSERT_NE(nullptr, descrambler.get());
if (mIsTestDescrambler) {
sp<IDescrambler> descrambler = IDescrambler::castFrom(mDescramblerBase);
ASSERT_NE(nullptr, descrambler.get());
Status descrambleStatus = Status::OK;
Status descrambleStatus = Status::OK;
// test invalid src buffer offset
ASSERT_TRUE(descrambleTestOobInput(
descrambler,
&descrambleStatus,
{
.subSamples = kSubSamples,
.numSubSamples = sizeof(kSubSamples)/sizeof(SubSample),
.imemSizeActual = sizeof(kInBinaryBuffer),
.imemOffset = 0xcccccc,
.imemSize = sizeof(kInBinaryBuffer),
.srcOffset = 0,
.dstOffset = 0
}));
EXPECT_EQ(Status::BAD_VALUE, descrambleStatus);
// test invalid src buffer offset
ASSERT_TRUE(
descrambleTestOobInput(descrambler, &descrambleStatus,
{.subSamples = kSubSamples,
.numSubSamples = sizeof(kSubSamples) / sizeof(SubSample),
.imemSizeActual = sizeof(kInBinaryBuffer),
.imemOffset = 0xcccccc,
.imemSize = sizeof(kInBinaryBuffer),
.srcOffset = 0,
.dstOffset = 0}));
EXPECT_EQ(Status::BAD_VALUE, descrambleStatus);
// test invalid src buffer size
ASSERT_TRUE(descrambleTestOobInput(
descrambler,
&descrambleStatus,
{
.subSamples = kSubSamples,
.numSubSamples = sizeof(kSubSamples)/sizeof(SubSample),
.imemSizeActual = sizeof(kInBinaryBuffer),
.imemOffset = 0,
.imemSize = 0xcccccc,
.srcOffset = 0,
.dstOffset = 0
}));
EXPECT_EQ(Status::BAD_VALUE, descrambleStatus);
// test invalid src buffer size
ASSERT_TRUE(
descrambleTestOobInput(descrambler, &descrambleStatus,
{.subSamples = kSubSamples,
.numSubSamples = sizeof(kSubSamples) / sizeof(SubSample),
.imemSizeActual = sizeof(kInBinaryBuffer),
.imemOffset = 0,
.imemSize = 0xcccccc,
.srcOffset = 0,
.dstOffset = 0}));
EXPECT_EQ(Status::BAD_VALUE, descrambleStatus);
// test invalid src buffer size
ASSERT_TRUE(descrambleTestOobInput(
descrambler,
&descrambleStatus,
{
.subSamples = kSubSamples,
.numSubSamples = sizeof(kSubSamples)/sizeof(SubSample),
.imemSizeActual = sizeof(kInBinaryBuffer),
.imemOffset = 1,
.imemSize = (uint64_t)-1,
.srcOffset = 0,
.dstOffset = 0
}));
EXPECT_EQ(Status::BAD_VALUE, descrambleStatus);
// test invalid src buffer size
ASSERT_TRUE(
descrambleTestOobInput(descrambler, &descrambleStatus,
{.subSamples = kSubSamples,
.numSubSamples = sizeof(kSubSamples) / sizeof(SubSample),
.imemSizeActual = sizeof(kInBinaryBuffer),
.imemOffset = 1,
.imemSize = (uint64_t)-1,
.srcOffset = 0,
.dstOffset = 0}));
EXPECT_EQ(Status::BAD_VALUE, descrambleStatus);
// test invalid srcOffset
ASSERT_TRUE(descrambleTestOobInput(
descrambler,
&descrambleStatus,
{
.subSamples = kSubSamples,
.numSubSamples = sizeof(kSubSamples)/sizeof(SubSample),
.imemSizeActual = sizeof(kInBinaryBuffer),
.imemOffset = 0,
.imemSize = sizeof(kInBinaryBuffer),
.srcOffset = 0xcccccc,
.dstOffset = 0
}));
EXPECT_EQ(Status::BAD_VALUE, descrambleStatus);
// test invalid srcOffset
ASSERT_TRUE(
descrambleTestOobInput(descrambler, &descrambleStatus,
{.subSamples = kSubSamples,
.numSubSamples = sizeof(kSubSamples) / sizeof(SubSample),
.imemSizeActual = sizeof(kInBinaryBuffer),
.imemOffset = 0,
.imemSize = sizeof(kInBinaryBuffer),
.srcOffset = 0xcccccc,
.dstOffset = 0}));
EXPECT_EQ(Status::BAD_VALUE, descrambleStatus);
// test invalid dstOffset
ASSERT_TRUE(descrambleTestOobInput(
descrambler,
&descrambleStatus,
{
.subSamples = kSubSamples,
.numSubSamples = sizeof(kSubSamples)/sizeof(SubSample),
.imemSizeActual = sizeof(kInBinaryBuffer),
.imemOffset = 0,
.imemSize = sizeof(kInBinaryBuffer),
.srcOffset = 0,
.dstOffset = 0xcccccc
}));
EXPECT_EQ(Status::BAD_VALUE, descrambleStatus);
// test invalid dstOffset
ASSERT_TRUE(
descrambleTestOobInput(descrambler, &descrambleStatus,
{.subSamples = kSubSamples,
.numSubSamples = sizeof(kSubSamples) / sizeof(SubSample),
.imemSizeActual = sizeof(kInBinaryBuffer),
.imemOffset = 0,
.imemSize = sizeof(kInBinaryBuffer),
.srcOffset = 0,
.dstOffset = 0xcccccc}));
EXPECT_EQ(Status::BAD_VALUE, descrambleStatus);
// test detection of oob subsample sizes
const SubSample invalidSubSamples1[] =
{{162, 0}, {0, 184}, {0, 0xdddddd}};
// test detection of oob subsample sizes
const SubSample invalidSubSamples1[] = {{162, 0}, {0, 184}, {0, 0xdddddd}};
ASSERT_TRUE(descrambleTestOobInput(
descrambler,
&descrambleStatus,
{
.subSamples = invalidSubSamples1,
.numSubSamples = sizeof(invalidSubSamples1)/sizeof(SubSample),
.imemSizeActual = sizeof(kInBinaryBuffer),
.imemOffset = 0,
.imemSize = sizeof(kInBinaryBuffer),
.srcOffset = 0,
.dstOffset = 0
}));
EXPECT_EQ(Status::BAD_VALUE, descrambleStatus);
ASSERT_TRUE(descrambleTestOobInput(
descrambler, &descrambleStatus,
{.subSamples = invalidSubSamples1,
.numSubSamples = sizeof(invalidSubSamples1) / sizeof(SubSample),
.imemSizeActual = sizeof(kInBinaryBuffer),
.imemOffset = 0,
.imemSize = sizeof(kInBinaryBuffer),
.srcOffset = 0,
.dstOffset = 0}));
EXPECT_EQ(Status::BAD_VALUE, descrambleStatus);
// test detection of overflowing subsample sizes
const SubSample invalidSubSamples2[] =
{{162, 0}, {0, 184}, {2, (uint32_t)-1}};
// test detection of overflowing subsample sizes
const SubSample invalidSubSamples2[] = {{162, 0}, {0, 184}, {2, (uint32_t)-1}};
ASSERT_TRUE(descrambleTestOobInput(
descrambler,
&descrambleStatus,
{
.subSamples = invalidSubSamples2,
.numSubSamples = sizeof(invalidSubSamples2)/sizeof(SubSample),
.imemSizeActual = sizeof(kInBinaryBuffer),
.imemOffset = 0,
.imemSize = sizeof(kInBinaryBuffer),
.srcOffset = 0,
.dstOffset = 0
}));
EXPECT_EQ(Status::BAD_VALUE, descrambleStatus);
returnStatus = mDescramblerBase->release();
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
ASSERT_TRUE(descrambleTestOobInput(
descrambler, &descrambleStatus,
{.subSamples = invalidSubSamples2,
.numSubSamples = sizeof(invalidSubSamples2) / sizeof(SubSample),
.imemSizeActual = sizeof(kInBinaryBuffer),
.imemOffset = 0,
.imemSize = sizeof(kInBinaryBuffer),
.srcOffset = 0,
.dstOffset = 0}));
EXPECT_EQ(Status::BAD_VALUE, descrambleStatus);
returnStatus = mDescramblerBase->release();
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
}
returnStatus = mMediaCas->release();
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);

View file

@ -21,6 +21,7 @@ cc_test {
static_libs: [
"android.hardware.cas@1.0",
"android.hardware.cas@1.1",
"android.hardware.cas@1.2",
"android.hardware.cas.native@1.0",
"android.hidl.allocator@1.0",
"android.hidl.memory@1.0",

View file

@ -22,6 +22,7 @@
#include <android/hardware/cas/1.1/ICas.h>
#include <android/hardware/cas/1.1/ICasListener.h>
#include <android/hardware/cas/1.1/IMediaCasService.h>
#include <android/hardware/cas/1.2/IMediaCasService.h>
#include <android/hardware/cas/native/1.0/IDescrambler.h>
#include <android/hardware/cas/native/1.0/types.h>
#include <binder/MemoryDealer.h>
@ -255,6 +256,10 @@ void MediaCasListener::testSessionEventEcho(sp<ICas>& mediaCas, const hidl_vec<u
class MediaCasHidlTest : public testing::TestWithParam<std::string> {
public:
virtual void SetUp() override {
if (android::hardware::cas::V1_2::IMediaCasService::getService(GetParam()) == nullptr) {
ALOGI("Descrambler is need to be tested before cas@1.2.");
mIsTestDescrambler = true;
}
mService = IMediaCasService::getService(GetParam());
ASSERT_NE(mService, nullptr);
}
@ -269,6 +274,7 @@ class MediaCasHidlTest : public testing::TestWithParam<std::string> {
sp<ICas> mMediaCas;
sp<IDescramblerBase> mDescramblerBase;
sp<MediaCasListener> mCasListener;
bool mIsTestDescrambler = false;
typedef struct _OobInputTestParams {
const SubSample* subSamples;
uint32_t numSubSamples;
@ -311,8 +317,15 @@ class MediaCasHidlTest : public testing::TestWithParam<std::string> {
auto descramblerStatus = mService->createDescrambler(caSystemId);
if (!descramblerStatus.isOk()) {
return ::testing::AssertionFailure();
if (mIsTestDescrambler) {
return ::testing::AssertionFailure();
} else {
ALOGI("Skip Descrambler test since it's not required in cas@1.2.");
return ::testing::AssertionSuccess();
}
}
mIsTestDescrambler = true;
mDescramblerBase = descramblerStatus;
return ::testing::AssertionResult(mDescramblerBase != nullptr);
}
@ -468,13 +481,15 @@ TEST_P(MediaCasHidlTest, TestClearKeyApisWithSession) {
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
returnStatus = mDescramblerBase->setMediaCasSession(sessionId);
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
if (mIsTestDescrambler) {
returnStatus = mDescramblerBase->setMediaCasSession(sessionId);
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
returnStatus = mDescramblerBase->setMediaCasSession(streamSessionId);
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
returnStatus = mDescramblerBase->setMediaCasSession(streamSessionId);
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
}
hidl_vec<uint8_t> hidlNullPtr;
hidlNullPtr.setToExternal(static_cast<uint8_t*>(nullptr), 0);
@ -518,29 +533,31 @@ TEST_P(MediaCasHidlTest, TestClearKeyApisWithSession) {
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
EXPECT_FALSE(mDescramblerBase->requiresSecureDecoderComponent("video/avc"));
if (mIsTestDescrambler) {
EXPECT_FALSE(mDescramblerBase->requiresSecureDecoderComponent("video/avc"));
sp<IDescrambler> descrambler;
descrambler = IDescrambler::castFrom(mDescramblerBase);
ASSERT_NE(descrambler, nullptr);
sp<IDescrambler> descrambler;
descrambler = IDescrambler::castFrom(mDescramblerBase);
ASSERT_NE(descrambler, nullptr);
Status descrambleStatus = Status::OK;
sp<IMemory> dataMemory;
Status descrambleStatus = Status::OK;
sp<IMemory> dataMemory;
ASSERT_TRUE(descrambleTestInputBuffer(descrambler, &descrambleStatus, &dataMemory));
EXPECT_EQ(Status::OK, descrambleStatus);
ASSERT_TRUE(descrambleTestInputBuffer(descrambler, &descrambleStatus, &dataMemory));
EXPECT_EQ(Status::OK, descrambleStatus);
ASSERT_NE(nullptr, dataMemory.get());
uint8_t* opBuffer = static_cast<uint8_t*>(static_cast<void*>(dataMemory->unsecurePointer()));
ASSERT_NE(nullptr, dataMemory.get());
uint8_t* opBuffer = static_cast<uint8_t*>(static_cast<void*>(dataMemory->unsecurePointer()));
int compareResult =
memcmp(static_cast<const void*>(opBuffer),
static_cast<const void*>(kOutRefBinaryBuffer), sizeof(kOutRefBinaryBuffer));
EXPECT_EQ(0, compareResult);
int compareResult =
memcmp(static_cast<const void*>(opBuffer),
static_cast<const void*>(kOutRefBinaryBuffer), sizeof(kOutRefBinaryBuffer));
EXPECT_EQ(0, compareResult);
returnStatus = mDescramblerBase->release();
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
returnStatus = mDescramblerBase->release();
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
}
returnStatus = mMediaCas->release();
EXPECT_TRUE(returnStatus.isOk());

View file

@ -311,6 +311,7 @@ class MediaCasHidlTest : public testing::TestWithParam<std::string> {
sp<ICas> mMediaCas;
sp<IDescramblerBase> mDescramblerBase;
sp<MediaCasListener> mCasListener;
bool mIsTestDescrambler = false;
typedef struct _OobInputTestParams {
const SubSample* subSamples;
uint32_t numSubSamples;
@ -355,8 +356,11 @@ class MediaCasHidlTest : public testing::TestWithParam<std::string> {
auto descramblerStatus = mService->createDescrambler(caSystemId);
if (!descramblerStatus.isOk()) {
return ::testing::AssertionFailure();
ALOGI("Skip Descrambler test since it's not required in cas@1.2.");
return ::testing::AssertionSuccess();
}
mIsTestDescrambler = true;
mDescramblerBase = descramblerStatus;
return ::testing::AssertionResult(mDescramblerBase != nullptr);
}
@ -512,14 +516,15 @@ TEST_P(MediaCasHidlTest, TestClearKeyApisWithSession) {
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
returnStatus = mDescramblerBase->setMediaCasSession(sessionId);
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
returnStatus = mDescramblerBase->setMediaCasSession(streamSessionId);
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
if (mIsTestDescrambler) {
returnStatus = mDescramblerBase->setMediaCasSession(sessionId);
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
returnStatus = mDescramblerBase->setMediaCasSession(streamSessionId);
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
}
hidl_vec<uint8_t> hidlNullPtr;
hidlNullPtr.setToExternal(static_cast<uint8_t*>(nullptr), 0);
returnStatus = mMediaCas->refreshEntitlements(3, hidlNullPtr);
@ -566,29 +571,31 @@ TEST_P(MediaCasHidlTest, TestClearKeyApisWithSession) {
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
EXPECT_FALSE(mDescramblerBase->requiresSecureDecoderComponent("video/avc"));
if (mIsTestDescrambler) {
EXPECT_FALSE(mDescramblerBase->requiresSecureDecoderComponent("video/avc"));
sp<IDescrambler> descrambler;
descrambler = IDescrambler::castFrom(mDescramblerBase);
ASSERT_NE(descrambler, nullptr);
sp<IDescrambler> descrambler;
descrambler = IDescrambler::castFrom(mDescramblerBase);
ASSERT_NE(descrambler, nullptr);
Status descrambleStatus = Status::OK;
sp<IMemory> dataMemory;
Status descrambleStatus = Status::OK;
sp<IMemory> dataMemory;
ASSERT_TRUE(descrambleTestInputBuffer(descrambler, &descrambleStatus, &dataMemory));
EXPECT_EQ(Status::OK, descrambleStatus);
ASSERT_TRUE(descrambleTestInputBuffer(descrambler, &descrambleStatus, &dataMemory));
EXPECT_EQ(Status::OK, descrambleStatus);
ASSERT_NE(nullptr, dataMemory.get());
uint8_t* opBuffer = static_cast<uint8_t*>(static_cast<void*>(dataMemory->unsecurePointer()));
ASSERT_NE(nullptr, dataMemory.get());
uint8_t* opBuffer = static_cast<uint8_t*>(static_cast<void*>(dataMemory->unsecurePointer()));
int compareResult =
memcmp(static_cast<const void*>(opBuffer),
static_cast<const void*>(kOutRefBinaryBuffer), sizeof(kOutRefBinaryBuffer));
EXPECT_EQ(0, compareResult);
int compareResult =
memcmp(static_cast<const void*>(opBuffer),
static_cast<const void*>(kOutRefBinaryBuffer), sizeof(kOutRefBinaryBuffer));
EXPECT_EQ(0, compareResult);
returnStatus = mDescramblerBase->release();
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
returnStatus = mDescramblerBase->release();
EXPECT_TRUE(returnStatus.isOk());
EXPECT_EQ(Status::OK, returnStatus);
}
returnStatus = mMediaCas->release();
EXPECT_TRUE(returnStatus.isOk());