diff options
Diffstat (limited to 'drm/drmserver/DrmManagerService.cpp')
-rw-r--r-- | drm/drmserver/DrmManagerService.cpp | 55 |
1 files changed, 50 insertions, 5 deletions
diff --git a/drm/drmserver/DrmManagerService.cpp b/drm/drmserver/DrmManagerService.cpp index 8cf510d..0901a44 100644 --- a/drm/drmserver/DrmManagerService.cpp +++ b/drm/drmserver/DrmManagerService.cpp @@ -18,18 +18,50 @@ #define LOG_TAG "DrmManagerService(Native)" #include <utils/Log.h> +#include <private/android_filesystem_config.h> + #include <errno.h> #include <utils/threads.h> #include <binder/IServiceManager.h> +#include <binder/IPCThreadState.h> #include <sys/stat.h> #include "DrmManagerService.h" #include "DrmManager.h" using namespace android; +static Vector<uid_t> trustedUids; + +static bool isProtectedCallAllowed() { + // TODO + // Following implementation is just for reference. + // Each OEM manufacturer should implement/replace with their own solutions. + bool result = false; + + IPCThreadState* ipcState = IPCThreadState::self(); + uid_t uid = ipcState->getCallingUid(); + + for (unsigned int i = 0; i < trustedUids.size(); ++i) { + if (trustedUids[i] == uid) { + result = true; + break; + } + } + return result; +} + void DrmManagerService::instantiate() { LOGV("instantiate"); defaultServiceManager()->addService(String16("drm.drmManager"), new DrmManagerService()); + + if (0 >= trustedUids.size()) { + // TODO + // Following implementation is just for reference. + // Each OEM manufacturer should implement/replace with their own solutions. + + // Add trusted uids here + trustedUids.push(AID_MEDIA); + } } DrmManagerService::DrmManagerService() : @@ -79,6 +111,11 @@ DrmConstraints* DrmManagerService::getConstraints( return mDrmManager->getConstraints(uniqueId, path, action); } +DrmMetadata* DrmManagerService::getMetadata(int uniqueId, const String8* path) { + LOGV("Entering getMetadata from content"); + return mDrmManager->getMetadata(uniqueId, path); +} + bool DrmManagerService::canHandle(int uniqueId, const String8& path, const String8& mimeType) { LOGV("Entering canHandle"); return mDrmManager->canHandle(uniqueId, path, mimeType); @@ -125,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); } @@ -170,15 +207,23 @@ 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"); - return mDrmManager->openDecryptSession(uniqueId, fd, offset, length); + if (isProtectedCallAllowed()) { + return mDrmManager->openDecryptSession(uniqueId, fd, offset, length); + } + + return NULL; } DecryptHandle* DrmManagerService::openDecryptSession( int uniqueId, const char* uri) { LOGV("Entering DrmManagerService::openDecryptSession with uri"); - return mDrmManager->openDecryptSession(uniqueId, uri); + if (isProtectedCallAllowed()) { + return mDrmManager->openDecryptSession(uniqueId, uri); + } + + return NULL; } status_t DrmManagerService::closeDecryptSession(int uniqueId, DecryptHandle* decryptHandle) { @@ -206,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); } |