Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 1467cd25 authored by Siarhei Vishniakou's avatar Siarhei Vishniakou Committed by Automerger Merge Worker
Browse files

Merge "Update input event type to enum class" into udc-dev am: 150c188a

parents 47ede514 150c188a
Loading
Loading
Loading
Loading
+66 −62
Original line number Diff line number Diff line
@@ -368,17 +368,19 @@ status_t NativeInputEventReceiver::consumeEvents(JNIEnv* env,

            jobject inputEventObj;
            switch (inputEvent->getType()) {
            case AINPUT_EVENT_TYPE_KEY:
                case InputEventType::KEY:
                    if (kDebugDispatchCycle) {
                        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));
                    break;

            case AINPUT_EVENT_TYPE_MOTION: {
                case InputEventType::MOTION: {
                    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);
                    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);
                    break;
                }
            case AINPUT_EVENT_TYPE_FOCUS: {
                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,
                    env->CallVoidMethod(receiverObj.get(),
                                        gInputEventReceiverClassInfo.onFocusEvent,
                                        jboolean(focusEvent->getHasFocus()));
                    finishInputEvent(seq, true /* handled */);
                    continue;
                }
            case AINPUT_EVENT_TYPE_CAPTURE: {
                case InputEventType::CAPTURE: {
                    const CaptureEvent* captureEvent = static_cast<CaptureEvent*>(inputEvent);
                    if (kDebugDispatchCycle) {
                        ALOGD("channel '%s' ~ Received capture event: pointerCaptureEnabled=%s",
@@ -411,7 +414,7 @@ status_t NativeInputEventReceiver::consumeEvents(JNIEnv* env,
                    finishInputEvent(seq, true /* handled */);
                    continue;
                }
            case AINPUT_EVENT_TYPE_DRAG: {
                case InputEventType::DRAG: {
                    const DragEvent* dragEvent = static_cast<DragEvent*>(inputEvent);
                    if (kDebugDispatchCycle) {
                        ALOGD("channel '%s' ~ Received drag event: isExiting=%s",
@@ -423,11 +426,12 @@ status_t NativeInputEventReceiver::consumeEvents(JNIEnv* env,
                    finishInputEvent(seq, true /* handled */);
                    continue;
                }
            case AINPUT_EVENT_TYPE_TOUCH_MODE: {
                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()));
                              getInputChannelName().c_str(),
                              toString(touchModeEvent->isInTouchMode()));
                    }
                    env->CallVoidMethod(receiverObj.get(),
                                        gInputEventReceiverClassInfo.onTouchModeChanged,
+1 −1
Original line number Diff line number Diff line
@@ -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);
+3 −1
Original line number Diff line number Diff line
@@ -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) {
+11 −11
Original line number Diff line number Diff line
@@ -1311,14 +1311,14 @@ 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:
        case InputEventType::KEY:
            inputEventObj =
                android_view_MotionEvent_obtainAsCopy(env,
                                                      static_cast<const MotionEvent&>(*inputEvent));
                    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