summaryrefslogtreecommitdiffstats
path: root/drm/drmserver
diff options
context:
space:
mode:
authorGloria Wang <gwang@google.com>2010-11-22 21:29:08 -0800
committerAndroid Git Automerger <android-git-automerger@android.com>2010-11-22 21:29:08 -0800
commit35f2d3997efe62ce7660ac558578ac5ca834f357 (patch)
tree9f6031e2e4bb9665e619bc881839477c14898a21 /drm/drmserver
parentc0ec802e96788c3002b737b02707875049758f98 (diff)
parent24a90c2674270fee0783bafa54fd5d845bdf0c18 (diff)
downloadframeworks_base-35f2d3997efe62ce7660ac558578ac5ca834f357.zip
frameworks_base-35f2d3997efe62ce7660ac558578ac5ca834f357.tar.gz
frameworks_base-35f2d3997efe62ce7660ac558578ac5ca834f357.tar.bz2
am 24a90c26: am d9334934: Merge "Update of DRM Framework."
* commit '24a90c2674270fee0783bafa54fd5d845bdf0c18': Update of DRM Framework.
Diffstat (limited to 'drm/drmserver')
-rw-r--r--drm/drmserver/DrmManager.cpp10
-rw-r--r--drm/drmserver/DrmManagerService.cpp49
2 files changed, 57 insertions, 2 deletions
diff --git a/drm/drmserver/DrmManager.cpp b/drm/drmserver/DrmManager.cpp
index 8da8176..9a6f787 100644
--- a/drm/drmserver/DrmManager.cpp
+++ b/drm/drmserver/DrmManager.cpp
@@ -23,6 +23,7 @@
#include <drm/DrmInfoEvent.h>
#include <drm/DrmRights.h>
#include <drm/DrmConstraints.h>
+#include <drm/DrmMetadata.h>
#include <drm/DrmInfoStatus.h>
#include <drm/DrmInfoRequest.h>
#include <drm/DrmSupportInfo.h>
@@ -148,6 +149,15 @@ DrmConstraints* DrmManager::getConstraints(int uniqueId, const String8* path, co
return NULL;
}
+DrmMetadata* DrmManager::getMetadata(int uniqueId, const String8* path) {
+ const String8 plugInId = getSupportedPlugInIdFromPath(uniqueId, *path);
+ if (EMPTY_STRING != plugInId) {
+ IDrmEngine& rDrmEngine = mPlugInManager.getPlugIn(plugInId);
+ return rDrmEngine.getMetadata(uniqueId, path);
+ }
+ return NULL;
+}
+
status_t DrmManager::installDrmEngine(int uniqueId, const String8& absolutePath) {
mPlugInManager.loadPlugIn(absolutePath);
diff --git a/drm/drmserver/DrmManagerService.cpp b/drm/drmserver/DrmManagerService.cpp
index efd7bae..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);
@@ -172,13 +209,21 @@ status_t DrmManagerService::getAllSupportInfo(
DecryptHandle* DrmManagerService::openDecryptSession(
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) {