catch Camera RuntimeExceptions

fixes #3895
Closes #4083
// FREEBIE
pull/1/head
Jake McGinty 9 years ago committed by Moxie Marlinspike
parent 336962eb55
commit a7e05c4cd6

@ -114,6 +114,7 @@ public class CameraView extends FrameLayout {
host.onCameraFail(result);
return;
}
try {
cameraReady = true;
if (getActivity().getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
onOrientationChange.enable();
@ -127,6 +128,14 @@ public class CameraView extends FrameLayout {
requestLayout();
invalidate();
Log.w(TAG, "onResume() completed");
} catch (RuntimeException re) {
Log.w(TAG, "exception when starting camera preview", re);
try {
previewDestroyed();
} catch (RuntimeException re2) {
Log.w(TAG, "also failed to release camera", re2);
}
}
}
});
}
@ -272,9 +281,12 @@ public class CameraView extends FrameLayout {
}
void previewDestroyed() {
try {
if (camera != null) {
previewStopped();
camera.release();
}
} finally {
camera = null;
}
}

Loading…
Cancel
Save