diff --git a/drm/1.2/vts/functional/drm_hal_common.cpp b/drm/1.2/vts/functional/drm_hal_common.cpp index b169268e29..8a68608933 100644 --- a/drm/1.2/vts/functional/drm_hal_common.cpp +++ b/drm/1.2/vts/functional/drm_hal_common.cpp @@ -176,6 +176,50 @@ hidl_array DrmHalTest::getVendorUUID() { return hidl_array(&uuid[0]); } +void DrmHalTest::provision() { + hidl_string certificateType; + hidl_string certificateAuthority; + hidl_vec provisionRequest; + hidl_string defaultUrl; + auto res = drmPlugin->getProvisionRequest_1_2( + certificateType, certificateAuthority, + [&](StatusV1_2 status, const hidl_vec& request, + const hidl_string& url) { + if (status == StatusV1_2::OK) { + EXPECT_NE(request.size(), 0u); + provisionRequest = request; + defaultUrl = url; + } else if (status == StatusV1_2::ERROR_DRM_CANNOT_HANDLE) { + EXPECT_EQ(0u, request.size()); + } + }); + EXPECT_OK(res); + + if (provisionRequest.size() > 0) { + vector response = vendorModule->handleProvisioningRequest( + provisionRequest, defaultUrl); + ASSERT_NE(0u, response.size()); + + auto res = drmPlugin->provideProvisionResponse( + response, [&](StatusV1_0 status, const hidl_vec&, + const hidl_vec&) { + EXPECT_EQ(StatusV1_0::OK, status); + }); + EXPECT_OK(res); + } +} + +SessionId DrmHalTest::openSession(SecurityLevel level, StatusV1_0 *err) { + SessionId sessionId; + auto res = drmPlugin->openSession_1_1(level, + [&](StatusV1_0 status, const hidl_vec &id) { + *err = status; + sessionId = id; + }); + EXPECT_OK(res); + return sessionId; +} + /** * Helper method to open a session and verify that a non-empty * session ID is returned diff --git a/drm/1.2/vts/functional/drm_hal_common.h b/drm/1.2/vts/functional/drm_hal_common.h index 03b1b87905..6b71aa4b01 100644 --- a/drm/1.2/vts/functional/drm_hal_common.h +++ b/drm/1.2/vts/functional/drm_hal_common.h @@ -36,14 +36,17 @@ using ::android::hardware::drm::V1_0::EventType; using ::android::hardware::drm::V1_0::KeyedVector; -using KeyStatusV1_0 = ::android::hardware::drm::V1_0::KeyStatus; using ::android::hardware::drm::V1_0::KeyType; using ::android::hardware::drm::V1_0::Mode; using ::android::hardware::drm::V1_0::Pattern; using ::android::hardware::drm::V1_0::SessionId; using ::android::hardware::drm::V1_0::SubSample; +using KeyStatusV1_0 = ::android::hardware::drm::V1_0::KeyStatus; +using StatusV1_0 = ::android::hardware::drm::V1_0::Status; + using ::android::hardware::drm::V1_1::ICryptoFactory; +using ::android::hardware::drm::V1_1::SecurityLevel; using StatusV1_2 = ::android::hardware::drm::V1_2::Status; @@ -77,6 +80,8 @@ class DrmHalTest : public ::testing::TestWithParam { protected: hidl_array getVendorUUID(); + void provision(); + SessionId openSession(SecurityLevel level, StatusV1_0* err); SessionId openSession(); void closeSession(const SessionId& sessionId); hidl_vec loadKeys(const SessionId& sessionId, diff --git a/drm/1.2/vts/functional/drm_hal_test.cpp b/drm/1.2/vts/functional/drm_hal_test.cpp index 48becc18bf..71296dce95 100644 --- a/drm/1.2/vts/functional/drm_hal_test.cpp +++ b/drm/1.2/vts/functional/drm_hal_test.cpp @@ -48,6 +48,7 @@ static const char* const kDrmErrorTestKey = "drmErrorTest"; static const char* const kDrmErrorInvalidState = "invalidState"; static const char* const kDrmErrorResourceContention = "resourceContention"; static const SecurityLevel kSwSecureCrypto = SecurityLevel::SW_SECURE_CRYPTO; +static const SecurityLevel kHwSecureAll = SecurityLevel::HW_SECURE_ALL; /** * Ensure drm factory supports module UUID Scheme @@ -97,35 +98,17 @@ TEST_P(DrmHalTest, BadMimeNotSupported) { * that is delivered back to the HAL. */ TEST_P(DrmHalTest, DoProvisioning) { - hidl_string certificateType; - hidl_string certificateAuthority; - hidl_vec provisionRequest; - hidl_string defaultUrl; - auto res = drmPlugin->getProvisionRequest_1_2( - certificateType, certificateAuthority, - [&](StatusV1_2 status, const hidl_vec& request, - const hidl_string& url) { - if (status == StatusV1_2::OK) { - EXPECT_NE(request.size(), 0u); - provisionRequest = request; - defaultUrl = url; - } else if (status == StatusV1_2::ERROR_DRM_CANNOT_HANDLE) { - EXPECT_EQ(0u, request.size()); - } - }); - EXPECT_OK(res); - - if (provisionRequest.size() > 0) { - vector response = vendorModule->handleProvisioningRequest( - provisionRequest, defaultUrl); - ASSERT_NE(0u, response.size()); - - auto res = drmPlugin->provideProvisionResponse( - response, [&](Status status, const hidl_vec&, - const hidl_vec&) { - EXPECT_EQ(Status::OK, status); - }); - EXPECT_OK(res); + for (auto level : {kHwSecureAll, kSwSecureCrypto}) { + StatusV1_0 err = StatusV1_0::OK; + auto sid = openSession(level, &err); + if (err == StatusV1_0::OK) { + closeSession(sid); + } else if (err == StatusV1_0::ERROR_DRM_CANNOT_HANDLE) { + continue; + } else { + EXPECT_EQ(StatusV1_0::ERROR_DRM_NOT_PROVISIONED, err); + provision(); + } } } @@ -416,7 +399,6 @@ TEST_P(DrmHalTest, EncryptedAesCtrSegmentTestNoKeys) { * Ensure clearkey drm factory doesn't support security level higher than supported */ TEST_P(DrmHalClearkeyTest, BadLevelNotSupported) { - const SecurityLevel kHwSecureAll = SecurityLevel::HW_SECURE_ALL; EXPECT_FALSE(drmFactory->isCryptoSchemeSupported_1_2(getVendorUUID(), kVideoMp4, kHwSecureAll)); }