summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorcodeworkx <daniel.hillenbrand@codeworkx.de>2017-08-26 12:48:59 +0200
committerMichael Bestas <mkbestas@lineageos.org>2019-11-09 22:15:24 +0200
commit70e618bdd825eb8b088d66feeefc0a7f0b06c7ed (patch)
tree535b5344e36baa9bf4f93a54006d61de3abf4788
parent4fc4f6529753dc9c45b947ae70c72e5af042bf85 (diff)
downloadandroid_packages_apps_Snap-70e618bdd825eb8b088d66feeefc0a7f0b06c7ed.zip
android_packages_apps_Snap-70e618bdd825eb8b088d66feeefc0a7f0b06c7ed.tar.gz
android_packages_apps_Snap-70e618bdd825eb8b088d66feeefc0a7f0b06c7ed.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 d52996b..591d82d 100755
--- a/src/com/android/camera/CaptureModule.java
+++ b/src/com/android/camera/CaptureModule.java
@@ -2666,6 +2666,7 @@ public class CaptureModule implements CameraModule, PhotoController,
CameraManager manager = (CameraManager) mActivity.getSystemService(Context.CAMERA_SERVICE);
try {
String[] cameraIdList = manager.getCameraIdList();
+ int cameraIdListLength = cameraIdList.length;
//inti heifWriter and get input surface
if (mSettingsManager.getSavePictureFormat() == SettingsManager.HEIF_FORMAT) {
String tmpPath = mActivity.getCacheDir().getPath() + "/" + "heif.tmp";
@@ -2675,7 +2676,16 @@ public class CaptureModule implements CameraModule, PhotoController,
mInitHeifWriter = createHEIFEncoder(tmpPath, mPictureSize.getWidth(),
mPictureSize.getHeight(), 0,1, 85);
}
- for (int i = 0; i < cameraIdList.length; i++) {
+
+ 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);