Loading core/jni/android_view_MotionEvent.cpp +4 −17 Original line number Diff line number Diff line Loading @@ -85,24 +85,9 @@ static void android_view_MotionEvent_setNativePtr(JNIEnv* env, ScopedLocalRef<jo ScopedLocalRef<jobject> android_view_MotionEvent_obtainAsCopy(JNIEnv* env, const MotionEvent& event) { ScopedLocalRef<jobject> eventObj(env, env->CallStaticObjectMethod(gMotionEventClassInfo.clazz, gMotionEventClassInfo.obtain)); if (env->ExceptionCheck() || !eventObj.get()) { ALOGE("An exception occurred while obtaining a motion event."); LOGE_EX(env); env->ExceptionClear(); return ScopedLocalRef<jobject>(env); } MotionEvent* destEvent = android_view_MotionEvent_getNativePtr(env, eventObj.get()); if (!destEvent) { destEvent = new MotionEvent(); android_view_MotionEvent_setNativePtr(env, eventObj, destEvent); } std::unique_ptr<MotionEvent> destEvent = std::make_unique<MotionEvent>(); destEvent->copyFrom(&event, true); return eventObj; return android_view_MotionEvent_obtainFromNative(env, std::move(destEvent)); } ScopedLocalRef<jobject> android_view_MotionEvent_obtainFromNative( Loading @@ -117,6 +102,8 @@ ScopedLocalRef<jobject> android_view_MotionEvent_obtainFromNative( LOGE_EX(env); LOG_ALWAYS_FATAL("An exception occurred while obtaining a Java motion event."); } MotionEvent* oldEvent = android_view_MotionEvent_getNativePtr(env, eventObj.get()); delete oldEvent; android_view_MotionEvent_setNativePtr(env, eventObj, event.release()); return eventObj; } Loading Loading
core/jni/android_view_MotionEvent.cpp +4 −17 Original line number Diff line number Diff line Loading @@ -85,24 +85,9 @@ static void android_view_MotionEvent_setNativePtr(JNIEnv* env, ScopedLocalRef<jo ScopedLocalRef<jobject> android_view_MotionEvent_obtainAsCopy(JNIEnv* env, const MotionEvent& event) { ScopedLocalRef<jobject> eventObj(env, env->CallStaticObjectMethod(gMotionEventClassInfo.clazz, gMotionEventClassInfo.obtain)); if (env->ExceptionCheck() || !eventObj.get()) { ALOGE("An exception occurred while obtaining a motion event."); LOGE_EX(env); env->ExceptionClear(); return ScopedLocalRef<jobject>(env); } MotionEvent* destEvent = android_view_MotionEvent_getNativePtr(env, eventObj.get()); if (!destEvent) { destEvent = new MotionEvent(); android_view_MotionEvent_setNativePtr(env, eventObj, destEvent); } std::unique_ptr<MotionEvent> destEvent = std::make_unique<MotionEvent>(); destEvent->copyFrom(&event, true); return eventObj; return android_view_MotionEvent_obtainFromNative(env, std::move(destEvent)); } ScopedLocalRef<jobject> android_view_MotionEvent_obtainFromNative( Loading @@ -117,6 +102,8 @@ ScopedLocalRef<jobject> android_view_MotionEvent_obtainFromNative( LOGE_EX(env); LOG_ALWAYS_FATAL("An exception occurred while obtaining a Java motion event."); } MotionEvent* oldEvent = android_view_MotionEvent_getNativePtr(env, eventObj.get()); delete oldEvent; android_view_MotionEvent_setNativePtr(env, eventObj, event.release()); return eventObj; } Loading