summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Dan Sandler <dsandler@android.com> 2015-04-09 23:50:15 -0400
committer Daniel Sandler <dsandler@android.com> 2015-04-16 04:09:50 +0000
commit5ce0430edfc176de29c0cf503975570dfda8111f (patch)
tree66850a182cad5ab1484d38c4365cf5735aec6974
parent3a1b164f6525ad25e79af8b1c712e96acbf9b2df (diff)
Add ashmem stats to Parcels.
Developers can now analyze the true RAM cost of the parcels they create when those parcels contain ashmem blobs (such as Bitmap data). Requires change Ifaf115da in frameworks/native. Bug: 20079551 Change-Id: Ifaf115dabd1a59cdb1b46e2d49c41f64ac107de4
-rw-r--r--core/java/android/os/Parcel.java9
-rw-r--r--core/jni/android_os_Parcel.cpp11
2 files changed, 20 insertions, 0 deletions
diff --git a/core/java/android/os/Parcel.java b/core/java/android/os/Parcel.java
index 9d8a1bafb93e..77c50877978b 100644
--- a/core/java/android/os/Parcel.java
+++ b/core/java/android/os/Parcel.java
@@ -283,6 +283,8 @@ public final class Parcel {
private static native void nativeWriteInterfaceToken(long nativePtr, String interfaceName);
private static native void nativeEnforceInterface(long nativePtr, String interfaceName);
+ private static native long nativeGetAshmemSize(long nativePtr);
+
public final static Parcelable.Creator<String> STRING_CREATOR
= new Parcelable.Creator<String>() {
public String createFromParcel(Parcel source) {
@@ -2594,4 +2596,11 @@ public final class Parcel {
N--;
}
}
+
+ /**
+ * @hide For testing
+ */
+ public long getBlobAshmemSize() {
+ return nativeGetBlobAshmemSize(mNativePtr);
+ }
}
diff --git a/core/jni/android_os_Parcel.cpp b/core/jni/android_os_Parcel.cpp
index 4f29c5027423..c2a9bbde5113 100644
--- a/core/jni/android_os_Parcel.cpp
+++ b/core/jni/android_os_Parcel.cpp
@@ -704,6 +704,15 @@ static jlong android_os_Parcel_getGlobalAllocCount(JNIEnv* env, jclass clazz)
return Parcel::getGlobalAllocCount();
}
+static jlong android_os_Parcel_getBlobAshmemSize(JNIEnv* env, jclass clazz, jlong nativePtr)
+{
+ Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
+ if (parcel != NULL) {
+ return parcel->getBlobAshmemSize();
+ }
+ return 0;
+}
+
// ----------------------------------------------------------------------------
static const JNINativeMethod gParcelMethods[] = {
@@ -756,6 +765,8 @@ static const JNINativeMethod gParcelMethods[] = {
{"getGlobalAllocSize", "()J", (void*)android_os_Parcel_getGlobalAllocSize},
{"getGlobalAllocCount", "()J", (void*)android_os_Parcel_getGlobalAllocCount},
+
+ {"nativeGetAshmemSize", "(J)J", (void*)android_os_Parcel_getAshmemSize},
};
const char* const kParcelPathName = "android/os/Parcel";