summaryrefslogtreecommitdiffstats
path: root/core/jni/android_view_InputEventSender.cpp
diff options
context:
space:
mode:
authorAndreas Gampe <agampe@google.com>2014-11-20 22:02:20 -0800
committerAndreas Gampe <agampe@google.com>2014-11-21 10:15:08 -0800
commited6b9dff563c5e22f040ff37e12c0d771e0478ae (patch)
treede1338ef208f874dd3c92a255a0c98c4d6f21cf3 /core/jni/android_view_InputEventSender.cpp
parentf926d71b8ef2790da067550144860705c1a61fe5 (diff)
downloadframeworks_base-ed6b9dff563c5e22f040ff37e12c0d771e0478ae.zip
frameworks_base-ed6b9dff563c5e22f040ff37e12c0d771e0478ae.tar.gz
frameworks_base-ed6b9dff563c5e22f040ff37e12c0d771e0478ae.tar.bz2
Frameworks/base: Consistency in core/jni
Make consistent use of core_jni_helpers for registration. Translate some #ifdefs into const bools. Change-Id: I37639aa053dd50f003a552cbd8550dddecc811c5
Diffstat (limited to 'core/jni/android_view_InputEventSender.cpp')
-rw-r--r--core/jni/android_view_InputEventSender.cpp58
1 files changed, 29 insertions, 29 deletions
diff --git a/core/jni/android_view_InputEventSender.cpp b/core/jni/android_view_InputEventSender.cpp
index de65d0d..e7388cf 100644
--- a/core/jni/android_view_InputEventSender.cpp
+++ b/core/jni/android_view_InputEventSender.cpp
@@ -18,10 +18,6 @@
//#define LOG_NDEBUG 0
-// Log debug messages about the dispatch cycle.
-#define DEBUG_DISPATCH_CYCLE 0
-
-
#include "JNIHelp.h"
#include <android_runtime/AndroidRuntime.h>
@@ -41,6 +37,9 @@
namespace android {
+// Log debug messages about the dispatch cycle.
+static const bool kDebugDispatchCycle = false;
+
static struct {
jclass clazz;
@@ -84,9 +83,9 @@ NativeInputEventSender::NativeInputEventSender(JNIEnv* env,
mSenderWeakGlobal(env->NewGlobalRef(senderWeak)),
mInputPublisher(inputChannel), mMessageQueue(messageQueue),
mNextPublishedSeq(1) {
-#if DEBUG_DISPATCH_CYCLE
- ALOGD("channel '%s' ~ Initializing input event sender.", getInputChannelName());
-#endif
+ if (kDebugDispatchCycle) {
+ ALOGD("channel '%s' ~ Initializing input event sender.", getInputChannelName());
+ }
}
NativeInputEventSender::~NativeInputEventSender() {
@@ -101,17 +100,17 @@ status_t NativeInputEventSender::initialize() {
}
void NativeInputEventSender::dispose() {
-#if DEBUG_DISPATCH_CYCLE
- ALOGD("channel '%s' ~ Disposing input event sender.", getInputChannelName());
-#endif
+ if (kDebugDispatchCycle) {
+ ALOGD("channel '%s' ~ Disposing input event sender.", getInputChannelName());
+ }
mMessageQueue->getLooper()->removeFd(mInputPublisher.getChannel()->getFd());
}
status_t NativeInputEventSender::sendKeyEvent(uint32_t seq, const KeyEvent* event) {
-#if DEBUG_DISPATCH_CYCLE
- ALOGD("channel '%s' ~ Sending key event, seq=%u.", getInputChannelName(), seq);
-#endif
+ if (kDebugDispatchCycle) {
+ ALOGD("channel '%s' ~ Sending key event, seq=%u.", getInputChannelName(), seq);
+ }
uint32_t publishedSeq = mNextPublishedSeq++;
status_t status = mInputPublisher.publishKeyEvent(publishedSeq,
@@ -128,9 +127,9 @@ status_t NativeInputEventSender::sendKeyEvent(uint32_t seq, const KeyEvent* even
}
status_t NativeInputEventSender::sendMotionEvent(uint32_t seq, const MotionEvent* event) {
-#if DEBUG_DISPATCH_CYCLE
- ALOGD("channel '%s' ~ Sending motion event, seq=%u.", getInputChannelName(), seq);
-#endif
+ if (kDebugDispatchCycle) {
+ ALOGD("channel '%s' ~ Sending motion event, seq=%u.", getInputChannelName(), seq);
+ }
uint32_t publishedSeq;
for (size_t i = 0; i <= event->getHistorySize(); i++) {
@@ -155,13 +154,14 @@ status_t NativeInputEventSender::sendMotionEvent(uint32_t seq, const MotionEvent
int NativeInputEventSender::handleEvent(int receiveFd, int events, void* data) {
if (events & (ALOOPER_EVENT_ERROR | ALOOPER_EVENT_HANGUP)) {
-#if DEBUG_DISPATCH_CYCLE
// This error typically occurs when the consumer has closed the input channel
// as part of finishing an IME session, in which case the publisher will
// soon be disposed as well.
- ALOGD("channel '%s' ~ Consumer closed input channel or an error occurred. "
- "events=0x%x", getInputChannelName(), events);
-#endif
+ if (kDebugDispatchCycle) {
+ ALOGD("channel '%s' ~ Consumer closed input channel or an error occurred. "
+ "events=0x%x", getInputChannelName(), events);
+ }
+
return 0; // remove the callback
}
@@ -178,9 +178,9 @@ int NativeInputEventSender::handleEvent(int receiveFd, int events, void* data) {
}
status_t NativeInputEventSender::receiveFinishedSignals(JNIEnv* env) {
-#if DEBUG_DISPATCH_CYCLE
- ALOGD("channel '%s' ~ Receiving finished signals.", getInputChannelName());
-#endif
+ if (kDebugDispatchCycle) {
+ ALOGD("channel '%s' ~ Receiving finished signals.", getInputChannelName());
+ }
ScopedLocalRef<jobject> senderObj(env, NULL);
bool skipCallbacks = false;
@@ -202,12 +202,12 @@ status_t NativeInputEventSender::receiveFinishedSignals(JNIEnv* env) {
uint32_t seq = mPublishedSeqMap.valueAt(index);
mPublishedSeqMap.removeItemsAt(index);
-#if DEBUG_DISPATCH_CYCLE
- ALOGD("channel '%s' ~ Received finished signal, seq=%u, handled=%s, "
- "pendingEvents=%u.",
- getInputChannelName(), seq, handled ? "true" : "false",
- mPublishedSeqMap.size());
-#endif
+ if (kDebugDispatchCycle) {
+ ALOGD("channel '%s' ~ Received finished signal, seq=%u, handled=%s, "
+ "pendingEvents=%u.",
+ getInputChannelName(), seq, handled ? "true" : "false",
+ mPublishedSeqMap.size());
+ }
if (!skipCallbacks) {
if (!senderObj.get()) {