From 1aa33ec9b212bbc8a392a83dbb0516f14b06fe64 Mon Sep 17 00:00:00 2001
From: Torsten Grote <t@grobox.de>
Date: Tue, 1 Aug 2017 10:49:04 -0300
Subject: [PATCH] Catch RuntimeException when getting camera parameters

---
 .../briar/android/keyagreement/QrCodeDecoder.java     | 11 ++++++++---
 1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/briar-android/src/main/java/org/briarproject/briar/android/keyagreement/QrCodeDecoder.java b/briar-android/src/main/java/org/briarproject/briar/android/keyagreement/QrCodeDecoder.java
index e69dc2da71..6482e72394 100644
--- a/briar-android/src/main/java/org/briarproject/briar/android/keyagreement/QrCodeDecoder.java
+++ b/briar-android/src/main/java/org/briarproject/briar/android/keyagreement/QrCodeDecoder.java
@@ -22,6 +22,7 @@ import org.briarproject.bramble.api.nullsafety.ParametersNotNullByDefault;
 import java.util.logging.Logger;
 
 import static java.util.logging.Level.INFO;
+import static java.util.logging.Level.WARNING;
 
 @SuppressWarnings("deprecation")
 @MethodsNotNullByDefault
@@ -60,8 +61,12 @@ class QrCodeDecoder implements PreviewConsumer, PreviewCallback {
 	@Override
 	public void onPreviewFrame(byte[] data, Camera camera) {
 		if (camera == this.camera) {
-			Size size = camera.getParameters().getPreviewSize();
-			new DecoderTask(data, size.width, size.height).execute();
+			try {
+				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 int width, height;
 
-		DecoderTask(byte[] data, int width, int height) {
+		private DecoderTask(byte[] data, int width, int height) {
 			this.data = data;
 			this.width = width;
 			this.height = height;
-- 
GitLab