summaryrefslogtreecommitdiffstats
path: root/drm
diff options
context:
space:
mode:
authorJames Dong <jdong@google.com>2011-03-14 17:01:38 -0700
committerJames Dong <jdong@google.com>2011-03-14 18:48:19 -0700
commited73246b32a725d00b0b7d7e171e5817d9f27a80 (patch)
treefbece72e18da95325bc6022714633f242474724b /drm
parent75a1ef8d14de25850a171ee80fc7f9a5b70611b5 (diff)
downloadframeworks_base-ed73246b32a725d00b0b7d7e171e5817d9f27a80.zip
frameworks_base-ed73246b32a725d00b0b7d7e171e5817d9f27a80.tar.gz
frameworks_base-ed73246b32a725d00b0b7d7e171e5817d9f27a80.tar.bz2
Add memory leak tracking/debugging code to drm server
bug - 4099038 Change-Id: I6c048eaf3d7f34bc144b8daaa5fdef1ed474af66
Diffstat (limited to 'drm')
-rw-r--r--drm/drmserver/Android.mk1
-rw-r--r--drm/drmserver/DrmManagerService.cpp29
-rw-r--r--drm/libdrmframework/include/DrmManagerService.h2
3 files changed, 32 insertions, 0 deletions
diff --git a/drm/drmserver/Android.mk b/drm/drmserver/Android.mk
index 5df2ff8..b5ad147 100644
--- a/drm/drmserver/Android.mk
+++ b/drm/drmserver/Android.mk
@@ -23,6 +23,7 @@ LOCAL_SRC_FILES:= \
StringTokenizer.cpp
LOCAL_SHARED_LIBRARIES := \
+ libmedia \
libutils \
libbinder
diff --git a/drm/drmserver/DrmManagerService.cpp b/drm/drmserver/DrmManagerService.cpp
index 0901a44..583669e 100644
--- a/drm/drmserver/DrmManagerService.cpp
+++ b/drm/drmserver/DrmManagerService.cpp
@@ -19,6 +19,7 @@
#include <utils/Log.h>
#include <private/android_filesystem_config.h>
+#include <media/MemoryLeakTrackUtil.h>
#include <errno.h>
#include <utils/threads.h>
@@ -256,3 +257,31 @@ ssize_t DrmManagerService::pread(int uniqueId, DecryptHandle* decryptHandle,
return mDrmManager->pread(uniqueId, decryptHandle, buffer, numBytes, offset);
}
+status_t DrmManagerService::dump(int fd, const Vector<String16>& args)
+{
+ const size_t SIZE = 256;
+ char buffer[SIZE];
+ String8 result;
+ if (checkCallingPermission(String16("android.permission.DUMP")) == false) {
+ snprintf(buffer, SIZE, "Permission Denial: "
+ "can't dump DrmManagerService from pid=%d, uid=%d\n",
+ IPCThreadState::self()->getCallingPid(),
+ IPCThreadState::self()->getCallingUid());
+ result.append(buffer);
+ } else {
+#if DRM_MEMORY_LEAK_TRACK
+ bool dumpMem = false;
+ for (size_t i = 0; i < args.size(); i++) {
+ if (args[i] == String16("-m")) {
+ dumpMem = true;
+ }
+ }
+ if (dumpMem) {
+ dumpMemoryAddresses(fd);
+ }
+#endif
+ }
+ write(fd, result.string(), result.size());
+ return NO_ERROR;
+}
+
diff --git a/drm/libdrmframework/include/DrmManagerService.h b/drm/libdrmframework/include/DrmManagerService.h
index d0a0db7..227496a 100644
--- a/drm/libdrmframework/include/DrmManagerService.h
+++ b/drm/libdrmframework/include/DrmManagerService.h
@@ -115,6 +115,8 @@ public:
ssize_t pread(int uniqueId, DecryptHandle* decryptHandle,
void* buffer, ssize_t numBytes, off64_t offset);
+ virtual status_t dump(int fd, const Vector<String16>& args);
+
private:
DrmManager* mDrmManager;
};