aidl drm: independent min/max SecurityLevel for each supported mime

Interface change 16873294

[Merge of go/wvgerrit/145969]

Bug: 219528925
Test: atest MediaDrmTest.testIsCryptoSchemeSupportedForSecurityLevels
Change-Id: I5c0d511358c394aff6885135de851395f199dac0
Merged-In: I5c0d511358c394aff6885135de851395f199dac0
This commit is contained in:
Robert Shih
2022-02-14 16:11:48 -08:00
parent 93b5514a27
commit f2d89aaf77

View File

@@ -35,6 +35,7 @@ using std::vector;
using ::aidl::android::hardware::drm::CryptoSchemes;
using ::aidl::android::hardware::drm::SecurityLevel;
using ::aidl::android::hardware::drm::Status;
using ::aidl::android::hardware::drm::SupportedContentType;
using ::aidl::android::hardware::drm::Uuid;
WVGenericCryptoInterface WVDrmFactory::sOemCryptoInterface;
@@ -130,17 +131,19 @@ int32_t WVDrmFactory::firstApiLevel() {
for (const auto& uuid : wvdrm::getSupportedCryptoSchemes()) {
schemes.uuids.push_back({uuid});
}
schemes.minLevel = schemes.maxLevel = SecurityLevel::SW_SECURE_CRYPTO;
if (wvcdm::WvContentDecryptionModule::IsSecurityLevelSupported(
wvcdm::kSecurityLevelL1)) {
schemes.maxLevel = SecurityLevel::HW_SECURE_ALL;
}
schemes.mimeTypes = {
wvcdm::ISO_BMFF_VIDEO_MIME_TYPE, wvcdm::ISO_BMFF_AUDIO_MIME_TYPE,
wvcdm::WEBM_VIDEO_MIME_TYPE, wvcdm::WEBM_AUDIO_MIME_TYPE,
wvcdm::CENC_INIT_DATA_FORMAT, wvcdm::HLS_INIT_DATA_FORMAT,
wvcdm::WEBM_INIT_DATA_FORMAT};
bool isL1 = wvcdm::WvContentDecryptionModule::IsSecurityLevelSupported(wvcdm::kSecurityLevelL1);
for (auto mime : {wvcdm::ISO_BMFF_VIDEO_MIME_TYPE, wvcdm::ISO_BMFF_AUDIO_MIME_TYPE,
wvcdm::WEBM_VIDEO_MIME_TYPE, wvcdm::WEBM_AUDIO_MIME_TYPE,
wvcdm::CENC_INIT_DATA_FORMAT, wvcdm::HLS_INIT_DATA_FORMAT,
wvcdm::WEBM_INIT_DATA_FORMAT}) {
bool isAudio = wvcdm::WvContentDecryptionModule::IsAudio(mime);
SupportedContentType ct{mime, SecurityLevel::SW_SECURE_CRYPTO, SecurityLevel::SW_SECURE_DECODE};
if (isL1) {
ct.maxLevel = isAudio ? SecurityLevel::HW_SECURE_DECODE : SecurityLevel::HW_SECURE_ALL;
}
schemes.mimeTypes.push_back(ct);
}
*_aidl_return = schemes;
return ::ndk::ScopedAStatus::ok();
}