From 389da0467faa14ddc1b937882eb48dfb885fd64a Mon Sep 17 00:00:00 2001 From: Mattia Iavarone Date: Mon, 15 Jul 2019 11:13:25 -0300 Subject: [PATCH] Fix sublist bug (#501) --- .../otaliastudios/cameraview/engine/Camera2Engine.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/engine/Camera2Engine.java b/cameraview/src/main/java/com/otaliastudios/cameraview/engine/Camera2Engine.java index 354fae7e..306954a3 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/engine/Camera2Engine.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/engine/Camera2Engine.java @@ -1173,16 +1173,19 @@ public class Camera2Engine extends CameraEngine implements ImageReader.OnImageAv int maxReagionsAe = readCharacteristic(CameraCharacteristics.CONTROL_MAX_REGIONS_AE, 0); int maxReagionsAwb = readCharacteristic(CameraCharacteristics.CONTROL_MAX_REGIONS_AWB, 0); if (maxReagionsAf > 0) { + int max = Math.min(maxReagionsAf, areas.size()); mRepeatingRequestBuilder.set(CaptureRequest.CONTROL_AF_REGIONS, - areas.subList(0, maxReagionsAf).toArray(new MeteringRectangle[]{})); + areas.subList(0, max).toArray(new MeteringRectangle[]{})); } if (maxReagionsAe > 0) { + int max = Math.min(maxReagionsAe, areas.size()); mRepeatingRequestBuilder.set(CaptureRequest.CONTROL_AE_REGIONS, - areas.subList(0, maxReagionsAe).toArray(new MeteringRectangle[]{})); + areas.subList(0, max).toArray(new MeteringRectangle[]{})); } if (maxReagionsAwb > 0) { + int max = Math.min(maxReagionsAwb, areas.size()); mRepeatingRequestBuilder.set(CaptureRequest.CONTROL_AWB_REGIONS, - areas.subList(0, maxReagionsAwb).toArray(new MeteringRectangle[]{})); + areas.subList(0, max).toArray(new MeteringRectangle[]{})); } // 8. Set AF mode to AUTO so it doesn't use the CONTINUOUS schedule.