libmediadrm: supported schemes w per mime min/max level
Other misc changes:
* don't unmap null
* more detailed error logging
Bug: 219528925
Test: GtsMediaTestCases
Change-Id: I4370354dc505227ae1b5e71a6b691828f4a73bf6
Merged-In: I4370354dc505227ae1b5e71a6b691828f4a73bf6
diff --git a/drm/libmediadrm/CryptoHalAidl.cpp b/drm/libmediadrm/CryptoHalAidl.cpp
index 642264f..db26204 100644
--- a/drm/libmediadrm/CryptoHalAidl.cpp
+++ b/drm/libmediadrm/CryptoHalAidl.cpp
@@ -355,8 +355,7 @@
std::string msgStr(statusAidl.getMessage());
*errorDetailMsg = toString8(msgStr);
if (err != OK) {
- ALOGE("Failed on decrypt, error message:%s, bytes written:%d", statusAidl.getMessage(),
- result);
+ ALOGE("Failed on decrypt, error description:%s", statusAidl.getDescription().c_str());
return err;
}
diff --git a/drm/libmediadrm/DrmHalAidl.cpp b/drm/libmediadrm/DrmHalAidl.cpp
index dc6d23e..284abd5 100644
--- a/drm/libmediadrm/DrmHalAidl.cpp
+++ b/drm/libmediadrm/DrmHalAidl.cpp
@@ -19,6 +19,7 @@
#include <array>
#include <algorithm>
+#include <map>
#include <android/binder_auto_utils.h>
#include <android/binder_manager.h>
#include <media/PluginMetricsReporting.h>
@@ -52,6 +53,7 @@
using ::aidl::android::hardware::drm::SecureStopId;
using ::aidl::android::hardware::drm::SecurityLevel;
using ::aidl::android::hardware::drm::Status;
+using ::aidl::android::hardware::drm::SupportedContentType;
using ::aidl::android::hardware::drm::Uuid;
using DrmMetricGroupAidl = ::aidl::android::hardware::drm::DrmMetricGroup;
using DrmMetricGroupHidl = ::android::hardware::drm::V1_1::DrmMetricGroup;
@@ -420,16 +422,30 @@
continue;
}
- if (levelAidl != SecurityLevel::DEFAULT && levelAidl != SecurityLevel::UNKNOWN) {
- if (levelAidl > schemes.maxLevel || levelAidl < schemes.minLevel) {
- continue;
- }
+ ALOGV("supported schemes: %s; query: level %d mime %s",
+ schemes.toString().c_str(), levelAidl, mimeType.c_str());
+ std::map<std::string, SupportedContentType> contentTypes;
+ for (auto ct : schemes.mimeTypes) {
+ contentTypes[ct.mime] = ct;
}
- if (!mimeTypeStr.empty()) {
- if (!std::count(schemes.mimeTypes.begin(), schemes.mimeTypes.end(), mimeTypeStr)) {
- continue;
+ // handle default value cases
+ if (levelAidl == SecurityLevel::DEFAULT || levelAidl == SecurityLevel::UNKNOWN) {
+ if (mimeType == "") {
+ // isCryptoSchemeSupported(uuid)
+ *isSupported = true;
+ } else {
+ // isCryptoSchemeSupported(uuid, mimeType)
+ *isSupported = contentTypes.count(mimeTypeStr);
}
+ return OK;
+ } else if (mimeType == "") {
+ return BAD_VALUE;
+ }
+
+ auto ct = contentTypes[mimeTypeStr];
+ if (levelAidl > ct.maxLevel || levelAidl < ct.minLevel) {
+ continue;
}
*isSupported = true;
diff --git a/drm/mediadrm/plugins/clearkey/aidl/CryptoPlugin.cpp b/drm/mediadrm/plugins/clearkey/aidl/CryptoPlugin.cpp
index 651d8f5..201cf02 100644
--- a/drm/mediadrm/plugins/clearkey/aidl/CryptoPlugin.cpp
+++ b/drm/mediadrm/plugins/clearkey/aidl/CryptoPlugin.cpp
@@ -227,7 +227,7 @@
}
SharedBufferBase::~SharedBufferBase() {
- if (munmap(mBase, mSize)) {
+ if (mBase && munmap(mBase, mSize)) {
ALOGE("munmap err: base %p; errno %s",
mBase, strerror(errno));
}
diff --git a/drm/mediadrm/plugins/clearkey/aidl/DrmFactory.cpp b/drm/mediadrm/plugins/clearkey/aidl/DrmFactory.cpp
index bef05ec..30db4c0 100644
--- a/drm/mediadrm/plugins/clearkey/aidl/DrmFactory.cpp
+++ b/drm/mediadrm/plugins/clearkey/aidl/DrmFactory.cpp
@@ -82,10 +82,12 @@
for (const auto& uuid : ::aidl::android::hardware::drm::clearkey::getSupportedCryptoSchemes()) {
schemes.uuids.push_back({uuid});
}
- schemes.minLevel = SecurityLevel::SW_SECURE_CRYPTO;
- schemes.maxLevel = SecurityLevel::SW_SECURE_CRYPTO;
- schemes.mimeTypes = {kIsoBmffVideoMimeType, kIsoBmffAudioMimeType, kCencInitDataFormat,
- kWebmVideoMimeType, kWebmAudioMimeType, kWebmInitDataFormat};
+ for (auto mime : {kIsoBmffVideoMimeType, kIsoBmffAudioMimeType, kCencInitDataFormat,
+ kWebmVideoMimeType, kWebmAudioMimeType, kWebmInitDataFormat}) {
+ const auto minLevel = SecurityLevel::SW_SECURE_CRYPTO;
+ const auto maxLevel = SecurityLevel::SW_SECURE_CRYPTO;
+ schemes.mimeTypes.push_back({mime, minLevel, maxLevel});
+ }
*_aidl_return = schemes;
return ndk::ScopedAStatus::ok();
}