Loading apex/statsd/Android.bp +1 −1 Original line number Diff line number Diff line Loading @@ -62,8 +62,8 @@ prebuilt_etc { cc_library_shared { name: "libstats_jni", srcs: ["jni/**/*.cpp"], header_libs: ["libnativehelper_header_only"], shared_libs: [ "libnativehelper", // Has stable abi - should not be copied into apex. "liblog", // Has a stable abi - should not be copied into apex. "libstatssocket", ], Loading apex/statsd/jni/android_util_StatsLog.cpp +20 −10 Original line number Diff line number Diff line Loading @@ -17,9 +17,9 @@ #define LOG_NAMESPACE "StatsLog.tag." #define LOG_TAG "StatsLog_println" #include "jni.h" #include <jni.h> #include <log/log.h> #include <nativehelper/JNIHelp.h> #include <nativehelper/scoped_local_ref.h> #include "stats_buffer_writer.h" namespace android { Loading Loading @@ -54,8 +54,23 @@ static const JNINativeMethod gMethods[] = { int register_android_util_StatsLog(JNIEnv* env) { return jniRegisterNativeMethods(env, "android/util/StatsLog", gMethods, NELEM(gMethods)); static const char* kStatsLogClass = "android/util/StatsLog"; ScopedLocalRef<jclass> cls(env, env->FindClass(kStatsLogClass)); if (cls.get() == nullptr) { ALOGE("jni statsd registration failure, class not found '%s'", kStatsLogClass); return JNI_ERR; } const jint count = sizeof(gMethods) / sizeof(gMethods[0]); int status = env->RegisterNatives(cls.get(), gMethods, count); if (status < 0) { ALOGE("jni statsd registration failure, status: %d", status); return JNI_ERR; } return JNI_VERSION_1_4; } }; // namespace android /* Loading @@ -63,7 +78,6 @@ int register_android_util_StatsLog(JNIEnv* env) */ jint JNI_OnLoad(JavaVM* jvm, void* reserved) { JNIEnv* e; int status; ALOGV("statsd : loading JNI\n"); // Check JNI version Loading @@ -71,10 +85,6 @@ jint JNI_OnLoad(JavaVM* jvm, void* reserved) { ALOGE("JNI version mismatch error"); return JNI_ERR; } status = android::register_android_util_StatsLog(e); if (status < 0) { ALOGE("jni statsd registration failure, status: %d", status); return JNI_ERR; } return JNI_VERSION_1_4; return android::register_android_util_StatsLog(e); } Loading
apex/statsd/Android.bp +1 −1 Original line number Diff line number Diff line Loading @@ -62,8 +62,8 @@ prebuilt_etc { cc_library_shared { name: "libstats_jni", srcs: ["jni/**/*.cpp"], header_libs: ["libnativehelper_header_only"], shared_libs: [ "libnativehelper", // Has stable abi - should not be copied into apex. "liblog", // Has a stable abi - should not be copied into apex. "libstatssocket", ], Loading
apex/statsd/jni/android_util_StatsLog.cpp +20 −10 Original line number Diff line number Diff line Loading @@ -17,9 +17,9 @@ #define LOG_NAMESPACE "StatsLog.tag." #define LOG_TAG "StatsLog_println" #include "jni.h" #include <jni.h> #include <log/log.h> #include <nativehelper/JNIHelp.h> #include <nativehelper/scoped_local_ref.h> #include "stats_buffer_writer.h" namespace android { Loading Loading @@ -54,8 +54,23 @@ static const JNINativeMethod gMethods[] = { int register_android_util_StatsLog(JNIEnv* env) { return jniRegisterNativeMethods(env, "android/util/StatsLog", gMethods, NELEM(gMethods)); static const char* kStatsLogClass = "android/util/StatsLog"; ScopedLocalRef<jclass> cls(env, env->FindClass(kStatsLogClass)); if (cls.get() == nullptr) { ALOGE("jni statsd registration failure, class not found '%s'", kStatsLogClass); return JNI_ERR; } const jint count = sizeof(gMethods) / sizeof(gMethods[0]); int status = env->RegisterNatives(cls.get(), gMethods, count); if (status < 0) { ALOGE("jni statsd registration failure, status: %d", status); return JNI_ERR; } return JNI_VERSION_1_4; } }; // namespace android /* Loading @@ -63,7 +78,6 @@ int register_android_util_StatsLog(JNIEnv* env) */ jint JNI_OnLoad(JavaVM* jvm, void* reserved) { JNIEnv* e; int status; ALOGV("statsd : loading JNI\n"); // Check JNI version Loading @@ -71,10 +85,6 @@ jint JNI_OnLoad(JavaVM* jvm, void* reserved) { ALOGE("JNI version mismatch error"); return JNI_ERR; } status = android::register_android_util_StatsLog(e); if (status < 0) { ALOGE("jni statsd registration failure, status: %d", status); return JNI_ERR; } return JNI_VERSION_1_4; return android::register_android_util_StatsLog(e); }