diff options
| author | Jeff Brown <jeffbrown@google.com> | 2015-04-28 13:26:48 -0700 |
|---|---|---|
| committer | Jeff Brown <jeffbrown@google.com> | 2015-04-28 17:53:32 -0700 |
| commit | e7e9ccea3246eec3607bfc77bc8500611989e84c (patch) | |
| tree | e7fadd486939848ea17582e21e315617978b3f8c /core/jni | |
| parent | 4703273e400981e9ec1bca7e9fbf949b20e91d57 (diff) | |
| download | frameworks_base-e7e9ccea3246eec3607bfc77bc8500611989e84c.zip frameworks_base-e7e9ccea3246eec3607bfc77bc8500611989e84c.tar.gz frameworks_base-e7e9ccea3246eec3607bfc77bc8500611989e84c.tar.bz2 | |
Add float support to binary event log.
Bug: 20664753
Change-Id: I90456400b878f943e39cbddec45649662176e2aa
Diffstat (limited to 'core/jni')
| -rw-r--r-- | core/jni/android_util_EventLog.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/core/jni/android_util_EventLog.cpp b/core/jni/android_util_EventLog.cpp index 5cb8b2e..05bc125 100644 --- a/core/jni/android_util_EventLog.cpp +++ b/core/jni/android_util_EventLog.cpp @@ -40,6 +40,9 @@ static jfieldID gIntegerValueID; static jclass gLongClass; static jfieldID gLongValueID; +static jclass gFloatClass; +static jfieldID gFloatValueID; + static jclass gStringClass; /* @@ -66,6 +69,17 @@ static jint android_util_EventLog_writeEvent_Long(JNIEnv* env UNUSED, /* * In class android.util.EventLog: + * static native int writeEvent(long tag, float value) + */ +static jint android_util_EventLog_writeEvent_Float(JNIEnv* env UNUSED, + jobject clazz UNUSED, + jint tag, jfloat value) +{ + return android_btWriteLog(tag, EVENT_TYPE_FLOAT, &value, sizeof(value)); +} + +/* + * In class android.util.EventLog: * static native int writeEvent(int tag, String value) */ static jint android_util_EventLog_writeEvent_String(JNIEnv* env, @@ -128,6 +142,12 @@ static jint android_util_EventLog_writeEvent_Array(JNIEnv* env, jobject clazz, buf[pos++] = EVENT_TYPE_LONG; memcpy(&buf[pos], &longVal, sizeof(longVal)); pos += sizeof(longVal); + } else if (env->IsInstanceOf(item, gFloatClass)) { + jfloat floatVal = env->GetFloatField(item, gFloatValueID); + if (pos + 1 + sizeof(floatVal) > max) break; + buf[pos++] = EVENT_TYPE_FLOAT; + memcpy(&buf[pos], &floatVal, sizeof(floatVal)); + pos += sizeof(floatVal); } else { jniThrowException(env, "java/lang/IllegalArgumentException", @@ -233,6 +253,7 @@ static JNINativeMethod gRegisterMethods[] = { /* name, signature, funcPtr */ { "writeEvent", "(II)I", (void*) android_util_EventLog_writeEvent_Integer }, { "writeEvent", "(IJ)I", (void*) android_util_EventLog_writeEvent_Long }, + { "writeEvent", "(IF)I", (void*) android_util_EventLog_writeEvent_Float }, { "writeEvent", "(ILjava/lang/String;)I", (void*) android_util_EventLog_writeEvent_String @@ -251,6 +272,7 @@ static struct { const char *name; jclass *clazz; } gClasses[] = { { "android/util/EventLog$Event", &gEventClass }, { "java/lang/Integer", &gIntegerClass }, { "java/lang/Long", &gLongClass }, + { "java/lang/Float", &gFloatClass }, { "java/lang/String", &gStringClass }, { "java/util/Collection", &gCollectionClass }, }; @@ -258,6 +280,7 @@ static struct { const char *name; jclass *clazz; } gClasses[] = { static struct { jclass *c; const char *name, *ft; jfieldID *id; } gFields[] = { { &gIntegerClass, "value", "I", &gIntegerValueID }, { &gLongClass, "value", "J", &gLongValueID }, + { &gFloatClass, "value", "F", &gFloatValueID }, }; static struct { jclass *c; const char *name, *mt; jmethodID *id; } gMethods[] = { |
