summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcodeworkx <daniel.hillenbrand@codeworkx.de>2017-08-26 12:48:59 +0200
committerDaniel Hillenbrand <daniel.hillenbrand@codeworkx.de>2018-03-11 15:31:09 +0000
commitea3d12e41cb9626e4ffe3b976dda98f5c5630306 (patch)
tree4fd3594735d7786e0c824b95aa0fb0803068a489
parentfff57959003fbdcead9be891a33bf045f075035d (diff)
downloadandroid_packages_apps_Snap-ea3d12e41cb9626e4ffe3b976dda98f5c5630306.zip
android_packages_apps_Snap-ea3d12e41cb9626e4ffe3b976dda98f5c5630306.tar.gz
android_packages_apps_Snap-ea3d12e41cb9626e4ffe3b976dda98f5c5630306.tar.bz2
Snap: don't try to set up cameras with ids greater than MAX_NUM_CAM
* fixes ArrayIndexOutOfBoundsException on setUpCameraOutputs Change-Id: I1565576b604bdcebea85d65f3c7a2b332292ed2d
-rwxr-xr-xsrc/com/android/camera/CaptureModule.java12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java
index 3766c82..1e2ceb8 100755
--- a/src/com/android/camera/CaptureModule.java
+++ b/src/com/android/camera/CaptureModule.java
@@ -1768,7 +1768,17 @@ public class CaptureModule implements CameraModule, PhotoController,
CameraManager manager = (CameraManager) mActivity.getSystemService(Context.CAMERA_SERVICE);
try {
String[] cameraIdList = manager.getCameraIdList();
- for (int i = 0; i < cameraIdList.length; i++) {
+ int cameraIdListLength = cameraIdList.length;
+
+ if (cameraIdListLength > MAX_NUM_CAM)
+ Log.w(TAG, "Number of available cameras (" + cameraIdListLength + ") exceeds "
+ + "max supported cameras (" + MAX_NUM_CAM + ")");
+
+ for (int i = 0; i < cameraIdListLength; i++) {
+ if (i >= MAX_NUM_CAM) {
+ Log.w(TAG, "Skipping set up for camera with id " + i);
+ break;
+ }
String cameraId = cameraIdList[i];
CameraCharacteristics characteristics = manager.getCameraCharacteristics(cameraId);