summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcodeworkx <daniel.hillenbrand@codeworkx.de>2017-08-26 12:48:59 +0200
committercodeworkx <daniel.hillenbrand@codeworkx.de>2017-08-26 17:07:24 +0200
commit2cf2582cdf8d08891b96fa24f99e5fe1ed8acf1e (patch)
treebf49ba4bcde4264069e99475ef1bbadbf831373c
parente6ab3158d302f062e590cbd94d8186fa8429c87e (diff)
downloadandroid_packages_apps_Snap-2cf2582cdf8d08891b96fa24f99e5fe1ed8acf1e.tar.gz
android_packages_apps_Snap-2cf2582cdf8d08891b96fa24f99e5fe1ed8acf1e.tar.bz2
android_packages_apps_Snap-2cf2582cdf8d08891b96fa24f99e5fe1ed8acf1e.zip
Snap: fix ArrayIndexOutOfBoundsException on setUpCameraOutputs
Change-Id: I23b0bdb2f637cc6cc78677dfaf2b6a23eebeb6cf
-rw-r--r--src/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 e21fd3029..0ad6212df 100644
--- a/src/com/android/camera/CaptureModule.java
+++ b/src/com/android/camera/CaptureModule.java
@@ -1349,7 +1349,17 @@ public class CaptureModule extends BaseModule<CaptureUI> implements PhotoControl
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);