summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteve Kondik <shade@chemlab.org>2013-12-07 06:07:02 -0800
committerMichael Bestas <mikeioannina@gmail.com>2015-09-17 23:26:01 +0300
commit09f757a7c83d0e4255828e2a6536656005f284aa (patch)
treed4a62054dbab6f22dc0368b40c54c90cf0a1bf8c
parentb9347d9cf727fa14f9b44adb43e0db60fbe32d8d (diff)
downloadandroid_packages_apps_Snap-09f757a7c83d0e4255828e2a6536656005f284aa.zip
android_packages_apps_Snap-09f757a7c83d0e4255828e2a6536656005f284aa.tar.gz
android_packages_apps_Snap-09f757a7c83d0e4255828e2a6536656005f284aa.tar.bz2
camera: Cleanup and compatibility fixes
* Don't crash for unavailable integer parameters * Kill logspam Change-Id: I6dbcf5560f96ce6173a847501721f589766889bc
-rw-r--r--src/com/android/camera/CameraSettings.java12
-rw-r--r--src/com/android/camera/PhotoModule.java72
-rw-r--r--src/com/android/camera/VideoModule.java4
-rw-r--r--src/com/android/camera/util/CameraUtil.java8
4 files changed, 67 insertions, 29 deletions
diff --git a/src/com/android/camera/CameraSettings.java b/src/com/android/camera/CameraSettings.java
index ac27cc4..70263da 100644
--- a/src/com/android/camera/CameraSettings.java
+++ b/src/com/android/camera/CameraSettings.java
@@ -639,6 +639,18 @@ public class CameraSettings {
selectableZoneAf, mParameters.getSupportedSelectableZoneAf());
}
+ if (saturation != null && !CameraUtil.isSupported(mParameters, "saturation")) {
+ removePreference(group, saturation.getKey());
+ }
+
+ if (contrast != null && !CameraUtil.isSupported(mParameters, "contrast")) {
+ removePreference(group, contrast.getKey());
+ }
+
+ if (sharpness != null && !CameraUtil.isSupported(mParameters, "sharpness")) {
+ removePreference(group, sharpness.getKey());
+ }
+
if (mIso != null) {
filterUnsupportedOptions(group,
mIso, mParameters.getSupportedIsoValues());
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index ade3b47..2062bce 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -1212,7 +1212,11 @@ public class PhotoModule
if(mSnapshotMode == CameraInfo.CAMERA_SUPPORT_MODE_ZSL) {
Log.v(TAG, "JpegPictureCallback : in zslmode");
mParameters = mCameraDevice.getParameters();
- mBurstSnapNum = mParameters.getInt("num-snaps-per-shutter");
+ if (CameraUtil.isBurstSupported(mParameters)) {
+ mBurstSnapNum = mParameters.getInt("num-snaps-per-shutter");
+ } else {
+ mBurstSnapNum = 1;
+ }
}
Log.v(TAG, "JpegPictureCallback: Received = " + mReceivedSnapNum +
"Burst count = " + mBurstSnapNum);
@@ -1576,7 +1580,11 @@ public class PhotoModule
mParameters = mCameraDevice.getParameters();
}
- mBurstSnapNum = mParameters.getInt("num-snaps-per-shutter");
+ if (CameraUtil.isBurstSupported(mParameters)) {
+ mBurstSnapNum = mParameters.getInt("num-snaps-per-shutter");
+ } else {
+ mBurstSnapNum = 1;
+ }
mReceivedSnapNum = 0;
mPreviewRestartSupport = SystemProperties.getBoolean(
PERSIST_PREVIEW_RESTART, false);
@@ -2510,6 +2518,9 @@ public class PhotoModule
}
return true;
case KeyEvent.KEYCODE_DPAD_LEFT:
+ if (!CameraUtil.isSupported(mParameters, "luma-adaptation")) {
+ break;
+ }
if ( (mCameraState != PREVIEW_STOPPED) && (mFocusManager != null) &&
(mFocusManager.getCurrentFocusState() != mFocusManager.STATE_FOCUSING) &&
(mFocusManager.getCurrentFocusState() != mFocusManager.STATE_FOCUSING_SNAP_ON_FINISH) ) {
@@ -2531,6 +2542,9 @@ public class PhotoModule
}
break;
case KeyEvent.KEYCODE_DPAD_RIGHT:
+ if (!CameraUtil.isSupported(mParameters, "luma-adaptation")) {
+ break;
+ }
if ( (mCameraState != PREVIEW_STOPPED) && (mFocusManager != null) &&
(mFocusManager.getCurrentFocusState() != mFocusManager.STATE_FOCUSING) &&
(mFocusManager.getCurrentFocusState() != mFocusManager.STATE_FOCUSING_SNAP_ON_FINISH) ) {
@@ -2911,32 +2925,38 @@ public class PhotoModule
mParameters.setColorEffect(colorEffect);
}
//Set Saturation
- String saturationStr = mPreferences.getString(
- CameraSettings.KEY_SATURATION,
- mActivity.getString(R.string.pref_camera_saturation_default));
- int saturation = Integer.parseInt(saturationStr);
- Log.v(TAG, "Saturation value =" + saturation);
- if((0 <= saturation) && (saturation <= mParameters.getMaxSaturation())){
- mParameters.setSaturation(saturation);
+ if (CameraUtil.isSupported(mParameters, "saturation")) {
+ String saturationStr = mPreferences.getString(
+ CameraSettings.KEY_SATURATION,
+ mActivity.getString(R.string.pref_camera_saturation_default));
+ int saturation = Integer.parseInt(saturationStr);
+ Log.v(TAG, "Saturation value =" + saturation);
+ if((0 <= saturation) && (saturation <= mParameters.getMaxSaturation())){
+ mParameters.setSaturation(saturation);
+ }
}
// Set contrast parameter.
- String contrastStr = mPreferences.getString(
- CameraSettings.KEY_CONTRAST,
- mActivity.getString(R.string.pref_camera_contrast_default));
- int contrast = Integer.parseInt(contrastStr);
- Log.v(TAG, "Contrast value =" +contrast);
- if((0 <= contrast) && (contrast <= mParameters.getMaxContrast())){
- mParameters.setContrast(contrast);
+ if (CameraUtil.isSupported(mParameters, "contrast")) {
+ String contrastStr = mPreferences.getString(
+ CameraSettings.KEY_CONTRAST,
+ mActivity.getString(R.string.pref_camera_contrast_default));
+ int contrast = Integer.parseInt(contrastStr);
+ Log.v(TAG, "Contrast value =" + contrast);
+ if ((0 <= contrast) && (contrast <= mParameters.getMaxContrast())) {
+ mParameters.setContrast(contrast);
+ }
}
// Set sharpness parameter
- String sharpnessStr = mPreferences.getString(
- CameraSettings.KEY_SHARPNESS,
- mActivity.getString(R.string.pref_camera_sharpness_default));
- int sharpness = Integer.parseInt(sharpnessStr) *
- (mParameters.getMaxSharpness()/MAX_SHARPNESS_LEVEL);
- Log.v(TAG, "Sharpness value =" + sharpness);
- if((0 <= sharpness) && (sharpness <= mParameters.getMaxSharpness())){
- mParameters.setSharpness(sharpness);
+ if (CameraUtil.isSupported(mParameters, "sharpness")) {
+ String sharpnessStr = mPreferences.getString(
+ CameraSettings.KEY_SHARPNESS,
+ mActivity.getString(R.string.pref_camera_sharpness_default));
+ int sharpness = Integer.parseInt(sharpnessStr) *
+ (mParameters.getMaxSharpness() / MAX_SHARPNESS_LEVEL);
+ Log.v(TAG, "Sharpness value =" + sharpness);
+ if ((0 <= sharpness) && (sharpness <= mParameters.getMaxSharpness())) {
+ mParameters.setSharpness(sharpness);
+ }
}
// Set Face Recognition
String faceRC = mPreferences.getString(
@@ -4542,8 +4562,6 @@ class GraphView extends View {
private CameraManager.CameraProxy mGraphCameraDevice;
private float scaled;
private static final int STATS_SIZE = 256;
- private static final String TAG = "GraphView";
-
public GraphView(Context context, AttributeSet attrs) {
super(context,attrs);
@@ -4562,9 +4580,7 @@ class GraphView extends View {
}
@Override
protected void onDraw(Canvas canvas) {
- Log.v(TAG, "in Camera.java ondraw");
if(mPhotoModule == null || !mPhotoModule.mHiston ) {
- Log.e(TAG, "returning as histogram is off ");
return;
}
diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java
index b821926..ad25dc3 100644
--- a/src/com/android/camera/VideoModule.java
+++ b/src/com/android/camera/VideoModule.java
@@ -2340,7 +2340,9 @@ public class VideoModule implements CameraModule,
videoHeight = mProfile.videoFrameHeight;
String recordSize = videoWidth + "x" + videoHeight;
Log.e(TAG,"Video dimension in App->"+recordSize);
- mParameters.set("video-size", recordSize);
+ if (CameraUtil.isSupported(mParameters, "video-size")) {
+ mParameters.set("video-size", recordSize);
+ }
// Set white balance parameter.
String whiteBalance = mPreferences.getString(
CameraSettings.KEY_WHITE_BALANCE,
diff --git a/src/com/android/camera/util/CameraUtil.java b/src/com/android/camera/util/CameraUtil.java
index 8017849..559f7fd 100644
--- a/src/com/android/camera/util/CameraUtil.java
+++ b/src/com/android/camera/util/CameraUtil.java
@@ -164,6 +164,14 @@ public class CameraUtil {
params.getSupportedFocusModes()));
}
+ public static boolean isSupported(Parameters params, String key) {
+ return (params.get(key) != null && !"null".equals(params.get(key)));
+ }
+
+ public static boolean isBurstSupported(Parameters params) {
+ return isSupported(params, "num-snaps-per-shutter");
+ }
+
// Private intent extras. Test only.
private static final String EXTRAS_CAMERA_FACING =
"android.intent.extras.CAMERA_FACING";