summaryrefslogtreecommitdiffstats
path: root/camera2/portability/src/com/android/ex/camera2/portability/CameraSettings.java
diff options
context:
space:
mode:
Diffstat (limited to 'camera2/portability/src/com/android/ex/camera2/portability/CameraSettings.java')
-rw-r--r--camera2/portability/src/com/android/ex/camera2/portability/CameraSettings.java86
1 files changed, 58 insertions, 28 deletions
diff --git a/camera2/portability/src/com/android/ex/camera2/portability/CameraSettings.java b/camera2/portability/src/com/android/ex/camera2/portability/CameraSettings.java
index cae022d..ccd980a 100644
--- a/camera2/portability/src/com/android/ex/camera2/portability/CameraSettings.java
+++ b/camera2/portability/src/com/android/ex/camera2/portability/CameraSettings.java
@@ -38,6 +38,7 @@ public abstract class CameraSettings {
protected final Map<String, String> mGeneralSetting = new TreeMap<>();
protected final List<Camera.Area> mMeteringAreas = new ArrayList<>();
protected final List<Camera.Area> mFocusAreas = new ArrayList<>();
+ protected boolean mSizesLocked;
protected int mPreviewFpsRangeMin;
protected int mPreviewFpsRangeMax;
protected int mPreviewFrameRate;
@@ -47,7 +48,6 @@ public abstract class CameraSettings {
protected byte mJpegCompressQuality;
protected int mCurrentPhotoFormat;
protected float mCurrentZoomRatio;
- protected int mCurrentZoomIndex;
protected int mExposureCompensationIndex;
protected CameraCapabilities.FlashMode mCurrentFlashMode;
protected CameraCapabilities.FocusMode mCurrentFocusMode;
@@ -58,7 +58,7 @@ public abstract class CameraSettings {
protected boolean mAutoWhiteBalanceLocked;
protected boolean mRecordingHintEnabled;
protected GpsData mGpsData;
- protected Size mExifThumbnailSize = new Size(0,0);
+ protected Size mExifThumbnailSize;
/**
* An immutable class storing GPS related information.
@@ -117,6 +117,7 @@ public abstract class CameraSettings {
mGeneralSetting.putAll(src.mGeneralSetting);
mMeteringAreas.addAll(src.mMeteringAreas);
mFocusAreas.addAll(src.mFocusAreas);
+ mSizesLocked = src.mSizesLocked;
mPreviewFpsRangeMin = src.mPreviewFpsRangeMin;
mPreviewFpsRangeMax = src.mPreviewFpsRangeMax;
mPreviewFrameRate = src.mPreviewFrameRate;
@@ -128,7 +129,6 @@ public abstract class CameraSettings {
mJpegCompressQuality = src.mJpegCompressQuality;
mCurrentPhotoFormat = src.mCurrentPhotoFormat;
mCurrentZoomRatio = src.mCurrentZoomRatio;
- mCurrentZoomIndex = src.mCurrentZoomIndex;
mExposureCompensationIndex = src.mExposureCompensationIndex;
mCurrentFlashMode = src.mCurrentFlashMode;
mCurrentFocusMode = src.mCurrentFocusMode;
@@ -153,6 +153,19 @@ public abstract class CameraSettings {
mGeneralSetting.put(key, value);
}
+ /**
+ * Changes whether classes outside this class are allowed to set the preview
+ * and photo capture sizes.
+ *
+ * @param locked Whether to prevent changes to these fields.
+ *
+ * @see #setPhotoSize
+ * @see #setPreviewSize
+ */
+ /*package*/ void setSizesLocked(boolean locked) {
+ mSizesLocked = locked;
+ }
+
/** Preview **/
/**
@@ -214,9 +227,16 @@ public abstract class CameraSettings {
/**
* @param previewSize The size to use for preview.
+ * @return Whether the operation was allowed (i.e. the sizes are unlocked).
*/
- public void setPreviewSize(Size previewSize) {
+ public boolean setPreviewSize(Size previewSize) {
+ if (mSizesLocked) {
+ Log.w(TAG, "Attempt to change preview size while locked");
+ return false;
+ }
+
mCurrentPreviewSize = new Size(previewSize);
+ return true;
}
/**
@@ -247,12 +267,17 @@ public abstract class CameraSettings {
}
/**
- * Sets the size for the photo.
- *
- * @param photoSize The photo size.
+ * @param photoSize The size to use for preview.
+ * @return Whether the operation was allowed (i.e. the sizes are unlocked).
*/
- public void setPhotoSize(Size photoSize) {
+ public boolean setPhotoSize(Size photoSize) {
+ if (mSizesLocked) {
+ Log.w(TAG, "Attempt to change photo size while locked");
+ return false;
+ }
+
mCurrentPhotoSize = new Size(photoSize);
+ return true;
}
/**
@@ -312,16 +337,6 @@ public abstract class CameraSettings {
mCurrentZoomRatio = ratio;
}
- @Deprecated
- public int getCurrentZoomIndex() {
- return mCurrentZoomIndex;
- }
-
- @Deprecated
- public void setZoomIndex(int index) {
- mCurrentZoomIndex = index;
- }
-
/** Exposure **/
public void setExposureCompensationIndex(int index) {
@@ -343,6 +358,14 @@ public abstract class CameraSettings {
return mAutoExposureLocked;
}
+ /**
+ * @param areas The areas for autoexposure. The coordinate system has domain
+ * and range [-1000,1000], measured relative to the visible
+ * preview image, with orientation matching that of the sensor.
+ * This means the coordinates must be transformed to account
+ * for the devices rotation---but not the zoom level---before
+ * being passed into this method.
+ */
public void setMeteringAreas(List<Camera.Area> areas) {
mMeteringAreas.clear();
if (areas != null) {
@@ -382,7 +405,12 @@ public abstract class CameraSettings {
}
/**
- * @param areas The areas to focus.
+ * @param areas The areas to focus. The coordinate system has domain and
+ * range [-1000,1000], measured relative to the visible preview
+ * image, with orientation matching that of the sensor. This
+ * means the coordinates must be transformed to account for
+ * the devices rotation---but not the zoom level---before being
+ * passed into this method.
*/
public void setFocusAreas(List<Camera.Area> areas) {
mFocusAreas.clear();
@@ -463,20 +491,22 @@ public abstract class CameraSettings {
}
/**
- * Sets the size of the thumbnail in EXIF header.
+ * Sets the size of the thumbnail in EXIF header. To suppress thumbnail
+ * generation, set a size of (0,0).
*
- * @param s The size for the thumbnail. {@code null} will clear the size to
- * (0,0).
+ * @param s The size for the thumbnail. If {@code null}, agent will not
+ * set a thumbnail size.
*/
public void setExifThumbnailSize(Size s) {
- if (s != null) {
- mExifThumbnailSize = s;
- } else {
- mExifThumbnailSize = new Size(0,0);
- }
+ mExifThumbnailSize = s;
}
+ /**
+ * Gets the size of the thumbnail in EXIF header.
+ *
+ * @return desired thumbnail size, or null if no size was set
+ */
public Size getExifThumbnailSize() {
- return new Size(mExifThumbnailSize);
+ return (mExifThumbnailSize == null) ? null : new Size(mExifThumbnailSize);
}
}