Catch RuntimeException when getting camera parameters

This commit is contained in:
Torsten Grote
2017-08-01 10:49:04 -03:00
parent 6702df1e22
commit 1aa33ec9b2

View File

@@ -22,6 +22,7 @@ import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
import java.util.logging.Logger; import java.util.logging.Logger;
import static java.util.logging.Level.INFO; import static java.util.logging.Level.INFO;
import static java.util.logging.Level.WARNING;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@MethodsNotNullByDefault @MethodsNotNullByDefault
@@ -60,8 +61,12 @@ class QrCodeDecoder implements PreviewConsumer, PreviewCallback {
@Override @Override
public void onPreviewFrame(byte[] data, Camera camera) { public void onPreviewFrame(byte[] data, Camera camera) {
if (camera == this.camera) { if (camera == this.camera) {
Size size = camera.getParameters().getPreviewSize(); try {
new DecoderTask(data, size.width, size.height).execute(); Size size = camera.getParameters().getPreviewSize();
new DecoderTask(data, size.width, size.height).execute();
} catch (RuntimeException e) {
LOG.log(WARNING, "Error getting camera parameters.", e);
}
} }
} }
@@ -70,7 +75,7 @@ class QrCodeDecoder implements PreviewConsumer, PreviewCallback {
private final byte[] data; private final byte[] data;
private final int width, height; private final int width, height;
DecoderTask(byte[] data, int width, int height) { private DecoderTask(byte[] data, int width, int height) {
this.data = data; this.data = data;
this.width = width; this.width = width;
this.height = height; this.height = height;