Handle any exception in Camera.setPreviewTexture.
On Meizu devices (and maybe on other devices too) when camera is
disallowed in settings `android.hardware.Camera.open` returns
non-null Camera instance, but when any method is invoked on `Camera`
instance the `RuntimeException` is thrown. It claims that Camera
instance is used after `release()` was invoked on that instance.
`Camera1Session.open` didn't handle that case and crashed whole
application when returned Camera instance was already released or
more likely was not even properly initialized during `Camera.open`.
Bug: webrtc:8685
Change-Id: I5cda397a599e87971bf9a4bd3faf6fc4a0d198f3
Reviewed-on: https://webrtc-review.googlesource.com/36300
Commit-Queue: Sami Kalliomäki <sakal@webrtc.org>
Reviewed-by: Sami Kalliomäki <sakal@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#21556}
diff --git a/sdk/android/src/java/org/webrtc/Camera1Session.java b/sdk/android/src/java/org/webrtc/Camera1Session.java
index c27b4fc..27e7d17 100644
--- a/sdk/android/src/java/org/webrtc/Camera1Session.java
+++ b/sdk/android/src/java/org/webrtc/Camera1Session.java
@@ -77,7 +77,7 @@
try {
camera.setPreviewTexture(surfaceTextureHelper.getSurfaceTexture());
- } catch (IOException e) {
+ } catch (IOException | RuntimeException e) {
camera.release();
callback.onFailure(FailureType.ERROR, e.getMessage());
return;