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

Commit 098b3ba5 authored by Mathias Agopian's avatar Mathias Agopian Committed by Android (Google) Code Review
Browse files

Merge "fix JNI use of incStrong/decStrong" into jb-mr2-dev

parents 7409c9d5 b1d90c8f
Loading
Loading
Loading
Loading
+4 −4
Original line number Diff line number Diff line
@@ -53,10 +53,10 @@ static void SurfaceTexture_setSurfaceTexture(JNIEnv* env, jobject thiz,
    GLConsumer* const p =
        (GLConsumer*)env->GetIntField(thiz, fields.surfaceTexture);
    if (surfaceTexture.get()) {
        surfaceTexture->incStrong(thiz);
        surfaceTexture->incStrong((void*)SurfaceTexture_setSurfaceTexture);
    }
    if (p) {
        p->decStrong(thiz);
        p->decStrong((void*)SurfaceTexture_setSurfaceTexture);
    }
    env->SetIntField(thiz, fields.surfaceTexture, (int)surfaceTexture.get());
}
@@ -68,10 +68,10 @@ static void SurfaceTexture_setFrameAvailableListener(JNIEnv* env,
        (GLConsumer::FrameAvailableListener*)
            env->GetIntField(thiz, fields.frameAvailableListener);
    if (listener.get()) {
        listener->incStrong(thiz);
        listener->incStrong((void*)SurfaceTexture_setSurfaceTexture);
    }
    if (p) {
        p->decStrong(thiz);
        p->decStrong((void*)SurfaceTexture_setSurfaceTexture);
    }
    env->SetIntField(thiz, fields.frameAvailableListener, (int)listener.get());
}
+2 −2
Original line number Diff line number Diff line
@@ -496,7 +496,7 @@ static void android_hardware_Camera_native_setup(JNIEnv *env, jobject thiz,
    // We use a weak reference so the Camera object can be garbage collected.
    // The reference is only used as a proxy for callbacks.
    sp<JNICameraContext> context = new JNICameraContext(env, weak_this, clazz, camera);
    context->incStrong(thiz);
    context->incStrong((void*)android_hardware_Camera_native_setup);
    camera->setListener(context);

    // save context in opaque field
@@ -534,7 +534,7 @@ static void android_hardware_Camera_release(JNIEnv *env, jobject thiz)
        }

        // remove context to prevent further Java access
        context->decStrong(thiz);
        context->decStrong((void*)android_hardware_Camera_native_setup);
    }
}

+2 −2
Original line number Diff line number Diff line
@@ -176,7 +176,7 @@ static jint nativeInitSensorEventQueue(JNIEnv *env, jclass clazz, jobject eventQ
    }

    sp<Receiver> receiver = new Receiver(queue, messageQueue, eventQ, scratch);
    receiver->incStrong(clazz);
    receiver->incStrong((void*)nativeInitSensorEventQueue);
    return jint(receiver.get());
}

@@ -193,7 +193,7 @@ static jint nativeDisableSensor(JNIEnv *env, jclass clazz, jint eventQ, jint han
static void nativeDestroySensorEventQueue(JNIEnv *env, jclass clazz, jint eventQ, jint handle) {
    sp<Receiver> receiver(reinterpret_cast<Receiver *>(eventQ));
    receiver->destroy();
    receiver->decStrong(clazz);
    receiver->decStrong((void*)nativeInitSensorEventQueue);
}


+2 −2
Original line number Diff line number Diff line
@@ -154,10 +154,10 @@ static sp<AudioRecord> setAudioRecord(JNIEnv* env, jobject thiz, const sp<AudioR
    sp<AudioRecord> old =
            (AudioRecord*)env->GetIntField(thiz, javaAudioRecordFields.nativeRecorderInJavaObj);
    if (ar.get()) {
        ar->incStrong(thiz);
        ar->incStrong((void*)setAudioRecord);
    }
    if (old != 0) {
        old->decStrong(thiz);
        old->decStrong((void*)setAudioRecord);
    }
    env->SetIntField(thiz, javaAudioRecordFields.nativeRecorderInJavaObj, (int)ar.get());
    return old;
+2 −2
Original line number Diff line number Diff line
@@ -191,10 +191,10 @@ static sp<AudioTrack> setAudioTrack(JNIEnv* env, jobject thiz, const sp<AudioTra
    sp<AudioTrack> old =
            (AudioTrack*)env->GetIntField(thiz, javaAudioTrackFields.nativeTrackInJavaObj);
    if (at.get()) {
        at->incStrong(thiz);
        at->incStrong((void*)setAudioTrack);
    }
    if (old != 0) {
        old->decStrong(thiz);
        old->decStrong((void*)setAudioTrack);
    }
    env->SetIntField(thiz, javaAudioTrackFields.nativeTrackInJavaObj, (int)at.get());
    return old;
Loading