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,19 +114,28 @@ public class CameraView extends FrameLayout {
host.onCameraFail(result);
return;
}
cameraReady = true;
if (getActivity().getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
onOrientationChange.enable();
}
setCameraDisplayOrientation();
synchronized (CameraView.this) {
CameraView.this.notifyAll();
try {
cameraReady = true;
if (getActivity().getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
onOrientationChange.enable();
}
setCameraDisplayOrientation();
synchronized (CameraView.this) {
CameraView.this.notifyAll();
}
previewCreated();
initPreview();
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);
}
}
previewCreated();
initPreview();
requestLayout();
invalidate();
Log.w(TAG, "onResume() completed");
}
});
}
@ -272,9 +281,12 @@ public class CameraView extends FrameLayout {
}
void previewDestroyed() {
if (camera != null) {
previewStopped();
camera.release();
try {
if (camera != null) {
previewStopped();
camera.release();
}
} finally {
camera = null;
}
}

Loading…
Cancel
Save