From 1c94137f7ac1739a963c0951ab805ac8658662fa Mon Sep 17 00:00:00 2001 From: Christian Juner Date: Tue, 18 Apr 2017 22:22:22 +0200 Subject: [PATCH] Fall back to Camera1Enumerator on exceptions If Camera2Enumerator.isSupported() throws, consider Camera2Enumerator to not be supported, log the Throwable, and use Camera1Enumerator instead. Before this patch, an exception thrown by Camera2Enumerator.isSupported would crash any Signal call (even if video was not enabled). Fixes #6537 // FREEBIE --- .../securesms/webrtc/PeerConnectionWrapper.java | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/org/thoughtcrime/securesms/webrtc/PeerConnectionWrapper.java b/src/org/thoughtcrime/securesms/webrtc/PeerConnectionWrapper.java index 7204296667..4b96a1096f 100644 --- a/src/org/thoughtcrime/securesms/webrtc/PeerConnectionWrapper.java +++ b/src/org/thoughtcrime/securesms/webrtc/PeerConnectionWrapper.java @@ -273,11 +273,18 @@ public class PeerConnectionWrapper { } private @Nullable CameraVideoCapturer createVideoCapturer(@NonNull Context context) { - Log.w(TAG, "Camera2 enumerator supported: " + Camera2Enumerator.isSupported(context)); + boolean camera2EnumeratorIsSupported = false; + try { + camera2EnumeratorIsSupported = Camera2Enumerator.isSupported(context); + } catch (final Throwable throwable) { + Log.w(TAG, "Camera2Enumator.isSupport() threw.", throwable); + } + + Log.w(TAG, "Camera2 enumerator supported: " + camera2EnumeratorIsSupported); CameraEnumerator enumerator; - if (Camera2Enumerator.isSupported(context)) enumerator = new Camera2Enumerator(context); - else enumerator = new Camera1Enumerator(true); + if (camera2EnumeratorIsSupported) enumerator = new Camera2Enumerator(context); + else enumerator = new Camera1Enumerator(true); String[] deviceNames = enumerator.getDeviceNames();