Add a try/catch to Android camera device listing. Might help #13091 and the issue seen in #13057.

This commit is contained in:
Henrik Rydgård 2020-07-04 23:21:05 +02:00
parent 1bf241d826
commit 7a58c8afbf

View File

@ -140,10 +140,14 @@ class CameraHelper {
ArrayList<String> deviceList = new ArrayList<>();
int nrCam = Camera.getNumberOfCameras();
for (int index = 0; index < nrCam; index++) {
Camera.CameraInfo info = new Camera.CameraInfo();
Camera.getCameraInfo(index, info);
String devName = index + ":" + (info.facing == Camera.CameraInfo.CAMERA_FACING_BACK ? "Back Camera" : "Front Camera");
deviceList.add(devName);
try {
Camera.CameraInfo info = new Camera.CameraInfo();
Camera.getCameraInfo(index, info);
String devName = index + ":" + (info.facing == Camera.CameraInfo.CAMERA_FACING_BACK ? "Back Camera" : "Front Camera");
deviceList.add(devName);
} catch (Exception e) {
Log.e(TAG, "Failed to get camera info: " + e.toString());
}
}
return deviceList;
}