Merge "Update input event type to enum class" into udc-dev
This commit is contained in:
committed by
Android (Google) Code Review
commit
150c188a69
@@ -368,17 +368,19 @@ status_t NativeInputEventReceiver::consumeEvents(JNIEnv* env,
|
|||||||
|
|
||||||
jobject inputEventObj;
|
jobject inputEventObj;
|
||||||
switch (inputEvent->getType()) {
|
switch (inputEvent->getType()) {
|
||||||
case AINPUT_EVENT_TYPE_KEY:
|
case InputEventType::KEY:
|
||||||
if (kDebugDispatchCycle) {
|
if (kDebugDispatchCycle) {
|
||||||
ALOGD("channel '%s' ~ Received key event.", getInputChannelName().c_str());
|
ALOGD("channel '%s' ~ Received key event.", getInputChannelName().c_str());
|
||||||
}
|
}
|
||||||
inputEventObj = android_view_KeyEvent_fromNative(env,
|
inputEventObj =
|
||||||
|
android_view_KeyEvent_fromNative(env,
|
||||||
static_cast<KeyEvent*>(inputEvent));
|
static_cast<KeyEvent*>(inputEvent));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case AINPUT_EVENT_TYPE_MOTION: {
|
case InputEventType::MOTION: {
|
||||||
if (kDebugDispatchCycle) {
|
if (kDebugDispatchCycle) {
|
||||||
ALOGD("channel '%s' ~ Received motion event.", getInputChannelName().c_str());
|
ALOGD("channel '%s' ~ Received motion event.",
|
||||||
|
getInputChannelName().c_str());
|
||||||
}
|
}
|
||||||
const MotionEvent& motionEvent = static_cast<const MotionEvent&>(*inputEvent);
|
const MotionEvent& motionEvent = static_cast<const MotionEvent&>(*inputEvent);
|
||||||
if ((motionEvent.getAction() & AMOTION_EVENT_ACTION_MOVE) && outConsumedBatch) {
|
if ((motionEvent.getAction() & AMOTION_EVENT_ACTION_MOVE) && outConsumedBatch) {
|
||||||
@@ -387,18 +389,19 @@ status_t NativeInputEventReceiver::consumeEvents(JNIEnv* env,
|
|||||||
inputEventObj = android_view_MotionEvent_obtainAsCopy(env, motionEvent);
|
inputEventObj = android_view_MotionEvent_obtainAsCopy(env, motionEvent);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case AINPUT_EVENT_TYPE_FOCUS: {
|
case InputEventType::FOCUS: {
|
||||||
FocusEvent* focusEvent = static_cast<FocusEvent*>(inputEvent);
|
FocusEvent* focusEvent = static_cast<FocusEvent*>(inputEvent);
|
||||||
if (kDebugDispatchCycle) {
|
if (kDebugDispatchCycle) {
|
||||||
ALOGD("channel '%s' ~ Received focus event: hasFocus=%s.",
|
ALOGD("channel '%s' ~ Received focus event: hasFocus=%s.",
|
||||||
getInputChannelName().c_str(), toString(focusEvent->getHasFocus()));
|
getInputChannelName().c_str(), toString(focusEvent->getHasFocus()));
|
||||||
}
|
}
|
||||||
env->CallVoidMethod(receiverObj.get(), gInputEventReceiverClassInfo.onFocusEvent,
|
env->CallVoidMethod(receiverObj.get(),
|
||||||
|
gInputEventReceiverClassInfo.onFocusEvent,
|
||||||
jboolean(focusEvent->getHasFocus()));
|
jboolean(focusEvent->getHasFocus()));
|
||||||
finishInputEvent(seq, true /* handled */);
|
finishInputEvent(seq, true /* handled */);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case AINPUT_EVENT_TYPE_CAPTURE: {
|
case InputEventType::CAPTURE: {
|
||||||
const CaptureEvent* captureEvent = static_cast<CaptureEvent*>(inputEvent);
|
const CaptureEvent* captureEvent = static_cast<CaptureEvent*>(inputEvent);
|
||||||
if (kDebugDispatchCycle) {
|
if (kDebugDispatchCycle) {
|
||||||
ALOGD("channel '%s' ~ Received capture event: pointerCaptureEnabled=%s",
|
ALOGD("channel '%s' ~ Received capture event: pointerCaptureEnabled=%s",
|
||||||
@@ -411,7 +414,7 @@ status_t NativeInputEventReceiver::consumeEvents(JNIEnv* env,
|
|||||||
finishInputEvent(seq, true /* handled */);
|
finishInputEvent(seq, true /* handled */);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case AINPUT_EVENT_TYPE_DRAG: {
|
case InputEventType::DRAG: {
|
||||||
const DragEvent* dragEvent = static_cast<DragEvent*>(inputEvent);
|
const DragEvent* dragEvent = static_cast<DragEvent*>(inputEvent);
|
||||||
if (kDebugDispatchCycle) {
|
if (kDebugDispatchCycle) {
|
||||||
ALOGD("channel '%s' ~ Received drag event: isExiting=%s",
|
ALOGD("channel '%s' ~ Received drag event: isExiting=%s",
|
||||||
@@ -423,11 +426,12 @@ status_t NativeInputEventReceiver::consumeEvents(JNIEnv* env,
|
|||||||
finishInputEvent(seq, true /* handled */);
|
finishInputEvent(seq, true /* handled */);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
case AINPUT_EVENT_TYPE_TOUCH_MODE: {
|
case InputEventType::TOUCH_MODE: {
|
||||||
const TouchModeEvent* touchModeEvent = static_cast<TouchModeEvent*>(inputEvent);
|
const TouchModeEvent* touchModeEvent = static_cast<TouchModeEvent*>(inputEvent);
|
||||||
if (kDebugDispatchCycle) {
|
if (kDebugDispatchCycle) {
|
||||||
ALOGD("channel '%s' ~ Received touch mode event: isInTouchMode=%s",
|
ALOGD("channel '%s' ~ Received touch mode event: isInTouchMode=%s",
|
||||||
getInputChannelName().c_str(), toString(touchModeEvent->isInTouchMode()));
|
getInputChannelName().c_str(),
|
||||||
|
toString(touchModeEvent->isInTouchMode()));
|
||||||
}
|
}
|
||||||
env->CallVoidMethod(receiverObj.get(),
|
env->CallVoidMethod(receiverObj.get(),
|
||||||
gInputEventReceiverClassInfo.onTouchModeChanged,
|
gInputEventReceiverClassInfo.onTouchModeChanged,
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ status_t InputQueue::getEvent(InputEvent** outEvent) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool InputQueue::preDispatchEvent(InputEvent* e) {
|
bool InputQueue::preDispatchEvent(InputEvent* e) {
|
||||||
if (e->getType() == AINPUT_EVENT_TYPE_KEY) {
|
if (e->getType() == InputEventType::KEY) {
|
||||||
KeyEvent* keyEvent = static_cast<KeyEvent*>(e);
|
KeyEvent* keyEvent = static_cast<KeyEvent*>(e);
|
||||||
if (keyEvent->getFlags() & AKEY_EVENT_FLAG_PREDISPATCH) {
|
if (keyEvent->getFlags() & AKEY_EVENT_FLAG_PREDISPATCH) {
|
||||||
finishEvent(e, false);
|
finishEvent(e, false);
|
||||||
|
|||||||
@@ -33,6 +33,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
|
|
||||||
using android::InputEvent;
|
using android::InputEvent;
|
||||||
|
using android::InputEventType;
|
||||||
using android::InputQueue;
|
using android::InputQueue;
|
||||||
using android::KeyEvent;
|
using android::KeyEvent;
|
||||||
using android::Looper;
|
using android::Looper;
|
||||||
@@ -41,7 +42,8 @@ using android::sp;
|
|||||||
using android::Vector;
|
using android::Vector;
|
||||||
|
|
||||||
int32_t AInputEvent_getType(const AInputEvent* event) {
|
int32_t AInputEvent_getType(const AInputEvent* event) {
|
||||||
return static_cast<const InputEvent*>(event)->getType();
|
const InputEventType eventType = static_cast<const InputEvent*>(event)->getType();
|
||||||
|
return static_cast<int32_t>(eventType);
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t AInputEvent_getDeviceId(const AInputEvent* event) {
|
int32_t AInputEvent_getDeviceId(const AInputEvent* event) {
|
||||||
|
|||||||
@@ -1311,14 +1311,14 @@ bool NativeInputManager::filterInputEvent(const InputEvent* inputEvent, uint32_t
|
|||||||
|
|
||||||
JNIEnv* env = jniEnv();
|
JNIEnv* env = jniEnv();
|
||||||
switch (inputEvent->getType()) {
|
switch (inputEvent->getType()) {
|
||||||
case AINPUT_EVENT_TYPE_KEY:
|
case InputEventType::KEY:
|
||||||
inputEventObj = android_view_KeyEvent_fromNative(env,
|
|
||||||
static_cast<const KeyEvent*>(inputEvent));
|
|
||||||
break;
|
|
||||||
case AINPUT_EVENT_TYPE_MOTION:
|
|
||||||
inputEventObj =
|
inputEventObj =
|
||||||
android_view_MotionEvent_obtainAsCopy(env,
|
android_view_KeyEvent_fromNative(env, static_cast<const KeyEvent*>(inputEvent));
|
||||||
static_cast<const MotionEvent&>(*inputEvent));
|
break;
|
||||||
|
case InputEventType::MOTION:
|
||||||
|
inputEventObj = android_view_MotionEvent_obtainAsCopy(env,
|
||||||
|
static_cast<const MotionEvent&>(
|
||||||
|
*inputEvent));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
return true; // dispatch the event normally
|
return true; // dispatch the event normally
|
||||||
|
|||||||
Reference in New Issue
Block a user