diff options
Diffstat (limited to 'drm/common/IDrmManagerService.cpp')
-rw-r--r-- | drm/common/IDrmManagerService.cpp | 114 |
1 files changed, 89 insertions, 25 deletions
diff --git a/drm/common/IDrmManagerService.cpp b/drm/common/IDrmManagerService.cpp index 4fc828a..c28527c 100644 --- a/drm/common/IDrmManagerService.cpp +++ b/drm/common/IDrmManagerService.cpp @@ -14,7 +14,7 @@ * limitations under the License. */ -#define LOG_NDEBUG 0 +//#define LOG_NDEBUG 0 #define LOG_TAG "IDrmManagerService(Native)" #include <utils/Log.h> @@ -36,6 +36,23 @@ using namespace android; +int BpDrmManagerService::addUniqueId(int uniqueId) { + LOGV("add uniqueid"); + Parcel data, reply; + data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); + data.writeInt32(uniqueId); + remote()->transact(ADD_UNIQUEID, data, &reply); + return reply.readInt32(); +} + +void BpDrmManagerService::removeUniqueId(int uniqueId) { + LOGV("remove uniqueid"); + Parcel data, reply; + data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); + data.writeInt32(uniqueId); + remote()->transact(REMOVE_UNIQUEID, data, &reply); +} + status_t BpDrmManagerService::loadPlugIns(int uniqueId) { LOGV("load plugins"); Parcel data, reply; @@ -237,7 +254,7 @@ DrmInfo* BpDrmManagerService::acquireDrmInfo(int uniqueId, const DrmInfoRequest* return drmInfo; } -void BpDrmManagerService::saveRights( +status_t BpDrmManagerService::saveRights( int uniqueId, const DrmRights& drmRights, const String8& rightsPath, const String8& contentPath) { LOGV("Save Rights"); @@ -264,6 +281,7 @@ void BpDrmManagerService::saveRights( data.writeString8((contentPath == String8("")) ? String8("NULL") : contentPath); remote()->transact(SAVE_RIGHTS, data, &reply); + return reply.readInt32(); } String8 BpDrmManagerService::getOriginalMimeType(int uniqueId, const String8& path) { @@ -307,10 +325,10 @@ int BpDrmManagerService::checkRightsStatus(int uniqueId, const String8& path, in return reply.readInt32(); } -void BpDrmManagerService::consumeRights( +status_t BpDrmManagerService::consumeRights( int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) { LOGV("consumeRights"); - Parcel data, reply; + Parcel data, reply; data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); data.writeInt32(uniqueId); @@ -330,9 +348,10 @@ void BpDrmManagerService::consumeRights( data.writeInt32(static_cast< int>(reserve)); remote()->transact(CONSUME_RIGHTS, data, &reply); + return reply.readInt32(); } -void BpDrmManagerService::setPlaybackStatus( +status_t BpDrmManagerService::setPlaybackStatus( int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) { LOGV("setPlaybackStatus"); Parcel data, reply; @@ -355,6 +374,7 @@ void BpDrmManagerService::setPlaybackStatus( data.writeInt32(position); remote()->transact(SET_PLAYBACK_STATUS, data, &reply); + return reply.readInt32(); } bool BpDrmManagerService::validateAction( @@ -375,7 +395,7 @@ bool BpDrmManagerService::validateAction( return static_cast<bool>(reply.readInt32()); } -void BpDrmManagerService::removeRights(int uniqueId, const String8& path) { +status_t BpDrmManagerService::removeRights(int uniqueId, const String8& path) { LOGV("removeRights"); Parcel data, reply; @@ -384,9 +404,10 @@ void BpDrmManagerService::removeRights(int uniqueId, const String8& path) { data.writeString8(path); remote()->transact(REMOVE_RIGHTS, data, &reply); + return reply.readInt32(); } -void BpDrmManagerService::removeAllRights(int uniqueId) { +status_t BpDrmManagerService::removeAllRights(int uniqueId) { LOGV("removeAllRights"); Parcel data, reply; @@ -394,6 +415,7 @@ void BpDrmManagerService::removeAllRights(int uniqueId) { data.writeInt32(uniqueId); remote()->transact(REMOVE_ALL_RIGHTS, data, &reply); + return reply.readInt32(); } int BpDrmManagerService::openConvertSession(int uniqueId, const String8& mimeType) { @@ -517,15 +539,12 @@ DecryptHandle* BpDrmManagerService::openDecryptSession( Parcel data, reply; const String16 interfaceDescriptor = IDrmManagerService::getInterfaceDescriptor(); - LOGV("BpDrmManagerService::openDecryptSession: InterfaceDescriptor name is %s", - interfaceDescriptor.string()); data.writeInterfaceToken(interfaceDescriptor); data.writeInt32(uniqueId); data.writeFileDescriptor(fd); data.writeInt32(offset); data.writeInt32(length); - LOGV("try to invoke remote onTransact() with code OPEN_DECRYPT_SESSION"); remote()->transact(OPEN_DECRYPT_SESSION, data, &reply); DecryptHandle* handle = NULL; @@ -546,7 +565,7 @@ DecryptHandle* BpDrmManagerService::openDecryptSession( return handle; } -void BpDrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) { +status_t BpDrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) { LOGV("closeDecryptSession"); Parcel data, reply; @@ -571,9 +590,10 @@ void BpDrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* decry delete decryptHandle->decryptInfo; decryptHandle->decryptInfo = NULL; } delete decryptHandle; decryptHandle = NULL; + return reply.readInt32(); } -void BpDrmManagerService::initializeDecryptUnit( +status_t BpDrmManagerService::initializeDecryptUnit( int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId, const DrmBuffer* headerInfo) { LOGV("initializeDecryptUnit"); @@ -598,11 +618,12 @@ void BpDrmManagerService::initializeDecryptUnit( data.write(headerInfo->data, headerInfo->length); remote()->transact(INITIALIZE_DECRYPT_UNIT, data, &reply); + return reply.readInt32(); } status_t BpDrmManagerService::decrypt( int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId, - const DrmBuffer* encBuffer, DrmBuffer** decBuffer) { + const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) { LOGV("decrypt"); Parcel data, reply; @@ -626,6 +647,11 @@ status_t BpDrmManagerService::decrypt( data.writeInt32(encBuffer->length); data.write(encBuffer->data, encBuffer->length); + if (NULL != IV) { + data.writeInt32(IV->length); + data.write(IV->data, IV->length); + } + remote()->transact(DECRYPT, data, &reply); const status_t status = reply.readInt32(); @@ -638,7 +664,7 @@ status_t BpDrmManagerService::decrypt( return status; } -void BpDrmManagerService::finalizeDecryptUnit( +status_t BpDrmManagerService::finalizeDecryptUnit( int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) { LOGV("finalizeDecryptUnit"); Parcel data, reply; @@ -660,6 +686,7 @@ void BpDrmManagerService::finalizeDecryptUnit( data.writeInt32(decryptUnitId); remote()->transact(FINALIZE_DECRYPT_UNIT, data, &reply); + return reply.readInt32(); } ssize_t BpDrmManagerService::pread( @@ -702,6 +729,23 @@ status_t BnDrmManagerService::onTransact( LOGV("Entering BnDrmManagerService::onTransact with code %d", code); switch (code) { + case ADD_UNIQUEID: + { + LOGV("BnDrmManagerService::onTransact :ADD_UNIQUEID"); + CHECK_INTERFACE(IDrmManagerService, data, reply); + int uniqueId = addUniqueId(data.readInt32()); + reply->writeInt32(uniqueId); + return DRM_NO_ERROR; + } + + case REMOVE_UNIQUEID: + { + LOGV("BnDrmManagerService::onTransact :REMOVE_UNIQUEID"); + CHECK_INTERFACE(IDrmManagerService, data, reply); + removeUniqueId(data.readInt32()); + return DRM_NO_ERROR; + } + case LOAD_PLUGINS: { LOGV("BnDrmManagerService::onTransact :LOAD_PLUGINS"); @@ -711,7 +755,6 @@ status_t BnDrmManagerService::onTransact( reply->writeInt32(status); return DRM_NO_ERROR; - } case LOAD_PLUGINS_FROM_PATH: @@ -745,7 +788,8 @@ status_t BnDrmManagerService::onTransact( LOGV("BnDrmManagerService::onTransact :UNLOAD_PLUGINS"); CHECK_INTERFACE(IDrmManagerService, data, reply); - status_t status = unloadPlugIns(data.readInt32()); + const int uniqueId = data.readInt32(); + status_t status = unloadPlugIns(uniqueId); reply->writeInt32(status); return DRM_NO_ERROR; @@ -923,10 +967,11 @@ status_t BnDrmManagerService::onTransact( ((accountId == String8("NULL")) ? String8("") : accountId), ((subscriptionId == String8("NULL")) ? String8("") : subscriptionId)); - saveRights(uniqueId, drmRights, + const status_t status = saveRights(uniqueId, drmRights, ((rightsPath == String8("NULL")) ? String8("") : rightsPath), ((contentPath == String8("NULL")) ? String8("") : contentPath)); + reply->writeInt32(status); return DRM_NO_ERROR; } @@ -985,7 +1030,10 @@ status_t BnDrmManagerService::onTransact( handle.decryptInfo->decryptBufferLength = bufferLength; } - consumeRights(uniqueId, &handle, data.readInt32(), static_cast<bool>(data.readInt32())); + const status_t status + = consumeRights(uniqueId, &handle, data.readInt32(), + static_cast<bool>(data.readInt32())); + reply->writeInt32(status); delete handle.decryptInfo; handle.decryptInfo = NULL; return DRM_NO_ERROR; @@ -1011,7 +1059,9 @@ status_t BnDrmManagerService::onTransact( handle.decryptInfo->decryptBufferLength = bufferLength; } - setPlaybackStatus(uniqueId, &handle, data.readInt32(), data.readInt32()); + const status_t status + = setPlaybackStatus(uniqueId, &handle, data.readInt32(), data.readInt32()); + reply->writeInt32(status); delete handle.decryptInfo; handle.decryptInfo = NULL; return DRM_NO_ERROR; @@ -1037,7 +1087,8 @@ status_t BnDrmManagerService::onTransact( LOGV("BnDrmManagerService::onTransact :REMOVE_RIGHTS"); CHECK_INTERFACE(IDrmManagerService, data, reply); - removeRights(data.readInt32(), data.readString8()); + const status_t status = removeRights(data.readInt32(), data.readString8()); + reply->writeInt32(status); return DRM_NO_ERROR; } @@ -1047,7 +1098,8 @@ status_t BnDrmManagerService::onTransact( LOGV("BnDrmManagerService::onTransact :REMOVE_ALL_RIGHTS"); CHECK_INTERFACE(IDrmManagerService, data, reply); - removeAllRights(data.readInt32()); + const status_t status = removeAllRights(data.readInt32()); + reply->writeInt32(status); return DRM_NO_ERROR; } @@ -1207,7 +1259,8 @@ status_t BnDrmManagerService::onTransact( handle->decryptInfo->decryptBufferLength = bufferLength; } - closeDecryptSession(uniqueId, handle); + const status_t status = closeDecryptSession(uniqueId, handle); + reply->writeInt32(status); return DRM_NO_ERROR; } @@ -1237,7 +1290,9 @@ status_t BnDrmManagerService::onTransact( DrmBuffer* headerInfo = NULL; headerInfo = new DrmBuffer((char *)data.readInplace(bufferSize), bufferSize); - initializeDecryptUnit(uniqueId, &handle, decryptUnitId, headerInfo); + const status_t status + = initializeDecryptUnit(uniqueId, &handle, decryptUnitId, headerInfo); + reply->writeInt32(status); delete handle.decryptInfo; handle.decryptInfo = NULL; delete headerInfo; headerInfo = NULL; @@ -1274,7 +1329,14 @@ status_t BnDrmManagerService::onTransact( buffer = new char[decBufferSize]; DrmBuffer* decBuffer = new DrmBuffer(buffer, decBufferSize); - const status_t status = decrypt(uniqueId, &handle, decryptUnitId, encBuffer, &decBuffer); + DrmBuffer* IV = NULL; + if (0 != data.dataAvail()) { + const int ivBufferlength = data.readInt32(); + IV = new DrmBuffer((char *)data.readInplace(ivBufferlength), ivBufferlength); + } + + const status_t status + = decrypt(uniqueId, &handle, decryptUnitId, encBuffer, &decBuffer, IV); reply->writeInt32(status); @@ -1286,6 +1348,7 @@ status_t BnDrmManagerService::onTransact( delete encBuffer; encBuffer = NULL; delete decBuffer; decBuffer = NULL; delete [] buffer; buffer = NULL; + delete IV; IV = NULL; return DRM_NO_ERROR; } @@ -1309,7 +1372,8 @@ status_t BnDrmManagerService::onTransact( handle.decryptInfo->decryptBufferLength = bufferLength; } - finalizeDecryptUnit(uniqueId, &handle, data.readInt32()); + const status_t status = finalizeDecryptUnit(uniqueId, &handle, data.readInt32()); + reply->writeInt32(status); delete handle.decryptInfo; handle.decryptInfo = NULL; return DRM_NO_ERROR; |