Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 5ce0430e authored by Dan Sandler's avatar Dan Sandler Committed by Daniel Sandler
Browse files

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
parent 3a1b164f
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -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);
    }
}
+11 −0
Original line number Diff line number Diff line
@@ -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";