From d42a5fd3e7fff38dbc8a82484dac53bfbcb61ac4 Mon Sep 17 00:00:00 2001 From: Igor Murashkin Date: Fri, 8 Aug 2014 17:40:17 -0700 Subject: [PATCH] camera2: (legacy) Fix the comparison for fixed-focus cameras * Use #equals instead of == for string comparison * Also make sure lens.info.minimumFocusDistance shows up in CameraCharacteristics#getKeys() for fixed-focus cameras Bug: 16900875 Change-Id: I3b9248c5cb62ddcfb13587c6349525e145e353ac --- .../camera2/legacy/LegacyMetadataMapper.java | 42 ++++++++++++++++--- 1 file changed, 36 insertions(+), 6 deletions(-) diff --git a/core/java/android/hardware/camera2/legacy/LegacyMetadataMapper.java b/core/java/android/hardware/camera2/legacy/LegacyMetadataMapper.java index faacbeb7ee6ea..0337c96fc5363 100644 --- a/core/java/android/hardware/camera2/legacy/LegacyMetadataMapper.java +++ b/core/java/android/hardware/camera2/legacy/LegacyMetadataMapper.java @@ -188,10 +188,6 @@ public class LegacyMetadataMapper { */ mapFlash(m, p); - /* - * request.* - */ - mapRequest(m, p); // TODO: map other fields /* @@ -224,6 +220,13 @@ public class LegacyMetadataMapper { */ mapScalerStreamConfigs(m, p); + // Order matters below: Put this last so that we can read the metadata set previously + + /* + * request.* + */ + mapRequest(m, p); + } private static void mapScalerStreamConfigs(CameraMetadataNative m, Camera.Parameters p) { @@ -553,11 +556,23 @@ public class LegacyMetadataMapper { * We can tell if the lens is fixed focus; * but if it's not, we can't tell the minimum focus distance, so leave it null then. */ - if (p.getFocusMode() == Camera.Parameters.FOCUS_MODE_FIXED) { + if (VERBOSE) { + Log.v(TAG, "mapLens - focus-mode='" + p.getFocusMode() + "'"); + } + + if (Camera.Parameters.FOCUS_MODE_FIXED.equals(p.getFocusMode())) { /* * lens.info.minimumFocusDistance */ m.set(LENS_INFO_MINIMUM_FOCUS_DISTANCE, LENS_INFO_MINIMUM_FOCUS_DISTANCE_FIXED_FOCUS); + + if (VERBOSE) { + Log.v(TAG, "mapLens - lens.info.minimumFocusDistance = 0"); + } + } else { + if (VERBOSE) { + Log.v(TAG, "mapLens - lens.info.minimumFocusDistance is unknown"); + } } float[] focalLengths = new float[] { p.getFocalLength() }; @@ -628,7 +643,17 @@ public class LegacyMetadataMapper { CameraCharacteristics.STATISTICS_INFO_MAX_FACE_COUNT , CameraCharacteristics.SYNC_MAX_LATENCY , }; - m.set(REQUEST_AVAILABLE_CHARACTERISTICS_KEYS, getTagsForKeys(availableKeys)); + List> characteristicsKeys = new ArrayList<>(Arrays.asList(availableKeys)); + + /* + * Add the conditional keys + */ + if (m.get(LENS_INFO_MINIMUM_FOCUS_DISTANCE) != null) { + characteristicsKeys.add(LENS_INFO_MINIMUM_FOCUS_DISTANCE); + } + + m.set(REQUEST_AVAILABLE_CHARACTERISTICS_KEYS, + getTagsForKeys(characteristicsKeys.toArray(new Key[0]))); } /* @@ -1141,6 +1166,11 @@ public class LegacyMetadataMapper { } } + if (VERBOSE) { + Log.v(TAG, "createRequestTemplate (templateId=" + templateId + ")," + + " afMode=" + afMode + ", minimumFocusDistance=" + minimumFocusDistance); + } + m.set(CaptureRequest.CONTROL_AF_MODE, afMode); }