From afb28116d3e156a7477f73c18d973853a82f6e11 Mon Sep 17 00:00:00 2001 From: Xavier Lepaul Date: Wed, 16 Jun 2021 09:43:06 +0200 Subject: [PATCH] Catch possible `RuntimeException` from `getCameraCharacteristics` MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also changed the logging of exceptions to give more details Bug: webrtc:10804 Change-Id: Ifba6dee3d1c8ba4ecab408ca7715c3b792d9c004 Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/222641 Commit-Queue: Xavier Lepaul‎ Reviewed-by: Paulina Hensman Cr-Commit-Position: refs/heads/master@{#34325} --- sdk/android/api/org/webrtc/Camera2Enumerator.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/sdk/android/api/org/webrtc/Camera2Enumerator.java b/sdk/android/api/org/webrtc/Camera2Enumerator.java index b32b3ad302..2c6bb57b68 100644 --- a/sdk/android/api/org/webrtc/Camera2Enumerator.java +++ b/sdk/android/api/org/webrtc/Camera2Enumerator.java @@ -55,7 +55,7 @@ public class Camera2Enumerator implements CameraEnumerator { // catch statement with an Exception from a newer API, even if the code is never executed. // https://code.google.com/p/android/issues/detail?id=209129 } catch (/* CameraAccessException */ AndroidException e) { - Logging.e(TAG, "Camera access exception: " + e); + Logging.e(TAG, "Camera access exception", e); return new String[] {}; } } @@ -97,7 +97,7 @@ public class Camera2Enumerator implements CameraEnumerator { // catch statement with an Exception from a newer API, even if the code is never executed. // https://code.google.com/p/android/issues/detail?id=209129 } catch (/* CameraAccessException */ AndroidException e) { - Logging.e(TAG, "Camera access exception: " + e); + Logging.e(TAG, "Camera access exception", e); return null; } } @@ -123,8 +123,8 @@ public class Camera2Enumerator implements CameraEnumerator { // On Android OS pre 4.4.2, a class will not load because of VerifyError if it contains a // catch statement with an Exception from a newer API, even if the code is never executed. // https://code.google.com/p/android/issues/detail?id=209129 - } catch (/* CameraAccessException */ AndroidException e) { - Logging.e(TAG, "Camera access exception: " + e); + } catch (/* CameraAccessException */ AndroidException | RuntimeException e) { + Logging.e(TAG, "Failed to check if camera2 is supported", e); return false; } return true; @@ -186,7 +186,7 @@ public class Camera2Enumerator implements CameraEnumerator { try { cameraCharacteristics = cameraManager.getCameraCharacteristics(cameraId); } catch (Exception ex) { - Logging.e(TAG, "getCameraCharacteristics(): " + ex); + Logging.e(TAG, "getCameraCharacteristics()", ex); return new ArrayList(); }