diff options
Diffstat (limited to 'drm')
25 files changed, 244 insertions, 648 deletions
diff --git a/drm/common/Android.mk b/drm/common/Android.mk index c79a91a..f1136c9 100644 --- a/drm/common/Android.mk +++ b/drm/common/Android.mk @@ -26,7 +26,6 @@ LOCAL_SRC_FILES:= \ DrmInfoStatus.cpp \ DrmRights.cpp \ DrmSupportInfo.cpp \ - IDrmIOService.cpp \ IDrmManagerService.cpp \ IDrmServiceListener.cpp \ DrmInfoEvent.cpp \ diff --git a/drm/common/DrmEngineBase.cpp b/drm/common/DrmEngineBase.cpp index ac360eb..9b16c36 100644 --- a/drm/common/DrmEngineBase.cpp +++ b/drm/common/DrmEngineBase.cpp @@ -84,7 +84,7 @@ status_t DrmEngineBase::consumeRights( } status_t DrmEngineBase::setPlaybackStatus( - int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) { + int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position) { return onSetPlaybackStatus(uniqueId, decryptHandle, playbackStatus, position); } @@ -120,7 +120,7 @@ DrmSupportInfo* DrmEngineBase::getSupportInfo(int uniqueId) { } status_t DrmEngineBase::openDecryptSession( - int uniqueId, DecryptHandle* decryptHandle, int fd, int offset, int length) { + int uniqueId, DecryptHandle* decryptHandle, int fd, off64_t offset, off64_t length) { return onOpenDecryptSession(uniqueId, decryptHandle, fd, offset, length); } @@ -150,7 +150,7 @@ status_t DrmEngineBase::finalizeDecryptUnit( } ssize_t DrmEngineBase::pread( - int uniqueId, DecryptHandle* decryptHandle, void* buffer, ssize_t numBytes, off_t offset) { + int uniqueId, DecryptHandle* decryptHandle, void* buffer, ssize_t numBytes, off64_t offset) { return onPread(uniqueId, decryptHandle, buffer, numBytes, offset); } diff --git a/drm/common/DrmSupportInfo.cpp b/drm/common/DrmSupportInfo.cpp index ffc8953..c0bff0e 100644 --- a/drm/common/DrmSupportInfo.cpp +++ b/drm/common/DrmSupportInfo.cpp @@ -45,7 +45,7 @@ bool DrmSupportInfo::isSupportedMimeType(const String8& mimeType) const { for (unsigned int i = 0; i < mMimeTypeVector.size(); i++) { const String8 item = mMimeTypeVector.itemAt(i); - if (String8("") != mimeType && item.find(mimeType) != -1) { + if (!strcasecmp(item.string(), mimeType.string())) { return true; } } @@ -56,7 +56,7 @@ bool DrmSupportInfo::isSupportedFileSuffix(const String8& fileType) const { for (unsigned int i = 0; i < mFileSuffixVector.size(); i++) { const String8 item = mFileSuffixVector.itemAt(i); - if (String8("") != fileType && item.find(fileType) != -1) { + if (!strcasecmp(item.string(), fileType.string())) { return true; } } diff --git a/drm/common/IDrmIOService.cpp b/drm/common/IDrmIOService.cpp deleted file mode 100644 index e44ca55..0000000 --- a/drm/common/IDrmIOService.cpp +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include <stdint.h> -#include <sys/types.h> -#include <binder/Parcel.h> -#include <binder/IPCThreadState.h> -#include <drm/drm_framework_common.h> -#include "IDrmIOService.h" - -using namespace android; - -void BpDrmIOService::writeToFile(const String8& filePath, const String8& dataBuffer) { - Parcel data, reply; - - data.writeInterfaceToken(IDrmIOService::getInterfaceDescriptor()); - data.writeString8(filePath); - data.writeString8(dataBuffer); - - remote()->transact(WRITE_TO_FILE, data, &reply); -} - -String8 BpDrmIOService::readFromFile(const String8& filePath) { - - Parcel data, reply; - - data.writeInterfaceToken(IDrmIOService::getInterfaceDescriptor()); - data.writeString8(filePath); - - remote()->transact(READ_FROM_FILE, data, &reply); - return reply.readString8(); -} - -IMPLEMENT_META_INTERFACE(DrmIOService, "drm.IDrmIOService"); - -status_t BnDrmIOService::onTransact( - uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags) { - - switch (code) { - case WRITE_TO_FILE: - { - CHECK_INTERFACE(IDrmIOService, data, reply); - - writeToFile(data.readString8(), data.readString8()); - return DRM_NO_ERROR; - } - - case READ_FROM_FILE: - { - CHECK_INTERFACE(IDrmIOService, data, reply); - - String8 dataBuffer = readFromFile(data.readString8()); - reply->writeString8(dataBuffer); - return DRM_NO_ERROR; - } - - default: - return BBinder::onTransact(code, data, reply, flags); - } -} - diff --git a/drm/common/IDrmManagerService.cpp b/drm/common/IDrmManagerService.cpp index 723b50e..346934b 100644 --- a/drm/common/IDrmManagerService.cpp +++ b/drm/common/IDrmManagerService.cpp @@ -37,6 +37,78 @@ using namespace android; +static void writeDecrptHandleToParcelData( + const DecryptHandle* handle, Parcel* data) { + data->writeInt32(handle->decryptId); + data->writeString8(handle->mimeType); + data->writeInt32(handle->decryptApiType); + data->writeInt32(handle->status); + + int size = handle->copyControlVector.size(); + data->writeInt32(size); + 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++) { + data->writeString8(handle->extendedData.keyAt(i)); + data->writeString8(handle->extendedData.valueAt(i)); + } + + if (NULL != handle->decryptInfo) { + data->writeInt32(handle->decryptInfo->decryptBufferLength); + } else { + data->writeInt32(INVALID_BUFFER_LENGTH); + } +} + +static void readDecryptHandleFromParcelData( + DecryptHandle* handle, const Parcel& data) { + if (0 == data.dataAvail()) { + return; + } + + handle->decryptId = data.readInt32(); + handle->mimeType = data.readString8(); + handle->decryptApiType = data.readInt32(); + handle->status = data.readInt32(); + + int size = data.readInt32(); + 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 ++) { + String8 key = data.readString8(); + String8 value = data.readString8(); + handle->extendedData.add(key, value); + } + + handle->decryptInfo = NULL; + const int bufferLen = data.readInt32(); + if (INVALID_BUFFER_LENGTH != bufferLen) { + handle->decryptInfo = new DecryptInfo(); + handle->decryptInfo->decryptBufferLength = bufferLen; + } +} + +static void clearDecryptHandle(DecryptHandle* handle) { + if (handle == NULL) { + return; + } + if (handle->decryptInfo) { + delete handle->decryptInfo; + handle->decryptInfo = NULL; + } + handle->copyControlVector.clear(); +} + int BpDrmManagerService::addUniqueId(int uniqueId) { LOGV("add uniqueid"); Parcel data, reply; @@ -344,16 +416,7 @@ status_t BpDrmManagerService::consumeRights( data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); data.writeInt32(uniqueId); - data.writeInt32(decryptHandle->decryptId); - data.writeString8(decryptHandle->mimeType); - data.writeInt32(decryptHandle->decryptApiType); - data.writeInt32(decryptHandle->status); - - if (NULL != decryptHandle->decryptInfo) { - data.writeInt32(decryptHandle->decryptInfo->decryptBufferLength); - } else { - data.writeInt32(INVALID_BUFFER_LENGTH); - } + writeDecrptHandleToParcelData(decryptHandle, &data); data.writeInt32(action); data.writeInt32(static_cast< int>(reserve)); @@ -363,26 +426,17 @@ status_t BpDrmManagerService::consumeRights( } status_t BpDrmManagerService::setPlaybackStatus( - int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) { + int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position) { LOGV("setPlaybackStatus"); Parcel data, reply; data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); data.writeInt32(uniqueId); - data.writeInt32(decryptHandle->decryptId); - data.writeString8(decryptHandle->mimeType); - data.writeInt32(decryptHandle->decryptApiType); - data.writeInt32(decryptHandle->status); - - if (NULL != decryptHandle->decryptInfo) { - data.writeInt32(decryptHandle->decryptInfo->decryptBufferLength); - } else { - data.writeInt32(INVALID_BUFFER_LENGTH); - } + writeDecrptHandleToParcelData(decryptHandle, &data); data.writeInt32(playbackStatus); - data.writeInt32(position); + data.writeInt64(position); remote()->transact(SET_PLAYBACK_STATUS, data, &reply); return reply.readInt32(); @@ -459,7 +513,7 @@ DrmConvertedStatus* BpDrmManagerService::convertData( if (0 != reply.dataAvail()) { //Filling DRM Converted Status const int statusCode = reply.readInt32(); - const int offset = reply.readInt32(); + const off64_t offset = reply.readInt64(); DrmBuffer* convertedData = NULL; if (0 != reply.dataAvail()) { @@ -491,7 +545,7 @@ DrmConvertedStatus* BpDrmManagerService::closeConvertSession(int uniqueId, int c if (0 != reply.dataAvail()) { //Filling DRM Converted Status const int statusCode = reply.readInt32(); - const int offset = reply.readInt32(); + const off64_t offset = reply.readInt64(); DrmBuffer* convertedData = NULL; if (0 != reply.dataAvail()) { @@ -545,32 +599,22 @@ status_t BpDrmManagerService::getAllSupportInfo( } DecryptHandle* BpDrmManagerService::openDecryptSession( - int uniqueId, int fd, int offset, int length) { + int uniqueId, int fd, off64_t offset, off64_t length) { LOGV("Entering BpDrmManagerService::openDecryptSession"); Parcel data, reply; data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); data.writeInt32(uniqueId); data.writeFileDescriptor(fd); - data.writeInt32(offset); - data.writeInt32(length); + data.writeInt64(offset); + data.writeInt64(length); remote()->transact(OPEN_DECRYPT_SESSION, 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"); + readDecryptHandleFromParcelData(handle, reply); } return handle; } @@ -588,17 +632,9 @@ DecryptHandle* BpDrmManagerService::openDecryptSession(int uniqueId, const char* 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(); - } + readDecryptHandleFromParcelData(handle, reply); } else { - LOGE("no decryptHandle is generated in service side"); + LOGV("no decryptHandle is generated in service side"); } return handle; } @@ -610,16 +646,7 @@ status_t BpDrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* d data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); data.writeInt32(uniqueId); - data.writeInt32(decryptHandle->decryptId); - data.writeString8(decryptHandle->mimeType); - data.writeInt32(decryptHandle->decryptApiType); - data.writeInt32(decryptHandle->status); - - if (NULL != decryptHandle->decryptInfo) { - data.writeInt32(decryptHandle->decryptInfo->decryptBufferLength); - } else { - data.writeInt32(INVALID_BUFFER_LENGTH); - } + writeDecrptHandleToParcelData(decryptHandle, &data); remote()->transact(CLOSE_DECRYPT_SESSION, data, &reply); @@ -640,16 +667,8 @@ status_t BpDrmManagerService::initializeDecryptUnit( data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); data.writeInt32(uniqueId); - data.writeInt32(decryptHandle->decryptId); - data.writeString8(decryptHandle->mimeType); - data.writeInt32(decryptHandle->decryptApiType); - data.writeInt32(decryptHandle->status); + writeDecrptHandleToParcelData(decryptHandle, &data); - if (NULL != decryptHandle->decryptInfo) { - data.writeInt32(decryptHandle->decryptInfo->decryptBufferLength); - } else { - data.writeInt32(INVALID_BUFFER_LENGTH); - } data.writeInt32(decryptUnitId); data.writeInt32(headerInfo->length); @@ -668,16 +687,7 @@ status_t BpDrmManagerService::decrypt( data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); data.writeInt32(uniqueId); - data.writeInt32(decryptHandle->decryptId); - data.writeString8(decryptHandle->mimeType); - data.writeInt32(decryptHandle->decryptApiType); - data.writeInt32(decryptHandle->status); - - if (NULL != decryptHandle->decryptInfo) { - data.writeInt32(decryptHandle->decryptInfo->decryptBufferLength); - } else { - data.writeInt32(INVALID_BUFFER_LENGTH); - } + writeDecrptHandleToParcelData(decryptHandle, &data); data.writeInt32(decryptUnitId); data.writeInt32((*decBuffer)->length); @@ -710,16 +720,7 @@ status_t BpDrmManagerService::finalizeDecryptUnit( data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); data.writeInt32(uniqueId); - data.writeInt32(decryptHandle->decryptId); - data.writeString8(decryptHandle->mimeType); - data.writeInt32(decryptHandle->decryptApiType); - data.writeInt32(decryptHandle->status); - - if (NULL != decryptHandle->decryptInfo) { - data.writeInt32(decryptHandle->decryptInfo->decryptBufferLength); - } else { - data.writeInt32(INVALID_BUFFER_LENGTH); - } + writeDecrptHandleToParcelData(decryptHandle, &data); data.writeInt32(decryptUnitId); @@ -729,7 +730,7 @@ status_t BpDrmManagerService::finalizeDecryptUnit( ssize_t BpDrmManagerService::pread( int uniqueId, DecryptHandle* decryptHandle, void* buffer, - ssize_t numBytes, off_t offset) { + ssize_t numBytes, off64_t offset) { LOGV("read"); Parcel data, reply; int result; @@ -737,19 +738,10 @@ ssize_t BpDrmManagerService::pread( data.writeInterfaceToken(IDrmManagerService::getInterfaceDescriptor()); data.writeInt32(uniqueId); - data.writeInt32(decryptHandle->decryptId); - data.writeString8(decryptHandle->mimeType); - data.writeInt32(decryptHandle->decryptApiType); - data.writeInt32(decryptHandle->status); - - if (NULL != decryptHandle->decryptInfo) { - data.writeInt32(decryptHandle->decryptInfo->decryptBufferLength); - } else { - data.writeInt32(INVALID_BUFFER_LENGTH); - } + writeDecrptHandleToParcelData(decryptHandle, &data); data.writeInt32(numBytes); - data.writeInt32(offset); + data.writeInt64(offset); remote()->transact(PREAD, data, &reply); result = reply.readInt32(); @@ -1071,24 +1063,14 @@ status_t BnDrmManagerService::onTransact( const int uniqueId = data.readInt32(); DecryptHandle handle; - handle.decryptId = data.readInt32(); - handle.mimeType = data.readString8(); - handle.decryptApiType = data.readInt32(); - handle.status = data.readInt32(); - handle.decryptInfo = NULL; - - const int bufferLength = data.readInt32(); - if (INVALID_BUFFER_LENGTH != bufferLength) { - handle.decryptInfo = new DecryptInfo(); - handle.decryptInfo->decryptBufferLength = bufferLength; - } + readDecryptHandleFromParcelData(&handle, data); const status_t status = consumeRights(uniqueId, &handle, data.readInt32(), static_cast<bool>(data.readInt32())); reply->writeInt32(status); - delete handle.decryptInfo; handle.decryptInfo = NULL; + clearDecryptHandle(&handle); return DRM_NO_ERROR; } @@ -1100,23 +1082,13 @@ status_t BnDrmManagerService::onTransact( const int uniqueId = data.readInt32(); DecryptHandle handle; - handle.decryptId = data.readInt32(); - handle.mimeType = data.readString8(); - handle.decryptApiType = data.readInt32(); - handle.status = data.readInt32(); - handle.decryptInfo = NULL; - - const int bufferLength = data.readInt32(); - if (INVALID_BUFFER_LENGTH != bufferLength) { - handle.decryptInfo = new DecryptInfo(); - handle.decryptInfo->decryptBufferLength = bufferLength; - } + readDecryptHandleFromParcelData(&handle, data); const status_t status - = setPlaybackStatus(uniqueId, &handle, data.readInt32(), data.readInt32()); + = setPlaybackStatus(uniqueId, &handle, data.readInt32(), data.readInt64()); reply->writeInt32(status); - delete handle.decryptInfo; handle.decryptInfo = NULL; + clearDecryptHandle(&handle); return DRM_NO_ERROR; } @@ -1185,7 +1157,7 @@ status_t BnDrmManagerService::onTransact( if (NULL != drmConvertedStatus) { //Filling Drm Converted Ststus reply->writeInt32(drmConvertedStatus->statusCode); - reply->writeInt32(drmConvertedStatus->offset); + reply->writeInt64(drmConvertedStatus->offset); if (NULL != drmConvertedStatus->convertedData) { const DrmBuffer* convertedData = drmConvertedStatus->convertedData; @@ -1214,7 +1186,7 @@ status_t BnDrmManagerService::onTransact( if (NULL != drmConvertedStatus) { //Filling Drm Converted Ststus reply->writeInt32(drmConvertedStatus->statusCode); - reply->writeInt32(drmConvertedStatus->offset); + reply->writeInt64(drmConvertedStatus->offset); if (NULL != drmConvertedStatus->convertedData) { const DrmBuffer* convertedData = drmConvertedStatus->convertedData; @@ -1274,21 +1246,13 @@ status_t BnDrmManagerService::onTransact( const int fd = data.readFileDescriptor(); DecryptHandle* handle - = openDecryptSession(uniqueId, fd, data.readInt32(), data.readInt32()); + = openDecryptSession(uniqueId, fd, data.readInt64(), data.readInt64()); 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"); + writeDecrptHandleToParcelData(handle, reply); + clearDecryptHandle(handle); + delete handle; handle = NULL; } - delete handle; handle = NULL; return DRM_NO_ERROR; } @@ -1303,18 +1267,13 @@ status_t BnDrmManagerService::onTransact( 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; - } + writeDecrptHandleToParcelData(handle, reply); + + clearDecryptHandle(handle); + delete handle; handle = NULL; } else { - LOGE("NULL decryptHandle is returned"); + LOGV("NULL decryptHandle is returned"); } - delete handle; handle = NULL; return DRM_NO_ERROR; } @@ -1326,17 +1285,7 @@ status_t BnDrmManagerService::onTransact( const int uniqueId = data.readInt32(); DecryptHandle* handle = new DecryptHandle(); - handle->decryptId = data.readInt32(); - handle->mimeType = data.readString8(); - handle->decryptApiType = data.readInt32(); - handle->status = data.readInt32(); - handle->decryptInfo = NULL; - - const int bufferLength = data.readInt32(); - if (INVALID_BUFFER_LENGTH != bufferLength) { - handle->decryptInfo = new DecryptInfo(); - handle->decryptInfo->decryptBufferLength = bufferLength; - } + readDecryptHandleFromParcelData(handle, data); const status_t status = closeDecryptSession(uniqueId, handle); reply->writeInt32(status); @@ -1351,17 +1300,8 @@ status_t BnDrmManagerService::onTransact( const int uniqueId = data.readInt32(); DecryptHandle handle; - handle.decryptId = data.readInt32(); - handle.mimeType = data.readString8(); - handle.decryptApiType = data.readInt32(); - handle.status = data.readInt32(); - handle.decryptInfo = NULL; - - const int bufferLength = data.readInt32(); - if (INVALID_BUFFER_LENGTH != bufferLength) { - handle.decryptInfo = new DecryptInfo(); - handle.decryptInfo->decryptBufferLength = bufferLength; - } + readDecryptHandleFromParcelData(&handle, data); + const int decryptUnitId = data.readInt32(); //Filling Header info @@ -1373,7 +1313,7 @@ status_t BnDrmManagerService::onTransact( = initializeDecryptUnit(uniqueId, &handle, decryptUnitId, headerInfo); reply->writeInt32(status); - delete handle.decryptInfo; handle.decryptInfo = NULL; + clearDecryptHandle(&handle); delete headerInfo; headerInfo = NULL; return DRM_NO_ERROR; } @@ -1386,17 +1326,8 @@ status_t BnDrmManagerService::onTransact( const int uniqueId = data.readInt32(); DecryptHandle handle; - handle.decryptId = data.readInt32(); - handle.mimeType = data.readString8(); - handle.decryptApiType = data.readInt32(); - handle.status = data.readInt32(); - handle.decryptInfo = NULL; - - const int bufferLength = data.readInt32(); - if (INVALID_BUFFER_LENGTH != bufferLength) { - handle.decryptInfo = new DecryptInfo(); - handle.decryptInfo->decryptBufferLength = bufferLength; - } + readDecryptHandleFromParcelData(&handle, data); + const int decryptUnitId = data.readInt32(); const int decBufferSize = data.readInt32(); @@ -1423,7 +1354,7 @@ status_t BnDrmManagerService::onTransact( reply->writeInt32(size); reply->write(decBuffer->data, size); - delete handle.decryptInfo; handle.decryptInfo = NULL; + clearDecryptHandle(&handle); delete encBuffer; encBuffer = NULL; delete decBuffer; decBuffer = NULL; delete [] buffer; buffer = NULL; @@ -1439,22 +1370,12 @@ status_t BnDrmManagerService::onTransact( const int uniqueId = data.readInt32(); DecryptHandle handle; - handle.decryptId = data.readInt32(); - handle.mimeType = data.readString8(); - handle.decryptApiType = data.readInt32(); - handle.status = data.readInt32(); - handle.decryptInfo = NULL; - - const int bufferLength = data.readInt32(); - if (INVALID_BUFFER_LENGTH != bufferLength) { - handle.decryptInfo = new DecryptInfo(); - handle.decryptInfo->decryptBufferLength = bufferLength; - } + readDecryptHandleFromParcelData(&handle, data); const status_t status = finalizeDecryptUnit(uniqueId, &handle, data.readInt32()); reply->writeInt32(status); - delete handle.decryptInfo; handle.decryptInfo = NULL; + clearDecryptHandle(&handle); return DRM_NO_ERROR; } @@ -1466,22 +1387,12 @@ status_t BnDrmManagerService::onTransact( const int uniqueId = data.readInt32(); DecryptHandle handle; - handle.decryptId = data.readInt32(); - handle.mimeType = data.readString8(); - handle.decryptApiType = data.readInt32(); - handle.status = data.readInt32(); - handle.decryptInfo = NULL; - - const int bufferLength = data.readInt32(); - if (INVALID_BUFFER_LENGTH != bufferLength) { - handle.decryptInfo = new DecryptInfo(); - handle.decryptInfo->decryptBufferLength = bufferLength; - } + readDecryptHandleFromParcelData(&handle, data); const int numBytes = data.readInt32(); char* buffer = new char[numBytes]; - const off_t offset = data.readInt32(); + const off64_t offset = data.readInt64(); ssize_t result = pread(uniqueId, &handle, buffer, numBytes, offset); reply->writeInt32(result); @@ -1489,7 +1400,7 @@ status_t BnDrmManagerService::onTransact( reply->write(buffer, result); } - delete handle.decryptInfo; handle.decryptInfo = NULL; + clearDecryptHandle(&handle); delete [] buffer, buffer = NULL; return DRM_NO_ERROR; } diff --git a/drm/common/ReadWriteUtils.cpp b/drm/common/ReadWriteUtils.cpp index 7ec4fa2..c16214e 100644 --- a/drm/common/ReadWriteUtils.cpp +++ b/drm/common/ReadWriteUtils.cpp @@ -42,7 +42,7 @@ String8 ReadWriteUtils::readBytes(const String8& filePath) { struct stat sb; if (fstat(fd, &sb) == 0 && sb.st_size > 0) { - int length = sb.st_size; + off64_t length = sb.st_size; char* bytes = new char[length]; if (length == read(fd, (void*) bytes, length)) { string.append(bytes, length); @@ -57,7 +57,7 @@ String8 ReadWriteUtils::readBytes(const String8& filePath) { int ReadWriteUtils::readBytes(const String8& filePath, char** buffer) { FILE* file = NULL; file = fopen(filePath.string(), "r"); - int length = 0; + off64_t length = 0; if (NULL != file) { int fd = fileno(file); diff --git a/drm/drmserver/Android.mk b/drm/drmserver/Android.mk index 5df2ff8..f94f9a3 100644 --- a/drm/drmserver/Android.mk +++ b/drm/drmserver/Android.mk @@ -19,8 +19,7 @@ include $(CLEAR_VARS) LOCAL_SRC_FILES:= \ main_drmserver.cpp \ DrmManager.cpp \ - DrmManagerService.cpp \ - StringTokenizer.cpp + DrmManagerService.cpp LOCAL_SHARED_LIBRARIES := \ libutils \ diff --git a/drm/drmserver/DrmManager.cpp b/drm/drmserver/DrmManager.cpp index 49df1c8..1eee5f2 100644 --- a/drm/drmserver/DrmManager.cpp +++ b/drm/drmserver/DrmManager.cpp @@ -51,6 +51,7 @@ DrmManager::~DrmManager() { } int DrmManager::addUniqueId(int uniqueId) { + Mutex::Autolock _l(mLock); if (0 == uniqueId) { int temp = 0; bool foundUniqueId = false; @@ -78,6 +79,7 @@ int DrmManager::addUniqueId(int uniqueId) { } void DrmManager::removeUniqueId(int uniqueId) { + Mutex::Autolock _l(mLock); for (unsigned int i = 0; i < mUniqueIdVector.size(); i++) { if (uniqueId == mUniqueIdVector.itemAt(i)) { mUniqueIdVector.removeAt(i); @@ -87,7 +89,7 @@ void DrmManager::removeUniqueId(int uniqueId) { } status_t DrmManager::loadPlugIns() { - String8 pluginDirPath("/system/lib/drm/plugins/native"); + String8 pluginDirPath("/system/lib/drm"); return loadPlugIns(pluginDirPath); } @@ -107,6 +109,7 @@ status_t DrmManager::loadPlugIns(const String8& plugInDirPath) { } status_t DrmManager::unloadPlugIns() { + Mutex::Autolock _l(mLock); mConvertSessionMap.clear(); mDecryptSessionMap.clear(); mPlugInManager.unloadPlugIns(); @@ -116,7 +119,7 @@ status_t DrmManager::unloadPlugIns() { status_t DrmManager::setDrmServiceListener( int uniqueId, const sp<IDrmServiceListener>& drmServiceListener) { - Mutex::Autolock _l(mLock); + Mutex::Autolock _l(mListenerLock); if (NULL != drmServiceListener.get()) { mServiceListeners.add(uniqueId, drmServiceListener); } else { @@ -126,6 +129,7 @@ status_t DrmManager::setDrmServiceListener( } void DrmManager::addClient(int uniqueId) { + Mutex::Autolock _l(mLock); if (!mSupportInfoToPlugInIdMap.isEmpty()) { Vector<String8> plugInIdList = mPlugInManager.getPlugInIdList(); for (unsigned int index = 0; index < plugInIdList.size(); index++) { @@ -137,6 +141,7 @@ void DrmManager::addClient(int uniqueId) { } void DrmManager::removeClient(int uniqueId) { + Mutex::Autolock _l(mLock); Vector<String8> plugInIdList = mPlugInManager.getPlugInIdList(); for (unsigned int index = 0; index < plugInIdList.size(); index++) { IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInIdList.itemAt(index)); @@ -145,6 +150,7 @@ void DrmManager::removeClient(int uniqueId) { } DrmConstraints* DrmManager::getConstraints(int uniqueId, const String8* path, const int action) { + Mutex::Autolock _l(mLock); const String8 plugInId = getSupportedPlugInIdFromPath(uniqueId, *path); if (EMPTY_STRING != plugInId) { IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId); @@ -154,6 +160,7 @@ DrmConstraints* DrmManager::getConstraints(int uniqueId, const String8* path, co } DrmMetadata* DrmManager::getMetadata(int uniqueId, const String8* path) { + Mutex::Autolock _l(mLock); const String8 plugInId = getSupportedPlugInIdFromPath(uniqueId, *path); if (EMPTY_STRING != plugInId) { IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId); @@ -163,6 +170,7 @@ DrmMetadata* DrmManager::getMetadata(int uniqueId, const String8* path) { } status_t DrmManager::installDrmEngine(int uniqueId, const String8& absolutePath) { + Mutex::Autolock _l(mLock); mPlugInManager.loadPlugIn(absolutePath); IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(absolutePath); @@ -176,6 +184,7 @@ status_t DrmManager::installDrmEngine(int uniqueId, const String8& absolutePath) } bool DrmManager::canHandle(int uniqueId, const String8& path, const String8& mimeType) { + Mutex::Autolock _l(mLock); const String8 plugInId = getSupportedPlugInId(mimeType); bool result = (EMPTY_STRING != plugInId) ? true : false; @@ -184,13 +193,17 @@ bool DrmManager::canHandle(int uniqueId, const String8& path, const String8& mim IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId); result = rDrmEngine.canHandle(uniqueId, path); } else { - result = canHandle(uniqueId, path); + String8 extension = path.getPathExtension(); + if (String8("") != extension) { + result = canHandle(uniqueId, path); + } } } return result; } DrmInfoStatus* DrmManager::processDrmInfo(int uniqueId, const DrmInfo* drmInfo) { + Mutex::Autolock _l(mLock); const String8 plugInId = getSupportedPlugInId(drmInfo->getMimeType()); if (EMPTY_STRING != plugInId) { IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId); @@ -215,6 +228,7 @@ bool DrmManager::canHandle(int uniqueId, const String8& path) { } DrmInfo* DrmManager::acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInfoRequest) { + Mutex::Autolock _l(mLock); const String8 plugInId = getSupportedPlugInId(drmInfoRequest->getMimeType()); if (EMPTY_STRING != plugInId) { IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId); @@ -225,6 +239,7 @@ DrmInfo* DrmManager::acquireDrmInfo(int uniqueId, const DrmInfoRequest* drmInfoR status_t DrmManager::saveRights(int uniqueId, const DrmRights& drmRights, const String8& rightsPath, const String8& contentPath) { + Mutex::Autolock _l(mLock); const String8 plugInId = getSupportedPlugInId(drmRights.getMimeType()); status_t result = DRM_ERROR_UNKNOWN; if (EMPTY_STRING != plugInId) { @@ -235,6 +250,7 @@ status_t DrmManager::saveRights(int uniqueId, const DrmRights& drmRights, } String8 DrmManager::getOriginalMimeType(int uniqueId, const String8& path) { + Mutex::Autolock _l(mLock); const String8 plugInId = getSupportedPlugInIdFromPath(uniqueId, path); if (EMPTY_STRING != plugInId) { IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId); @@ -244,6 +260,7 @@ String8 DrmManager::getOriginalMimeType(int uniqueId, const String8& path) { } int DrmManager::getDrmObjectType(int uniqueId, const String8& path, const String8& mimeType) { + Mutex::Autolock _l(mLock); const String8 plugInId = getSupportedPlugInId(uniqueId, path, mimeType); if (EMPTY_STRING != plugInId) { IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId); @@ -253,6 +270,7 @@ int DrmManager::getDrmObjectType(int uniqueId, const String8& path, const String } int DrmManager::checkRightsStatus(int uniqueId, const String8& path, int action) { + Mutex::Autolock _l(mLock); const String8 plugInId = getSupportedPlugInIdFromPath(uniqueId, path); if (EMPTY_STRING != plugInId) { IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId); @@ -264,6 +282,7 @@ int DrmManager::checkRightsStatus(int uniqueId, const String8& path, int action) status_t DrmManager::consumeRights( int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) { status_t result = DRM_ERROR_UNKNOWN; + Mutex::Autolock _l(mDecryptLock); if (mDecryptSessionMap.indexOfKey(decryptHandle->decryptId) != NAME_NOT_FOUND) { IDrmEngine* drmEngine = mDecryptSessionMap.valueFor(decryptHandle->decryptId); result = drmEngine->consumeRights(uniqueId, decryptHandle, action, reserve); @@ -272,8 +291,9 @@ status_t DrmManager::consumeRights( } status_t DrmManager::setPlaybackStatus( - int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) { + int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position) { status_t result = DRM_ERROR_UNKNOWN; + Mutex::Autolock _l(mDecryptLock); if (mDecryptSessionMap.indexOfKey(decryptHandle->decryptId) != NAME_NOT_FOUND) { IDrmEngine* drmEngine = mDecryptSessionMap.valueFor(decryptHandle->decryptId); result = drmEngine->setPlaybackStatus(uniqueId, decryptHandle, playbackStatus, position); @@ -283,6 +303,7 @@ status_t DrmManager::setPlaybackStatus( bool DrmManager::validateAction( int uniqueId, const String8& path, int action, const ActionDescription& description) { + Mutex::Autolock _l(mLock); const String8 plugInId = getSupportedPlugInIdFromPath(uniqueId, path); if (EMPTY_STRING != plugInId) { IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId); @@ -292,6 +313,7 @@ bool DrmManager::validateAction( } status_t DrmManager::removeRights(int uniqueId, const String8& path) { + Mutex::Autolock _l(mLock); const String8 plugInId = getSupportedPlugInIdFromPath(uniqueId, path); status_t result = DRM_ERROR_UNKNOWN; if (EMPTY_STRING != plugInId) { @@ -315,6 +337,7 @@ status_t DrmManager::removeAllRights(int uniqueId) { } int DrmManager::openConvertSession(int uniqueId, const String8& mimeType) { + Mutex::Autolock _l(mConvertLock); int convertId = -1; const String8 plugInId = getSupportedPlugInId(mimeType); @@ -322,7 +345,6 @@ int DrmManager::openConvertSession(int uniqueId, const String8& mimeType) { IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId); if (DRM_NO_ERROR == rDrmEngine.openConvertSession(uniqueId, mConvertId + 1)) { - Mutex::Autolock _l(mConvertLock); ++mConvertId; convertId = mConvertId; mConvertSessionMap.add(convertId, &rDrmEngine); @@ -335,6 +357,7 @@ DrmConvertedStatus* DrmManager::convertData( int uniqueId, int convertId, const DrmBuffer* inputData) { DrmConvertedStatus *drmConvertedStatus = NULL; + Mutex::Autolock _l(mConvertLock); if (mConvertSessionMap.indexOfKey(convertId) != NAME_NOT_FOUND) { IDrmEngine* drmEngine = mConvertSessionMap.valueFor(convertId); drmConvertedStatus = drmEngine->convertData(uniqueId, convertId, inputData); @@ -343,6 +366,7 @@ DrmConvertedStatus* DrmManager::convertData( } DrmConvertedStatus* DrmManager::closeConvertSession(int uniqueId, int convertId) { + Mutex::Autolock _l(mConvertLock); DrmConvertedStatus *drmConvertedStatus = NULL; if (mConvertSessionMap.indexOfKey(convertId) != NAME_NOT_FOUND) { @@ -355,6 +379,7 @@ DrmConvertedStatus* DrmManager::closeConvertSession(int uniqueId, int convertId) status_t DrmManager::getAllSupportInfo( int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray) { + Mutex::Autolock _l(mLock); Vector<String8> plugInPathList = mPlugInManager.getPlugInIdList(); int size = plugInPathList.size(); int validPlugins = 0; @@ -384,7 +409,7 @@ status_t DrmManager::getAllSupportInfo( return DRM_NO_ERROR; } -DecryptHandle* DrmManager::openDecryptSession(int uniqueId, int fd, int offset, int length) { +DecryptHandle* DrmManager::openDecryptSession(int uniqueId, int fd, off64_t offset, off64_t length) { Mutex::Autolock _l(mDecryptLock); status_t result = DRM_ERROR_CANNOT_HANDLE; Vector<String8> plugInIdList = mPlugInManager.getPlugInIdList(); @@ -407,7 +432,6 @@ DecryptHandle* DrmManager::openDecryptSession(int uniqueId, int fd, int offset, } if (DRM_NO_ERROR != result) { delete handle; handle = NULL; - LOGE("DrmManager::openDecryptSession: no capable plug-in found"); } return handle; } @@ -435,7 +459,7 @@ DecryptHandle* DrmManager::openDecryptSession(int uniqueId, const char* uri) { } if (DRM_NO_ERROR != result) { delete handle; handle = NULL; - LOGE("DrmManager::openDecryptSession: no capable plug-in found"); + LOGV("DrmManager::openDecryptSession: no capable plug-in found"); } return handle; } @@ -456,6 +480,7 @@ status_t DrmManager::closeDecryptSession(int uniqueId, DecryptHandle* decryptHan status_t DrmManager::initializeDecryptUnit( int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId, const DrmBuffer* headerInfo) { status_t result = DRM_ERROR_UNKNOWN; + Mutex::Autolock _l(mDecryptLock); if (mDecryptSessionMap.indexOfKey(decryptHandle->decryptId) != NAME_NOT_FOUND) { IDrmEngine* drmEngine = mDecryptSessionMap.valueFor(decryptHandle->decryptId); result = drmEngine->initializeDecryptUnit(uniqueId, decryptHandle, decryptUnitId, headerInfo); @@ -466,6 +491,8 @@ status_t DrmManager::initializeDecryptUnit( status_t DrmManager::decrypt(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId, const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) { status_t result = DRM_ERROR_UNKNOWN; + + Mutex::Autolock _l(mDecryptLock); if (mDecryptSessionMap.indexOfKey(decryptHandle->decryptId) != NAME_NOT_FOUND) { IDrmEngine* drmEngine = mDecryptSessionMap.valueFor(decryptHandle->decryptId); result = drmEngine->decrypt( @@ -477,6 +504,7 @@ status_t DrmManager::decrypt(int uniqueId, DecryptHandle* decryptHandle, int dec status_t DrmManager::finalizeDecryptUnit( int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) { status_t result = DRM_ERROR_UNKNOWN; + Mutex::Autolock _l(mDecryptLock); if (mDecryptSessionMap.indexOfKey(decryptHandle->decryptId) != NAME_NOT_FOUND) { IDrmEngine* drmEngine = mDecryptSessionMap.valueFor(decryptHandle->decryptId); result = drmEngine->finalizeDecryptUnit(uniqueId, decryptHandle, decryptUnitId); @@ -485,9 +513,10 @@ status_t DrmManager::finalizeDecryptUnit( } ssize_t DrmManager::pread(int uniqueId, DecryptHandle* decryptHandle, - void* buffer, ssize_t numBytes, off_t offset) { + void* buffer, ssize_t numBytes, off64_t offset) { ssize_t result = DECRYPT_FILE_ERROR; + Mutex::Autolock _l(mDecryptLock); if (mDecryptSessionMap.indexOfKey(decryptHandle->decryptId) != NAME_NOT_FOUND) { IDrmEngine* drmEngine = mDecryptSessionMap.valueFor(decryptHandle->decryptId); result = drmEngine->pread(uniqueId, decryptHandle, buffer, numBytes, offset); @@ -544,7 +573,7 @@ String8 DrmManager::getSupportedPlugInIdFromPath(int uniqueId, const String8& pa } void DrmManager::onInfo(const DrmInfoEvent& event) { - Mutex::Autolock _l(mLock); + Mutex::Autolock _l(mListenerLock); for (unsigned int index = 0; index < mServiceListeners.size(); index++) { int uniqueId = mServiceListeners.keyAt(index); diff --git a/drm/drmserver/DrmManagerService.cpp b/drm/drmserver/DrmManagerService.cpp index 4dcfa72..0901a44 100644 --- a/drm/drmserver/DrmManagerService.cpp +++ b/drm/drmserver/DrmManagerService.cpp @@ -162,7 +162,7 @@ status_t DrmManagerService::consumeRights( } status_t DrmManagerService::setPlaybackStatus( - int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) { + int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position) { LOGV("Entering setPlaybackStatus"); return mDrmManager->setPlaybackStatus(uniqueId, decryptHandle, playbackStatus, position); } @@ -207,7 +207,7 @@ status_t DrmManagerService::getAllSupportInfo( } DecryptHandle* DrmManagerService::openDecryptSession( - int uniqueId, int fd, int offset, int length) { + int uniqueId, int fd, off64_t offset, off64_t length) { LOGV("Entering DrmManagerService::openDecryptSession"); if (isProtectedCallAllowed()) { return mDrmManager->openDecryptSession(uniqueId, fd, offset, length); @@ -251,7 +251,7 @@ status_t DrmManagerService::finalizeDecryptUnit( } ssize_t DrmManagerService::pread(int uniqueId, DecryptHandle* decryptHandle, - void* buffer, ssize_t numBytes, off_t offset) { + void* buffer, ssize_t numBytes, off64_t offset) { LOGV("Entering pread"); return mDrmManager->pread(uniqueId, decryptHandle, buffer, numBytes, offset); } diff --git a/drm/drmserver/StringTokenizer.cpp b/drm/drmserver/StringTokenizer.cpp deleted file mode 100644 index 2130a00..0000000 --- a/drm/drmserver/StringTokenizer.cpp +++ /dev/null @@ -1,66 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include "StringTokenizer.h" - -using namespace android; - -StringTokenizer::StringTokenizer(const String8& string, const String8& delimiter) { - splitString(string, delimiter); -} - -void StringTokenizer::splitString(const String8& string, const String8& delimiter) { - for (unsigned int i = 0; i < string.length(); i++) { - unsigned int position = string.find(delimiter.string(), i); - if (string.length() != position) { - String8 token(string.string()+i, position-i); - if (token.length()) { - mStringTokenizerVector.push(token); - i = position + delimiter.length() - 1; - } - } else { - mStringTokenizerVector.push(String8(string.string()+i, string.length()-i)); - break; - } - } -} - -StringTokenizer::Iterator StringTokenizer::iterator() { - return Iterator(this); -} - -StringTokenizer::Iterator::Iterator(const StringTokenizer::Iterator& iterator) : - mStringTokenizer(iterator.mStringTokenizer), - mIndex(iterator.mIndex) { -} - -StringTokenizer::Iterator& StringTokenizer::Iterator::operator=( - const StringTokenizer::Iterator& iterator) { - mStringTokenizer = iterator.mStringTokenizer; - mIndex = iterator.mIndex; - return *this; -} - -bool StringTokenizer::Iterator::hasNext() { - return mIndex < mStringTokenizer->mStringTokenizerVector.size(); -} - -String8& StringTokenizer::Iterator::next() { - String8& value = mStringTokenizer->mStringTokenizerVector.editItemAt(mIndex); - mIndex++; - return value; -} - diff --git a/drm/libdrmframework/DrmManagerClient.cpp b/drm/libdrmframework/DrmManagerClient.cpp index 8bb00c3..c1f382a 100644 --- a/drm/libdrmframework/DrmManagerClient.cpp +++ b/drm/libdrmframework/DrmManagerClient.cpp @@ -32,7 +32,6 @@ DrmManagerClient::~DrmManagerClient() { DrmManagerClientImpl::remove(mUniqueId); mDrmManagerClientImpl->removeClient(mUniqueId); mDrmManagerClientImpl->setOnInfoListener(mUniqueId, NULL); - delete mDrmManagerClientImpl; mDrmManagerClientImpl = NULL; } status_t DrmManagerClient::setOnInfoListener( @@ -78,12 +77,11 @@ int DrmManagerClient::checkRightsStatus(const String8& path, int action) { } status_t DrmManagerClient::consumeRights(DecryptHandle* decryptHandle, int action, bool reserve) { - Mutex::Autolock _l(mDecryptLock); return mDrmManagerClientImpl->consumeRights(mUniqueId, decryptHandle, action, reserve); } status_t DrmManagerClient::setPlaybackStatus( - DecryptHandle* decryptHandle, int playbackStatus, int position) { + DecryptHandle* decryptHandle, int playbackStatus, int64_t position) { return mDrmManagerClientImpl ->setPlaybackStatus(mUniqueId, decryptHandle, playbackStatus, position); } @@ -117,7 +115,7 @@ status_t DrmManagerClient::getAllSupportInfo(int* length, DrmSupportInfo** drmSu return mDrmManagerClientImpl->getAllSupportInfo(mUniqueId, length, drmSupportInfoArray); } -DecryptHandle* DrmManagerClient::openDecryptSession(int fd, int offset, int length) { +DecryptHandle* DrmManagerClient::openDecryptSession(int fd, off64_t offset, off64_t length) { return mDrmManagerClientImpl->openDecryptSession(mUniqueId, fd, offset, length); } @@ -131,7 +129,6 @@ status_t DrmManagerClient::closeDecryptSession(DecryptHandle* decryptHandle) { status_t DrmManagerClient::initializeDecryptUnit( DecryptHandle* decryptHandle, int decryptUnitId, const DrmBuffer* headerInfo) { - Mutex::Autolock _l(mDecryptLock); return mDrmManagerClientImpl->initializeDecryptUnit( mUniqueId, decryptHandle, decryptUnitId, headerInfo); } @@ -139,19 +136,16 @@ status_t DrmManagerClient::initializeDecryptUnit( status_t DrmManagerClient::decrypt( DecryptHandle* decryptHandle, int decryptUnitId, const DrmBuffer* encBuffer, DrmBuffer** decBuffer, DrmBuffer* IV) { - Mutex::Autolock _l(mDecryptLock); return mDrmManagerClientImpl->decrypt( mUniqueId, decryptHandle, decryptUnitId, encBuffer, decBuffer, IV); } status_t DrmManagerClient::finalizeDecryptUnit(DecryptHandle* decryptHandle, int decryptUnitId) { - Mutex::Autolock _l(mDecryptLock); return mDrmManagerClientImpl->finalizeDecryptUnit(mUniqueId, decryptHandle, decryptUnitId); } ssize_t DrmManagerClient::pread( - DecryptHandle* decryptHandle, void* buffer, ssize_t numBytes, off_t offset) { - Mutex::Autolock _l(mDecryptLock); + 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 eea312b..9c7fed3 100644 --- a/drm/libdrmframework/DrmManagerClientImpl.cpp +++ b/drm/libdrmframework/DrmManagerClientImpl.cpp @@ -28,8 +28,9 @@ using namespace android; #define INVALID_VALUE -1 -Mutex DrmManagerClientImpl::mMutex; -sp<IDrmManagerService> DrmManagerClientImpl::mDrmManagerService; +Mutex DrmManagerClientImpl::sMutex; +sp<IDrmManagerService> DrmManagerClientImpl::sDrmManagerService; +sp<DrmManagerClientImpl::DeathNotifier> DrmManagerClientImpl::sDeathNotifier; const String8 DrmManagerClientImpl::EMPTY_STRING(""); DrmManagerClientImpl* DrmManagerClientImpl::create(int* pUniqueId) { @@ -47,8 +48,8 @@ void DrmManagerClientImpl::remove(int uniqueId) { } const sp<IDrmManagerService>& DrmManagerClientImpl::getDrmManagerService() { - mMutex.lock(); - if (NULL == mDrmManagerService.get()) { + Mutex::Autolock lock(sMutex); + if (NULL == sDrmManagerService.get()) { sp<IServiceManager> sm = defaultServiceManager(); sp<IBinder> binder; do { @@ -62,11 +63,13 @@ const sp<IDrmManagerService>& DrmManagerClientImpl::getDrmManagerService() { reqt.tv_nsec = 500000000; //0.5 sec nanosleep(&reqt, NULL); } while (true); - - mDrmManagerService = interface_cast<IDrmManagerService>(binder); + if (NULL == sDeathNotifier.get()) { + sDeathNotifier = new DeathNotifier(); + } + binder->linkToDeath(sDeathNotifier); + sDrmManagerService = interface_cast<IDrmManagerService>(binder); } - mMutex.unlock(); - return mDrmManagerService; + return sDrmManagerService; } void DrmManagerClientImpl::addClient(int uniqueId) { @@ -179,7 +182,7 @@ status_t DrmManagerClientImpl::consumeRights( } status_t DrmManagerClientImpl::setPlaybackStatus( - int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) { + int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position) { status_t status = DRM_ERROR_UNKNOWN; if (NULL != decryptHandle) { status = getDrmManagerService()->setPlaybackStatus( @@ -240,7 +243,7 @@ status_t DrmManagerClientImpl::getAllSupportInfo( } DecryptHandle* DrmManagerClientImpl::openDecryptSession( - int uniqueId, int fd, int offset, int length) { + int uniqueId, int fd, off64_t offset, off64_t length) { return getDrmManagerService()->openDecryptSession(uniqueId, fd, offset, length); } @@ -292,7 +295,7 @@ status_t DrmManagerClientImpl::finalizeDecryptUnit( } ssize_t DrmManagerClientImpl::pread(int uniqueId, DecryptHandle* decryptHandle, - void* buffer, ssize_t numBytes, off_t offset) { + 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); @@ -309,3 +312,16 @@ status_t DrmManagerClientImpl::notify(const DrmInfoEvent& event) { return DRM_NO_ERROR; } +DrmManagerClientImpl::DeathNotifier::~DeathNotifier() { + Mutex::Autolock lock(sMutex); + if (NULL != sDrmManagerService.get()) { + sDrmManagerService->asBinder()->unlinkToDeath(this); + } +} + +void DrmManagerClientImpl::DeathNotifier::binderDied(const wp<IBinder>& who) { + Mutex::Autolock lock(sMutex); + DrmManagerClientImpl::sDrmManagerService.clear(); + LOGW("DrmManager server died!"); +} + diff --git a/drm/libdrmframework/include/DrmIOService.h b/drm/libdrmframework/include/DrmIOService.h deleted file mode 100644 index 244124e..0000000 --- a/drm/libdrmframework/include/DrmIOService.h +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __DRM_IO_SERVICE_H__ -#define __DRM_IO_SERVICE_H__ - -#include "IDrmIOService.h" - -namespace android { - -/** - * This is the implementation class for DRM IO service. - * - * The instance of this class is created while starting the DRM IO service. - * - */ -class DrmIOService : public BnDrmIOService { -public: - static void instantiate(); - -private: - DrmIOService(); - virtual ~DrmIOService(); - -public: - void writeToFile(const String8& filePath, const String8& dataBuffer); - String8 readFromFile(const String8& filePath); -}; - -}; - -#endif /* __DRM_IO_SERVICE_H__ */ - diff --git a/drm/libdrmframework/include/DrmManager.h b/drm/libdrmframework/include/DrmManager.h index bc462c2..c7276f9 100644 --- a/drm/libdrmframework/include/DrmManager.h +++ b/drm/libdrmframework/include/DrmManager.h @@ -95,7 +95,7 @@ public: status_t consumeRights(int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve); status_t setPlaybackStatus( - int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position); + int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position); bool validateAction( int uniqueId, const String8& path, int action, const ActionDescription& description); @@ -112,7 +112,7 @@ public: status_t getAllSupportInfo(int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray); - DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length); + DecryptHandle* openDecryptSession(int uniqueId, int fd, off64_t offset, off64_t length); DecryptHandle* openDecryptSession(int uniqueId, const char* uri); @@ -127,7 +127,7 @@ public: status_t finalizeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId); ssize_t pread(int uniqueId, DecryptHandle* decryptHandle, - void* buffer, ssize_t numBytes, off_t offset); + void* buffer, ssize_t numBytes, off64_t offset); void onInfo(const DrmInfoEvent& event); @@ -147,6 +147,7 @@ private: int mDecryptSessionId; int mConvertId; Mutex mLock; + Mutex mListenerLock; Mutex mDecryptLock; Mutex mConvertLock; TPlugInManager<IDrmEngine> mPlugInManager; diff --git a/drm/libdrmframework/include/DrmManagerClientImpl.h b/drm/libdrmframework/include/DrmManagerClientImpl.h index ff84fc7..429e4c3 100644 --- a/drm/libdrmframework/include/DrmManagerClientImpl.h +++ b/drm/libdrmframework/include/DrmManagerClientImpl.h @@ -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, int position); + int uniqueId, 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, int offset, int length); + DecryptHandle* openDecryptSession(int uniqueId, int fd, off64_t offset, off64_t length); /** * Open the decrypt session to decrypt the given protected content @@ -381,7 +381,7 @@ public: * @return Number of bytes read. Returns -1 for Failure. */ ssize_t pread(int uniqueId, DecryptHandle* decryptHandle, - void* buffer, ssize_t numBytes, off_t offset); + void* buffer, ssize_t numBytes, off64_t offset); /** * Notify the event to the registered listener @@ -407,9 +407,17 @@ private: Mutex mLock; sp<DrmManagerClient::OnInfoListener> mOnInfoListener; + class DeathNotifier: public IBinder::DeathRecipient { + public: + DeathNotifier() {} + virtual ~DeathNotifier(); + virtual void binderDied(const wp<IBinder>& who); + }; + private: - static Mutex mMutex; - static sp<IDrmManagerService> mDrmManagerService; + static Mutex sMutex; + static sp<DeathNotifier> sDeathNotifier; + static sp<IDrmManagerService> sDrmManagerService; static const sp<IDrmManagerService>& getDrmManagerService(); static const String8 EMPTY_STRING; }; diff --git a/drm/libdrmframework/include/DrmManagerService.h b/drm/libdrmframework/include/DrmManagerService.h index f346356..d0a0db7 100644 --- a/drm/libdrmframework/include/DrmManagerService.h +++ b/drm/libdrmframework/include/DrmManagerService.h @@ -81,7 +81,7 @@ public: status_t consumeRights(int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve); status_t setPlaybackStatus( - int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position); + int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position); bool validateAction(int uniqueId, const String8& path, int action, const ActionDescription& description); @@ -98,7 +98,7 @@ public: status_t getAllSupportInfo(int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray); - DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length); + DecryptHandle* openDecryptSession(int uniqueId, int fd, off64_t offset, off64_t length); DecryptHandle* openDecryptSession(int uniqueId, const char* uri); @@ -113,7 +113,7 @@ public: status_t finalizeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId); ssize_t pread(int uniqueId, DecryptHandle* decryptHandle, - void* buffer, ssize_t numBytes, off_t offset); + void* buffer, ssize_t numBytes, off64_t offset); private: DrmManager* mDrmManager; diff --git a/drm/libdrmframework/include/IDrmIOService.h b/drm/libdrmframework/include/IDrmIOService.h deleted file mode 100644 index 5e0d907..0000000 --- a/drm/libdrmframework/include/IDrmIOService.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __IDRM_IO_SERVICE_H__ -#define __IDRM_IO_SERVICE_H__ - -#include <utils/RefBase.h> -#include <binder/IInterface.h> -#include <binder/Parcel.h> - -namespace android { - -/** - * This is the interface class for DRM IO service. - * - */ -class IDrmIOService : public IInterface -{ -public: - enum { - WRITE_TO_FILE = IBinder::FIRST_CALL_TRANSACTION, - READ_FROM_FILE - }; - -public: - DECLARE_META_INTERFACE(DrmIOService); - -public: - /** - * Writes the data into the file path provided - * - * @param[in] filePath Path of the file - * @param[in] dataBuffer Data to write - */ - virtual void writeToFile(const String8& filePath, const String8& dataBuffer) = 0; - - /** - * Reads the data from the file path provided - * - * @param[in] filePath Path of the file - * @return Data read from the file - */ - virtual String8 readFromFile(const String8& filePath) = 0; -}; - -/** - * This is the Binder implementation class for DRM IO service. - */ -class BpDrmIOService: public BpInterface<IDrmIOService> -{ -public: - BpDrmIOService(const sp<IBinder>& impl) - : BpInterface<IDrmIOService>(impl) {} - - virtual void writeToFile(const String8& filePath, const String8& dataBuffer); - - virtual String8 readFromFile(const String8& filePath); -}; - -/** - * This is the Binder implementation class for DRM IO service. - */ -class BnDrmIOService: public BnInterface<IDrmIOService> -{ -public: - virtual status_t onTransact( - uint32_t code, const Parcel& data, Parcel* reply, uint32_t flags = 0); -}; - -}; - -#endif /* __IDRM_IO_SERVICE_H__ */ - diff --git a/drm/libdrmframework/include/IDrmManagerService.h b/drm/libdrmframework/include/IDrmManagerService.h index f1dabd3..2424ea5 100644 --- a/drm/libdrmframework/include/IDrmManagerService.h +++ b/drm/libdrmframework/include/IDrmManagerService.h @@ -120,7 +120,7 @@ public: int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve) = 0; virtual status_t setPlaybackStatus( - int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) = 0; + int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position) = 0; virtual bool validateAction( int uniqueId, const String8& path, @@ -140,7 +140,7 @@ public: virtual status_t getAllSupportInfo( int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray) = 0; - virtual DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length) = 0; + virtual DecryptHandle* openDecryptSession(int uniqueId, int fd, off64_t offset, off64_t length) = 0; virtual DecryptHandle* openDecryptSession(int uniqueId, const char* uri) = 0; @@ -156,7 +156,7 @@ public: int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId) = 0; virtual ssize_t pread(int uniqueId, DecryptHandle* decryptHandle, - void* buffer, ssize_t numBytes,off_t offset) = 0; + void* buffer, ssize_t numBytes,off64_t offset) = 0; }; /** @@ -204,7 +204,7 @@ public: int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve); virtual status_t setPlaybackStatus( - int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position); + int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position); virtual bool validateAction( int uniqueId, const String8& path, int action, const ActionDescription& description); @@ -223,7 +223,7 @@ public: virtual status_t getAllSupportInfo( int uniqueId, int* length, DrmSupportInfo** drmSupportInfoArray); - virtual DecryptHandle* openDecryptSession(int uniqueId, int fd, int offset, int length); + virtual DecryptHandle* openDecryptSession(int uniqueId, int fd, off64_t offset, off64_t length); virtual DecryptHandle* openDecryptSession(int uniqueId, const char* uri); @@ -239,7 +239,7 @@ public: int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId); virtual ssize_t pread(int uniqueId, DecryptHandle* decryptHandle, - void* buffer, ssize_t numBytes, off_t offset); + void* buffer, ssize_t numBytes, off64_t offset); }; /** diff --git a/drm/libdrmframework/include/PlugInManager.h b/drm/libdrmframework/include/PlugInManager.h index 9ad195f..8029138 100644 --- a/drm/libdrmframework/include/PlugInManager.h +++ b/drm/libdrmframework/include/PlugInManager.h @@ -230,11 +230,9 @@ private: */ bool isPlugIn(const struct dirent* pEntry) const { String8 sName(pEntry->d_name); - int extentionPos = sName.size() - String8(PLUGIN_EXTENSION).size(); - if (extentionPos < 0) { - return false; - } - return extentionPos == (int)sName.find(PLUGIN_EXTENSION); + String8 extension(sName.getPathExtension()); + // Note that the plug-in extension must exactly match case + return extension == String8(PLUGIN_EXTENSION); } /** diff --git a/drm/libdrmframework/include/StringTokenizer.h b/drm/libdrmframework/include/StringTokenizer.h deleted file mode 100644 index 70e7558..0000000 --- a/drm/libdrmframework/include/StringTokenizer.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * Copyright (C) 2010 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#ifndef __STRING_TOKENIZER_H__ -#define __STRING_TOKENIZER_H__ - -#include <drm/drm_framework_common.h> - -namespace android { - -/** - * This is an utility class for String manipulation. - * - */ -class StringTokenizer { -public: - /** - * Iterator for string tokens - */ - class Iterator { - friend class StringTokenizer; - private: - Iterator(StringTokenizer* StringTokenizer) - : mStringTokenizer(StringTokenizer), mIndex(0) {} - - public: - Iterator(const Iterator& iterator); - Iterator& operator=(const Iterator& iterator); - virtual ~Iterator() {} - - public: - bool hasNext(); - String8& next(); - - private: - StringTokenizer* mStringTokenizer; - unsigned int mIndex; - }; - -public: - /** - * Constructor for StringTokenizer - * - * @param[in] string Complete string data - * @param[in] delimeter Delimeter used to split the string - */ - StringTokenizer(const String8& string, const String8& delimeter); - - /** - * Destructor for StringTokenizer - */ - ~StringTokenizer() {} - -private: - /** - * Splits the string according to the delimeter - */ - void splitString(const String8& string, const String8& delimeter); - -public: - /** - * Returns Iterator object to walk through the split string values - * - * @return Iterator object - */ - Iterator iterator(); - -private: - Vector<String8> mStringTokenizerVector; -}; - -}; -#endif /* __STRING_TOKENIZER_H__ */ - diff --git a/drm/libdrmframework/plugins/common/include/DrmEngineBase.h b/drm/libdrmframework/plugins/common/include/DrmEngineBase.h index 67b6355..b61e3d3 100644 --- a/drm/libdrmframework/plugins/common/include/DrmEngineBase.h +++ b/drm/libdrmframework/plugins/common/include/DrmEngineBase.h @@ -62,7 +62,7 @@ public: status_t consumeRights(int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve); status_t setPlaybackStatus( - int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position); + int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position); bool validateAction( int uniqueId, const String8& path, int action, const ActionDescription& description); @@ -80,7 +80,7 @@ public: DrmSupportInfo* getSupportInfo(int uniqueId); status_t openDecryptSession( - int uniqueId, DecryptHandle* decryptHandle, int fd, int offset, int length); + int uniqueId, DecryptHandle* decryptHandle, int fd, off64_t offset, off64_t length); status_t openDecryptSession( int uniqueId, DecryptHandle* decryptHandle, const char* uri); @@ -96,7 +96,7 @@ public: status_t finalizeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId); ssize_t pread(int uniqueId, DecryptHandle* decryptHandle, - void* buffer, ssize_t numBytes, off_t offset); + void* buffer, ssize_t numBytes, off64_t offset); protected: ///////////////////////////////////////////////////// @@ -268,7 +268,7 @@ protected: * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure */ virtual status_t onSetPlaybackStatus( - int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position) = 0; + int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position) = 0; /** * Validates whether an action on the DRM content is allowed or not. @@ -369,7 +369,7 @@ protected: * DRM_ERROR_CANNOT_HANDLE for failure and DRM_NO_ERROR for success */ virtual status_t onOpenDecryptSession( - int uniqueId, DecryptHandle* decryptHandle, int fd, int offset, int length) = 0; + int uniqueId, DecryptHandle* decryptHandle, int fd, off64_t offset, off64_t length) = 0; /** * Open the decrypt session to decrypt the given protected content @@ -450,7 +450,7 @@ protected: * @return Number of bytes read. Returns -1 for Failure. */ virtual ssize_t onPread(int uniqueId, DecryptHandle* decryptHandle, - void* buffer, ssize_t numBytes, off_t offset) = 0; + void* buffer, ssize_t numBytes, off64_t offset) = 0; }; }; diff --git a/drm/libdrmframework/plugins/common/include/IDrmEngine.h b/drm/libdrmframework/plugins/common/include/IDrmEngine.h index f839070..d05c24f 100644 --- a/drm/libdrmframework/plugins/common/include/IDrmEngine.h +++ b/drm/libdrmframework/plugins/common/include/IDrmEngine.h @@ -224,7 +224,7 @@ public: * Returns DRM_NO_ERROR for success, DRM_ERROR_UNKNOWN for failure */ virtual status_t setPlaybackStatus(int uniqueId, DecryptHandle* decryptHandle, - int playbackStatus, int position) = 0; + int playbackStatus, int64_t position) = 0; /** * Validates whether an action on the DRM content is allowed or not. @@ -325,7 +325,7 @@ public: * DRM_ERROR_CANNOT_HANDLE for failure and DRM_NO_ERROR for success */ virtual status_t openDecryptSession( - int uniqueId, DecryptHandle* decryptHandle, int fd, int offset, int length) = 0; + int uniqueId, DecryptHandle* decryptHandle, int fd, off64_t offset, off64_t length) = 0; /** * Open the decrypt session to decrypt the given protected content @@ -406,7 +406,7 @@ public: * @return Number of bytes read. Returns -1 for Failure. */ virtual ssize_t pread(int uniqueId, DecryptHandle* decryptHandle, - void* buffer, ssize_t numBytes, off_t offset) = 0; + void* buffer, ssize_t numBytes, off64_t offset) = 0; }; }; diff --git a/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/Android.mk b/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/Android.mk index 21de4ea..35fa734 100644 --- a/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/Android.mk +++ b/drm/libdrmframework/plugins/forward-lock/FwdLockEngine/Android.mk @@ -63,7 +63,7 @@ LOCAL_C_INCLUDES += \ $(LOCAL_PATH)/include \ external/openssl/include -LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/drm/plugins/native +LOCAL_MODULE_PATH := $(TARGET_OUT_SHARED_LIBRARIES)/drm LOCAL_MODULE_TAGS := optional diff --git a/drm/libdrmframework/plugins/passthru/include/DrmPassthruPlugIn.h b/drm/libdrmframework/plugins/passthru/include/DrmPassthruPlugIn.h index bbcd9ed..f941f70 100644 --- a/drm/libdrmframework/plugins/passthru/include/DrmPassthruPlugIn.h +++ b/drm/libdrmframework/plugins/passthru/include/DrmPassthruPlugIn.h @@ -56,7 +56,7 @@ protected: status_t onConsumeRights(int uniqueId, DecryptHandle* decryptHandle, int action, bool reserve); status_t onSetPlaybackStatus( - int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int position); + int uniqueId, DecryptHandle* decryptHandle, int playbackStatus, int64_t position); bool onValidateAction( int uniqueId, const String8& path, int action, const ActionDescription& description); @@ -74,7 +74,7 @@ protected: DrmSupportInfo* onGetSupportInfo(int uniqueId); status_t onOpenDecryptSession( - int uniqueId, DecryptHandle* decryptHandle, int fd, int offset, int length); + int uniqueId, DecryptHandle* decryptHandle, int fd, off64_t offset, off64_t length); status_t onOpenDecryptSession( int uniqueId, DecryptHandle* decryptHandle, const char* uri); @@ -90,7 +90,7 @@ protected: status_t onFinalizeDecryptUnit(int uniqueId, DecryptHandle* decryptHandle, int decryptUnitId); ssize_t onPread(int uniqueId, DecryptHandle* decryptHandle, - void* buffer, ssize_t numBytes, off_t offset); + void* buffer, ssize_t numBytes, off64_t offset); private: DecryptHandle* openDecryptSessionImpl(); diff --git a/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp b/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp index dee1fdb..976978f 100644 --- a/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp +++ b/drm/libdrmframework/plugins/passthru/src/DrmPassthruPlugIn.cpp @@ -187,7 +187,7 @@ status_t DrmPassthruPlugIn::onConsumeRights(int uniqueId, DecryptHandle* decrypt } status_t DrmPassthruPlugIn::onSetPlaybackStatus(int uniqueId, DecryptHandle* decryptHandle, - int playbackStatus, int position) { + int playbackStatus, int64_t position) { LOGD("DrmPassthruPlugIn::onSetPlaybackStatus() : %d", uniqueId); return DRM_NO_ERROR; } @@ -234,7 +234,7 @@ DrmConvertedStatus* DrmPassthruPlugIn::onCloseConvertSession(int uniqueId, int c } status_t DrmPassthruPlugIn::onOpenDecryptSession( - int uniqueId, DecryptHandle* decryptHandle, int fd, int offset, int length) { + int uniqueId, DecryptHandle* decryptHandle, int fd, off64_t offset, off64_t length) { LOGD("DrmPassthruPlugIn::onOpenDecryptSession() : %d", uniqueId); #ifdef ENABLE_PASSTHRU_DECRYPTION @@ -292,7 +292,7 @@ status_t DrmPassthruPlugIn::onFinalizeDecryptUnit( } ssize_t DrmPassthruPlugIn::onPread(int uniqueId, DecryptHandle* decryptHandle, - void* buffer, ssize_t numBytes, off_t offset) { + void* buffer, ssize_t numBytes, off64_t offset) { LOGD("DrmPassthruPlugIn::onPread() : %d", uniqueId); return 0; } |