From ef1a4ecc65916e4e8d097ff91d8ccfceea858eb8 Mon Sep 17 00:00:00 2001 From: Mattia Iavarone Date: Tue, 27 Feb 2018 20:41:55 +0100 Subject: [PATCH] Check focus area max number before applying (#167) --- .../src/main/java/com/otaliastudios/cameraview/Camera1.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java b/cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java index 39d01df2..893dab91 100644 --- a/cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java +++ b/cameraview/src/main/java/com/otaliastudios/cameraview/Camera1.java @@ -38,8 +38,10 @@ class Camera1 extends CameraController implements Camera.PreviewCallback, Camera if (!isCameraAvailable()) return; mCamera.cancelAutoFocus(); Camera.Parameters params = mCamera.getParameters(); - params.setFocusAreas(null); - params.setMeteringAreas(null); + int maxAF = params.getMaxNumFocusAreas(); + int maxAE = params.getMaxNumMeteringAreas(); + if (maxAF > 0) params.setFocusAreas(null); + if (maxAE > 0) params.setMeteringAreas(null); applyDefaultFocus(params); // Revert to internal focus. mCamera.setParameters(params); }