summaryrefslogtreecommitdiffstats
path: root/core/jni
diff options
context:
space:
mode:
authorDan Egnor <egnor@google.com>2010-01-06 23:12:57 -0800
committerDan Egnor <egnor@google.com>2010-01-07 00:28:58 -0800
commit6916089e838662b41d902cd9a0d2560b04633ef9 (patch)
tree8ec507232b223c4362c816bb0ba6c8543f136759 /core/jni
parent4cd9f5454aa51a284e6cc70ecc932cb6213b5f10 (diff)
downloadframeworks_base-6916089e838662b41d902cd9a0d2560b04633ef9.zip
frameworks_base-6916089e838662b41d902cd9a0d2560b04633ef9.tar.gz
frameworks_base-6916089e838662b41d902cd9a0d2560b04633ef9.tar.bz2
Remove old EventLog tests from here, they will be replaced by a
(better) EventLog test in CTS. Fix some minor errors in the handling of too-large event log values.
Diffstat (limited to 'core/jni')
-rw-r--r--core/jni/android_util_EventLog.cpp9
1 files changed, 6 insertions, 3 deletions
diff --git a/core/jni/android_util_EventLog.cpp b/core/jni/android_util_EventLog.cpp
index 78356cf..75f6cb2 100644
--- a/core/jni/android_util_EventLog.cpp
+++ b/core/jni/android_util_EventLog.cpp
@@ -21,6 +21,9 @@
#include "jni.h"
#include "cutils/logger.h"
+// The size of the tag number comes out of the payload size.
+#define MAX_EVENT_PAYLOAD (LOGGER_ENTRY_MAX_PAYLOAD - sizeof(int32_t))
+
namespace android {
static jclass gCollectionClass;
@@ -66,7 +69,7 @@ static jint android_util_EventLog_writeEvent_Long(JNIEnv* env, jobject clazz,
*/
static jint android_util_EventLog_writeEvent_String(JNIEnv* env, jobject clazz,
jint tag, jstring value) {
- uint8_t buf[LOGGER_ENTRY_MAX_PAYLOAD];
+ uint8_t buf[MAX_EVENT_PAYLOAD];
// Don't throw NPE -- I feel like it's sort of mean for a logging function
// to be all crashy if you pass in NULL -- but make the NULL value explicit.
@@ -94,12 +97,12 @@ static jint android_util_EventLog_writeEvent_Array(JNIEnv* env, jobject clazz,
return android_util_EventLog_writeEvent_String(env, clazz, tag, NULL);
}
- uint8_t buf[LOGGER_ENTRY_MAX_PAYLOAD];
+ uint8_t buf[MAX_EVENT_PAYLOAD];
const size_t max = sizeof(buf) - 1; // leave room for final newline
size_t pos = 2; // Save room for type tag & array count
jsize copied = 0, num = env->GetArrayLength(value);
- for (; copied < num && copied < 256; ++copied) {
+ for (; copied < num && copied < 255; ++copied) {
jobject item = env->GetObjectArrayElement(value, copied);
if (item == NULL || env->IsInstanceOf(item, gStringClass)) {
if (pos + 1 + sizeof(jint) > max) break;