Skip to content

Commit

Permalink
Merge pull request #13093 from hrydgard/android-camera-try-catch
Browse files Browse the repository at this point in the history
Add a try/catch to Android camera device listing.
  • Loading branch information
hrydgard authored Jul 4, 2020
2 parents 1bf241d + 7a58c8a commit 5fc83eb
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions android/src/org/ppsspp/ppsspp/CameraHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,14 @@ static ArrayList<String> getDeviceList() {
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;
}
Expand Down

0 comments on commit 5fc83eb

Please sign in to comment.