summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIliyan Malchev <malchev@google.com>2011-11-16 22:18:26 -0600
committerIliyan Malchev <malchev@google.com>2011-11-17 11:45:29 -0800
commit80f7f7110d7a93595c329919f63bc6cf4b46a94a (patch)
tree54f58f98d9a6f95d18f9d2c9eeeaf6549b036365
parent2ede94fc726e7dcd3d0ca4936efa3386d403f99c (diff)
downloadhardware_ti_omap4-80f7f7110d7a93595c329919f63bc6cf4b46a94a.zip
hardware_ti_omap4-80f7f7110d7a93595c329919f63bc6cf4b46a94a.tar.gz
hardware_ti_omap4-80f7f7110d7a93595c329919f63bc6cf4b46a94a.tar.bz2
CameraHAL: Do not return error if AF fails
Fixes b/5612881 Some third-party apps do not handle errors thrown by the camera HAL when they try to invoke autoFocus while AF is in progress. The Barcode Scanner, in particular, will quit in this case without releasing the Camera handle, wreaking all sorts of power-management havoc. Even though CTS does not mandate it, previous versions of Android and other camera HAL implementations simply return success in this case. This patch makes this HAL conform to this behavior. Change-Id: I758e2de7f84b61043267f052169068b64d75d0d1 Signed-off-by: Sundar Raman <sunds@ti.com>
-rw-r--r--camera/CameraHal.cpp28
-rw-r--r--camera/inc/CameraHal.h11
2 files changed, 24 insertions, 15 deletions
diff --git a/camera/CameraHal.cpp b/camera/CameraHal.cpp
index 7e18330..c192007 100644
--- a/camera/CameraHal.cpp
+++ b/camera/CameraHal.cpp
@@ -2158,17 +2158,30 @@ status_t CameraHal::autoFocus()
#endif
-
LOG_FUNCTION_NAME;
- {
Mutex::Autolock lock(mLock);
+
mMsgEnabled |= CAMERA_MSG_FOCUS;
- }
+ if ( NULL == mCameraAdapter )
+ {
+ ret = -1;
+ goto EXIT;
+ }
+
+ CameraAdapter::AdapterState state;
+ ret = mCameraAdapter->getState(state);
+ if (ret != NO_ERROR)
+ {
+ goto EXIT;
+ }
- if ( NULL != mCameraAdapter )
+ if (state == CameraAdapter::AF_STATE)
{
+ CAMHAL_LOGDA("Ignoring start-AF (already in progress)");
+ goto EXIT;
+ }
#if PPM_INSTRUMENTATION || PPM_INSTRUMENTATION_ABS
@@ -2181,12 +2194,7 @@ status_t CameraHal::autoFocus()
#endif
- }
- else
- {
- ret = -1;
- }
-
+EXIT:
LOG_FUNCTION_NAME_EXIT;
return ret;
diff --git a/camera/inc/CameraHal.h b/camera/inc/CameraHal.h
index f33515a..d139c9c 100644
--- a/camera/inc/CameraHal.h
+++ b/camera/inc/CameraHal.h
@@ -833,6 +833,12 @@ public:
// Rolls the state machine back to INTIALIZED_STATE from the current state
virtual status_t rollbackToInitializedState() = 0;
+
+ // Retrieves the current Adapter state - for internal use (not locked)
+ virtual status_t getState(AdapterState &state) = 0;
+ // Retrieves the next Adapter state - for internal use (not locked)
+ virtual status_t getNextState(AdapterState &state) = 0;
+
protected:
//The first two methods will try to switch the adapter state.
//Every call to setState() should be followed by a corresponding
@@ -841,11 +847,6 @@ protected:
virtual status_t setState(CameraCommands operation) = 0;
virtual status_t commitState() = 0;
virtual status_t rollbackState() = 0;
-
- // Retrieves the current Adapter state - for internal use (not locked)
- virtual status_t getState(AdapterState &state) = 0;
- // Retrieves the next Adapter state - for internal use (not locked)
- virtual status_t getNextState(AdapterState &state) = 0;
};
class DisplayAdapter : public BufferProvider, public virtual RefBase