summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Dong <jdong@google.com>2010-08-12 10:18:01 -0700
committerJames Dong <jdong@google.com>2010-08-12 11:59:56 -0700
commitd790c6485a388a3e8045dbd18b903b20a7dcf0d9 (patch)
tree09311db65325f0f66b934aa9afbf9d777215119e
parentae3a1f45951aeb716e1f6b9a99a09838eb55dab4 (diff)
downloadframeworks_base-d790c6485a388a3e8045dbd18b903b20a7dcf0d9.zip
frameworks_base-d790c6485a388a3e8045dbd18b903b20a7dcf0d9.tar.gz
frameworks_base-d790c6485a388a3e8045dbd18b903b20a7dcf0d9.tar.bz2
Add lost preview surface detection in the JNI layer
Throws an IOException if this happens rather than crashes Change-Id: I32bb4c889ae596f992a0d05283c9130a99b2d0d5
-rw-r--r--media/jni/android_media_MediaRecorder.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/media/jni/android_media_MediaRecorder.cpp b/media/jni/android_media_MediaRecorder.cpp
index c113ffe..f69b8ad 100644
--- a/media/jni/android_media_MediaRecorder.cpp
+++ b/media/jni/android_media_MediaRecorder.cpp
@@ -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;