diff options
Diffstat (limited to 'camera2/portability/src/com/android/ex/camera2/portability/CameraCapabilities.java')
-rw-r--r-- | camera2/portability/src/com/android/ex/camera2/portability/CameraCapabilities.java | 37 |
1 files changed, 12 insertions, 25 deletions
diff --git a/camera2/portability/src/com/android/ex/camera2/portability/CameraCapabilities.java b/camera2/portability/src/com/android/ex/camera2/portability/CameraCapabilities.java index 3dc19f7..31c47d3 100644 --- a/camera2/portability/src/com/android/ex/camera2/portability/CameraCapabilities.java +++ b/camera2/portability/src/com/android/ex/camera2/portability/CameraCapabilities.java @@ -22,6 +22,7 @@ import java.util.ArrayList; import java.util.EnumSet; import java.util.HashSet; import java.util.List; +import java.util.Locale; import java.util.Set; import java.util.TreeSet; @@ -36,6 +37,9 @@ public class CameraCapabilities { private static Log.Tag TAG = new Log.Tag("CamCapabs"); + /** Zoom ratio used for seeing sensor's full field of view. */ + protected static final float ZOOM_RATIO_UNZOOMED = 1.0f; + /* All internal states are declared final and should be thread-safe. */ protected final ArrayList<int[]> mSupportedPreviewFpsRange = new ArrayList<int[]>(); @@ -57,12 +61,10 @@ public class CameraCapabilities { protected int mMaxNumOfFacesSupported; protected int mMaxNumOfFocusAreas; protected int mMaxNumOfMeteringArea; - protected int mMaxZoomRatio; + protected float mMaxZoomRatio; protected float mHorizontalViewAngle; protected float mVerticalViewAngle; private final Stringifier mStringifier; - protected final ArrayList<Integer> mZoomRatioList = new ArrayList<Integer>(); - protected int mMaxZoomIndex; /** * Focus modes. @@ -183,7 +185,7 @@ public class CameraCapabilities { * Capture a scene using high dynamic range imaging techniques. * @see {@link android.hardware.Camera.Parameters#SCENE_MODE_HDR}. */ - // TODO: Unsupported on API 2 + // Note: Supported as a vendor tag on the Camera2 API for some LEGACY devices. HDR, /** * Take pictures on distant objects. @@ -322,17 +324,17 @@ public class CameraCapabilities { * @return The converted string. */ private static String toApiCase(String enumCase) { - return enumCase.toLowerCase().replaceAll("_", "-"); + return enumCase.toLowerCase(Locale.US).replaceAll("_", "-"); } /** - * Conerts the string to underscore-delimited uppercase to match the enum constant names. + * Converts the string to underscore-delimited uppercase to match the enum constant names. * * @param apiCase An API-related string representation. * @return The converted string. */ private static String toEnumCase(String apiCase) { - return apiCase.toUpperCase().replaceAll("-", "_"); + return apiCase.toUpperCase(Locale.US).replaceAll("-", "_"); } /** @@ -488,8 +490,6 @@ public class CameraCapabilities { mMaxNumOfFacesSupported = src.mMaxNumOfFacesSupported; mMaxNumOfFocusAreas = src.mMaxNumOfFocusAreas; mMaxNumOfMeteringArea = src.mMaxNumOfMeteringArea; - mMaxZoomIndex = src.mMaxZoomIndex; - mZoomRatioList.addAll(src.mZoomRatioList); mMaxZoomRatio = src.mMaxZoomRatio; mHorizontalViewAngle = src.mHorizontalViewAngle; mVerticalViewAngle = src.mVerticalViewAngle; @@ -635,17 +635,6 @@ public class CameraCapabilities { return mMaxZoomRatio; } - // We'll replace these old style methods with new ones. - @Deprecated - public int getMaxZoomIndex() { - return mMaxZoomIndex; - } - - @Deprecated - public List<Integer> getZoomRatioList() { - return new ArrayList<Integer>(mZoomRatioList); - } - /** * @return The min exposure compensation index. The EV is the compensation * index multiplied by the step value. If unsupported, both this method and @@ -689,17 +678,15 @@ public class CameraCapabilities { private boolean zoomCheck(final CameraSettings settings) { final float ratio = settings.getCurrentZoomRatio(); - final int index = settings.getCurrentZoomIndex(); if (!supports(Feature.ZOOM)) { - if (ratio != 1.0f || index != 0) { + if (ratio != ZOOM_RATIO_UNZOOMED) { Log.v(TAG, "Zoom is not supported"); return false; } } else { - if (settings.getCurrentZoomRatio() > getMaxZoomRatio() || - index > getMaxZoomIndex()) { + if (settings.getCurrentZoomRatio() > getMaxZoomRatio()) { Log.v(TAG, "Zoom ratio is not supported: ratio = " + - settings.getCurrentZoomRatio() + ", index = " + index); + settings.getCurrentZoomRatio()); return false; } } |