diff options
author | codeworkx <daniel.hillenbrand@codeworkx.de> | 2017-08-26 12:48:59 +0200 |
---|---|---|
committer | Michael Bestas <mkbestas@lineageos.org> | 2019-11-09 22:15:24 +0200 |
commit | 70e618bdd825eb8b088d66feeefc0a7f0b06c7ed (patch) | |
tree | 535b5344e36baa9bf4f93a54006d61de3abf4788 /src | |
parent | 4fc4f6529753dc9c45b947ae70c72e5af042bf85 (diff) | |
download | android_packages_apps_Snap-70e618bdd825eb8b088d66feeefc0a7f0b06c7ed.tar.gz android_packages_apps_Snap-70e618bdd825eb8b088d66feeefc0a7f0b06c7ed.tar.bz2 android_packages_apps_Snap-70e618bdd825eb8b088d66feeefc0a7f0b06c7ed.zip |
Snap: don't try to set up cameras with ids greater than MAX_NUM_CAM
* fixes ArrayIndexOutOfBoundsException on setUpCameraOutputs
Change-Id: I1565576b604bdcebea85d65f3c7a2b332292ed2d
Diffstat (limited to 'src')
-rwxr-xr-x | src/com/android/camera/CaptureModule.java | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java index d52996b38..591d82df7 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); |