diff options
Diffstat (limited to 'drm')
19 files changed, 273 insertions, 182 deletions
diff --git a/drm/common/DrmInfoEvent.cpp b/drm/common/DrmInfoEvent.cpp index 8d115a8..27a5a2d 100644 --- a/drm/common/DrmInfoEvent.cpp +++ b/drm/common/DrmInfoEvent.cpp @@ -19,7 +19,7 @@ using namespace android; -DrmInfoEvent::DrmInfoEvent(int uniqueId, int infoType, const String8& message) +DrmInfoEvent::DrmInfoEvent(int uniqueId, int infoType, const String8 message) : mUniqueId(uniqueId), mInfoType(infoType), mMessage(message) { @@ -34,7 +34,7 @@ int DrmInfoEvent::getType() const { return mInfoType; } -const String8& DrmInfoEvent::getMessage() const { +const String8 DrmInfoEvent::getMessage() const { return mMessage; } diff --git a/drm/common/DrmSupportInfo.cpp b/drm/common/DrmSupportInfo.cpp index c0bff0e..5400bdd 100644 --- a/drm/common/DrmSupportInfo.cpp +++ b/drm/common/DrmSupportInfo.cpp @@ -15,6 +15,7 @@ */ #include <drm/DrmSupportInfo.h> +#include <strings.h> using namespace android; @@ -42,6 +43,10 @@ bool DrmSupportInfo::operator==(const DrmSupportInfo& drmSupportInfo) const { } bool DrmSupportInfo::isSupportedMimeType(const String8& mimeType) const { + if (String8("") == mimeType) { + return false; + } + for (unsigned int i = 0; i < mMimeTypeVector.size(); i++) { const String8 item = mMimeTypeVector.itemAt(i); @@ -152,4 +157,3 @@ String8& DrmSupportInfo::MimeTypeIterator::next() { mIndex++; return value; } - diff --git a/drm/common/IDrmManagerService.cpp b/drm/common/IDrmManagerService.cpp index 346934b..0b76a36 100644 --- a/drm/common/IDrmManagerService.cpp +++ b/drm/common/IDrmManagerService.cpp @@ -37,7 +37,7 @@ using namespace android; -static void writeDecrptHandleToParcelData( +static void writeDecryptHandleToParcelData( const DecryptHandle* handle, Parcel* data) { data->writeInt32(handle->decryptId); data->writeString8(handle->mimeType); @@ -46,14 +46,14 @@ static void writeDecrptHandleToParcelData( int size = handle->copyControlVector.size(); data->writeInt32(size); - for(int i = 0; i < size; i++) { + for (int i = 0; i < size; i++) { data->writeInt32(handle->copyControlVector.keyAt(i)); data->writeInt32(handle->copyControlVector.valueAt(i)); } size = handle->extendedData.size(); data->writeInt32(size); - for(int i = 0; i < size; i++) { + for (int i = 0; i < size; i++) { data->writeString8(handle->extendedData.keyAt(i)); data->writeString8(handle->extendedData.valueAt(i)); } @@ -77,14 +77,14 @@ static void readDecryptHandleFromParcelData( handle->status = data.readInt32(); int size = data.readInt32(); - for (int i = 0; i < size; i ++) { + for (int i = 0; i < size; i++) { DrmCopyControl key = (DrmCopyControl)data.readInt32(); int value = data.readInt32(); handle->copyControlVector.add(key, value); } size = data.readInt32(); - for (int i = 0; i < size; i ++) { + for (int i = 0; i < size; i++) { String8 key = data.readString8(); String8 value = data.readString8(); handle->extendedData.add(key, value); @@ -107,13 +107,14 @@ static void clearDecryptHandle(DecryptHandle* handle) { handle->decryptInfo = NULL; } handle->copyControlVector.clear(); + handle->extendedData.clear(); } -int BpDrmManagerService::addUniqueId(int uniqueId) { +int BpDrmManagerService::addUniqueId(bool isNative) { LOGV("add uniqueid"); Parcel data, reply; data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); - data.writeInt32(uniqueId); + data.writeInt32(isNative); remote()->transact(ADD_UNIQUEID, data, &reply); return reply.readInt32(); } @@ -416,7 +417,7 @@ status_t BpDrmManagerService::consumeRights( data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); data.writeInt32(uniqueId); - writeDecrptHandleToParcelData(decryptHandle, &data); + writeDecryptHandleToParcelData(decryptHandle, &data); data.writeInt32(action); data.writeInt32(static_cast< int>(reserve)); @@ -433,7 +434,7 @@ status_t BpDrmManagerService::setPlaybackStatus( data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); data.writeInt32(uniqueId); - writeDecrptHandleToParcelData(decryptHandle, &data); + writeDecryptHandleToParcelData(decryptHandle, &data); data.writeInt32(playbackStatus); data.writeInt64(position); @@ -646,15 +647,10 @@ status_t BpDrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* d data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); data.writeInt32(uniqueId); - writeDecrptHandleToParcelData(decryptHandle, &data); + writeDecryptHandleToParcelData(decryptHandle, &data); remote()->transact(CLOSE_DECRYPT_SESSION, data, &reply); - if (NULL != decryptHandle->decryptInfo) { - LOGV("deleting decryptInfo"); - delete decryptHandle->decryptInfo; decryptHandle->decryptInfo = NULL; - } - delete decryptHandle; decryptHandle = NULL; return reply.readInt32(); } @@ -667,7 +663,7 @@ status_t BpDrmManagerService::initializeDecryptUnit( data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); data.writeInt32(uniqueId); - writeDecrptHandleToParcelData(decryptHandle, &data); + writeDecryptHandleToParcelData(decryptHandle, &data); data.writeInt32(decryptUnitId); @@ -687,7 +683,7 @@ status_t BpDrmManagerService::decrypt( data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); data.writeInt32(uniqueId); - writeDecrptHandleToParcelData(decryptHandle, &data); + writeDecryptHandleToParcelData(decryptHandle, &data); data.writeInt32(decryptUnitId); data.writeInt32((*decBuffer)->length); @@ -720,7 +716,7 @@ status_t BpDrmManagerService::finalizeDecryptUnit( data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); data.writeInt32(uniqueId); - writeDecrptHandleToParcelData(decryptHandle, &data); + writeDecryptHandleToParcelData(decryptHandle, &data); data.writeInt32(decryptUnitId); @@ -738,7 +734,7 @@ ssize_t BpDrmManagerService::pread( data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); data.writeInt32(uniqueId); - writeDecrptHandleToParcelData(decryptHandle, &data); + writeDecryptHandleToParcelData(decryptHandle, &data); data.writeInt32(numBytes); data.writeInt64(offset); @@ -812,7 +808,9 @@ status_t BnDrmManagerService::onTransact( LOGV("BnDrmManagerService::onTransact :INSTALL_DRM_ENGINE"); CHECK_INTERFACE(IDrmManagerService, data, reply); - status_t status = installDrmEngine(data.readInt32(), data.readString8()); + const int uniqueId = data.readInt32(); + const String8 engineFile = data.readString8(); + status_t status = installDrmEngine(uniqueId, engineFile); reply->writeInt32(status); return DRM_NO_ERROR; @@ -826,7 +824,8 @@ status_t BnDrmManagerService::onTransact( const int uniqueId = data.readInt32(); const String8 path = data.readString8(); - DrmConstraints* drmConstraints = getConstraints(uniqueId, &path, data.readInt32()); + DrmConstraints* drmConstraints + = getConstraints(uniqueId, &path, data.readInt32()); if (NULL != drmConstraints) { //Filling DRM Constraints contents @@ -952,7 +951,9 @@ status_t BnDrmManagerService::onTransact( const int uniqueId = data.readInt32(); //Filling DRM info Request - DrmInfoRequest* drmInfoRequest = new DrmInfoRequest(data.readInt32(), data.readString8()); + const int infoType = data.readInt32(); + const String8 mimeType = data.readString8(); + DrmInfoRequest* drmInfoRequest = new DrmInfoRequest(infoType, mimeType); const int size = data.readInt32(); for (int index = 0; index < size; ++index) { @@ -1025,7 +1026,9 @@ status_t BnDrmManagerService::onTransact( LOGV("BnDrmManagerService::onTransact :GET_ORIGINAL_MIMETYPE"); CHECK_INTERFACE(IDrmManagerService, data, reply); - const String8 originalMimeType = getOriginalMimeType(data.readInt32(), data.readString8()); + const int uniqueId = data.readInt32(); + const String8 path = data.readString8(); + const String8 originalMimeType = getOriginalMimeType(uniqueId, path); reply->writeString8(originalMimeType); return DRM_NO_ERROR; @@ -1036,8 +1039,10 @@ status_t BnDrmManagerService::onTransact( LOGV("BnDrmManagerService::onTransact :GET_DRM_OBJECT_TYPE"); CHECK_INTERFACE(IDrmManagerService, data, reply); - const int drmObjectType - = getDrmObjectType(data.readInt32(), data.readString8(), data.readString8()); + const int uniqueId = data.readInt32(); + const String8 path = data.readString8(); + const String8 mimeType = data.readString8(); + const int drmObjectType = getDrmObjectType(uniqueId, path, mimeType); reply->writeInt32(drmObjectType); return DRM_NO_ERROR; @@ -1048,8 +1053,10 @@ status_t BnDrmManagerService::onTransact( LOGV("BnDrmManagerService::onTransact :CHECK_RIGHTS_STATUS"); CHECK_INTERFACE(IDrmManagerService, data, reply); - const int result - = checkRightsStatus(data.readInt32(), data.readString8(), data.readInt32()); + const int uniqueId = data.readInt32(); + const String8 path = data.readString8(); + const int action = data.readInt32(); + const int result = checkRightsStatus(uniqueId, path, action); reply->writeInt32(result); return DRM_NO_ERROR; @@ -1065,9 +1072,10 @@ status_t BnDrmManagerService::onTransact( DecryptHandle handle; readDecryptHandleFromParcelData(&handle, data); + const int action = data.readInt32(); + const bool reserve = static_cast<bool>(data.readInt32()); const status_t status - = consumeRights(uniqueId, &handle, data.readInt32(), - static_cast<bool>(data.readInt32())); + = consumeRights(uniqueId, &handle, action, reserve); reply->writeInt32(status); clearDecryptHandle(&handle); @@ -1084,8 +1092,10 @@ status_t BnDrmManagerService::onTransact( DecryptHandle handle; readDecryptHandleFromParcelData(&handle, data); + const int playbackStatus = data.readInt32(); + const int64_t position = data.readInt64(); const status_t status - = setPlaybackStatus(uniqueId, &handle, data.readInt32(), data.readInt64()); + = setPlaybackStatus(uniqueId, &handle, playbackStatus, position); reply->writeInt32(status); clearDecryptHandle(&handle); @@ -1097,11 +1107,13 @@ status_t BnDrmManagerService::onTransact( LOGV("BnDrmManagerService::onTransact :VALIDATE_ACTION"); CHECK_INTERFACE(IDrmManagerService, data, reply); - bool result = validateAction( - data.readInt32(), - data.readString8(), - data.readInt32(), - ActionDescription(data.readInt32(), data.readInt32())); + const int uniqueId = data.readInt32(); + const String8 path = data.readString8(); + const int action = data.readInt32(); + const int outputType = data.readInt32(); + const int configuration = data.readInt32(); + bool result = validateAction(uniqueId, path, action, + ActionDescription(outputType, configuration)); reply->writeInt32(result); return DRM_NO_ERROR; @@ -1112,7 +1124,9 @@ status_t BnDrmManagerService::onTransact( LOGV("BnDrmManagerService::onTransact :REMOVE_RIGHTS"); CHECK_INTERFACE(IDrmManagerService, data, reply); - const status_t status = removeRights(data.readInt32(), data.readString8()); + int uniqueId = data.readInt32(); + String8 path = data.readString8(); + const status_t status = removeRights(uniqueId, path); reply->writeInt32(status); return DRM_NO_ERROR; @@ -1134,7 +1148,9 @@ status_t BnDrmManagerService::onTransact( LOGV("BnDrmManagerService::onTransact :OPEN_CONVERT_SESSION"); CHECK_INTERFACE(IDrmManagerService, data, reply); - const int convertId = openConvertSession(data.readInt32(), data.readString8()); + const int uniqueId = data.readInt32(); + const String8 mimeType = data.readString8(); + const int convertId = openConvertSession(uniqueId, mimeType); reply->writeInt32(convertId); return DRM_NO_ERROR; @@ -1180,8 +1196,10 @@ status_t BnDrmManagerService::onTransact( LOGV("BnDrmManagerService::onTransact :CLOSE_CONVERT_SESSION"); CHECK_INTERFACE(IDrmManagerService, data, reply); - DrmConvertedStatus* drmConvertedStatus - = closeConvertSession(data.readInt32(), data.readInt32()); + const int uniqueId = data.readInt32(); + const int convertId = data.readInt32(); + DrmConvertedStatus* drmConvertedStatus + = closeConvertSession(uniqueId, convertId); if (NULL != drmConvertedStatus) { //Filling Drm Converted Ststus @@ -1245,11 +1263,13 @@ status_t BnDrmManagerService::onTransact( const int uniqueId = data.readInt32(); const int fd = data.readFileDescriptor(); + const off64_t offset = data.readInt64(); + const off64_t length = data.readInt64(); DecryptHandle* handle - = openDecryptSession(uniqueId, fd, data.readInt64(), data.readInt64()); + = openDecryptSession(uniqueId, fd, offset, length); if (NULL != handle) { - writeDecrptHandleToParcelData(handle, reply); + writeDecryptHandleToParcelData(handle, reply); clearDecryptHandle(handle); delete handle; handle = NULL; } @@ -1267,7 +1287,7 @@ status_t BnDrmManagerService::onTransact( DecryptHandle* handle = openDecryptSession(uniqueId, uri.string()); if (NULL != handle) { - writeDecrptHandleToParcelData(handle, reply); + writeDecryptHandleToParcelData(handle, reply); clearDecryptHandle(handle); delete handle; handle = NULL; diff --git a/drm/drmserver/Android.mk b/drm/drmserver/Android.mk index f94f9a3..fd417cb 100644 --- a/drm/drmserver/Android.mk +++ b/drm/drmserver/Android.mk @@ -22,14 +22,10 @@ LOCAL_SRC_FILES:= \ DrmManagerService.cpp LOCAL_SHARED_LIBRARIES := \ + libmedia \ libutils \ - libbinder - -ifeq ($(TARGET_SIMULATOR),true) - LOCAL_LDLIBS += -ldl -else - LOCAL_SHARED_LIBRARIES += libdl -endif + libbinder \ + libdl LOCAL_STATIC_LIBRARIES := libdrmframeworkcommon diff --git a/drm/drmserver/DrmManager.cpp b/drm/drmserver/DrmManager.cpp index 1eee5f2..3e4fe8c 100644 --- a/drm/drmserver/DrmManager.cpp +++ b/drm/drmserver/DrmManager.cpp @@ -37,7 +37,6 @@ using namespace android; -Vector<int> DrmManager::mUniqueIdVector; const String8 DrmManager::EMPTY_STRING(""); DrmManager::DrmManager() : @@ -50,32 +49,42 @@ DrmManager::~DrmManager() { } -int DrmManager::addUniqueId(int uniqueId) { +int DrmManager::addUniqueId(bool isNative) { Mutex::Autolock _l(mLock); - if (0 == uniqueId) { - int temp = 0; - bool foundUniqueId = false; - srand(time(NULL)); - - while (!foundUniqueId) { - const int size = mUniqueIdVector.size(); - temp = rand() % 100; - - int index = 0; - for (; index < size; ++index) { - if (mUniqueIdVector.itemAt(index) == temp) { - foundUniqueId = false; - break; - } - } - if (index == size) { - foundUniqueId = true; + + int temp = 0; + bool foundUniqueId = false; + const int size = mUniqueIdVector.size(); + const int uniqueIdRange = 0xfff; + int maxLoopTimes = (uniqueIdRange - 1) / 2; + srand(time(NULL)); + + while (!foundUniqueId) { + temp = rand() & uniqueIdRange; + + if (isNative) { + // set a flag to differentiate DrmManagerClient + // created from native side and java side + temp |= 0x1000; + } + + int index = 0; + for (; index < size; ++index) { + if (mUniqueIdVector.itemAt(index) == temp) { + foundUniqueId = false; + break; } } - uniqueId = temp; + if (index == size) { + foundUniqueId = true; + } + + maxLoopTimes --; + LOG_FATAL_IF(maxLoopTimes <= 0, "cannot find an unique ID for this session"); } - mUniqueIdVector.push(uniqueId); - return uniqueId; + + mUniqueIdVector.push(temp); + return temp; } void DrmManager::removeUniqueId(int uniqueId) { @@ -102,6 +111,7 @@ status_t DrmManager::loadPlugIns(const String8& plugInDirPath) { DrmSupportInfo* info = mPlugInManager.getPlugIn(plugInPath).getSupportInfo(0); if (NULL != info) { mSupportInfoToPlugInIdMap.add(*info, plugInPath); + delete info; } } } @@ -179,6 +189,7 @@ status_t DrmManager::installDrmEngine(int uniqueId, const String8& absolutePath) DrmSupportInfo* info = rDrmEngine.getSupportInfo(0); mSupportInfoToPlugInIdMap.add(*info, absolutePath); + delete info; return DRM_NO_ERROR; } diff --git a/drm/drmserver/DrmManagerService.cpp b/drm/drmserver/DrmManagerService.cpp index 0901a44..7ebcac3 100644 --- a/drm/drmserver/DrmManagerService.cpp +++ b/drm/drmserver/DrmManagerService.cpp @@ -19,6 +19,7 @@ #include <utils/Log.h> #include <private/android_filesystem_config.h> +#include <media/MemoryLeakTrackUtil.h> #include <errno.h> #include <utils/threads.h> @@ -77,8 +78,8 @@ DrmManagerService::~DrmManagerService() { delete mDrmManager; mDrmManager = NULL; } -int DrmManagerService::addUniqueId(int uniqueId) { - return mDrmManager->addUniqueId(uniqueId); +int DrmManagerService::addUniqueId(bool isNative) { + return mDrmManager->addUniqueId(isNative); } void DrmManagerService::removeUniqueId(int uniqueId) { @@ -256,3 +257,31 @@ ssize_t DrmManagerService::pread(int uniqueId, DecryptHandle* decryptHandle, return mDrmManager->pread(uniqueId, decryptHandle, buffer, numBytes, offset); } +status_t DrmManagerService::dump(int fd, const Vector<String16>& args) +{ + const size_t SIZE = 256; + char buffer[SIZE]; + String8 result; + if (checkCallingPermission(String16("android.permission.DUMP")) == false) { + snprintf(buffer, SIZE, "Permission Denial: " + "can't dump DrmManagerService from pid=%d, uid=%d\n", + IPCThreadState::self()->getCallingPid(), + IPCThreadState::self()->getCallingUid()); + result.append(buffer); + } else { +#if DRM_MEMORY_LEAK_TRACK + bool dumpMem = false; + for (size_t i = 0; i < args.size(); i++) { + if (args[i] == String16("-m")) { + dumpMem = true; + } + } + if (dumpMem) { + dumpMemoryAddresses(fd); + } +#endif + } + write(fd, result.string(), result.size()); + return NO_ERROR; +} + diff --git a/drm/libdrmframework/Android.mk b/drm/libdrmframework/Android.mk index 99133ba..c534402 100644 --- a/drm/libdrmframework/Android.mk +++ b/drm/libdrmframework/Android.mk @@ -25,13 +25,8 @@ LOCAL_MODULE:= libdrmframework LOCAL_SHARED_LIBRARIES := \ libutils \ - libbinder - -ifeq ($(TARGET_SIMULATOR),true) - LOCAL_LDLIBS += -ldl -else - LOCAL_SHARED_LIBRARIES += libdl -endif + libbinder \ + libdl LOCAL_STATIC_LIBRARIES := \ libdrmframeworkcommon @@ -40,7 +35,7 @@ LOCAL_C_INCLUDES += \ $(TOP)/frameworks/base/drm/libdrmframework/include \ $(TOP)/frameworks/base/include -LOCAL_PRELINK_MODULE := false + LOCAL_MODULE_TAGS := optional diff --git a/drm/libdrmframework/DrmManagerClient.cpp b/drm/libdrmframework/DrmManagerClient.cpp index c1f382a..c9c0d57 100644 --- a/drm/libdrmframework/DrmManagerClient.cpp +++ b/drm/libdrmframework/DrmManagerClient.cpp @@ -24,7 +24,7 @@ using namespace android; DrmManagerClient::DrmManagerClient(): mUniqueId(0), mDrmManagerClientImpl(NULL) { - mDrmManagerClientImpl = DrmManagerClientImpl::create(&mUniqueId); + mDrmManagerClientImpl = DrmManagerClientImpl::create(&mUniqueId, true); mDrmManagerClientImpl->addClient(mUniqueId); } @@ -76,12 +76,13 @@ int DrmManagerClient::checkRightsStatus(const String8& path, int action) { return mDrmManagerClientImpl->checkRightsStatus(mUniqueId, path, action); } -status_t DrmManagerClient::consumeRights(DecryptHandle* decryptHandle, int action, bool reserve) { +status_t DrmManagerClient::consumeRights( + sp<DecryptHandle> &decryptHandle, int action, bool reserve) { return mDrmManagerClientImpl->consumeRights(mUniqueId, decryptHandle, action, reserve); } status_t DrmManagerClient::setPlaybackStatus( - DecryptHandle* decryptHandle, int playbackStatus, int64_t position) { + sp<DecryptHandle> &decryptHandle, int playbackStatus, int64_t position) { return mDrmManagerClientImpl ->setPlaybackStatus(mUniqueId, decryptHandle, playbackStatus, position); } @@ -115,37 +116,39 @@ status_t DrmManagerClient::getAllSupportInfo(int* length, DrmSupportInfo** drmSu return mDrmManagerClientImpl->getAllSupportInfo(mUniqueId, length, drmSupportInfoArray); } -DecryptHandle* DrmManagerClient::openDecryptSession(int fd, off64_t offset, off64_t length) { +sp<DecryptHandle> DrmManagerClient::openDecryptSession(int fd, off64_t offset, off64_t length) { return mDrmManagerClientImpl->openDecryptSession(mUniqueId, fd, offset, length); } -DecryptHandle* DrmManagerClient::openDecryptSession(const char* uri) { +sp<DecryptHandle> DrmManagerClient::openDecryptSession(const char* uri) { return mDrmManagerClientImpl->openDecryptSession(mUniqueId, uri); } -status_t DrmManagerClient::closeDecryptSession(DecryptHandle* decryptHandle) { +status_t DrmManagerClient::closeDecryptSession(sp<DecryptHandle> &decryptHandle) { return mDrmManagerClientImpl->closeDecryptSession(mUniqueId, decryptHandle); } status_t DrmManagerClient::initializeDecryptUnit( - DecryptHandle* decryptHandle, int decryptUnitId, const DrmBuffer* headerInfo) { + sp<DecryptHandle> &decryptHandle, int decryptUnitId, const DrmBuffer* headerInfo) { return mDrmManagerClientImpl->initializeDecryptUnit( mUniqueId, decryptHandle, decryptUnitId, headerInfo); } status_t DrmManagerClient::decrypt( - DecryptHandle* decryptHandle, int decryptUnitId, - const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) { + sp<DecryptHandle> &decryptHandle, int decryptUnitId, + const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) { return mDrmManagerClientImpl->decrypt( mUniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer, IV); } -status_t DrmManagerClient::finalizeDecryptUnit(DecryptHandle* decryptHandle, int decryptUnitId) { - return mDrmManagerClientImpl->finalizeDecryptUnit(mUniqueId, decryptHandle, decryptUnitId); +status_t DrmManagerClient::finalizeDecryptUnit( + sp<DecryptHandle> &decryptHandle, int decryptUnitId) { + return mDrmManagerClientImpl->finalizeDecryptUnit(mUniqueId, + decryptHandle, decryptUnitId); } ssize_t DrmManagerClient::pread( - DecryptHandle* decryptHandle, void* buffer, ssize_t numBytes, off64_t offset) { + sp<DecryptHandle> &decryptHandle, void* buffer, ssize_t numBytes, off64_t offset) { return mDrmManagerClientImpl->pread(mUniqueId, decryptHandle, buffer, numBytes, offset); } diff --git a/drm/libdrmframework/DrmManagerClientImpl.cpp b/drm/libdrmframework/DrmManagerClientImpl.cpp index 9c7fed3..67f58ca 100644 --- a/drm/libdrmframework/DrmManagerClientImpl.cpp +++ b/drm/libdrmframework/DrmManagerClientImpl.cpp @@ -33,13 +33,10 @@ sp<IDrmManagerService> DrmManagerClientImpl::sDrmManagerService; sp<DrmManagerClientImpl::DeathNotifier> DrmManagerClientImpl::sDeathNotifier; const String8 DrmManagerClientImpl::EMPTY_STRING(""); -DrmManagerClientImpl* DrmManagerClientImpl::create(int* pUniqueId) { - if (0 == *pUniqueId) { - int uniqueId = getDrmManagerService()->addUniqueId(*pUniqueId); - *pUniqueId = uniqueId; - } else { - getDrmManagerService()->addUniqueId(*pUniqueId); - } +DrmManagerClientImpl* DrmManagerClientImpl::create( + int* pUniqueId, bool isNative) { + *pUniqueId = getDrmManagerService()->addUniqueId(isNative); + return new DrmManagerClientImpl(); } @@ -81,14 +78,16 @@ void DrmManagerClientImpl::removeClient(int uniqueId) { } status_t DrmManagerClientImpl::setOnInfoListener( - int uniqueId, const sp<DrmManagerClient::OnInfoListener>& infoListener) { + int uniqueId, + const sp<DrmManagerClient::OnInfoListener>& infoListener) { Mutex::Autolock _l(mLock); mOnInfoListener = infoListener; return getDrmManagerService()->setDrmServiceListener(uniqueId, (NULL != infoListener.get()) ? this : NULL); } -status_t DrmManagerClientImpl::installDrmEngine(int uniqueId, const String8& drmEngineFile) { +status_t DrmManagerClientImpl::installDrmEngine( + int uniqueId, const String8& drmEngineFile) { status_t status = DRM_ERROR_UNKNOWN; if (EMPTY_STRING != drmEngineFile) { status = getDrmManagerService()->installDrmEngine(uniqueId, drmEngineFile); @@ -100,7 +99,8 @@ DrmConstraints* DrmManagerClientImpl::getConstraints( int uniqueId, const String8* path, const int action) { DrmConstraints *drmConstraints = NULL; if ((NULL != path) && (EMPTY_STRING != *path)) { - drmConstraints = getDrmManagerService()->getConstraints(uniqueId, path, action); + drmConstraints = + getDrmManagerService()->getConstraints(uniqueId, path, action); } return drmConstraints; } @@ -113,7 +113,8 @@ DrmMetadata* DrmManagerClientImpl::getMetadata(int uniqueId, const String8* path return drmMetadata; } -bool DrmManagerClientImpl::canHandle(int uniqueId, const String8& path, const String8& mimeType) { +bool DrmManagerClientImpl::canHandle( + int uniqueId, const String8& path, const String8& mimeType) { bool retCode = false; if ((EMPTY_STRING != path) || (EMPTY_STRING != mimeType)) { retCode = getDrmManagerService()->canHandle(uniqueId, path, mimeType); @@ -121,7 +122,8 @@ bool DrmManagerClientImpl::canHandle(int uniqueId, const String8& path, const St return retCode; } -DrmInfoStatus* DrmManagerClientImpl::processDrmInfo(int uniqueId, const DrmInfo* drmInfo) { +DrmInfoStatus* DrmManagerClientImpl::processDrmInfo( + int uniqueId, const DrmInfo* drmInfo) { DrmInfoStatus *drmInfoStatus = NULL; if (NULL != drmInfo) { drmInfoStatus = getDrmManagerService()->processDrmInfo(uniqueId, drmInfo); @@ -129,7 +131,8 @@ DrmInfoStatus* DrmManagerClientImpl::processDrmInfo(int uniqueId, const DrmInfo* return drmInfoStatus; } -DrmInfo* DrmManagerClientImpl::acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInfoRequest) { +DrmInfo* DrmManagerClientImpl::acquireDrmInfo( + int uniqueId, const DrmInfoRequest* drmInfoRequest) { DrmInfo* drmInfo = NULL; if (NULL != drmInfoRequest) { drmInfo = getDrmManagerService()->acquireDrmInfo(uniqueId, drmInfoRequest); @@ -139,14 +142,12 @@ DrmInfo* DrmManagerClientImpl::acquireDrmInfo(int uniqueId, const DrmInfoRequest status_t DrmManagerClientImpl::saveRights(int uniqueId, const DrmRights& drmRights, const String8& rightsPath, const String8& contentPath) { - status_t status = DRM_ERROR_UNKNOWN; - if (EMPTY_STRING != contentPath) { - status = getDrmManagerService()->saveRights(uniqueId, drmRights, rightsPath, contentPath); - } - return status; + return getDrmManagerService()->saveRights( + uniqueId, drmRights, rightsPath, contentPath); } -String8 DrmManagerClientImpl::getOriginalMimeType(int uniqueId, const String8& path) { +String8 DrmManagerClientImpl::getOriginalMimeType( + int uniqueId, const String8& path) { String8 mimeType = EMPTY_STRING; if (EMPTY_STRING != path) { mimeType = getDrmManagerService()->getOriginalMimeType(uniqueId, path); @@ -158,7 +159,8 @@ int DrmManagerClientImpl::getDrmObjectType( int uniqueId, const String8& path, const String8& mimeType) { int drmOjectType = DrmObjectType::UNKNOWN; if ((EMPTY_STRING != path) || (EMPTY_STRING != mimeType)) { - drmOjectType = getDrmManagerService()->getDrmObjectType(uniqueId, path, mimeType); + drmOjectType = + getDrmManagerService()->getDrmObjectType(uniqueId, path, mimeType); } return drmOjectType; } @@ -167,35 +169,41 @@ int DrmManagerClientImpl::checkRightsStatus( int uniqueId, const String8& path, int action) { int rightsStatus = RightsStatus::RIGHTS_INVALID; if (EMPTY_STRING != path) { - rightsStatus = getDrmManagerService()->checkRightsStatus(uniqueId, path, action); + rightsStatus = + getDrmManagerService()->checkRightsStatus(uniqueId, path, action); } return rightsStatus; } status_t DrmManagerClientImpl::consumeRights( - int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) { + int uniqueId, sp<DecryptHandle> &decryptHandle, + int action, bool reserve) { status_t status = DRM_ERROR_UNKNOWN; - if (NULL != decryptHandle) { - status = getDrmManagerService()->consumeRights(uniqueId, decryptHandle, action, reserve); + if (NULL != decryptHandle.get()) { + status = getDrmManagerService()->consumeRights( + uniqueId, decryptHandle.get(), action, reserve); } return status; } status_t DrmManagerClientImpl::setPlaybackStatus( - int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position) { + int uniqueId, sp<DecryptHandle> &decryptHandle, + int playbackStatus, int64_t position) { status_t status = DRM_ERROR_UNKNOWN; - if (NULL != decryptHandle) { + if (NULL != decryptHandle.get()) { status = getDrmManagerService()->setPlaybackStatus( - uniqueId, decryptHandle, playbackStatus, position); + uniqueId, decryptHandle.get(), playbackStatus, position); } return status; } bool DrmManagerClientImpl::validateAction( - int uniqueId, const String8& path, int action, const ActionDescription& description) { + int uniqueId, const String8& path, + int action, const ActionDescription& description) { bool retCode = false; if (EMPTY_STRING != path) { - retCode = getDrmManagerService()->validateAction(uniqueId, path, action, description); + retCode = getDrmManagerService()->validateAction( + uniqueId, path, action, description); } return retCode; } @@ -212,7 +220,8 @@ status_t DrmManagerClientImpl::removeAllRights(int uniqueId) { return getDrmManagerService()->removeAllRights(uniqueId); } -int DrmManagerClientImpl::openConvertSession(int uniqueId, const String8& mimeType) { +int DrmManagerClientImpl::openConvertSession( + int uniqueId, const String8& mimeType) { int retCode = INVALID_VALUE; if (EMPTY_STRING != mimeType) { retCode = getDrmManagerService()->openConvertSession(uniqueId, mimeType); @@ -224,12 +233,14 @@ DrmConvertedStatus* DrmManagerClientImpl::convertData( int uniqueId, int convertId, const DrmBuffer* inputData) { DrmConvertedStatus* drmConvertedStatus = NULL; if (NULL != inputData) { - drmConvertedStatus = getDrmManagerService()->convertData(uniqueId, convertId, inputData); + drmConvertedStatus = + getDrmManagerService()->convertData(uniqueId, convertId, inputData); } return drmConvertedStatus; } -DrmConvertedStatus* DrmManagerClientImpl::closeConvertSession(int uniqueId, int convertId) { +DrmConvertedStatus* DrmManagerClientImpl::closeConvertSession( + int uniqueId, int convertId) { return getDrmManagerService()->closeConvertSession(uniqueId, convertId); } @@ -237,17 +248,19 @@ status_t DrmManagerClientImpl::getAllSupportInfo( int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray) { status_t status = DRM_ERROR_UNKNOWN; if ((NULL != drmSupportInfoArray) && (NULL != length)) { - status = getDrmManagerService()->getAllSupportInfo(uniqueId, length, drmSupportInfoArray); + status = getDrmManagerService()->getAllSupportInfo( + uniqueId, length, drmSupportInfoArray); } return status; } -DecryptHandle* DrmManagerClientImpl::openDecryptSession( +sp<DecryptHandle> DrmManagerClientImpl::openDecryptSession( int uniqueId, int fd, off64_t offset, off64_t length) { return getDrmManagerService()->openDecryptSession(uniqueId, fd, offset, length); } -DecryptHandle* DrmManagerClientImpl::openDecryptSession(int uniqueId, const char* uri) { +sp<DecryptHandle> DrmManagerClientImpl::openDecryptSession( + int uniqueId, const char* uri) { DecryptHandle* handle = NULL; if (NULL != uri) { handle = getDrmManagerService()->openDecryptSession(uniqueId, uri); @@ -255,50 +268,57 @@ DecryptHandle* DrmManagerClientImpl::openDecryptSession(int uniqueId, const char return handle; } -status_t DrmManagerClientImpl::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) { +status_t DrmManagerClientImpl::closeDecryptSession( + int uniqueId, sp<DecryptHandle> &decryptHandle) { status_t status = DRM_ERROR_UNKNOWN; - if (NULL != decryptHandle) { - status = getDrmManagerService()->closeDecryptSession( uniqueId, decryptHandle); + if (NULL != decryptHandle.get()) { + status = getDrmManagerService()->closeDecryptSession( + uniqueId, decryptHandle.get()); } return status; } -status_t DrmManagerClientImpl::initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, - int decryptUnitId, const DrmBuffer* headerInfo) { +status_t DrmManagerClientImpl::initializeDecryptUnit( + int uniqueId, sp<DecryptHandle> &decryptHandle, + int decryptUnitId, const DrmBuffer* headerInfo) { status_t status = DRM_ERROR_UNKNOWN; - if ((NULL != decryptHandle) && (NULL != headerInfo)) { + if ((NULL != decryptHandle.get()) && (NULL != headerInfo)) { status = getDrmManagerService()->initializeDecryptUnit( - uniqueId, decryptHandle, decryptUnitId, headerInfo); + uniqueId, decryptHandle.get(), decryptUnitId, headerInfo); } return status; } -status_t DrmManagerClientImpl::decrypt(int uniqueId, DecryptHandle* decryptHandle, - int decryptUnitId, const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) { +status_t DrmManagerClientImpl::decrypt( + int uniqueId, sp<DecryptHandle> &decryptHandle, + int decryptUnitId, const DrmBuffer* encBuffer, + DrmBuffer** decBuffer, DrmBuffer* IV) { status_t status = DRM_ERROR_UNKNOWN; - if ((NULL != decryptHandle) && (NULL != encBuffer) + if ((NULL != decryptHandle.get()) && (NULL != encBuffer) && (NULL != decBuffer) && (NULL != *decBuffer)) { status = getDrmManagerService()->decrypt( - uniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer, IV); + uniqueId, decryptHandle.get(), decryptUnitId, + encBuffer, decBuffer, IV); } return status; } status_t DrmManagerClientImpl::finalizeDecryptUnit( - int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) { + int uniqueId, sp<DecryptHandle> &decryptHandle, int decryptUnitId) { status_t status = DRM_ERROR_UNKNOWN; - if (NULL != decryptHandle) { - status - = getDrmManagerService()->finalizeDecryptUnit(uniqueId, decryptHandle, decryptUnitId); + if (NULL != decryptHandle.get()) { + status = getDrmManagerService()->finalizeDecryptUnit( + uniqueId, decryptHandle.get(), decryptUnitId); } return status; } -ssize_t DrmManagerClientImpl::pread(int uniqueId, DecryptHandle* decryptHandle, +ssize_t DrmManagerClientImpl::pread(int uniqueId, sp<DecryptHandle> &decryptHandle, void* buffer, ssize_t numBytes, off64_t offset) { ssize_t retCode = INVALID_VALUE; - if ((NULL != decryptHandle) && (NULL != buffer) && (0 < numBytes)) { - retCode = getDrmManagerService()->pread(uniqueId, decryptHandle, buffer, numBytes, offset); + if ((NULL != decryptHandle.get()) && (NULL != buffer) && (0 < numBytes)) { + retCode = getDrmManagerService()->pread( + uniqueId, decryptHandle.get(), buffer, numBytes, offset); } return retCode; } diff --git a/drm/libdrmframework/include/DrmManager.h b/drm/libdrmframework/include/DrmManager.h index c7276f9..ac2b946 100644 --- a/drm/libdrmframework/include/DrmManager.h +++ b/drm/libdrmframework/include/DrmManager.h @@ -30,7 +30,6 @@ class IDrmManager; class DrmRegistrationInfo; class DrmUnregistrationInfo; class DrmRightsAcquisitionInfo; -class DrmContentIds; class DrmConstraints; class DrmMetadata; class DrmRights; @@ -54,7 +53,7 @@ public: virtual ~DrmManager(); public: - int addUniqueId(int uniqueId); + int addUniqueId(bool isNative); void removeUniqueId(int uniqueId); @@ -141,7 +140,7 @@ private: bool canHandle(int uniqueId, const String8& path); private: - static Vector<int> mUniqueIdVector; + Vector<int> mUniqueIdVector; static const String8 EMPTY_STRING; int mDecryptSessionId; diff --git a/drm/libdrmframework/include/DrmManagerClientImpl.h b/drm/libdrmframework/include/DrmManagerClientImpl.h index 429e4c3..e3338d9 100644 --- a/drm/libdrmframework/include/DrmManagerClientImpl.h +++ b/drm/libdrmframework/include/DrmManagerClientImpl.h @@ -38,7 +38,7 @@ private: DrmManagerClientImpl() { } public: - static DrmManagerClientImpl* create(int* pUniqueId); + static DrmManagerClientImpl* create(int* pUniqueId, bool isNative); static void remove(int uniqueId); @@ -189,7 +189,7 @@ public: * @return status_t * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure */ - status_t consumeRights(int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve); + status_t consumeRights(int uniqueId, sp<DecryptHandle> &decryptHandle, int action, bool reserve); /** * Informs the DRM engine about the playback actions performed on the DRM files. @@ -203,7 +203,7 @@ public: * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure */ status_t setPlaybackStatus( - int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position); + int uniqueId, sp<DecryptHandle> &decryptHandle, int playbackStatus, int64_t position); /** * Validates whether an action on the DRM content is allowed or not. @@ -303,7 +303,7 @@ public: * @return * Handle for the decryption session */ - DecryptHandle* openDecryptSession(int uniqueId, int fd, off64_t offset, off64_t length); + sp<DecryptHandle> openDecryptSession(int uniqueId, int fd, off64_t offset, off64_t length); /** * Open the decrypt session to decrypt the given protected content @@ -313,7 +313,7 @@ public: * @return * Handle for the decryption session */ - DecryptHandle* openDecryptSession(int uniqueId, const char* uri); + sp<DecryptHandle> openDecryptSession(int uniqueId, const char* uri); /** * Close the decrypt session for the given handle @@ -323,7 +323,7 @@ public: * @return status_t * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure */ - status_t closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle); + status_t closeDecryptSession(int uniqueId, sp<DecryptHandle> &decryptHandle); /** * Initialize decryption for the given unit of the protected content @@ -335,7 +335,7 @@ public: * @return status_t * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure */ - status_t initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, + status_t initializeDecryptUnit(int uniqueId, sp<DecryptHandle> &decryptHandle, int decryptUnitId, const DrmBuffer* headerInfo); /** @@ -355,7 +355,7 @@ public: * DRM_ERROR_SESSION_NOT_OPENED, DRM_ERROR_DECRYPT_UNIT_NOT_INITIALIZED, * DRM_ERROR_DECRYPT for failure. */ - status_t decrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId, + status_t decrypt(int uniqueId, sp<DecryptHandle> &decryptHandle, int decryptUnitId, const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV); /** @@ -367,7 +367,7 @@ public: * @return status_t * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure */ - status_t finalizeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId); + status_t finalizeDecryptUnit(int uniqueId, sp<DecryptHandle> &decryptHandle, int decryptUnitId); /** * Reads the specified number of bytes from an open DRM file. @@ -380,7 +380,7 @@ public: * * @return Number of bytes read. Returns -1 for Failure. */ - ssize_t pread(int uniqueId, DecryptHandle* decryptHandle, + ssize_t pread(int uniqueId, sp<DecryptHandle> &decryptHandle, void* buffer, ssize_t numBytes, off64_t offset); /** diff --git a/drm/libdrmframework/include/DrmManagerService.h b/drm/libdrmframework/include/DrmManagerService.h index d0a0db7..9cb5804 100644 --- a/drm/libdrmframework/include/DrmManagerService.h +++ b/drm/libdrmframework/include/DrmManagerService.h @@ -46,7 +46,7 @@ private: virtual ~DrmManagerService(); public: - int addUniqueId(int uniqueId); + int addUniqueId(bool isNative); void removeUniqueId(int uniqueId); @@ -115,6 +115,8 @@ public: ssize_t pread(int uniqueId, DecryptHandle* decryptHandle, void* buffer, ssize_t numBytes, off64_t offset); + virtual status_t dump(int fd, const Vector<String16>& args); + private: DrmManager* mDrmManager; }; diff --git a/drm/libdrmframework/include/IDrmManagerService.h b/drm/libdrmframework/include/IDrmManagerService.h index 2424ea5..b9618bb 100644 --- a/drm/libdrmframework/include/IDrmManagerService.h +++ b/drm/libdrmframework/include/IDrmManagerService.h @@ -25,7 +25,6 @@ namespace android { -class DrmContentIds; class DrmConstraints; class DrmMetadata; class DrmRights; @@ -82,7 +81,7 @@ public: DECLARE_META_INTERFACE(DrmManagerService); public: - virtual int addUniqueId(int uniqueId) = 0; + virtual int addUniqueId(bool isNative) = 0; virtual void removeUniqueId(int uniqueId) = 0; @@ -168,7 +167,7 @@ public: BpDrmManagerService(const sp<IBinder>& impl) : BpInterface<IDrmManagerService>(impl) {} - virtual int addUniqueId(int uniqueId); + virtual int addUniqueId(bool isNative); virtual void removeUniqueId(int uniqueId); diff --git a/drm/libdrmframework/include/PlugInManager.h b/drm/libdrmframework/include/PlugInManager.h index 8029138..7bb143f 100644 --- a/drm/libdrmframework/include/PlugInManager.h +++ b/drm/libdrmframework/include/PlugInManager.h @@ -202,7 +202,7 @@ private: Vector<String8> getPlugInPathList(const String8& rsDirPath) { Vector<String8> fileList; DIR* pDir = opendir(rsDirPath.string()); - struct dirent* pEntry = new dirent(); + struct dirent* pEntry; while (NULL != pDir && NULL != (pEntry = readdir(pDir))) { if (!isPlugIn(pEntry)) { @@ -219,8 +219,6 @@ private: if (NULL != pDir) { closedir(pDir); } - delete pEntry; - pEntry = NULL; return fileList; } diff --git a/drm/libdrmframework/plugins/common/include/DrmEngineBase.h b/drm/libdrmframework/plugins/common/include/DrmEngineBase.h index b61e3d3..4a5afcf 100644 --- a/drm/libdrmframework/plugins/common/include/DrmEngineBase.h +++ b/drm/libdrmframework/plugins/common/include/DrmEngineBase.h @@ -143,7 +143,13 @@ protected: * Register a callback to be invoked when the caller required to * receive necessary information * - * @param[in] uniqueId Unique identifier for a session + * @param[in] uniqueId Unique identifier for a session. uniqueId is a random + * number generated in the DRM service. If the DrmManagerClient + * is created in native code, uniqueId will be a number ranged + * from 0x1000 to 0x1fff. If it comes from Java code, the uniqueId + * will be a number ranged from 0x00 to 0xfff. So bit 0x1000 in + * uniqueId could be used in DRM plugins to differentiate native + * OnInfoListener and Java OnInfoListener. * @param[in] infoListener Listener * @return status_t * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure diff --git a/drm/libdrmframework/plugins/common/include/IDrmEngine.h b/drm/libdrmframework/plugins/common/include/IDrmEngine.h index d05c24f..77460f6 100644 --- a/drm/libdrmframework/plugins/common/include/IDrmEngine.h +++ b/drm/libdrmframework/plugins/common/include/IDrmEngine.h @@ -21,7 +21,6 @@ namespace android { -class DrmContentIds; class DrmConstraints; class DrmMetadata; class DrmRights; diff --git a/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/Android.mk b/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/Android.mk index 35fa734..e359dbd 100644 --- a/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/Android.mk +++ b/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/Android.mk @@ -50,7 +50,7 @@ LOCAL_STATIC_LIBRARIES := \ libfwdlock-converter \ libfwdlock-decoder -LOCAL_PRELINK_MODULE := false + LOCAL_C_INCLUDES += \ $(JNI_H_INCLUDE) \ diff --git a/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/src/FwdLockEngine.cpp b/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/src/FwdLockEngine.cpp index 9453a20..e184545 100644 --- a/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/src/FwdLockEngine.cpp +++ b/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/src/FwdLockEngine.cpp @@ -472,11 +472,14 @@ status_t FwdLockEngine::onOpenDecryptSession(int uniqueId, } else { LOG_VERBOSE("FwdLockEngine::onOpenDecryptSession Integrity Check failed for the fd"); FwdLockFile_detach(fileDesc); - ::close(fileDesc); delete decodeSession; } } + if (DRM_NO_ERROR != result && -1 < fileDesc) { + ::close(fileDesc); + } + LOG_VERBOSE("FwdLockEngine::onOpenDecryptSession Exit. result = %d", result); return result; @@ -526,6 +529,19 @@ status_t FwdLockEngine::onCloseDecryptSession(int uniqueId, } } + if (NULL != decryptHandle) { + if (NULL != decryptHandle->decryptInfo) { + delete decryptHandle->decryptInfo; + decryptHandle->decryptInfo = NULL; + } + + decryptHandle->copyControlVector.clear(); + decryptHandle->extendedData.clear(); + + delete decryptHandle; + decryptHandle = NULL; + } + LOG_VERBOSE("FwdLockEngine::onCloseDecryptSession Exit"); return result; } diff --git a/drm/libdrmframework/plugins/passthru/Android.mk b/drm/libdrmframework/plugins/passthru/Android.mk index 7856d37..d0d1439 100644 --- a/drm/libdrmframework/plugins/passthru/Android.mk +++ b/drm/libdrmframework/plugins/passthru/Android.mk @@ -24,15 +24,9 @@ LOCAL_MODULE := libdrmpassthruplugin LOCAL_STATIC_LIBRARIES := libdrmframeworkcommon LOCAL_SHARED_LIBRARIES := \ - libutils + libutils \ + libdl -ifeq ($(TARGET_SIMULATOR),true) - LOCAL_LDLIBS += -ldl -else - LOCAL_SHARED_LIBRARIES += libdl -endif - -LOCAL_PRELINK_MODULE := false LOCAL_C_INCLUDES += \ $(TOP)/frameworks/base/drm/libdrmframework/include \ |