Frameworks/base: Replace LOG_FATAL_IF in core/jni
Do not use LOG_FATAL_IF in JNI setup. This is one-time on startup
and important enough to always check.
Add a header with common helper definitions. Move to inlined functions
instead of macros to clean up the code.
Change-Id: Ib12d0eed61b110c45d748e80ec36c563e9dec7e5
diff --git a/core/jni/android_view_InputQueue.cpp b/core/jni/android_view_InputQueue.cpp
index 21b73b1..96ccdee 100644
--- a/core/jni/android_view_InputQueue.cpp
+++ b/core/jni/android_view_InputQueue.cpp
@@ -33,6 +33,8 @@
#include "android_view_KeyEvent.h"
#include "android_view_MotionEvent.h"
+#include "core_jni_helpers.h"
+
namespace android {
static struct {
@@ -256,27 +258,13 @@
static const char* const kInputQueuePathName = "android/view/InputQueue";
-#define FIND_CLASS(var, className) \
- do { \
- var = env->FindClass(className); \
- LOG_FATAL_IF(! var, "Unable to find class %s", className); \
- } while(0)
-
-#define GET_METHOD_ID(var, clazz, methodName, fieldDescriptor) \
- do { \
- var = env->GetMethodID(clazz, methodName, fieldDescriptor); \
- LOG_FATAL_IF(! var, "Unable to find method" methodName); \
- } while(0)
-
int register_android_view_InputQueue(JNIEnv* env)
{
- jclass clazz;
- FIND_CLASS(clazz, kInputQueuePathName);
- GET_METHOD_ID(gInputQueueClassInfo.finishInputEvent, clazz, "finishInputEvent", "(JZ)V");
+ jclass clazz = FindClassOrDie(env, kInputQueuePathName);
+ gInputQueueClassInfo.finishInputEvent = GetMethodIDOrDie(env, clazz, "finishInputEvent",
+ "(JZ)V");
- return AndroidRuntime::registerNativeMethods(
- env, kInputQueuePathName,
- g_methods, NELEM(g_methods));
+ return RegisterMethodsOrDie(env, kInputQueuePathName, g_methods, NELEM(g_methods));
}
} // namespace android