diff options
Diffstat (limited to 'drm/common/IDrmManagerService.cpp')
| -rw-r--r-- | drm/common/IDrmManagerService.cpp | 219 |
1 files changed, 150 insertions, 69 deletions
diff --git a/drm/common/IDrmManagerService.cpp b/drm/common/IDrmManagerService.cpp index 4fc828a..b8ae852 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,27 +36,35 @@ using namespace android; -status_t BpDrmManagerService::loadPlugIns(int uniqueId) { - LOGV("load plugins"); +int BpDrmManagerService::addUniqueId(int uniqueId) { + LOGV("add uniqueid"); Parcel data, reply; - data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); data.writeInt32(uniqueId); - - remote()->transact(LOAD_PLUGINS, data, &reply); + remote()->transact(ADD_UNIQUEID, data, &reply); return reply.readInt32(); } -status_t BpDrmManagerService::loadPlugIns(int uniqueId, const String8& plugInDirPath) { - LOGV("load plugins from path"); +void BpDrmManagerService::removeUniqueId(int uniqueId) { + LOGV("remove uniqueid"); Parcel data, reply; + data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); + data.writeInt32(uniqueId); + remote()->transact(REMOVE_UNIQUEID, data, &reply); +} +void BpDrmManagerService::addClient(int uniqueId) { + Parcel data, reply; data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); data.writeInt32(uniqueId); - data.writeString8(plugInDirPath); + remote()->transact(ADD_CLIENT, data, &reply); +} - remote()->transact(LOAD_PLUGINS_FROM_PATH, data, &reply); - return reply.readInt32(); +void BpDrmManagerService::removeClient(int uniqueId) { + Parcel data, reply; + data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); + data.writeInt32(uniqueId); + remote()->transact(REMOVE_CLIENT, data, &reply); } status_t BpDrmManagerService::setDrmServiceListener( @@ -71,17 +79,6 @@ status_t BpDrmManagerService::setDrmServiceListener( return reply.readInt32(); } -status_t BpDrmManagerService::unloadPlugIns(int uniqueId) { - LOGV("unload plugins"); - Parcel data, reply; - - data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); - data.writeInt32(uniqueId); - - remote()->transact(UNLOAD_PLUGINS, data, &reply); - return reply.readInt32(); -} - status_t BpDrmManagerService::installDrmEngine(int uniqueId, const String8& drmEngineFile) { LOGV("Install DRM Engine"); Parcel data, reply; @@ -174,6 +171,7 @@ DrmInfoStatus* BpDrmManagerService::processDrmInfo(int uniqueId, const DrmInfo* if (0 != reply.dataAvail()) { //Filling DRM Info Status const int statusCode = reply.readInt32(); + const int infoType = reply.readInt32(); const String8 mimeType = reply.readString8(); DrmBuffer* drmBuffer = NULL; @@ -186,7 +184,7 @@ DrmInfoStatus* BpDrmManagerService::processDrmInfo(int uniqueId, const DrmInfo* } drmBuffer = new DrmBuffer(data, bufferSize); } - drmInfoStatus = new DrmInfoStatus(statusCode, drmBuffer, mimeType); + drmInfoStatus = new DrmInfoStatus(statusCode, infoType, drmBuffer, mimeType); } return drmInfoStatus; } @@ -237,7 +235,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 +262,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 +306,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 +329,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 +355,7 @@ void BpDrmManagerService::setPlaybackStatus( data.writeInt32(position); remote()->transact(SET_PLAYBACK_STATUS, data, &reply); + return reply.readInt32(); } bool BpDrmManagerService::validateAction( @@ -375,7 +376,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 +385,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 +396,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) { @@ -516,16 +519,12 @@ DecryptHandle* BpDrmManagerService::openDecryptSession( LOGV("Entering BpDrmManagerService::openDecryptSession"); Parcel data, reply; - const String16 interfaceDescriptor = IDrmManagerService::getInterfaceDescriptor(); - LOGV("BpDrmManagerService::openDecryptSession: InterfaceDescriptor name is %s", - interfaceDescriptor.string()); - data.writeInterfaceToken(interfaceDescriptor); + data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); 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 +545,35 @@ DecryptHandle* BpDrmManagerService::openDecryptSession( return handle; } -void BpDrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) { +DecryptHandle* BpDrmManagerService::openDecryptSession(int uniqueId, const char* uri) { + LOGV("Entering BpDrmManagerService::openDecryptSession"); + Parcel data, reply; + + data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); + data.writeInt32(uniqueId); + data.writeString8(String8(uri)); + + remote()->transact(OPEN_DECRYPT_SESSION_FROM_URI, data, &reply); + + DecryptHandle* handle = NULL; + if (0 != reply.dataAvail()) { + handle = new DecryptHandle(); + handle->decryptId = reply.readInt32(); + handle->mimeType = reply.readString8(); + handle->decryptApiType = reply.readInt32(); + handle->status = reply.readInt32(); + handle->decryptInfo = NULL; + if (0 != reply.dataAvail()) { + handle->decryptInfo = new DecryptInfo(); + handle->decryptInfo->decryptBufferLength = reply.readInt32(); + } + } else { + LOGE("no decryptHandle is generated in service side"); + } + return handle; +} + +status_t BpDrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) { LOGV("closeDecryptSession"); Parcel data, reply; @@ -571,9 +598,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 +626,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 +655,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 +672,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 +694,7 @@ void BpDrmManagerService::finalizeDecryptUnit( data.writeInt32(decryptUnitId); remote()->transact(FINALIZE_DECRYPT_UNIT, data, &reply); + return reply.readInt32(); } ssize_t BpDrmManagerService::pread( @@ -702,26 +737,36 @@ status_t BnDrmManagerService::onTransact( LOGV("Entering BnDrmManagerService::onTransact with code %d", code); switch (code) { - case LOAD_PLUGINS: + case ADD_UNIQUEID: { - LOGV("BnDrmManagerService::onTransact :LOAD_PLUGINS"); + LOGV("BnDrmManagerService::onTransact :ADD_UNIQUEID"); CHECK_INTERFACE(IDrmManagerService, data, reply); - - status_t status = loadPlugIns(data.readInt32()); - - reply->writeInt32(status); + int uniqueId = addUniqueId(data.readInt32()); + reply->writeInt32(uniqueId); return DRM_NO_ERROR; - } - case LOAD_PLUGINS_FROM_PATH: + case REMOVE_UNIQUEID: { - LOGV("BnDrmManagerService::onTransact :LOAD_PLUGINS_FROM_PATH"); + LOGV("BnDrmManagerService::onTransact :REMOVE_UNIQUEID"); CHECK_INTERFACE(IDrmManagerService, data, reply); + removeUniqueId(data.readInt32()); + return DRM_NO_ERROR; + } - status_t status = loadPlugIns(data.readInt32(), data.readString8()); + case ADD_CLIENT: + { + LOGV("BnDrmManagerService::onTransact :ADD_CLIENT"); + CHECK_INTERFACE(IDrmManagerService, data, reply); + addClient(data.readInt32()); + return DRM_NO_ERROR; + } - reply->writeInt32(status); + case REMOVE_CLIENT: + { + LOGV("BnDrmManagerService::onTransact :REMOVE_CLIENT"); + CHECK_INTERFACE(IDrmManagerService, data, reply); + removeClient(data.readInt32()); return DRM_NO_ERROR; } @@ -740,17 +785,6 @@ status_t BnDrmManagerService::onTransact( return DRM_NO_ERROR; } - case UNLOAD_PLUGINS: - { - LOGV("BnDrmManagerService::onTransact :UNLOAD_PLUGINS"); - CHECK_INTERFACE(IDrmManagerService, data, reply); - - status_t status = unloadPlugIns(data.readInt32()); - - reply->writeInt32(status); - return DRM_NO_ERROR; - } - case INSTALL_DRM_ENGINE: { LOGV("BnDrmManagerService::onTransact :INSTALL_DRM_ENGINE"); @@ -837,6 +871,7 @@ status_t BnDrmManagerService::onTransact( if (NULL != drmInfoStatus) { //Filling DRM Info Status contents reply->writeInt32(drmInfoStatus->statusCode); + reply->writeInt32(drmInfoStatus->infoType); reply->writeString8(drmInfoStatus->mimeType); if (NULL != drmInfoStatus->drmBuffer) { @@ -923,10 +958,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 +1021,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 +1050,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 +1078,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 +1089,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; } @@ -1187,6 +1230,32 @@ status_t BnDrmManagerService::onTransact( return DRM_NO_ERROR; } + case OPEN_DECRYPT_SESSION_FROM_URI: + { + LOGV("BnDrmManagerService::onTransact :OPEN_DECRYPT_SESSION_FROM_URI"); + CHECK_INTERFACE(IDrmManagerService, data, reply); + + const int uniqueId = data.readInt32(); + const String8 uri = data.readString8(); + + DecryptHandle* handle = openDecryptSession(uniqueId, uri.string()); + + if (NULL != handle) { + reply->writeInt32(handle->decryptId); + reply->writeString8(handle->mimeType); + reply->writeInt32(handle->decryptApiType); + reply->writeInt32(handle->status); + if (NULL != handle->decryptInfo) { + reply->writeInt32(handle->decryptInfo->decryptBufferLength); + delete handle->decryptInfo; handle->decryptInfo = NULL; + } + } else { + LOGE("NULL decryptHandle is returned"); + } + delete handle; handle = NULL; + return DRM_NO_ERROR; + } + case CLOSE_DECRYPT_SESSION: { LOGV("BnDrmManagerService::onTransact :CLOSE_DECRYPT_SESSION"); @@ -1207,7 +1276,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 +1307,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 +1346,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 +1365,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 +1389,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; |
