diff options
-rw-r--r-- | core/java/com/android/internal/os/BinderCallsStats.java | 13 | ||||
-rw-r--r-- | core/jni/android_media_MediaMetricsJNI.h | 1 | ||||
-rw-r--r-- | core/tests/coretests/src/com/android/internal/os/BinderCallsStatsTest.java | 20 | ||||
-rw-r--r-- | media/jni/android_media_Media2DataSource.cpp | 16 | ||||
-rw-r--r-- | media/jni/android_media_Media2HTTPConnection.cpp | 18 | ||||
-rw-r--r-- | media/jni/android_media_Media2HTTPService.cpp | 8 | ||||
-rw-r--r-- | media/jni/android_media_MediaPlayer2.cpp | 14 |
7 files changed, 59 insertions, 31 deletions
diff --git a/core/java/com/android/internal/os/BinderCallsStats.java b/core/java/com/android/internal/os/BinderCallsStats.java index 20eab92d018b..6177923d83c6 100644 --- a/core/java/com/android/internal/os/BinderCallsStats.java +++ b/core/java/com/android/internal/os/BinderCallsStats.java @@ -16,6 +16,7 @@ package com.android.internal.os; +import android.annotation.Nullable; import android.os.Binder; import android.os.SystemClock; import android.os.UserHandle; @@ -75,10 +76,10 @@ public class BinderCallsStats { } public CallSession callStarted(Binder binder, int code) { - return callStarted(binder.getClass().getName(), code); + return callStarted(binder.getClass().getName(), code, binder.getTransactionName(code)); } - private CallSession callStarted(String className, int code) { + private CallSession callStarted(String className, int code, @Nullable String methodName) { if (!mEnabled) { return NOT_ENABLED; } @@ -90,6 +91,7 @@ public class BinderCallsStats { s.callStat.className = className; s.callStat.msg = code; + s.callStat.methodName = methodName; s.exceptionThrown = false; s.cpuTimeStarted = -1; s.timeStarted = -1; @@ -169,6 +171,7 @@ public class BinderCallsStats { callStat = s.sampledCallStat; } callStat.callCount++; + callStat.methodName = s.callStat.methodName; if (s.cpuTimeStarted >= 0) { callStat.cpuTimeMicros += duration; callStat.maxCpuTimeMicros = Math.max(callStat.maxCpuTimeMicros, duration); @@ -250,6 +253,7 @@ public class BinderCallsStats { sb.setLength(0); sb.append(" ") .append(uidToString(uidEntry.uid, appIdToPkgNameMap)) + .append(",").append(e) .append(',').append(e.cpuTimeMicros) .append(',').append(e.maxCpuTimeMicros) .append(',').append(e.latencyMicros) @@ -372,6 +376,9 @@ public class BinderCallsStats { public static class CallStat { public String className; public int msg; + // Method name might be null when we cannot resolve the transaction code. For instance, if + // the binder was not generated by AIDL. + public @Nullable String methodName; public long cpuTimeMicros; public long maxCpuTimeMicros; public long latencyMicros; @@ -410,7 +417,7 @@ public class BinderCallsStats { @Override public String toString() { - return className + "/" + msg; + return className + "#" + (methodName == null ? msg : methodName); } } diff --git a/core/jni/android_media_MediaMetricsJNI.h b/core/jni/android_media_MediaMetricsJNI.h index 16081b4af1cb..b3cb4d293399 100644 --- a/core/jni/android_media_MediaMetricsJNI.h +++ b/core/jni/android_media_MediaMetricsJNI.h @@ -17,7 +17,6 @@ #ifndef _ANDROID_MEDIA_MEDIAMETRICSJNI_H_ #define _ANDROID_MEDIA_MEDIAMETRICSJNI_H_ -#include <android_runtime/AndroidRuntime.h> #include <jni.h> #include <nativehelper/JNIHelp.h> #include <media/MediaAnalyticsItem.h> diff --git a/core/tests/coretests/src/com/android/internal/os/BinderCallsStatsTest.java b/core/tests/coretests/src/com/android/internal/os/BinderCallsStatsTest.java index 914fb7409c74..3d348806c4d5 100644 --- a/core/tests/coretests/src/com/android/internal/os/BinderCallsStatsTest.java +++ b/core/tests/coretests/src/com/android/internal/os/BinderCallsStatsTest.java @@ -226,6 +226,26 @@ public class BinderCallsStatsTest { } @Test + public void testTransactionCodeResolved() { + TestBinderCallsStats bcs = new TestBinderCallsStats(); + bcs.setDetailedTracking(true); + Binder binder = new Binder() { + @Override + public String getTransactionName(int code) { + return "resolved"; + } + }; + BinderCallsStats.CallSession callSession = bcs.callStarted(binder, 1); + bcs.time += 10; + bcs.callEnded(callSession, REQUEST_SIZE, REPLY_SIZE); + + List<BinderCallsStats.CallStat> callStatsList = + bcs.getUidEntries().get(TEST_UID).getCallStatsList(); + assertEquals(1, callStatsList.get(0).msg); + assertEquals("resolved", callStatsList.get(0).methodName); + } + + @Test public void testParcelSize() { TestBinderCallsStats bcs = new TestBinderCallsStats(); bcs.setDetailedTracking(true); diff --git a/media/jni/android_media_Media2DataSource.cpp b/media/jni/android_media_Media2DataSource.cpp index bc3f6bd80cd8..b3434e9ab8ea 100644 --- a/media/jni/android_media_Media2DataSource.cpp +++ b/media/jni/android_media_Media2DataSource.cpp @@ -20,12 +20,12 @@ #include "android_media_Media2DataSource.h" -#include "android_runtime/AndroidRuntime.h" -#include "android_runtime/Log.h" +#include "log/log.h" #include "jni.h" #include <nativehelper/JNIHelp.h> #include <drm/drm_framework_common.h> +#include <mediaplayer2/JavaVMHelper.h> #include <media/stagefright/foundation/ADebug.h> #include <nativehelper/ScopedLocalRef.h> @@ -56,7 +56,7 @@ JMedia2DataSource::JMedia2DataSource(JNIEnv* env, jobject source) } JMedia2DataSource::~JMedia2DataSource() { - JNIEnv* env = AndroidRuntime::getJNIEnv(); + JNIEnv* env = JavaVMHelper::getJNIEnv(); env->DeleteGlobalRef(mMedia2DataSourceObj); env->DeleteGlobalRef(mByteArrayObj); } @@ -75,12 +75,12 @@ ssize_t JMedia2DataSource::readAt(off64_t offset, void *data, size_t size) { size = kBufferSize; } - JNIEnv* env = AndroidRuntime::getJNIEnv(); + JNIEnv* env = JavaVMHelper::getJNIEnv(); jint numread = env->CallIntMethod(mMedia2DataSourceObj, mReadAtMethod, (jlong)offset, mByteArrayObj, (jint)0, (jint)size); if (env->ExceptionCheck()) { ALOGW("An exception occurred in readAt()"); - LOGW_EX(env); + jniLogException(env, ANDROID_LOG_WARN, LOG_TAG); env->ExceptionClear(); mJavaObjStatus = UNKNOWN_ERROR; return -1; @@ -117,11 +117,11 @@ status_t JMedia2DataSource::getSize(off64_t* size) { return OK; } - JNIEnv* env = AndroidRuntime::getJNIEnv(); + JNIEnv* env = JavaVMHelper::getJNIEnv(); *size = env->CallLongMethod(mMedia2DataSourceObj, mGetSizeMethod); if (env->ExceptionCheck()) { ALOGW("An exception occurred in getSize()"); - LOGW_EX(env); + jniLogException(env, ANDROID_LOG_WARN, LOG_TAG); env->ExceptionClear(); // After returning an error, size shouldn't be used by callers. *size = UNKNOWN_ERROR; @@ -142,7 +142,7 @@ status_t JMedia2DataSource::getSize(off64_t* size) { void JMedia2DataSource::close() { Mutex::Autolock lock(mLock); - JNIEnv* env = AndroidRuntime::getJNIEnv(); + JNIEnv* env = JavaVMHelper::getJNIEnv(); env->CallVoidMethod(mMedia2DataSourceObj, mCloseMethod); // The closed state is effectively the same as an error state. mJavaObjStatus = UNKNOWN_ERROR; diff --git a/media/jni/android_media_Media2HTTPConnection.cpp b/media/jni/android_media_Media2HTTPConnection.cpp index 60176e3d238e..d02ee06dba49 100644 --- a/media/jni/android_media_Media2HTTPConnection.cpp +++ b/media/jni/android_media_Media2HTTPConnection.cpp @@ -18,14 +18,14 @@ #define LOG_TAG "Media2HTTPConnection-JNI" #include <utils/Log.h> +#include <mediaplayer2/JavaVMHelper.h> #include <media/stagefright/foundation/ADebug.h> #include <nativehelper/ScopedLocalRef.h> #include "android_media_Media2HTTPConnection.h" #include "android_util_Binder.h" -#include "android_runtime/AndroidRuntime.h" -#include "android_runtime/Log.h" +#include "log/log.h" #include "jni.h" #include <nativehelper/JNIHelp.h> @@ -84,7 +84,7 @@ JMedia2HTTPConnection::JMedia2HTTPConnection(JNIEnv *env, jobject thiz) { } JMedia2HTTPConnection::~JMedia2HTTPConnection() { - JNIEnv *env = AndroidRuntime::getJNIEnv(); + JNIEnv *env = JavaVMHelper::getJNIEnv(); env->DeleteGlobalRef(mMedia2HTTPConnectionObj); env->DeleteGlobalRef(mByteArrayObj); } @@ -101,7 +101,7 @@ bool JMedia2HTTPConnection::connect( } } - JNIEnv* env = AndroidRuntime::getJNIEnv(); + JNIEnv* env = JavaVMHelper::getJNIEnv(); jstring juri = env->NewStringUTF(uri); jstring jheaders = env->NewStringUTF(tmp.string()); @@ -115,12 +115,12 @@ bool JMedia2HTTPConnection::connect( } void JMedia2HTTPConnection::disconnect() { - JNIEnv* env = AndroidRuntime::getJNIEnv(); + JNIEnv* env = JavaVMHelper::getJNIEnv(); env->CallVoidMethod(mMedia2HTTPConnectionObj, mDisconnectMethod); } ssize_t JMedia2HTTPConnection::readAt(off64_t offset, void *data, size_t size) { - JNIEnv* env = AndroidRuntime::getJNIEnv(); + JNIEnv* env = JavaVMHelper::getJNIEnv(); if (size > kBufferSize) { size = kBufferSize; @@ -141,12 +141,12 @@ ssize_t JMedia2HTTPConnection::readAt(off64_t offset, void *data, size_t size) { } off64_t JMedia2HTTPConnection::getSize() { - JNIEnv* env = AndroidRuntime::getJNIEnv(); + JNIEnv* env = JavaVMHelper::getJNIEnv(); return (off64_t)(env->CallLongMethod(mMedia2HTTPConnectionObj, mGetSizeMethod)); } status_t JMedia2HTTPConnection::getMIMEType(String8 *mimeType) { - JNIEnv* env = AndroidRuntime::getJNIEnv(); + JNIEnv* env = JavaVMHelper::getJNIEnv(); jstring jmime = (jstring)env->CallObjectMethod(mMedia2HTTPConnectionObj, mGetMIMETypeMethod); jboolean flag = env->ExceptionCheck(); if (flag) { @@ -165,7 +165,7 @@ status_t JMedia2HTTPConnection::getMIMEType(String8 *mimeType) { } status_t JMedia2HTTPConnection::getUri(String8 *uri) { - JNIEnv* env = AndroidRuntime::getJNIEnv(); + JNIEnv* env = JavaVMHelper::getJNIEnv(); jstring juri = (jstring)env->CallObjectMethod(mMedia2HTTPConnectionObj, mGetUriMethod); jboolean flag = env->ExceptionCheck(); if (flag) { diff --git a/media/jni/android_media_Media2HTTPService.cpp b/media/jni/android_media_Media2HTTPService.cpp index 382f099b7932..1c63889e2939 100644 --- a/media/jni/android_media_Media2HTTPService.cpp +++ b/media/jni/android_media_Media2HTTPService.cpp @@ -21,11 +21,11 @@ #include "android_media_Media2HTTPConnection.h" #include "android_media_Media2HTTPService.h" -#include "android_runtime/AndroidRuntime.h" -#include "android_runtime/Log.h" +#include "log/log.h" #include "jni.h" #include <nativehelper/JNIHelp.h> +#include <mediaplayer2/JavaVMHelper.h> #include <media/stagefright/foundation/ADebug.h> #include <nativehelper/ScopedLocalRef.h> @@ -46,12 +46,12 @@ JMedia2HTTPService::JMedia2HTTPService(JNIEnv *env, jobject thiz) { } JMedia2HTTPService::~JMedia2HTTPService() { - JNIEnv *env = AndroidRuntime::getJNIEnv(); + JNIEnv *env = JavaVMHelper::getJNIEnv(); env->DeleteGlobalRef(mMedia2HTTPServiceObj); } sp<MediaHTTPConnection> JMedia2HTTPService::makeHTTPConnection() { - JNIEnv* env = AndroidRuntime::getJNIEnv(); + JNIEnv* env = JavaVMHelper::getJNIEnv(); jobject media2HTTPConnectionObj = env->CallObjectMethod(mMedia2HTTPServiceObj, mMakeHTTPConnectionMethod); diff --git a/media/jni/android_media_MediaPlayer2.cpp b/media/jni/android_media_MediaPlayer2.cpp index abf053408633..426598727c89 100644 --- a/media/jni/android_media_MediaPlayer2.cpp +++ b/media/jni/android_media_MediaPlayer2.cpp @@ -29,6 +29,7 @@ #include <media/stagefright/Utils.h> #include <media/stagefright/foundation/ByteUtils.h> // for FOURCC definition #include <mediaplayer2/JAudioTrack.h> +#include <mediaplayer2/JavaVMHelper.h> #include <mediaplayer2/mediaplayer2.h> #include <stdio.h> #include <assert.h> @@ -39,7 +40,7 @@ #include "jni.h" #include <nativehelper/JNIHelp.h> #include "android/native_window_jni.h" -#include "android_runtime/Log.h" +#include "log/log.h" #include "utils/Errors.h" // for status_t #include "utils/KeyedVector.h" #include "utils/String8.h" @@ -184,14 +185,14 @@ JNIMediaPlayer2Listener::JNIMediaPlayer2Listener(JNIEnv* env, jobject thiz, jobj JNIMediaPlayer2Listener::~JNIMediaPlayer2Listener() { // remove global references - JNIEnv *env = AndroidRuntime::getJNIEnv(); + JNIEnv *env = JavaVMHelper::getJNIEnv(); env->DeleteGlobalRef(mObject); env->DeleteGlobalRef(mClass); } void JNIMediaPlayer2Listener::notify(int64_t srcId, int msg, int ext1, int ext2, const Parcel *obj) { - JNIEnv *env = AndroidRuntime::getJNIEnv(); + JNIEnv *env = JavaVMHelper::getJNIEnv(); if (obj && obj->dataSize() > 0) { jobject jParcel = createJavaParcelObject(env); if (jParcel != NULL) { @@ -207,7 +208,7 @@ void JNIMediaPlayer2Listener::notify(int64_t srcId, int msg, int ext1, int ext2, } if (env->ExceptionCheck()) { ALOGW("An exception occurred while notifying an event."); - LOGW_EX(env); + jniLogException(env, ANDROID_LOG_WARN, LOG_TAG); env->ExceptionClear(); } } @@ -1539,8 +1540,7 @@ static const JNINativeMethod gMethods[] = { // This function only registers the native methods static int register_android_media_MediaPlayer2Impl(JNIEnv *env) { - return AndroidRuntime::registerNativeMethods(env, - "android/media/MediaPlayer2Impl", gMethods, NELEM(gMethods)); + return jniRegisterNativeMethods(env, "android/media/MediaPlayer2Impl", gMethods, NELEM(gMethods)); } jint JNI_OnLoad(JavaVM* vm, void* /* reserved */) @@ -1559,6 +1559,8 @@ jint JNI_OnLoad(JavaVM* vm, void* /* reserved */) goto bail; } + JavaVMHelper::setJavaVM(vm); + /* success -- return valid version number */ result = JNI_VERSION_1_4; |