aidl drm: independent min/max SecurityLevel for each supported mime
Bug: 219528925
Test: atest MediaDrmTest.testIsCryptoSchemeSupportedForSecurityLevels
Change-Id: I9dcd786fe921c6ed4ac49bba5a6dddf887404df3
Merged-In: I9dcd786fe921c6ed4ac49bba5a6dddf887404df3
diff --git a/drm/aidl/vts/drm_hal_common.cpp b/drm/aidl/vts/drm_hal_common.cpp
index 9b315f4..de7dc28 100644
--- a/drm/aidl/vts/drm_hal_common.cpp
+++ b/drm/aidl/vts/drm_hal_common.cpp
@@ -256,7 +256,7 @@
std::vector<uint8_t> DrmHalTest::getVendorUUID() {
if (vendorModule == nullptr) {
ALOGW("vendor module for %s not found", GetParamService().c_str());
- return {};
+ return std::vector<uint8_t>(16);
}
return vendorModule->getUUID();
}
@@ -268,17 +268,22 @@
if (!ret.isOk() || !std::count(schemes.uuids.begin(), schemes.uuids.end(), uuid)) {
return false;
}
- if (level > schemes.maxLevel || level < schemes.minLevel) {
- if (level != SecurityLevel::DEFAULT && level != SecurityLevel::UNKNOWN) {
- return false;
+ if (mime.empty()) {
+ EXPECT_THAT(level, AnyOf(Eq(SecurityLevel::DEFAULT), Eq(SecurityLevel::UNKNOWN)));
+ return true;
+ }
+ for (auto ct : schemes.mimeTypes) {
+ if (ct.mime != mime) {
+ continue;
+ }
+ if (level == SecurityLevel::DEFAULT || level == SecurityLevel::UNKNOWN) {
+ return true;
+ }
+ if (level <= ct.maxLevel && level >= ct.minLevel) {
+ return true;
}
}
- if (!mime.empty()) {
- if (!std::count(schemes.mimeTypes.begin(), schemes.mimeTypes.end(), mime)) {
- return false;
- }
- }
- return true;
+ return false;
}
void DrmHalTest::provision() {
diff --git a/drm/aidl/vts/drm_hal_test.cpp b/drm/aidl/vts/drm_hal_test.cpp
index 266ea39..14b3acf 100644
--- a/drm/aidl/vts/drm_hal_test.cpp
+++ b/drm/aidl/vts/drm_hal_test.cpp
@@ -100,6 +100,19 @@
}
/**
+ * getSupportedCryptoSchemes confidence check
+ */
+TEST_P(DrmHalTest, SupportedCryptoSchemes) {
+ aidl::android::hardware::drm::CryptoSchemes schemes{};
+ auto result = drmFactory->getSupportedCryptoSchemes(&schemes);
+ EXPECT_FALSE(schemes.uuids.empty());
+ for(auto ct : schemes.mimeTypes) {
+ EXPECT_LE(ct.minLevel, ct.maxLevel);
+ }
+ EXPECT_OK(result);
+}
+
+/**
* DrmPlugin tests
*/
diff --git a/drm/aidl/vts/include/drm_hal_common.h b/drm/aidl/vts/include/drm_hal_common.h
index 2c7e514..d493bed 100644
--- a/drm/aidl/vts/include/drm_hal_common.h
+++ b/drm/aidl/vts/include/drm_hal_common.h
@@ -59,6 +59,9 @@
namespace drm {
namespace vts {
+using ::testing::AnyOf;
+using ::testing::Eq;
+
::aidl::android::hardware::drm::Status DrmErr(const ::ndk::ScopedAStatus& ret);
std::string HalBaseName(const std::string& fullname);
std::string HalFullName(const std::string& iface, const std::string& basename);