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

Commit b121c601 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Pass non-nullable event by reference instead of pointer"

parents 86c28d8d 573e4d9a
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -380,8 +380,8 @@ status_t NativeInputEventReceiver::consumeEvents(JNIEnv* env,
                if (kDebugDispatchCycle) {
                    ALOGD("channel '%s' ~ Received motion event.", getInputChannelName().c_str());
                }
                MotionEvent* motionEvent = static_cast<MotionEvent*>(inputEvent);
                if ((motionEvent->getAction() & AMOTION_EVENT_ACTION_MOVE) && outConsumedBatch) {
                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);
+2 −2
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ static void android_view_MotionEvent_setNativePtr(JNIEnv* env, jobject eventObj,
            reinterpret_cast<jlong>(event));
}

jobject android_view_MotionEvent_obtainAsCopy(JNIEnv* env, const MotionEvent* event) {
jobject android_view_MotionEvent_obtainAsCopy(JNIEnv* env, const MotionEvent& event) {
    jobject eventObj = env->CallStaticObjectMethod(gMotionEventClassInfo.clazz,
            gMotionEventClassInfo.obtain);
    if (env->ExceptionCheck() || !eventObj) {
@@ -98,7 +98,7 @@ jobject android_view_MotionEvent_obtainAsCopy(JNIEnv* env, const MotionEvent* ev
        android_view_MotionEvent_setNativePtr(env, eventObj, destEvent);
    }

    destEvent->copyFrom(event, true);
    destEvent->copyFrom(&event, true);
    return eventObj;
}

+1 −1
Original line number Diff line number Diff line
@@ -26,7 +26,7 @@ class MotionEvent;

/* Obtains an instance of a DVM MotionEvent object as a copy of a native MotionEvent instance.
 * Returns NULL on error. */
extern jobject android_view_MotionEvent_obtainAsCopy(JNIEnv* env, const MotionEvent* event);
extern jobject android_view_MotionEvent_obtainAsCopy(JNIEnv* env, const MotionEvent& event);

/* Gets the underlying native MotionEvent instance within a DVM MotionEvent object.
 * Returns NULL if the event is NULL or if it is uninitialized. */
+3 −2
Original line number Diff line number Diff line
@@ -1191,8 +1191,9 @@ bool NativeInputManager::filterInputEvent(const InputEvent* inputEvent, uint32_t
                static_cast<const KeyEvent*>(inputEvent));
        break;
    case AINPUT_EVENT_TYPE_MOTION:
        inputEventObj = android_view_MotionEvent_obtainAsCopy(env,
                static_cast<const MotionEvent*>(inputEvent));
        inputEventObj =
                android_view_MotionEvent_obtainAsCopy(env,
                                                      static_cast<const MotionEvent&>(*inputEvent));
        break;
    default:
        return true; // dispatch the event normally