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

Commit 46520694 authored by James Dong's avatar James Dong Committed by Android Git Automerger
Browse files

am b408f549: am d790c648: Add lost preview surface detection in the JNI layer...

am b408f549: am d790c648: Add lost preview surface detection in the JNI layer Throws an IOException if this happens rather than crashes

Merge commit 'b408f549'

* commit 'b408f549':
  Add lost preview surface detection in the JNI layer
parents 08c96ec7 b408f549
Loading
Loading
Loading
Loading
+9 −0
Original line number Diff line number Diff line
@@ -318,6 +318,15 @@ android_media_MediaRecorder_prepare(JNIEnv *env, jobject thiz)
    jobject surface = env->GetObjectField(thiz, fields.surface);
    if (surface != NULL) {
        const sp<Surface> native_surface = get_surface(env, surface);

        // The application may misbehave and
        // the preview surface becomes unavailable
        if (native_surface.get() == 0) {
            LOGE("Application lost the surface");
            jniThrowException(env, "java/io/IOException", "invalid preview surface");
            return;
        }

        LOGI("prepare: surface=%p (identity=%d)", native_surface.get(), native_surface->getIdentity());
        if (process_media_recorder_call(env, mr->setPreviewSurface(native_surface), "java/lang/RuntimeException", "setPreviewSurface failed.")) {
            return;