mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-15 20:29:52 +01:00
Fix crashes when no Bluetooth or no Camera is available
Briar crashed when run in a device without bluetooth or without camera such as an emulator. Closes #514
This commit is contained in:
@@ -225,6 +225,7 @@ public class ShowQrCodeFragment extends BaseEventFragment
|
||||
protected void onPostExecute(Camera camera) {
|
||||
if (camera == null) {
|
||||
// TODO better solution?
|
||||
LOG.info("No Camera found, finishing...");
|
||||
getActivity().finish();
|
||||
} else {
|
||||
cameraView.start(camera, decoder, 0);
|
||||
|
||||
@@ -86,7 +86,8 @@ public class CameraView extends SurfaceView implements SurfaceHolder.Callback,
|
||||
public void stop() {
|
||||
stopPreview();
|
||||
try {
|
||||
camera.release();
|
||||
if (camera != null)
|
||||
camera.release();
|
||||
} catch (RuntimeException e) {
|
||||
LOG.log(WARNING, "Error releasing camera", e);
|
||||
}
|
||||
@@ -106,7 +107,8 @@ public class CameraView extends SurfaceView implements SurfaceHolder.Callback,
|
||||
private void stopPreview() {
|
||||
try {
|
||||
stopConsumer();
|
||||
camera.stopPreview();
|
||||
if (camera != null)
|
||||
camera.stopPreview();
|
||||
} catch (RuntimeException e) {
|
||||
LOG.log(WARNING, "Error stopping camera preview", e);
|
||||
}
|
||||
@@ -118,7 +120,9 @@ public class CameraView extends SurfaceView implements SurfaceHolder.Callback,
|
||||
}
|
||||
|
||||
public void stopConsumer() {
|
||||
previewConsumer.stop();
|
||||
if (previewConsumer != null) {
|
||||
previewConsumer.stop();
|
||||
}
|
||||
if (autoFocus) camera.cancelAutoFocus();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user