diff options
Diffstat (limited to 'drm')
| -rw-r--r-- | drm/drmserver/DrmManagerService.cpp | 25 | ||||
| -rw-r--r-- | drm/drmserver/DrmManagerService.h | 2 | ||||
| -rw-r--r-- | drm/libmediadrm/DrmHal.cpp | 181 | ||||
| -rw-r--r-- | drm/libmediadrm/IDrm.cpp | 21 | ||||
| -rw-r--r-- | drm/libmediadrm/PluginMetricsReporting.cpp | 12 | ||||
| -rw-r--r-- | drm/mediadrm/plugins/clearkey/hidl/Android.bp | 19 | ||||
| -rw-r--r-- | drm/mediadrm/plugins/clearkey/hidl/DrmFactory.cpp | 8 | ||||
| -rw-r--r-- | drm/mediadrm/plugins/clearkey/hidl/android.hardware.drm@1.2-service-lazy.clearkey.rc | 14 | ||||
| -rw-r--r-- | drm/mediadrm/plugins/clearkey/hidl/android.hardware.drm@1.2-service.clearkey.rc | 6 | ||||
| -rw-r--r-- | drm/mediadrm/plugins/clearkey/hidl/include/ClearKeyTypes.h | 1 | ||||
| -rw-r--r-- | drm/mediadrm/plugins/clearkey/hidl/include/DrmFactory.h | 4 | ||||
| -rw-r--r-- | drm/mediadrm/plugins/clearkey/hidl/include/DrmPlugin.h | 8 | ||||
| -rw-r--r-- | drm/mediadrm/plugins/clearkey/hidl/service.cpp | 10 | ||||
| -rw-r--r-- | drm/mediadrm/plugins/clearkey/hidl/serviceLazy.cpp | 50 |
14 files changed, 256 insertions, 105 deletions
diff --git a/drm/drmserver/DrmManagerService.cpp b/drm/drmserver/DrmManagerService.cpp index 2532275119..2600a2c23e 100644 --- a/drm/drmserver/DrmManagerService.cpp +++ b/drm/drmserver/DrmManagerService.cpp @@ -58,22 +58,26 @@ const char *DrmManagerService::get_perm_label(drm_perm_t perm) { return drm_perm_labels[index]; } -bool DrmManagerService::selinuxIsProtectedCallAllowed(pid_t spid, drm_perm_t perm) { +bool DrmManagerService::selinuxIsProtectedCallAllowed(pid_t spid, const char* ssid, drm_perm_t perm) { if (selinux_enabled <= 0) { return true; } - char *sctx; + char *sctx = NULL; const char *selinux_class = "drmservice"; const char *str_perm = get_perm_label(perm); - if (getpidcon(spid, &sctx) != 0) { - ALOGE("SELinux: getpidcon(pid=%d) failed.\n", spid); - return false; + if (ssid == NULL) { + android_errorWriteLog(0x534e4554, "121035042"); + + if (getpidcon(spid, &sctx) != 0) { + ALOGE("SELinux: getpidcon(pid=%d) failed.\n", spid); + return false; + } } - bool allowed = (selinux_check_access(sctx, drmserver_context, selinux_class, - str_perm, NULL) == 0); + bool allowed = (selinux_check_access(ssid ? ssid : sctx, drmserver_context, + selinux_class, str_perm, NULL) == 0); freecon(sctx); return allowed; @@ -86,10 +90,11 @@ bool DrmManagerService::isProtectedCallAllowed(drm_perm_t perm) { IPCThreadState* ipcState = IPCThreadState::self(); uid_t uid = ipcState->getCallingUid(); pid_t spid = ipcState->getCallingPid(); + const char* ssid = ipcState->getCallingSid(); for (unsigned int i = 0; i < trustedUids.size(); ++i) { if (trustedUids[i] == uid) { - return selinuxIsProtectedCallAllowed(spid, perm); + return selinuxIsProtectedCallAllowed(spid, ssid, perm); } } return false; @@ -97,7 +102,9 @@ bool DrmManagerService::isProtectedCallAllowed(drm_perm_t perm) { void DrmManagerService::instantiate() { ALOGV("instantiate"); - defaultServiceManager()->addService(String16("drm.drmManager"), new DrmManagerService()); + sp<DrmManagerService> service = new DrmManagerService(); + service->setRequestingSid(true); + defaultServiceManager()->addService(String16("drm.drmManager"), service); if (0 >= trustedUids.size()) { // TODO diff --git a/drm/drmserver/DrmManagerService.h b/drm/drmserver/DrmManagerService.h index 7aaeab5f64..2e27a3c393 100644 --- a/drm/drmserver/DrmManagerService.h +++ b/drm/drmserver/DrmManagerService.h @@ -60,7 +60,7 @@ private: static const char *get_perm_label(drm_perm_t perm); - static bool selinuxIsProtectedCallAllowed(pid_t spid, drm_perm_t perm); + static bool selinuxIsProtectedCallAllowed(pid_t spid, const char* ssid, drm_perm_t perm); static bool isProtectedCallAllowed(drm_perm_t perm); diff --git a/drm/libmediadrm/DrmHal.cpp b/drm/libmediadrm/DrmHal.cpp index fc847ff72f..5888af0e58 100644 --- a/drm/libmediadrm/DrmHal.cpp +++ b/drm/libmediadrm/DrmHal.cpp @@ -24,7 +24,7 @@ #include <binder/IServiceManager.h> #include <android/hardware/drm/1.2/types.h> -#include <android/hidl/manager/1.0/IServiceManager.h> +#include <android/hidl/manager/1.2/IServiceManager.h> #include <hidl/ServiceManagement.h> #include <media/EventMetric.h> @@ -63,6 +63,7 @@ using ::android::sp; typedef drm::V1_1::KeyRequestType KeyRequestType_V1_1; typedef drm::V1_2::Status Status_V1_2; +typedef drm::V1_2::HdcpLevel HdcpLevel_V1_2; namespace { @@ -144,38 +145,55 @@ static DrmPlugin::SecurityLevel toSecurityLevel(SecurityLevel level) { } } +static SecurityLevel toHidlSecurityLevel(DrmPlugin::SecurityLevel level) { + switch(level) { + case DrmPlugin::kSecurityLevelSwSecureCrypto: + return SecurityLevel::SW_SECURE_CRYPTO; + case DrmPlugin::kSecurityLevelSwSecureDecode: + return SecurityLevel::SW_SECURE_DECODE; + case DrmPlugin::kSecurityLevelHwSecureCrypto: + return SecurityLevel::HW_SECURE_CRYPTO; + case DrmPlugin::kSecurityLevelHwSecureDecode: + return SecurityLevel::HW_SECURE_DECODE; + case DrmPlugin::kSecurityLevelHwSecureAll: + return SecurityLevel::HW_SECURE_ALL; + default: + return SecurityLevel::UNKNOWN; + } +} + static DrmPlugin::OfflineLicenseState toOfflineLicenseState( OfflineLicenseState licenseState) { switch(licenseState) { case OfflineLicenseState::USABLE: return DrmPlugin::kOfflineLicenseStateUsable; case OfflineLicenseState::INACTIVE: - return DrmPlugin::kOfflineLicenseStateInactive; + return DrmPlugin::kOfflineLicenseStateReleased; default: return DrmPlugin::kOfflineLicenseStateUnknown; } } -static DrmPlugin::HdcpLevel toHdcpLevel(HdcpLevel level) { +static DrmPlugin::HdcpLevel toHdcpLevel(HdcpLevel_V1_2 level) { switch(level) { - case HdcpLevel::HDCP_NONE: + case HdcpLevel_V1_2::HDCP_NONE: return DrmPlugin::kHdcpNone; - case HdcpLevel::HDCP_V1: + case HdcpLevel_V1_2::HDCP_V1: return DrmPlugin::kHdcpV1; - case HdcpLevel::HDCP_V2: + case HdcpLevel_V1_2::HDCP_V2: return DrmPlugin::kHdcpV2; - case HdcpLevel::HDCP_V2_1: + case HdcpLevel_V1_2::HDCP_V2_1: return DrmPlugin::kHdcpV2_1; - case HdcpLevel::HDCP_V2_2: + case HdcpLevel_V1_2::HDCP_V2_2: return DrmPlugin::kHdcpV2_2; - case HdcpLevel::HDCP_NO_OUTPUT: + case HdcpLevel_V1_2::HDCP_V2_3: + return DrmPlugin::kHdcpV2_3; + case HdcpLevel_V1_2::HDCP_NO_OUTPUT: return DrmPlugin::kHdcpNoOutput; default: return DrmPlugin::kHdcpLevelUnknown; } } - - static ::KeyedVector toHidlKeyedVector(const KeyedVector<String8, String8>& keyedVector) { std::vector<KeyValue> stdKeyedVector; @@ -353,10 +371,10 @@ void DrmHal::cleanup() { Vector<sp<IDrmFactory>> DrmHal::makeDrmFactories() { Vector<sp<IDrmFactory>> factories; - auto manager = hardware::defaultServiceManager(); + auto manager = hardware::defaultServiceManager1_2(); if (manager != NULL) { - manager->listByInterface(drm::V1_0::IDrmFactory::descriptor, + manager->listManifestByInterface(drm::V1_0::IDrmFactory::descriptor, [&factories](const hidl_vec<hidl_string> ®istered) { for (const auto &instance : registered) { auto factory = drm::V1_0::IDrmFactory::getService(instance); @@ -366,7 +384,7 @@ Vector<sp<IDrmFactory>> DrmHal::makeDrmFactories() { } } ); - manager->listByInterface(drm::V1_1::IDrmFactory::descriptor, + manager->listManifestByInterface(drm::V1_1::IDrmFactory::descriptor, [&factories](const hidl_vec<hidl_string> ®istered) { for (const auto &instance : registered) { auto factory = drm::V1_1::IDrmFactory::getService(instance); @@ -568,28 +586,57 @@ Return<void> DrmHal::sendSessionLostState( return Void(); } -bool DrmHal::isCryptoSchemeSupported(const uint8_t uuid[16], const String8 &mimeType) { - Mutex::Autolock autoLock(mLock); +status_t DrmHal::matchMimeTypeAndSecurityLevel(const sp<IDrmFactory> &factory, + const uint8_t uuid[16], + const String8 &mimeType, + DrmPlugin::SecurityLevel level, + bool *isSupported) { + *isSupported = false; - for (size_t i = 0; i < mFactories.size(); i++) { + // handle default value cases + if (level == DrmPlugin::kSecurityLevelUnknown) { + if (mimeType == "") { + // isCryptoSchemeSupported(uuid) + *isSupported = true; + } else { + // isCryptoSchemeSupported(uuid, mimeType) + *isSupported = factory->isContentTypeSupported(mimeType.string()); + } + return OK; + } else if (mimeType == "") { + return BAD_VALUE; + } + + sp<drm::V1_2::IDrmFactory> factoryV1_2 = drm::V1_2::IDrmFactory::castFrom(factory); + if (factoryV1_2 == NULL) { + return ERROR_UNSUPPORTED; + } else { + *isSupported = factoryV1_2->isCryptoSchemeSupported_1_2(uuid, + mimeType.string(), toHidlSecurityLevel(level)); + return OK; + } +} + +status_t DrmHal::isCryptoSchemeSupported(const uint8_t uuid[16], + const String8 &mimeType, + DrmPlugin::SecurityLevel level, + bool *isSupported) { + Mutex::Autolock autoLock(mLock); + *isSupported = false; + for (ssize_t i = mFactories.size() - 1; i >= 0; i--) { if (mFactories[i]->isCryptoSchemeSupported(uuid)) { - if (mimeType != "") { - if (mFactories[i]->isContentTypeSupported(mimeType.string())) { - return true; - } - } else { - return true; - } + return matchMimeTypeAndSecurityLevel(mFactories[i], + uuid, mimeType, level, isSupported); } } - return false; + return OK; } status_t DrmHal::createPlugin(const uint8_t uuid[16], const String8& appPackageName) { Mutex::Autolock autoLock(mLock); - for (size_t i = mFactories.size() - 1; i >= 0; i--) { + for (ssize_t i = mFactories.size() - 1; i >= 0; i--) { if (mFactories[i]->isCryptoSchemeSupported(uuid)) { auto plugin = makeDrmPlugin(mFactories[i], uuid, appPackageName); if (plugin != NULL) { @@ -633,30 +680,15 @@ status_t DrmHal::openSession(DrmPlugin::SecurityLevel level, Mutex::Autolock autoLock(mLock); INIT_CHECK(); - SecurityLevel hSecurityLevel; + SecurityLevel hSecurityLevel = toHidlSecurityLevel(level); bool setSecurityLevel = true; - switch(level) { - case DrmPlugin::kSecurityLevelSwSecureCrypto: - hSecurityLevel = SecurityLevel::SW_SECURE_CRYPTO; - break; - case DrmPlugin::kSecurityLevelSwSecureDecode: - hSecurityLevel = SecurityLevel::SW_SECURE_DECODE; - break; - case DrmPlugin::kSecurityLevelHwSecureCrypto: - hSecurityLevel = SecurityLevel::HW_SECURE_CRYPTO; - break; - case DrmPlugin::kSecurityLevelHwSecureDecode: - hSecurityLevel = SecurityLevel::HW_SECURE_DECODE; - break; - case DrmPlugin::kSecurityLevelHwSecureAll: - hSecurityLevel = SecurityLevel::HW_SECURE_ALL; - break; - case DrmPlugin::kSecurityLevelMax: + if (level == DrmPlugin::kSecurityLevelMax) { setSecurityLevel = false; - break; - default: - return ERROR_DRM_CANNOT_HANDLE; + } else { + if (hSecurityLevel == SecurityLevel::UNKNOWN) { + return ERROR_DRM_CANNOT_HANDLE; + } } status_t err = UNKNOWN_ERROR; @@ -1093,22 +1125,31 @@ status_t DrmHal::getHdcpLevels(DrmPlugin::HdcpLevel *connected, } status_t err = UNKNOWN_ERROR; - if (mPluginV1_1 == NULL) { - return ERROR_DRM_CANNOT_HANDLE; - } - *connected = DrmPlugin::kHdcpLevelUnknown; *max = DrmPlugin::kHdcpLevelUnknown; - Return<void> hResult = mPluginV1_1->getHdcpLevels( - [&](Status status, const HdcpLevel& hConnected, const HdcpLevel& hMax) { - if (status == Status::OK) { - *connected = toHdcpLevel(hConnected); - *max = toHdcpLevel(hMax); - } - err = toStatusT(status); - } - ); + Return<void> hResult; + if (mPluginV1_2 != NULL) { + hResult = mPluginV1_2->getHdcpLevels_1_2( + [&](Status_V1_2 status, const HdcpLevel_V1_2& hConnected, const HdcpLevel_V1_2& hMax) { + if (status == Status_V1_2::OK) { + *connected = toHdcpLevel(hConnected); + *max = toHdcpLevel(hMax); + } + err = toStatusT_1_2(status); + }); + } else if (mPluginV1_1 != NULL) { + hResult = mPluginV1_1->getHdcpLevels( + [&](Status status, const HdcpLevel& hConnected, const HdcpLevel& hMax) { + if (status == Status::OK) { + *connected = toHdcpLevel(static_cast<HdcpLevel_V1_2>(hConnected)); + *max = toHdcpLevel(static_cast<HdcpLevel_V1_2>(hMax)); + } + err = toStatusT(status); + }); + } else { + return ERROR_DRM_CANNOT_HANDLE; + } return hResult.isOk() ? err : DEAD_OBJECT; } @@ -1178,7 +1219,7 @@ status_t DrmHal::getOfflineLicenseKeySetIds(List<Vector<uint8_t>> &keySetIds) co } if (mPluginV1_2 == NULL) { - return ERROR_DRM_CANNOT_HANDLE; + return ERROR_UNSUPPORTED; } status_t err = UNKNOWN_ERROR; @@ -1203,7 +1244,7 @@ status_t DrmHal::removeOfflineLicense(Vector<uint8_t> const &keySetId) { } if (mPluginV1_2 == NULL) { - return ERROR_DRM_CANNOT_HANDLE; + return ERROR_UNSUPPORTED; } Return<Status> status = mPluginV1_2->removeOfflineLicense(toHidlVec(keySetId)); @@ -1219,7 +1260,7 @@ status_t DrmHal::getOfflineLicenseState(Vector<uint8_t> const &keySetId, } if (mPluginV1_2 == NULL) { - return ERROR_DRM_CANNOT_HANDLE; + return ERROR_UNSUPPORTED; } *licenseState = DrmPlugin::kOfflineLicenseStateUnknown; @@ -1515,22 +1556,22 @@ void DrmHal::writeByteArray(Parcel &obj, hidl_vec<uint8_t> const &vec) void DrmHal::reportFrameworkMetrics() const { - MediaAnalyticsItem item("mediadrm"); - item.generateSessionID(); - item.setPkgName(mMetrics.GetAppPackageName().c_str()); + std::unique_ptr<MediaAnalyticsItem> item(MediaAnalyticsItem::create("mediadrm")); + item->generateSessionID(); + item->setPkgName(mMetrics.GetAppPackageName().c_str()); String8 vendor; String8 description; status_t result = getPropertyStringInternal(String8("vendor"), vendor); if (result != OK) { ALOGE("Failed to get vendor from drm plugin: %d", result); } else { - item.setCString("vendor", vendor.c_str()); + item->setCString("vendor", vendor.c_str()); } result = getPropertyStringInternal(String8("description"), description); if (result != OK) { ALOGE("Failed to get description from drm plugin: %d", result); } else { - item.setCString("description", description.c_str()); + item->setCString("description", description.c_str()); } std::string serializedMetrics; @@ -1541,9 +1582,9 @@ void DrmHal::reportFrameworkMetrics() const std::string b64EncodedMetrics = toBase64StringNoPad(serializedMetrics.data(), serializedMetrics.size()); if (!b64EncodedMetrics.empty()) { - item.setCString("serialized_metrics", b64EncodedMetrics.c_str()); + item->setCString("serialized_metrics", b64EncodedMetrics.c_str()); } - if (!item.selfrecord()) { + if (!item->selfrecord()) { ALOGE("Failed to self record framework metrics"); } } diff --git a/drm/libmediadrm/IDrm.cpp b/drm/libmediadrm/IDrm.cpp index 8c26317128..51274d16c1 100644 --- a/drm/libmediadrm/IDrm.cpp +++ b/drm/libmediadrm/IDrm.cpp @@ -83,18 +83,22 @@ struct BpDrm : public BpInterface<IDrm> { return reply.readInt32(); } - virtual bool isCryptoSchemeSupported(const uint8_t uuid[16], const String8 &mimeType) { + virtual status_t isCryptoSchemeSupported(const uint8_t uuid[16], const String8 &mimeType, + DrmPlugin::SecurityLevel level, bool *isSupported) { Parcel data, reply; data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); data.write(uuid, 16); data.writeString8(mimeType); + data.writeInt32(level); + status_t status = remote()->transact(IS_CRYPTO_SUPPORTED, data, &reply); if (status != OK) { ALOGE("isCryptoSchemeSupported: binder call failed: %d", status); - return false; + return status; } + *isSupported = static_cast<bool>(reply.readInt32()); - return reply.readInt32() != 0; + return reply.readInt32(); } virtual status_t createPlugin(const uint8_t uuid[16], @@ -123,11 +127,11 @@ struct BpDrm : public BpInterface<IDrm> { return reply.readInt32(); } - virtual status_t openSession(DrmPlugin::SecurityLevel securityLevel, + virtual status_t openSession(DrmPlugin::SecurityLevel level, Vector<uint8_t> &sessionId) { Parcel data, reply; data.writeInterfaceToken(IDrm::getInterfaceDescriptor()); - data.writeInt32(securityLevel); + data.writeInt32(level); status_t status = remote()->transact(OPEN_SESSION, data, &reply); if (status != OK) { @@ -768,7 +772,12 @@ status_t BnDrm::onTransact( uint8_t uuid[16]; data.read(uuid, sizeof(uuid)); String8 mimeType = data.readString8(); - reply->writeInt32(isCryptoSchemeSupported(uuid, mimeType)); + DrmPlugin::SecurityLevel level = + static_cast<DrmPlugin::SecurityLevel>(data.readInt32()); + bool isSupported = false; + status_t result = isCryptoSchemeSupported(uuid, mimeType, level, &isSupported); + reply->writeInt32(isSupported); + reply->writeInt32(result); return OK; } diff --git a/drm/libmediadrm/PluginMetricsReporting.cpp b/drm/libmediadrm/PluginMetricsReporting.cpp index 5cb48bf678..8cd6f969cc 100644 --- a/drm/libmediadrm/PluginMetricsReporting.cpp +++ b/drm/libmediadrm/PluginMetricsReporting.cpp @@ -34,17 +34,17 @@ constexpr char kSerializedMetricsField[] = "serialized_metrics"; status_t reportVendorMetrics(const std::string& metrics, const String8& name, const String8& appPackageName) { - MediaAnalyticsItem analyticsItem(name.c_str()); - analyticsItem.generateSessionID(); + std::unique_ptr<MediaAnalyticsItem> analyticsItem(MediaAnalyticsItem::create(name.c_str())); + analyticsItem->generateSessionID(); std::string app_package_name(appPackageName.c_str(), appPackageName.size()); - analyticsItem.setPkgName(app_package_name); + analyticsItem->setPkgName(app_package_name); if (metrics.size() > 0) { - analyticsItem.setCString(kSerializedMetricsField, metrics.c_str()); + analyticsItem->setCString(kSerializedMetricsField, metrics.c_str()); } - if (!analyticsItem.selfrecord()) { - ALOGE("selfrecord() returned false. sessioId %" PRId64, analyticsItem.getSessionID()); + if (!analyticsItem->selfrecord()) { + ALOGE("selfrecord() returned false. sessioId %" PRId64, analyticsItem->getSessionID()); } return OK; diff --git a/drm/mediadrm/plugins/clearkey/hidl/Android.bp b/drm/mediadrm/plugins/clearkey/hidl/Android.bp index b44a6c7099..e91e918b1d 100644 --- a/drm/mediadrm/plugins/clearkey/hidl/Android.bp +++ b/drm/mediadrm/plugins/clearkey/hidl/Android.bp @@ -14,8 +14,8 @@ // limitations under the License. // -cc_binary { - name: "android.hardware.drm@1.2-service.clearkey", +cc_defaults { + name: "clearkey_service_defaults", vendor: true, srcs: [ @@ -33,13 +33,11 @@ cc_binary { "MemoryFileSystem.cpp", "Session.cpp", "SessionLibrary.cpp", - "service.cpp", ], relative_install_path: "hw", cflags: ["-Wall", "-Werror"], - init_rc: ["android.hardware.drm@1.2-service.clearkey.rc"], shared_libs: [ "android.hardware.drm@1.0", @@ -80,3 +78,16 @@ cc_library_static { }, srcs: ["protos/DeviceFiles.proto"], } +cc_binary { + name: "android.hardware.drm@1.2-service.clearkey", + defaults: ["clearkey_service_defaults"], + srcs: ["service.cpp"], + init_rc: ["android.hardware.drm@1.2-service.clearkey.rc"], +} +cc_binary { + name: "android.hardware.drm@1.2-service-lazy.clearkey", + overrides: ["android.hardware.drm@1.2-service.clearkey"], + defaults: ["clearkey_service_defaults"], + srcs: ["serviceLazy.cpp"], + init_rc: ["android.hardware.drm@1.2-service-lazy.clearkey.rc"], +} diff --git a/drm/mediadrm/plugins/clearkey/hidl/DrmFactory.cpp b/drm/mediadrm/plugins/clearkey/hidl/DrmFactory.cpp index 9d040a8fc1..9fb5bbefa5 100644 --- a/drm/mediadrm/plugins/clearkey/hidl/DrmFactory.cpp +++ b/drm/mediadrm/plugins/clearkey/hidl/DrmFactory.cpp @@ -34,6 +34,7 @@ namespace V1_2 { namespace clearkey { using ::android::hardware::drm::V1_0::Status; +using ::android::hardware::drm::V1_1::SecurityLevel; using ::android::hardware::Void; Return<bool> DrmFactory::isCryptoSchemeSupported( @@ -41,6 +42,13 @@ Return<bool> DrmFactory::isCryptoSchemeSupported( return clearkeydrm::isClearKeyUUID(uuid.data()); } +Return<bool> DrmFactory::isCryptoSchemeSupported_1_2(const hidl_array<uint8_t, 16>& uuid, + const hidl_string &mimeType, + SecurityLevel level) { + return isCryptoSchemeSupported(uuid) && isContentTypeSupported(mimeType) && + level == SecurityLevel::SW_SECURE_CRYPTO; +} + Return<bool> DrmFactory::isContentTypeSupported(const hidl_string &mimeType) { // This should match the mimeTypes handed by InitDataParser. return mimeType == kIsoBmffVideoMimeType || diff --git a/drm/mediadrm/plugins/clearkey/hidl/android.hardware.drm@1.2-service-lazy.clearkey.rc b/drm/mediadrm/plugins/clearkey/hidl/android.hardware.drm@1.2-service-lazy.clearkey.rc new file mode 100644 index 0000000000..9afd3d7979 --- /dev/null +++ b/drm/mediadrm/plugins/clearkey/hidl/android.hardware.drm@1.2-service-lazy.clearkey.rc @@ -0,0 +1,14 @@ +service vendor.drm-clearkey-hal-1-2 /vendor/bin/hw/android.hardware.drm@1.2-service-lazy.clearkey + interface android.hardware.drm@1.0::ICryptoFactory clearkey + interface android.hardware.drm@1.0::IDrmFactory clearkey + interface android.hardware.drm@1.1::ICryptoFactory clearkey + interface android.hardware.drm@1.1::IDrmFactory clearkey + interface android.hardware.drm@1.2::ICryptoFactory clearkey + interface android.hardware.drm@1.2::IDrmFactory clearkey + disabled + oneshot + class hal + user media + group media mediadrm + ioprio rt 4 + writepid /dev/cpuset/foreground/tasks diff --git a/drm/mediadrm/plugins/clearkey/hidl/android.hardware.drm@1.2-service.clearkey.rc b/drm/mediadrm/plugins/clearkey/hidl/android.hardware.drm@1.2-service.clearkey.rc index ac184f7105..5ba669dc50 100644 --- a/drm/mediadrm/plugins/clearkey/hidl/android.hardware.drm@1.2-service.clearkey.rc +++ b/drm/mediadrm/plugins/clearkey/hidl/android.hardware.drm@1.2-service.clearkey.rc @@ -1,4 +1,10 @@ service vendor.drm-clearkey-hal-1-2 /vendor/bin/hw/android.hardware.drm@1.2-service.clearkey + interface android.hardware.drm@1.0::ICryptoFactory clearkey + interface android.hardware.drm@1.0::IDrmFactory clearkey + interface android.hardware.drm@1.1::ICryptoFactory clearkey + interface android.hardware.drm@1.1::IDrmFactory clearkey + interface android.hardware.drm@1.2::ICryptoFactory clearkey + interface android.hardware.drm@1.2::IDrmFactory clearkey class hal user media group media mediadrm diff --git a/drm/mediadrm/plugins/clearkey/hidl/include/ClearKeyTypes.h b/drm/mediadrm/plugins/clearkey/hidl/include/ClearKeyTypes.h index 2dafa36936..03c434eaa3 100644 --- a/drm/mediadrm/plugins/clearkey/hidl/include/ClearKeyTypes.h +++ b/drm/mediadrm/plugins/clearkey/hidl/include/ClearKeyTypes.h @@ -28,6 +28,7 @@ namespace V1_2 { namespace clearkey { using ::android::hardware::drm::V1_0::KeyValue; +using ::android::hardware::drm::V1_1::SecurityLevel; using ::android::hardware::hidl_vec; const uint8_t kBlockSize = 16; //AES_BLOCK_SIZE; diff --git a/drm/mediadrm/plugins/clearkey/hidl/include/DrmFactory.h b/drm/mediadrm/plugins/clearkey/hidl/include/DrmFactory.h index ff715ea67f..4ca856d63e 100644 --- a/drm/mediadrm/plugins/clearkey/hidl/include/DrmFactory.h +++ b/drm/mediadrm/plugins/clearkey/hidl/include/DrmFactory.h @@ -39,6 +39,10 @@ struct DrmFactory : public IDrmFactory { Return<bool> isCryptoSchemeSupported(const hidl_array<uint8_t, 16>& uuid) override; + Return<bool> isCryptoSchemeSupported_1_2(const hidl_array<uint8_t, 16>& uuid, + const hidl_string& mimeType, + SecurityLevel level) override; + Return<bool> isContentTypeSupported(const hidl_string &mimeType) override; diff --git a/drm/mediadrm/plugins/clearkey/hidl/include/DrmPlugin.h b/drm/mediadrm/plugins/clearkey/hidl/include/DrmPlugin.h index a9b897b02e..ba5fa65092 100644 --- a/drm/mediadrm/plugins/clearkey/hidl/include/DrmPlugin.h +++ b/drm/mediadrm/plugins/clearkey/hidl/include/DrmPlugin.h @@ -63,6 +63,7 @@ using ::android::sp; typedef drm::V1_1::KeyRequestType KeyRequestType_V1_1; typedef drm::V1_2::IDrmPluginListener IDrmPluginListener_V1_2; typedef drm::V1_2::Status Status_V1_2; +typedef drm::V1_2::HdcpLevel HdcpLevel_V1_2; struct DrmPlugin : public IDrmPlugin { explicit DrmPlugin(SessionLibrary* sessionLibrary); @@ -162,6 +163,13 @@ struct DrmPlugin : public IDrmPlugin { return Void(); } + Return<void> getHdcpLevels_1_2(getHdcpLevels_1_2_cb _hidl_cb) { + HdcpLevel_V1_2 connectedLevel = HdcpLevel_V1_2::HDCP_NONE; + HdcpLevel_V1_2 maxLevel = HdcpLevel_V1_2::HDCP_NO_OUTPUT; + _hidl_cb(Status_V1_2::OK, connectedLevel, maxLevel); + return Void(); + } + Return<void> getNumberOfSessions(getNumberOfSessions_cb _hidl_cb) override; Return<void> getSecurityLevel(const hidl_vec<uint8_t>& sessionId, diff --git a/drm/mediadrm/plugins/clearkey/hidl/service.cpp b/drm/mediadrm/plugins/clearkey/hidl/service.cpp index 4ca31f35c1..b39ea018e4 100644 --- a/drm/mediadrm/plugins/clearkey/hidl/service.cpp +++ b/drm/mediadrm/plugins/clearkey/hidl/service.cpp @@ -13,13 +13,12 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -#define LOG_TAG "android.hardware.drm@1.2-service.clearkey" - #include <CryptoFactory.h> #include <DrmFactory.h> #include <android-base/logging.h> #include <binder/ProcessState.h> +#include <hidl/HidlLazyUtils.h> #include <hidl/HidlTransportSupport.h> using ::android::hardware::configureRpcThreadpool; @@ -31,14 +30,7 @@ using android::hardware::drm::V1_2::IDrmFactory; using android::hardware::drm::V1_2::clearkey::CryptoFactory; using android::hardware::drm::V1_2::clearkey::DrmFactory; - int main(int /* argc */, char** /* argv */) { - ALOGD("android.hardware.drm@1.2-service.clearkey starting..."); - - // The DRM HAL may communicate to other vendor components via - // /dev/vndbinder - android::ProcessState::initWithDriver("/dev/vndbinder"); - sp<IDrmFactory> drmFactory = new DrmFactory; sp<ICryptoFactory> cryptoFactory = new CryptoFactory; diff --git a/drm/mediadrm/plugins/clearkey/hidl/serviceLazy.cpp b/drm/mediadrm/plugins/clearkey/hidl/serviceLazy.cpp new file mode 100644 index 0000000000..99fd883b16 --- /dev/null +++ b/drm/mediadrm/plugins/clearkey/hidl/serviceLazy.cpp @@ -0,0 +1,50 @@ +/* + * Copyright 2019 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +#include <CryptoFactory.h> +#include <DrmFactory.h> + +#include <android-base/logging.h> +#include <binder/ProcessState.h> +#include <hidl/HidlLazyUtils.h> +#include <hidl/HidlTransportSupport.h> + +using ::android::hardware::configureRpcThreadpool; +using ::android::hardware::joinRpcThreadpool; +using ::android::sp; + +using android::hardware::drm::V1_2::ICryptoFactory; +using android::hardware::drm::V1_2::IDrmFactory; +using android::hardware::drm::V1_2::clearkey::CryptoFactory; +using android::hardware::drm::V1_2::clearkey::DrmFactory; +using android::hardware::LazyServiceRegistrar; + +int main(int /* argc */, char** /* argv */) { + sp<IDrmFactory> drmFactory = new DrmFactory; + sp<ICryptoFactory> cryptoFactory = new CryptoFactory; + + configureRpcThreadpool(8, true /* callerWillJoin */); + + // Setup hwbinder service + LazyServiceRegistrar serviceRegistrar; + + // Setup hwbinder service + CHECK_EQ(serviceRegistrar.registerService(drmFactory, "clearkey"), android::NO_ERROR) + << "Failed to register Clearkey Factory HAL"; + CHECK_EQ(serviceRegistrar.registerService(cryptoFactory, "clearkey"), android::NO_ERROR) + << "Failed to register Clearkey Crypto HAL"; + + joinRpcThreadpool(); +} |
