Cleanup old Android check for pre 4.4 versions

The minSdk is 21.

Bug: webrtc:13780
Change-Id: If21ffab16b21d957c1d1a9b6912d09cd2bc309ef
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/279902
Commit-Queue: Xavier Lepaul‎ <xalep@webrtc.org>
Reviewed-by: Xavier Lepaul‎ <xalep@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#38456}
This commit is contained in:
Saúl Ibarra Corretgé 2022-10-20 11:08:44 +02:00 committed by WebRTC LUCI CQ
parent 335a4e4e1f
commit 4a1c9ecc5c

View File

@ -13,13 +13,13 @@ package org.webrtc;
import android.content.Context; import android.content.Context;
import android.graphics.Rect; import android.graphics.Rect;
import android.graphics.SurfaceTexture; import android.graphics.SurfaceTexture;
import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraCharacteristics; import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CameraManager; import android.hardware.camera2.CameraManager;
import android.hardware.camera2.CameraMetadata; import android.hardware.camera2.CameraMetadata;
import android.hardware.camera2.params.StreamConfigurationMap; import android.hardware.camera2.params.StreamConfigurationMap;
import android.os.Build; import android.os.Build;
import android.os.SystemClock; import android.os.SystemClock;
import android.util.AndroidException;
import android.util.Range; import android.util.Range;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import java.util.ArrayList; import java.util.ArrayList;
@ -50,10 +50,7 @@ public class Camera2Enumerator implements CameraEnumerator {
public String[] getDeviceNames() { public String[] getDeviceNames() {
try { try {
return cameraManager.getCameraIdList(); return cameraManager.getCameraIdList();
// On Android OS pre 4.4.2, a class will not load because of VerifyError if it contains a } catch (CameraAccessException e) {
// 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[] {}; return new String[] {};
} }
@ -92,10 +89,7 @@ public class Camera2Enumerator implements CameraEnumerator {
private @Nullable CameraCharacteristics getCameraCharacteristics(String deviceName) { private @Nullable CameraCharacteristics getCameraCharacteristics(String deviceName) {
try { try {
return cameraManager.getCameraCharacteristics(deviceName); return cameraManager.getCameraCharacteristics(deviceName);
// On Android OS pre 4.4.2, a class will not load because of VerifyError if it contains a } catch (CameraAccessException | RuntimeException e) {
// 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; return null;
} }
@ -115,10 +109,7 @@ public class Camera2Enumerator implements CameraEnumerator {
return false; return false;
} }
} }
// On Android OS pre 4.4.2, a class will not load because of VerifyError if it contains a } catch (CameraAccessException | RuntimeException e) {
// 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 | RuntimeException e) {
Logging.e(TAG, "Failed to check if camera2 is supported", e); Logging.e(TAG, "Failed to check if camera2 is supported", e);
return false; return false;
} }