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); host.onCameraFail(result);
return; return;
} }
cameraReady = true; try {
if (getActivity().getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) { cameraReady = true;
onOrientationChange.enable(); if (getActivity().getRequestedOrientation() != ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED) {
} onOrientationChange.enable();
setCameraDisplayOrientation(); }
synchronized (CameraView.this) { setCameraDisplayOrientation();
CameraView.this.notifyAll(); 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() { void previewDestroyed() {
if (camera != null) { try {
previewStopped(); if (camera != null) {
camera.release(); previewStopped();
camera.release();
}
} finally {
camera = null; camera = null;
} }
} }

Loading…
Cancel
Save