Loading drm/mediadrm/plugins/clearkey/default/DrmPlugin.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -207,6 +207,7 @@ status_t DrmPlugin::queryKeyStatus( } infoMap.clear(); android::Mutex::Autolock lock(mPlayPolicyLock); for (size_t i = 0; i < mPlayPolicy.size(); ++i) { infoMap.add(mPlayPolicy.keyAt(i), mPlayPolicy.valueAt(i)); } Loading drm/mediadrm/plugins/clearkey/default/include/DrmPlugin.h +1 −1 Original line number Diff line number Diff line Loading @@ -262,7 +262,7 @@ private: void initProperties(); void setPlayPolicy(); android::Mutex mPlayPolicyLock; mutable android::Mutex mPlayPolicyLock; android::KeyedVector<String8, String8> mPlayPolicy; android::KeyedVector<String8, String8> mStringProperties; android::KeyedVector<String8, Vector<uint8_t>> mByteArrayProperties; Loading drm/mediadrm/plugins/clearkey/hidl/Android.bp +1 −1 Original line number Diff line number Diff line Loading @@ -50,7 +50,7 @@ cc_defaults { relative_install_path: "hw", cflags: ["-Wall", "-Werror"], cflags: ["-Wall", "-Werror", "-Wthread-safety"], shared_libs: [ "android.hardware.drm@1.0", Loading drm/mediadrm/plugins/clearkey/hidl/CryptoPlugin.cpp +10 −2 Original line number Diff line number Diff line Loading @@ -37,6 +37,8 @@ Return<void> CryptoPlugin::setSharedBufferBase( sp<IMemory> hidlMemory = mapMemory(base); ALOGE_IF(hidlMemory == nullptr, "mapMemory returns nullptr"); std::lock_guard<std::mutex> shared_buffer_lock(mSharedBufferLock); // allow mapMemory to return nullptr mSharedBufferMap[bufferId] = hidlMemory; return Void(); Loading Loading @@ -94,6 +96,7 @@ Return<void> CryptoPlugin::decrypt_1_2( return Void(); } std::unique_lock<std::mutex> shared_buffer_lock(mSharedBufferLock); if (mSharedBufferMap.find(source.bufferId) == mSharedBufferMap.end()) { _hidl_cb(Status_V1_2::ERROR_DRM_CANNOT_HANDLE, 0, "source decrypt buffer base not set"); Loading Loading @@ -142,12 +145,17 @@ Return<void> CryptoPlugin::decrypt_1_2( base = static_cast<uint8_t *>(static_cast<void *>(destBase->getPointer())); if (destBuffer.offset + destBuffer.size > destBase->getSize()) { totalSize = 0; if (__builtin_add_overflow(destBuffer.offset, destBuffer.size, &totalSize) || totalSize > destBase->getSize()) { android_errorWriteLog(0x534e4554, "176444622"); _hidl_cb(Status_V1_2::ERROR_DRM_FRAME_TOO_LARGE, 0, "invalid buffer size"); return Void(); } destPtr = static_cast<void*>(base + destination.nonsecureMemory.offset); // release mSharedBufferLock shared_buffer_lock.unlock(); // Calculate the output buffer size and determine if any subsamples are // encrypted. Loading drm/mediadrm/plugins/clearkey/hidl/DrmPlugin.cpp +12 −1 Original line number Diff line number Diff line Loading @@ -220,6 +220,7 @@ Status_V1_2 DrmPlugin::getKeyRequestCommon(const hidl_vec<uint8_t>& scope, if (requestString.find(kOfflineLicense) != std::string::npos) { std::string emptyResponse; std::string keySetIdString(keySetId.begin(), keySetId.end()); Mutex::Autolock lock(mFileHandleLock); if (!mFileHandle.StoreLicense(keySetIdString, DeviceFiles::kLicenseStateReleasing, emptyResponse)) { Loading Loading @@ -335,6 +336,7 @@ bool DrmPlugin::makeKeySetId(std::string* keySetId) { } *keySetId = kKeySetIdPrefix + ByteArrayToHexString( reinterpret_cast<const uint8_t*>(randomData.data()), randomData.size()); Mutex::Autolock lock(mFileHandleLock); if (mFileHandle.LicenseExists(*keySetId)) { // collision, regenerate ALOGV("Retry generating KeySetId"); Loading Loading @@ -392,6 +394,7 @@ Return<void> DrmPlugin::provideKeyResponse( if (status == Status::OK) { if (isOfflineLicense) { if (isRelease) { Mutex::Autolock lock(mFileHandleLock); mFileHandle.DeleteLicense(keySetId); mSessionLibrary->destroySession(session); } else { Loading @@ -400,6 +403,7 @@ Return<void> DrmPlugin::provideKeyResponse( return Void(); } Mutex::Autolock lock(mFileHandleLock); bool ok = mFileHandle.StoreLicense( keySetId, DeviceFiles::kLicenseStateActive, Loading Loading @@ -454,6 +458,7 @@ Return<Status> DrmPlugin::restoreKeys( DeviceFiles::LicenseState licenseState; std::string offlineLicense; Status status = Status::OK; Mutex::Autolock lock(mFileHandleLock); if (!mFileHandle.RetrieveLicense(std::string(keySetId.begin(), keySetId.end()), &licenseState, &offlineLicense)) { ALOGE("Failed to restore offline license"); Loading Loading @@ -576,7 +581,6 @@ Return<Status> DrmPlugin::setPropertyByteArray( Return<void> DrmPlugin::queryKeyStatus( const hidl_vec<uint8_t>& sessionId, queryKeyStatus_cb _hidl_cb) { if (sessionId.size() == 0) { // Returns empty key status KeyValue pair _hidl_cb(Status::BAD_VALUE, hidl_vec<KeyValue>()); Loading @@ -586,12 +590,14 @@ Return<void> DrmPlugin::queryKeyStatus( std::vector<KeyValue> infoMapVec; infoMapVec.clear(); mPlayPolicyLock.lock(); KeyValue keyValuePair; for (size_t i = 0; i < mPlayPolicy.size(); ++i) { keyValuePair.key = mPlayPolicy[i].key; keyValuePair.value = mPlayPolicy[i].value; infoMapVec.push_back(keyValuePair); } mPlayPolicyLock.unlock(); _hidl_cb(Status::OK, toHidlVec(infoMapVec)); return Void(); } Loading Loading @@ -704,6 +710,8 @@ Return<void> DrmPlugin::getMetrics(getMetrics_cb _hidl_cb) { } Return<void> DrmPlugin::getOfflineLicenseKeySetIds(getOfflineLicenseKeySetIds_cb _hidl_cb) { Mutex::Autolock lock(mFileHandleLock); std::vector<std::string> licenseNames = mFileHandle.ListLicenses(); std::vector<KeySetId> keySetIds; if (mMockError != Status_V1_2::OK) { Loading @@ -724,6 +732,7 @@ Return<Status> DrmPlugin::removeOfflineLicense(const KeySetId& keySetId) { return toStatus_1_0(mMockError); } std::string licenseName(keySetId.begin(), keySetId.end()); Mutex::Autolock lock(mFileHandleLock); if (mFileHandle.DeleteLicense(licenseName)) { return Status::OK; } Loading @@ -732,6 +741,8 @@ Return<Status> DrmPlugin::removeOfflineLicense(const KeySetId& keySetId) { Return<void> DrmPlugin::getOfflineLicenseState(const KeySetId& keySetId, getOfflineLicenseState_cb _hidl_cb) { Mutex::Autolock lock(mFileHandleLock); std::string licenseName(keySetId.begin(), keySetId.end()); DeviceFiles::LicenseState state; std::string license; Loading Loading
drm/mediadrm/plugins/clearkey/default/DrmPlugin.cpp +1 −0 Original line number Diff line number Diff line Loading @@ -207,6 +207,7 @@ status_t DrmPlugin::queryKeyStatus( } infoMap.clear(); android::Mutex::Autolock lock(mPlayPolicyLock); for (size_t i = 0; i < mPlayPolicy.size(); ++i) { infoMap.add(mPlayPolicy.keyAt(i), mPlayPolicy.valueAt(i)); } Loading
drm/mediadrm/plugins/clearkey/default/include/DrmPlugin.h +1 −1 Original line number Diff line number Diff line Loading @@ -262,7 +262,7 @@ private: void initProperties(); void setPlayPolicy(); android::Mutex mPlayPolicyLock; mutable android::Mutex mPlayPolicyLock; android::KeyedVector<String8, String8> mPlayPolicy; android::KeyedVector<String8, String8> mStringProperties; android::KeyedVector<String8, Vector<uint8_t>> mByteArrayProperties; Loading
drm/mediadrm/plugins/clearkey/hidl/Android.bp +1 −1 Original line number Diff line number Diff line Loading @@ -50,7 +50,7 @@ cc_defaults { relative_install_path: "hw", cflags: ["-Wall", "-Werror"], cflags: ["-Wall", "-Werror", "-Wthread-safety"], shared_libs: [ "android.hardware.drm@1.0", Loading
drm/mediadrm/plugins/clearkey/hidl/CryptoPlugin.cpp +10 −2 Original line number Diff line number Diff line Loading @@ -37,6 +37,8 @@ Return<void> CryptoPlugin::setSharedBufferBase( sp<IMemory> hidlMemory = mapMemory(base); ALOGE_IF(hidlMemory == nullptr, "mapMemory returns nullptr"); std::lock_guard<std::mutex> shared_buffer_lock(mSharedBufferLock); // allow mapMemory to return nullptr mSharedBufferMap[bufferId] = hidlMemory; return Void(); Loading Loading @@ -94,6 +96,7 @@ Return<void> CryptoPlugin::decrypt_1_2( return Void(); } std::unique_lock<std::mutex> shared_buffer_lock(mSharedBufferLock); if (mSharedBufferMap.find(source.bufferId) == mSharedBufferMap.end()) { _hidl_cb(Status_V1_2::ERROR_DRM_CANNOT_HANDLE, 0, "source decrypt buffer base not set"); Loading Loading @@ -142,12 +145,17 @@ Return<void> CryptoPlugin::decrypt_1_2( base = static_cast<uint8_t *>(static_cast<void *>(destBase->getPointer())); if (destBuffer.offset + destBuffer.size > destBase->getSize()) { totalSize = 0; if (__builtin_add_overflow(destBuffer.offset, destBuffer.size, &totalSize) || totalSize > destBase->getSize()) { android_errorWriteLog(0x534e4554, "176444622"); _hidl_cb(Status_V1_2::ERROR_DRM_FRAME_TOO_LARGE, 0, "invalid buffer size"); return Void(); } destPtr = static_cast<void*>(base + destination.nonsecureMemory.offset); // release mSharedBufferLock shared_buffer_lock.unlock(); // Calculate the output buffer size and determine if any subsamples are // encrypted. Loading
drm/mediadrm/plugins/clearkey/hidl/DrmPlugin.cpp +12 −1 Original line number Diff line number Diff line Loading @@ -220,6 +220,7 @@ Status_V1_2 DrmPlugin::getKeyRequestCommon(const hidl_vec<uint8_t>& scope, if (requestString.find(kOfflineLicense) != std::string::npos) { std::string emptyResponse; std::string keySetIdString(keySetId.begin(), keySetId.end()); Mutex::Autolock lock(mFileHandleLock); if (!mFileHandle.StoreLicense(keySetIdString, DeviceFiles::kLicenseStateReleasing, emptyResponse)) { Loading Loading @@ -335,6 +336,7 @@ bool DrmPlugin::makeKeySetId(std::string* keySetId) { } *keySetId = kKeySetIdPrefix + ByteArrayToHexString( reinterpret_cast<const uint8_t*>(randomData.data()), randomData.size()); Mutex::Autolock lock(mFileHandleLock); if (mFileHandle.LicenseExists(*keySetId)) { // collision, regenerate ALOGV("Retry generating KeySetId"); Loading Loading @@ -392,6 +394,7 @@ Return<void> DrmPlugin::provideKeyResponse( if (status == Status::OK) { if (isOfflineLicense) { if (isRelease) { Mutex::Autolock lock(mFileHandleLock); mFileHandle.DeleteLicense(keySetId); mSessionLibrary->destroySession(session); } else { Loading @@ -400,6 +403,7 @@ Return<void> DrmPlugin::provideKeyResponse( return Void(); } Mutex::Autolock lock(mFileHandleLock); bool ok = mFileHandle.StoreLicense( keySetId, DeviceFiles::kLicenseStateActive, Loading Loading @@ -454,6 +458,7 @@ Return<Status> DrmPlugin::restoreKeys( DeviceFiles::LicenseState licenseState; std::string offlineLicense; Status status = Status::OK; Mutex::Autolock lock(mFileHandleLock); if (!mFileHandle.RetrieveLicense(std::string(keySetId.begin(), keySetId.end()), &licenseState, &offlineLicense)) { ALOGE("Failed to restore offline license"); Loading Loading @@ -576,7 +581,6 @@ Return<Status> DrmPlugin::setPropertyByteArray( Return<void> DrmPlugin::queryKeyStatus( const hidl_vec<uint8_t>& sessionId, queryKeyStatus_cb _hidl_cb) { if (sessionId.size() == 0) { // Returns empty key status KeyValue pair _hidl_cb(Status::BAD_VALUE, hidl_vec<KeyValue>()); Loading @@ -586,12 +590,14 @@ Return<void> DrmPlugin::queryKeyStatus( std::vector<KeyValue> infoMapVec; infoMapVec.clear(); mPlayPolicyLock.lock(); KeyValue keyValuePair; for (size_t i = 0; i < mPlayPolicy.size(); ++i) { keyValuePair.key = mPlayPolicy[i].key; keyValuePair.value = mPlayPolicy[i].value; infoMapVec.push_back(keyValuePair); } mPlayPolicyLock.unlock(); _hidl_cb(Status::OK, toHidlVec(infoMapVec)); return Void(); } Loading Loading @@ -704,6 +710,8 @@ Return<void> DrmPlugin::getMetrics(getMetrics_cb _hidl_cb) { } Return<void> DrmPlugin::getOfflineLicenseKeySetIds(getOfflineLicenseKeySetIds_cb _hidl_cb) { Mutex::Autolock lock(mFileHandleLock); std::vector<std::string> licenseNames = mFileHandle.ListLicenses(); std::vector<KeySetId> keySetIds; if (mMockError != Status_V1_2::OK) { Loading @@ -724,6 +732,7 @@ Return<Status> DrmPlugin::removeOfflineLicense(const KeySetId& keySetId) { return toStatus_1_0(mMockError); } std::string licenseName(keySetId.begin(), keySetId.end()); Mutex::Autolock lock(mFileHandleLock); if (mFileHandle.DeleteLicense(licenseName)) { return Status::OK; } Loading @@ -732,6 +741,8 @@ Return<Status> DrmPlugin::removeOfflineLicense(const KeySetId& keySetId) { Return<void> DrmPlugin::getOfflineLicenseState(const KeySetId& keySetId, getOfflineLicenseState_cb _hidl_cb) { Mutex::Autolock lock(mFileHandleLock); std::string licenseName(keySetId.begin(), keySetId.end()); DeviceFiles::LicenseState state; std::string license; Loading