diff options
author | Takeshi Aimi <aimitakeshi@gmail.com> | 2010-09-20 23:40:41 +0900 |
---|---|---|
committer | Takeshi Aimi <aimitakeshi@gmail.com> | 2010-10-04 22:14:53 +0900 |
commit | 2272ee27d9022d173b6eab45c409b3c3f57f30ec (patch) | |
tree | 42fd86597781bdf6b3795907ec1d086b0b549a5c /drm/libdrmframework/DrmManagerClientImpl.cpp | |
parent | 0335b70c6cdbe96650d4bed817f9233cd8db1c6d (diff) | |
download | frameworks_av-2272ee27d9022d173b6eab45c409b3c3f57f30ec.zip frameworks_av-2272ee27d9022d173b6eab45c409b3c3f57f30ec.tar.gz frameworks_av-2272ee27d9022d173b6eab45c409b3c3f57f30ec.tar.bz2 |
Update of DRM framework.
- Change "void" type of return value to "int" for returning status.
- Add some of overloaded Java APIs which accept database Uri as input.
- Add asynchronous APIs
- Add OnEventListener and OnErrorListener for asynchronous APIs
- Disable debug log
- Change decrypt() API to accept an optional buffer needed by some of DRM schemes
Changes are incorporated by Sony Corporation.
Change-Id: I414a165e22cc79be6ea7cd28041788aa2b6b8f7c
Diffstat (limited to 'drm/libdrmframework/DrmManagerClientImpl.cpp')
-rw-r--r-- | drm/libdrmframework/DrmManagerClientImpl.cpp | 85 |
1 files changed, 38 insertions, 47 deletions
diff --git a/drm/libdrmframework/DrmManagerClientImpl.cpp b/drm/libdrmframework/DrmManagerClientImpl.cpp index 7274b49..272adcd 100644 --- a/drm/libdrmframework/DrmManagerClientImpl.cpp +++ b/drm/libdrmframework/DrmManagerClientImpl.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#define LOG_NDEBUG 0 +//#define LOG_NDEBUG 0 #define LOG_TAG "DrmManagerClientImpl(Native)" #include <utils/Log.h> @@ -29,44 +29,21 @@ using namespace android; #define INVALID_VALUE -1 Mutex DrmManagerClientImpl::mMutex; -Vector<int> DrmManagerClientImpl::mUniqueIdVector; sp<IDrmManagerService> DrmManagerClientImpl::mDrmManagerService; const String8 DrmManagerClientImpl::EMPTY_STRING(""); DrmManagerClientImpl* DrmManagerClientImpl::create(int* pUniqueId) { if (0 == *pUniqueId) { - int uniqueId = 0; - bool foundUniqueId = false; - srand(time(NULL)); - - while (!foundUniqueId) { - const int size = mUniqueIdVector.size(); - uniqueId = rand() % 100; - - int index = 0; - for (; index < size; ++index) { - if (mUniqueIdVector.itemAt(index) == uniqueId) { - foundUniqueId = false; - break; - } - } - if (index == size) { - foundUniqueId = true; - } - } + int uniqueId = getDrmManagerService()->addUniqueId(*pUniqueId); *pUniqueId = uniqueId; + } else { + getDrmManagerService()->addUniqueId(*pUniqueId); } - mUniqueIdVector.push(*pUniqueId); return new DrmManagerClientImpl(); } void DrmManagerClientImpl::remove(int uniqueId) { - for (int i = 0; i < mUniqueIdVector.size(); i++) { - if (uniqueId == mUniqueIdVector.itemAt(i)) { - mUniqueIdVector.removeAt(i); - break; - } - } + getDrmManagerService()->removeUniqueId(uniqueId); } DrmManagerClientImpl::DrmManagerClientImpl() { @@ -164,11 +141,13 @@ DrmInfo* DrmManagerClientImpl::acquireDrmInfo(int uniqueId, const DrmInfoRequest return drmInfo; } -void DrmManagerClientImpl::saveRights(int uniqueId, const DrmRights& drmRights, +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) { - getDrmManagerService()->saveRights(uniqueId, drmRights, rightsPath, contentPath); + status = getDrmManagerService()->saveRights(uniqueId, drmRights, rightsPath, contentPath); } + return status; } String8 DrmManagerClientImpl::getOriginalMimeType(int uniqueId, const String8& path) { @@ -197,19 +176,23 @@ int DrmManagerClientImpl::checkRightsStatus( return rightsStatus; } -void DrmManagerClientImpl::consumeRights( +status_t DrmManagerClientImpl::consumeRights( int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) { + status_t status = DRM_ERROR_UNKNOWN; if (NULL != decryptHandle) { - getDrmManagerService()->consumeRights(uniqueId, decryptHandle, action, reserve); + status = getDrmManagerService()->consumeRights(uniqueId, decryptHandle, action, reserve); } + return status; } -void DrmManagerClientImpl::setPlaybackStatus( +status_t DrmManagerClientImpl::setPlaybackStatus( int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) { + status_t status = DRM_ERROR_UNKNOWN; if (NULL != decryptHandle) { - getDrmManagerService()->setPlaybackStatus( + status = getDrmManagerService()->setPlaybackStatus( uniqueId, decryptHandle, playbackStatus, position); } + return status; } bool DrmManagerClientImpl::validateAction( @@ -221,14 +204,16 @@ bool DrmManagerClientImpl::validateAction( return retCode; } -void DrmManagerClientImpl::removeRights(int uniqueId, const String8& path) { +status_t DrmManagerClientImpl::removeRights(int uniqueId, const String8& path) { + status_t status = DRM_ERROR_UNKNOWN; if (EMPTY_STRING != path) { - getDrmManagerService()->removeRights(uniqueId, path); + status = getDrmManagerService()->removeRights(uniqueId, path); } + return status; } -void DrmManagerClientImpl::removeAllRights(int uniqueId) { - getDrmManagerService()->removeAllRights(uniqueId); +status_t DrmManagerClientImpl::removeAllRights(int uniqueId) { + return getDrmManagerService()->removeAllRights(uniqueId); } int DrmManagerClientImpl::openConvertSession(int uniqueId, const String8& mimeType) { @@ -263,40 +248,46 @@ status_t DrmManagerClientImpl::getAllSupportInfo( DecryptHandle* DrmManagerClientImpl::openDecryptSession( int uniqueId, int fd, int offset, int length) { - LOGV("Entering DrmManagerClientImpl::openDecryptSession"); return getDrmManagerService()->openDecryptSession(uniqueId, fd, offset, length); } -void DrmManagerClientImpl::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) { +status_t DrmManagerClientImpl::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) { + status_t status = DRM_ERROR_UNKNOWN; if (NULL != decryptHandle) { - getDrmManagerService()->closeDecryptSession( uniqueId, decryptHandle); + status = getDrmManagerService()->closeDecryptSession( uniqueId, decryptHandle); } + return status; } -void DrmManagerClientImpl::initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, +status_t DrmManagerClientImpl::initializeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId, const DrmBuffer* headerInfo) { + status_t status = DRM_ERROR_UNKNOWN; if ((NULL != decryptHandle) && (NULL != headerInfo)) { - getDrmManagerService()->initializeDecryptUnit( + status = getDrmManagerService()->initializeDecryptUnit( uniqueId, decryptHandle, decryptUnitId, headerInfo); } + return status; } status_t DrmManagerClientImpl::decrypt(int uniqueId, DecryptHandle* decryptHandle, - int decryptUnitId, const DrmBuffer* encBuffer, DrmBuffer** decBuffer) { + int decryptUnitId, const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) { status_t status = DRM_ERROR_UNKNOWN; if ((NULL != decryptHandle) && (NULL != encBuffer) && (NULL != decBuffer) && (NULL != *decBuffer)) { status = getDrmManagerService()->decrypt( - uniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer); + uniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer, IV); } return status; } -void DrmManagerClientImpl::finalizeDecryptUnit( +status_t DrmManagerClientImpl::finalizeDecryptUnit( int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) { + status_t status = DRM_ERROR_UNKNOWN; if (NULL != decryptHandle) { - getDrmManagerService()->finalizeDecryptUnit(uniqueId, decryptHandle, decryptUnitId); + status + = getDrmManagerService()->finalizeDecryptUnit(uniqueId, decryptHandle, decryptUnitId); } + return status; } ssize_t DrmManagerClientImpl::pread(int uniqueId, DecryptHandle* decryptHandle, |