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

Commit f61746b4 authored by Arpit Singh's avatar Arpit Singh
Browse files

Revert "Refactor android_view_MotionEvent_obtainAsCopyFromNative implementation"

This reverts commit 3d8cc938.

Reason for revert: b/326506223
This CL has been flagged to be causing significant increase in
unreachable memory bytes. Reverting to validate this finding, will
followup with a proper fix if needed.

Test: presubmit
Test: atest MotionEventTest
Change-Id: Id2cefb4cbd768ed2debb7cbbf9ba912826e64a85
parent 17f39ef0
Loading
Loading
Loading
Loading
+17 −2
Original line number Original line Diff line number Diff line
@@ -85,9 +85,24 @@ static void android_view_MotionEvent_setNativePtr(JNIEnv* env, ScopedLocalRef<jo


ScopedLocalRef<jobject> android_view_MotionEvent_obtainAsCopy(JNIEnv* env,
ScopedLocalRef<jobject> android_view_MotionEvent_obtainAsCopy(JNIEnv* env,
                                                              const MotionEvent& event) {
                                                              const MotionEvent& event) {
    std::unique_ptr<MotionEvent> destEvent = std::make_unique<MotionEvent>();
    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);
    }

    destEvent->copyFrom(&event, true);
    destEvent->copyFrom(&event, true);
    return android_view_MotionEvent_obtainFromNative(env, std::move(destEvent));
    return eventObj;
}
}


ScopedLocalRef<jobject> android_view_MotionEvent_obtainFromNative(
ScopedLocalRef<jobject> android_view_MotionEvent_obtainFromNative(