summaryrefslogtreecommitdiffstats
path: root/src/com/android
diff options
context:
space:
mode:
authorWu-cheng Li <wuchengli@google.com>2011-10-20 08:28:47 -0700
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-10-20 08:28:47 -0700
commitcf2f19fb053bfe7f39c552b67ffdfc72119ab2d1 (patch)
treeda52d514af995423b8d996040e7f3abba8e74802 /src/com/android
parent27c97af52157672f6201215d2e07497ff6361a8e (diff)
parent53be34deae057cfa297c3ee73eee91f880272650 (diff)
downloadpackages_apps_LegacyCamera-cf2f19fb053bfe7f39c552b67ffdfc72119ab2d1.zip
packages_apps_LegacyCamera-cf2f19fb053bfe7f39c552b67ffdfc72119ab2d1.tar.gz
packages_apps_LegacyCamera-cf2f19fb053bfe7f39c552b67ffdfc72119ab2d1.tar.bz2
Merge "Fix AE and AWB lock were incorrectly unlocked during autofocus." into ics-mr0
Diffstat (limited to 'src/com/android')
-rw-r--r--src/com/android/camera/Camera.java24
-rw-r--r--src/com/android/camera/FocusManager.java74
2 files changed, 60 insertions, 38 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java
index e3b1450..067ae23 100644
--- a/src/com/android/camera/Camera.java
+++ b/src/com/android/camera/Camera.java
@@ -124,7 +124,6 @@ public class Camera extends ActivityBase implements FocusManager.Listener,
private boolean mMeteringAreaSupported;
private boolean mAeLockSupported;
private boolean mAwbLockSupported;
- private boolean mAeAwbLock;
private MyOrientationEventListener mOrientationListener;
// The degrees of the device rotated clockwise from its natural orientation.
@@ -1361,18 +1360,10 @@ public class Camera extends ActivityBase implements FocusManager.Listener,
// Do not do focus if there is not enough storage.
if (pressed && !canTakePicture()) return;
- // Lock AE and AWB so users can half-press shutter and recompose.
- mAeAwbLock = pressed;
- if (mAeAwbLock && (mAeLockSupported || mAwbLockSupported)) {
- setCameraParameters(UPDATE_PARAM_PREFERENCE);
- }
-
- mFocusManager.doFocus(pressed);
-
- // Unlock AE and AWB after cancelAutoFocus. Camera API does not
- // guarantee setParameters can be called during autofocus.
- if (!mAeAwbLock && (mAeLockSupported || mAwbLockSupported)) {
- setCameraParameters(UPDATE_PARAM_PREFERENCE);
+ if (pressed) {
+ mFocusManager.onShutterDown();
+ } else {
+ mFocusManager.onShutterUp();
}
}
@@ -1761,7 +1752,8 @@ public class Camera extends ActivityBase implements FocusManager.Listener,
setPreviewDisplay(mSurfaceHolder);
setDisplayOrientation();
- mAeAwbLock = false; // Unlock AE and AWB.
+
+ mFocusManager.setAeAwbLock(false); // Unlock AE and AWB.
setCameraParameters(UPDATE_PARAM_ALL);
// If the focus mode is continuous autofocus, call cancelAutoFocus to
// resume it because it may have been paused by autoFocus call.
@@ -1835,11 +1827,11 @@ public class Camera extends ActivityBase implements FocusManager.Listener,
private void updateCameraParametersPreference() {
if (mAeLockSupported) {
- mParameters.setAutoExposureLock(mAeAwbLock);
+ mParameters.setAutoExposureLock(mFocusManager.getAeAwbLock());
}
if (mAwbLockSupported) {
- mParameters.setAutoWhiteBalanceLock(mAeAwbLock);
+ mParameters.setAutoWhiteBalanceLock(mFocusManager.getAeAwbLock());
}
if (mFocusAreaSupported) {
diff --git a/src/com/android/camera/FocusManager.java b/src/com/android/camera/FocusManager.java
index 6b9dbd6..228e2d1 100644
--- a/src/com/android/camera/FocusManager.java
+++ b/src/com/android/camera/FocusManager.java
@@ -55,6 +55,8 @@ public class FocusManager {
private boolean mInitialized;
private boolean mFocusAreaSupported;
private boolean mInLongPress;
+ private boolean mLockAeAwbNeeded;
+ private boolean mAeAwbLock;
private SoundPlayer mSoundPlayer;
private View mFocusIndicatorRotateLayout;
private FocusIndicatorView mFocusIndicator;
@@ -104,6 +106,8 @@ public class FocusManager {
mFocusAreaSupported = (mParameters.getMaxNumFocusAreas() > 0
&& isSupported(Parameters.FOCUS_MODE_AUTO,
mParameters.getSupportedFocusModes()));
+ mLockAeAwbNeeded = (mParameters.isAutoExposureLockSupported() ||
+ mParameters.isAutoWhiteBalanceLockSupported());
}
public void initialize(View focusIndicatorRotate, View previewFrame,
@@ -121,27 +125,42 @@ public class FocusManager {
}
}
- public void doFocus(boolean pressed) {
+ public void onShutterDown() {
if (!mInitialized) return;
- if (!(getFocusMode().equals(Parameters.FOCUS_MODE_INFINITY)
- || getFocusMode().equals(Parameters.FOCUS_MODE_FIXED)
- || getFocusMode().equals(Parameters.FOCUS_MODE_EDOF))) {
- if (pressed) { // Focus key down.
- // Do not focus if touch focus has been triggered.
- if (mState != STATE_SUCCESS && mState != STATE_FAIL) {
- autoFocus();
- }
- } else { // Focus key up.
- // User releases half-pressed focus key.
- if (mState == STATE_FOCUSING || mState == STATE_SUCCESS
- || mState == STATE_FAIL) {
- cancelAutoFocus();
- }
+ // Lock AE and AWB so users can half-press shutter and recompose.
+ if (mLockAeAwbNeeded && !mAeAwbLock) {
+ mAeAwbLock = true;
+ mListener.setFocusParameters();
+ }
+
+ if (needAutoFocusCall()) {
+ // Do not focus if touch focus has been triggered.
+ if (mState != STATE_SUCCESS && mState != STATE_FAIL) {
+ autoFocus();
}
}
}
+ public void onShutterUp() {
+ if (!mInitialized) return;
+
+ if (needAutoFocusCall()) {
+ // User releases half-pressed focus key.
+ if (mState == STATE_FOCUSING || mState == STATE_SUCCESS
+ || mState == STATE_FAIL) {
+ cancelAutoFocus();
+ }
+ }
+
+ // Unlock AE and AWB after cancelAutoFocus. Camera API does not
+ // guarantee setParameters can be called during autofocus.
+ if (mLockAeAwbNeeded && mAeAwbLock && (mState != STATE_FOCUSING_SNAP_ON_FINISH)) {
+ mAeAwbLock = false;
+ mListener.setFocusParameters();
+ }
+ }
+
public void shutterLongPressed() {
if (Parameters.FOCUS_MODE_CONTINUOUS_PICTURE.equals(mFocusMode)
&& isSupported(Parameters.FOCUS_MODE_AUTO, mParameters.getSupportedFocusModes())) {
@@ -151,9 +170,9 @@ public class FocusManager {
mInLongPress = true;
// Cancel any outstanding Auto focus requests. The auto focus mode
// will be changed from CAF to auto in cancelAutoFocus.
- doFocus(false);
+ onShutterUp();
// Call Autofocus
- doFocus(true);
+ onShutterDown();
mInLongPress = false;
}
}
@@ -164,11 +183,7 @@ public class FocusManager {
// If the user has half-pressed the shutter and focus is completed, we
// can take the photo right away. If the focus mode is infinity, we can
// also take the photo.
- if (getFocusMode().equals(Parameters.FOCUS_MODE_INFINITY)
- || getFocusMode().equals(Parameters.FOCUS_MODE_FIXED)
- || getFocusMode().equals(Parameters.FOCUS_MODE_EDOF)
- || (mState == STATE_SUCCESS
- || mState == STATE_FAIL)) {
+ if (!needAutoFocusCall() || (mState == STATE_SUCCESS || mState == STATE_FAIL)) {
capture();
} else if (mState == STATE_FOCUSING) {
// Half pressing the shutter (i.e. the focus button event) will
@@ -467,7 +482,22 @@ public class FocusManager {
mOverrideFocusMode = focusMode;
}
+ public void setAeAwbLock(boolean lock) {
+ mAeAwbLock = lock;
+ }
+
+ public boolean getAeAwbLock() {
+ return mAeAwbLock;
+ }
+
private static boolean isSupported(String value, List<String> supported) {
return supported == null ? false : supported.indexOf(value) >= 0;
}
+
+ private boolean needAutoFocusCall() {
+ String focusMode = getFocusMode();
+ return !(focusMode.equals(Parameters.FOCUS_MODE_INFINITY)
+ || focusMode.equals(Parameters.FOCUS_MODE_FIXED)
+ || focusMode.equals(Parameters.FOCUS_MODE_EDOF));
+ }
}