Update input event type to enum class
The native definitions for event type were changed to enum class. Update the usages here. Bug: 274073185 Test: m checkinput Change-Id: If80dc6fc568da2d195606b5fbece7b7b5975e061
This commit is contained in:
@@ -368,73 +368,77 @@ status_t NativeInputEventReceiver::consumeEvents(JNIEnv* env,
|
||||
|
||||
jobject inputEventObj;
|
||||
switch (inputEvent->getType()) {
|
||||
case AINPUT_EVENT_TYPE_KEY:
|
||||
if (kDebugDispatchCycle) {
|
||||
ALOGD("channel '%s' ~ Received key event.", getInputChannelName().c_str());
|
||||
}
|
||||
inputEventObj = android_view_KeyEvent_fromNative(env,
|
||||
static_cast<KeyEvent*>(inputEvent));
|
||||
break;
|
||||
case InputEventType::KEY:
|
||||
if (kDebugDispatchCycle) {
|
||||
ALOGD("channel '%s' ~ Received key event.", getInputChannelName().c_str());
|
||||
}
|
||||
inputEventObj =
|
||||
android_view_KeyEvent_fromNative(env,
|
||||
static_cast<KeyEvent*>(inputEvent));
|
||||
break;
|
||||
|
||||
case AINPUT_EVENT_TYPE_MOTION: {
|
||||
if (kDebugDispatchCycle) {
|
||||
ALOGD("channel '%s' ~ Received motion event.", getInputChannelName().c_str());
|
||||
case InputEventType::MOTION: {
|
||||
if (kDebugDispatchCycle) {
|
||||
ALOGD("channel '%s' ~ Received motion event.",
|
||||
getInputChannelName().c_str());
|
||||
}
|
||||
const MotionEvent& motionEvent = static_cast<const MotionEvent&>(*inputEvent);
|
||||
if ((motionEvent.getAction() & AMOTION_EVENT_ACTION_MOVE) && outConsumedBatch) {
|
||||
*outConsumedBatch = true;
|
||||
}
|
||||
inputEventObj = android_view_MotionEvent_obtainAsCopy(env, motionEvent);
|
||||
break;
|
||||
}
|
||||
const MotionEvent& motionEvent = static_cast<const MotionEvent&>(*inputEvent);
|
||||
if ((motionEvent.getAction() & AMOTION_EVENT_ACTION_MOVE) && outConsumedBatch) {
|
||||
*outConsumedBatch = true;
|
||||
case InputEventType::FOCUS: {
|
||||
FocusEvent* focusEvent = static_cast<FocusEvent*>(inputEvent);
|
||||
if (kDebugDispatchCycle) {
|
||||
ALOGD("channel '%s' ~ Received focus event: hasFocus=%s.",
|
||||
getInputChannelName().c_str(), toString(focusEvent->getHasFocus()));
|
||||
}
|
||||
env->CallVoidMethod(receiverObj.get(),
|
||||
gInputEventReceiverClassInfo.onFocusEvent,
|
||||
jboolean(focusEvent->getHasFocus()));
|
||||
finishInputEvent(seq, true /* handled */);
|
||||
continue;
|
||||
}
|
||||
inputEventObj = android_view_MotionEvent_obtainAsCopy(env, motionEvent);
|
||||
break;
|
||||
}
|
||||
case AINPUT_EVENT_TYPE_FOCUS: {
|
||||
FocusEvent* focusEvent = static_cast<FocusEvent*>(inputEvent);
|
||||
if (kDebugDispatchCycle) {
|
||||
ALOGD("channel '%s' ~ Received focus event: hasFocus=%s.",
|
||||
getInputChannelName().c_str(), toString(focusEvent->getHasFocus()));
|
||||
case InputEventType::CAPTURE: {
|
||||
const CaptureEvent* captureEvent = static_cast<CaptureEvent*>(inputEvent);
|
||||
if (kDebugDispatchCycle) {
|
||||
ALOGD("channel '%s' ~ Received capture event: pointerCaptureEnabled=%s",
|
||||
getInputChannelName().c_str(),
|
||||
toString(captureEvent->getPointerCaptureEnabled()));
|
||||
}
|
||||
env->CallVoidMethod(receiverObj.get(),
|
||||
gInputEventReceiverClassInfo.onPointerCaptureEvent,
|
||||
jboolean(captureEvent->getPointerCaptureEnabled()));
|
||||
finishInputEvent(seq, true /* handled */);
|
||||
continue;
|
||||
}
|
||||
env->CallVoidMethod(receiverObj.get(), gInputEventReceiverClassInfo.onFocusEvent,
|
||||
jboolean(focusEvent->getHasFocus()));
|
||||
finishInputEvent(seq, true /* handled */);
|
||||
continue;
|
||||
}
|
||||
case AINPUT_EVENT_TYPE_CAPTURE: {
|
||||
const CaptureEvent* captureEvent = static_cast<CaptureEvent*>(inputEvent);
|
||||
if (kDebugDispatchCycle) {
|
||||
ALOGD("channel '%s' ~ Received capture event: pointerCaptureEnabled=%s",
|
||||
getInputChannelName().c_str(),
|
||||
toString(captureEvent->getPointerCaptureEnabled()));
|
||||
case InputEventType::DRAG: {
|
||||
const DragEvent* dragEvent = static_cast<DragEvent*>(inputEvent);
|
||||
if (kDebugDispatchCycle) {
|
||||
ALOGD("channel '%s' ~ Received drag event: isExiting=%s",
|
||||
getInputChannelName().c_str(), toString(dragEvent->isExiting()));
|
||||
}
|
||||
env->CallVoidMethod(receiverObj.get(), gInputEventReceiverClassInfo.onDragEvent,
|
||||
jboolean(dragEvent->isExiting()), dragEvent->getX(),
|
||||
dragEvent->getY());
|
||||
finishInputEvent(seq, true /* handled */);
|
||||
continue;
|
||||
}
|
||||
env->CallVoidMethod(receiverObj.get(),
|
||||
gInputEventReceiverClassInfo.onPointerCaptureEvent,
|
||||
jboolean(captureEvent->getPointerCaptureEnabled()));
|
||||
finishInputEvent(seq, true /* handled */);
|
||||
continue;
|
||||
}
|
||||
case AINPUT_EVENT_TYPE_DRAG: {
|
||||
const DragEvent* dragEvent = static_cast<DragEvent*>(inputEvent);
|
||||
if (kDebugDispatchCycle) {
|
||||
ALOGD("channel '%s' ~ Received drag event: isExiting=%s",
|
||||
getInputChannelName().c_str(), toString(dragEvent->isExiting()));
|
||||
case InputEventType::TOUCH_MODE: {
|
||||
const TouchModeEvent* touchModeEvent = static_cast<TouchModeEvent*>(inputEvent);
|
||||
if (kDebugDispatchCycle) {
|
||||
ALOGD("channel '%s' ~ Received touch mode event: isInTouchMode=%s",
|
||||
getInputChannelName().c_str(),
|
||||
toString(touchModeEvent->isInTouchMode()));
|
||||
}
|
||||
env->CallVoidMethod(receiverObj.get(),
|
||||
gInputEventReceiverClassInfo.onTouchModeChanged,
|
||||
jboolean(touchModeEvent->isInTouchMode()));
|
||||
finishInputEvent(seq, true /* handled */);
|
||||
continue;
|
||||
}
|
||||
env->CallVoidMethod(receiverObj.get(), gInputEventReceiverClassInfo.onDragEvent,
|
||||
jboolean(dragEvent->isExiting()), dragEvent->getX(),
|
||||
dragEvent->getY());
|
||||
finishInputEvent(seq, true /* handled */);
|
||||
continue;
|
||||
}
|
||||
case AINPUT_EVENT_TYPE_TOUCH_MODE: {
|
||||
const TouchModeEvent* touchModeEvent = static_cast<TouchModeEvent*>(inputEvent);
|
||||
if (kDebugDispatchCycle) {
|
||||
ALOGD("channel '%s' ~ Received touch mode event: isInTouchMode=%s",
|
||||
getInputChannelName().c_str(), toString(touchModeEvent->isInTouchMode()));
|
||||
}
|
||||
env->CallVoidMethod(receiverObj.get(),
|
||||
gInputEventReceiverClassInfo.onTouchModeChanged,
|
||||
jboolean(touchModeEvent->isInTouchMode()));
|
||||
finishInputEvent(seq, true /* handled */);
|
||||
continue;
|
||||
}
|
||||
|
||||
default:
|
||||
assert(false); // InputConsumer should prevent this from ever happening
|
||||
|
||||
@@ -114,7 +114,7 @@ status_t InputQueue::getEvent(InputEvent** outEvent) {
|
||||
}
|
||||
|
||||
bool InputQueue::preDispatchEvent(InputEvent* e) {
|
||||
if (e->getType() == AINPUT_EVENT_TYPE_KEY) {
|
||||
if (e->getType() == InputEventType::KEY) {
|
||||
KeyEvent* keyEvent = static_cast<KeyEvent*>(e);
|
||||
if (keyEvent->getFlags() & AKEY_EVENT_FLAG_PREDISPATCH) {
|
||||
finishEvent(e, false);
|
||||
|
||||
@@ -33,6 +33,7 @@
|
||||
#include <errno.h>
|
||||
|
||||
using android::InputEvent;
|
||||
using android::InputEventType;
|
||||
using android::InputQueue;
|
||||
using android::KeyEvent;
|
||||
using android::Looper;
|
||||
@@ -41,7 +42,8 @@ using android::sp;
|
||||
using android::Vector;
|
||||
|
||||
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) {
|
||||
|
||||
@@ -1311,17 +1311,17 @@ bool NativeInputManager::filterInputEvent(const InputEvent* inputEvent, uint32_t
|
||||
|
||||
JNIEnv* env = jniEnv();
|
||||
switch (inputEvent->getType()) {
|
||||
case AINPUT_EVENT_TYPE_KEY:
|
||||
inputEventObj = android_view_KeyEvent_fromNative(env,
|
||||
static_cast<const KeyEvent*>(inputEvent));
|
||||
break;
|
||||
case AINPUT_EVENT_TYPE_MOTION:
|
||||
inputEventObj =
|
||||
android_view_MotionEvent_obtainAsCopy(env,
|
||||
static_cast<const MotionEvent&>(*inputEvent));
|
||||
break;
|
||||
default:
|
||||
return true; // dispatch the event normally
|
||||
case InputEventType::KEY:
|
||||
inputEventObj =
|
||||
android_view_KeyEvent_fromNative(env, static_cast<const KeyEvent*>(inputEvent));
|
||||
break;
|
||||
case InputEventType::MOTION:
|
||||
inputEventObj = android_view_MotionEvent_obtainAsCopy(env,
|
||||
static_cast<const MotionEvent&>(
|
||||
*inputEvent));
|
||||
break;
|
||||
default:
|
||||
return true; // dispatch the event normally
|
||||
}
|
||||
|
||||
if (!inputEventObj) {
|
||||
|
||||
Reference in New Issue
Block a user