Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(70)

Unified Diff: webrtc/api/android/java/src/org/webrtc/Camera2Enumerator.java

Issue 2185833003: Android Camera2Enumerator: Remove CameraAccessException to avoid VerifyError (Closed) Base URL: https://chromium.googlesource.com/external/webrtc.git@master
Patch Set: Use AndroidException instead Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: webrtc/api/android/java/src/org/webrtc/Camera2Enumerator.java
diff --git a/webrtc/api/android/java/src/org/webrtc/Camera2Enumerator.java b/webrtc/api/android/java/src/org/webrtc/Camera2Enumerator.java
index 3fd34ddd9236bfe59ff3b5816434c43718c9b8c1..fa0bb8df6657ce9587bfb22fce824f6ea59529a7 100644
--- a/webrtc/api/android/java/src/org/webrtc/Camera2Enumerator.java
+++ b/webrtc/api/android/java/src/org/webrtc/Camera2Enumerator.java
@@ -16,13 +16,13 @@ import android.annotation.TargetApi;
import android.content.Context;
import android.graphics.ImageFormat;
import android.graphics.SurfaceTexture;
-import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CameraManager;
import android.hardware.camera2.CameraMetadata;
import android.hardware.camera2.params.StreamConfigurationMap;
import android.os.Build;
import android.os.SystemClock;
+import android.util.AndroidException;
import android.util.Range;
import java.util.ArrayList;
@@ -52,7 +52,10 @@ public class Camera2Enumerator implements CameraEnumerator {
public String[] getDeviceNames() {
try {
return cameraManager.getCameraIdList();
- } catch (CameraAccessException e) {
+ // 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);
return new String[] {};
}
@@ -87,7 +90,10 @@ public class Camera2Enumerator implements CameraEnumerator {
private CameraCharacteristics getCameraCharacteristics(String deviceName) {
try {
return cameraManager.getCameraCharacteristics(deviceName);
- } catch (CameraAccessException e) {
+ // 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);
return null;
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698