summaryrefslogtreecommitdiffstats
path: root/src/com/android/camera/CaptureModule.java
diff options
context:
space:
mode:
authorJay Wang <jaywang@codeaurora.org>2016-08-09 13:35:10 -0700
committerGerrit - the friendly Code Review server <code-review@localhost>2016-09-27 11:13:56 -0700
commit30333e5845f055092c6a95b115c2025442dcee25 (patch)
treee9fa8afebb20d9c77696c13147ca1c02053a5245 /src/com/android/camera/CaptureModule.java
parentcd0a5fc487bd1e59870ea06d776a1152991b99a4 (diff)
downloadandroid_packages_apps_Snap-30333e5845f055092c6a95b115c2025442dcee25.tar.gz
android_packages_apps_Snap-30333e5845f055092c6a95b115c2025442dcee25.tar.bz2
android_packages_apps_Snap-30333e5845f055092c6a95b115c2025442dcee25.zip
SnapdragonCamera: Lock AE before taking snapshot
Issue and wait for AE lock before taking snapshot CRs-Fixed: 1050611 Change-Id: Ia9c5679a03e3a44ad1ef915cd66e94b9adcc0a81
Diffstat (limited to 'src/com/android/camera/CaptureModule.java')
-rw-r--r--src/com/android/camera/CaptureModule.java83
1 files changed, 59 insertions, 24 deletions
diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java
index 0ae9c5ef1..38f72c196 100644
--- a/src/com/android/camera/CaptureModule.java
+++ b/src/com/android/camera/CaptureModule.java
@@ -131,15 +131,15 @@ public class CaptureModule implements CameraModule, PhotoController,
/**
* Camera state: Waiting for the focus to be locked.
*/
- private static final int STATE_WAITING_LOCK = 1;
+ private static final int STATE_WAITING_AF_LOCK = 1;
/**
* Camera state: Waiting for the exposure to be precapture state.
*/
private static final int STATE_WAITING_PRECAPTURE = 2;
/**
- * Camera state: Waiting for the exposure state to be something other than precapture.
+ * Camera state: Waiting for the exposure state to be locked.
*/
- private static final int STATE_WAITING_NON_PRECAPTURE = 3;
+ private static final int STATE_WAITING_AE_LOCK = 3;
/**
* Camera state: Picture was taken.
*/
@@ -535,10 +535,10 @@ public class CaptureModule implements CameraModule, PhotoController,
case STATE_PREVIEW: {
break;
}
- case STATE_WAITING_LOCK: {
+ case STATE_WAITING_AF_LOCK: {
Integer afState = result.get(CaptureResult.CONTROL_AF_STATE);
Integer aeState = result.get(CaptureResult.CONTROL_AE_STATE);
- Log.d(TAG, "STATE_WAITING_LOCK id: " + id + " afState:" + afState + " aeState:" + aeState);
+ Log.d(TAG, "STATE_WAITING_AF_LOCK id: " + id + " afState:" + afState + " aeState:" + aeState);
// AF_PASSIVE is added for continous auto focus mode
if (CaptureResult.CONTROL_AF_STATE_FOCUSED_LOCKED == afState ||
CaptureResult.CONTROL_AF_STATE_NOT_FOCUSED_LOCKED == afState ||
@@ -546,38 +546,56 @@ public class CaptureModule implements CameraModule, PhotoController,
CaptureResult.CONTROL_AF_STATE_PASSIVE_UNFOCUSED == afState ||
(mLockRequestHashCode[id] == result.getRequest().hashCode() &&
afState == CaptureResult.CONTROL_AF_STATE_INACTIVE)) {
- // CONTROL_AE_STATE can be null on some devices
- if (aeState == null || (aeState == CaptureResult
- .CONTROL_AE_STATE_CONVERGED) && isFlashOff(id)) {
- checkAfAeStatesAndCapture(id);
+ if(id == MONO_ID && getCameraMode() == DUAL_MODE && isBackCamera()) {
+ // in dual mode, mono AE dictated by bayer AE.
+ // if not already locked, wait for lock update from bayer
+ if(aeState == CaptureResult.CONTROL_AE_STATE_LOCKED)
+ checkAfAeStatesAndCapture(id);
+ else
+ mState[id] = STATE_WAITING_AE_LOCK;
} else {
runPrecaptureSequence(id);
+ // CONTROL_AE_STATE can be null on some devices
+ if(aeState == null || (aeState == CaptureResult
+ .CONTROL_AE_STATE_CONVERGED) && isFlashOff(id)) {
+ lockExposure(id);
+ } else {
+ runPrecaptureSequence(id);
+ }
}
}
break;
}
case STATE_WAITING_PRECAPTURE: {
// CONTROL_AE_STATE can be null on some devices
+ Integer afState = result.get(CaptureResult.CONTROL_AF_STATE);
Integer aeState = result.get(CaptureResult.CONTROL_AE_STATE);
- Log.d(TAG, "STATE_WAITING_PRECAPTURE id: " + id + " aeState:" + aeState);
+ Log.d(TAG, "STATE_WAITING_PRECAPTURE id: " + id + " afState: " + afState + " aeState:" + aeState);
if (aeState == null ||
aeState == CaptureResult.CONTROL_AE_STATE_PRECAPTURE ||
aeState == CaptureResult.CONTROL_AE_STATE_FLASH_REQUIRED ||
aeState == CaptureResult.CONTROL_AE_STATE_CONVERGED) {
if (mPrecaptureRequestHashCode[id] == result.getRequest().hashCode())
- mState[id] = STATE_WAITING_NON_PRECAPTURE;
+ lockExposure(id);
}
break;
}
- case STATE_WAITING_NON_PRECAPTURE: {
+ case STATE_WAITING_AE_LOCK: {
// CONTROL_AE_STATE can be null on some devices
+ Integer afState = result.get(CaptureResult.CONTROL_AF_STATE);
Integer aeState = result.get(CaptureResult.CONTROL_AE_STATE);
- Log.d(TAG, "STATE_WAITING_NON_PRECAPTURE id: " + id + " aeState:" + aeState);
- if (aeState == null || aeState != CaptureResult.CONTROL_AE_STATE_PRECAPTURE) {
+ Log.d(TAG, "STATE_WAITING_AE_LOCK id: " + id + " afState: " + afState + " aeState:" + aeState);
+ if (aeState == null || aeState == CaptureResult.CONTROL_AE_STATE_LOCKED) {
checkAfAeStatesAndCapture(id);
}
break;
}
+ case STATE_AF_AE_LOCKED: {
+ Integer afState = result.get(CaptureResult.CONTROL_AF_STATE);
+ Integer aeState = result.get(CaptureResult.CONTROL_AE_STATE);
+ Log.d(TAG, "STATE_AF_AE_LOCKED id: " + id + " afState:" + afState + " aeState:" + aeState);
+ break;
+ }
case STATE_WAITING_TOUCH_FOCUS:
break;
}
@@ -968,7 +986,7 @@ public class CaptureModule implements CameraModule, PhotoController,
mTakingPicture[id] = true;
if (mState[id] == STATE_WAITING_TOUCH_FOCUS) {
mCameraHandler.removeMessages(CANCEL_TOUCH_FOCUS, id);
- mState[id] = STATE_WAITING_LOCK;
+ mState[id] = STATE_WAITING_AF_LOCK;
return;
}
@@ -981,7 +999,7 @@ public class CaptureModule implements CameraModule, PhotoController,
applySettingsForLockFocus(builder, id);
CaptureRequest request = builder.build();
mLockRequestHashCode[id] = request.hashCode();
- mState[id] = STATE_WAITING_LOCK;
+ mState[id] = STATE_WAITING_AF_LOCK;
mCaptureSession[id].capture(request, mCaptureCallback, mCameraHandler);
} catch (CameraAccessException e) {
e.printStackTrace();
@@ -1234,7 +1252,7 @@ public class CaptureModule implements CameraModule, PhotoController,
* we get a response in {@link #mCaptureCallback} from {@link #lockFocus()}.
*/
private void runPrecaptureSequence(int id) {
- Log.d(TAG, "runPrecaptureSequence");
+ Log.d(TAG, "runPrecaptureSequence: " + id);
try {
CaptureRequest.Builder builder = mCameraDevice[id].createCaptureRequest(CameraDevice
.TEMPLATE_PREVIEW);
@@ -1386,14 +1404,8 @@ public class CaptureModule implements CameraModule, PhotoController,
mCaptureSession[id].capture(builder.build(), mCaptureCallback, mCameraHandler);
mState[id] = STATE_PREVIEW;
mControlAFMode = CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE;
+ applySettingsForUnlockExposure(mPreviewRequestBuilder[id], id);
setAFModeToPreview(id, mControlAFMode);
- if(id == MONO_ID && !canStartMonoPreview()) {
- mCaptureSession[id].capture(mPreviewRequestBuilder[id]
- .build(), mCaptureCallback, mCameraHandler);
- } else {
- mCaptureSession[id].setRepeatingRequest(mPreviewRequestBuilder[id].build(),
- mCaptureCallback, mCameraHandler);
- }
mTakingPicture[id] = false;
mActivity.runOnUiThread(new Runnable() {
@Override
@@ -1480,6 +1492,21 @@ public class CaptureModule implements CameraModule, PhotoController,
}
}
+ /**
+ * Lock the exposure for capture
+ */
+ private void lockExposure(int id) {
+ Log.d(TAG, "lockExposure: " + id);
+ try {
+ applySettingsForLockExposure(mPreviewRequestBuilder[id], id);
+ mState[id] = STATE_WAITING_AE_LOCK;
+ mCaptureSession[id].setRepeatingRequest(mPreviewRequestBuilder[id].build(),
+ mCaptureCallback, mCameraHandler);
+ } catch (CameraAccessException e) {
+ e.printStackTrace();
+ }
+ }
+
private void applySettingsForLockFocus(CaptureRequest.Builder builder, int id) {
builder.set(CaptureRequest.CONTROL_AF_TRIGGER, CaptureRequest.CONTROL_AF_TRIGGER_START);
applyAFRegions(builder, id);
@@ -1501,6 +1528,14 @@ public class CaptureModule implements CameraModule, PhotoController,
applyFaceDetect(builder, id);
}
+ private void applySettingsForLockExposure(CaptureRequest.Builder builder, int id) {
+ builder.set(CaptureRequest.CONTROL_AE_LOCK, Boolean.TRUE);
+ }
+
+ private void applySettingsForUnlockExposure(CaptureRequest.Builder builder, int id) {
+ builder.set(CaptureRequest.CONTROL_AE_LOCK, Boolean.FALSE);
+ }
+
private void applySettingsForUnlockFocus(CaptureRequest.Builder builder, int id) {
builder.set(CaptureRequest.CONTROL_AF_TRIGGER,
CaptureRequest.CONTROL_AF_TRIGGER_CANCEL);