summaryrefslogtreecommitdiff
path: root/src/com/android/camera/CaptureModule.java
diff options
context:
space:
mode:
authorJay Wang <jaywang@codeaurora.org>2016-11-03 13:27:10 -0700
committerJay Wang <jaywang@codeaurora.org>2016-11-07 14:24:16 -0800
commitcebd17a6fcf0868f9dfaff960f5e87e11d7e6d88 (patch)
tree9ebd5a62dc41e3edab6c388e5fcb0de64252039c /src/com/android/camera/CaptureModule.java
parent44f769c74b09f2b0413a6b2af8ad555ee66af200 (diff)
SnapdragonCamera: Fix torch mode with continuous shot
Flash torch mode sometime doesn't work because the flash mode is overwritten by repeating preview request. To resolve the issue, re-configure the preview request with new flash mode. CRs-Fixed: 1077543 Change-Id: I614bac704562925cc843a9b8db2852c71368f4e5
Diffstat (limited to 'src/com/android/camera/CaptureModule.java')
-rw-r--r--src/com/android/camera/CaptureModule.java47
1 files changed, 38 insertions, 9 deletions
diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java
index a7f716797..5f8e96b62 100644
--- a/src/com/android/camera/CaptureModule.java
+++ b/src/com/android/camera/CaptureModule.java
@@ -552,6 +552,7 @@ public class CaptureModule implements CameraModule, PhotoController,
Integer afState = result.get(CaptureResult.CONTROL_AF_STATE);
Integer aeState = result.get(CaptureResult.CONTROL_AE_STATE);
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 ||
@@ -567,15 +568,20 @@ public class CaptureModule implements CameraModule, PhotoController,
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);
+ if ((mLockRequestHashCode[id] == result.getRequest().hashCode()) || (mLockRequestHashCode[id] == 0)) {
+
+ // 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);
+ }
}
}
+ } else if (mLockRequestHashCode[id] == result.getRequest().hashCode()){
+ Log.i(TAG, "AF lock request result received, but not focused");
+ mLockRequestHashCode[id] = 0;
}
break;
}
@@ -588,8 +594,16 @@ public class CaptureModule implements CameraModule, PhotoController,
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())
- lockExposure(id);
+ if ((mPrecaptureRequestHashCode[id] == result.getRequest().hashCode()) || (mPrecaptureRequestHashCode[id] == 0)) {
+ if (mLongshotActive && isFlashOn(id)) {
+ checkAfAeStatesAndCapture(id);
+ } else {
+ lockExposure(id);
+ }
+ }
+ } else if (mPrecaptureRequestHashCode[id] == result.getRequest().hashCode()) {
+ Log.i(TAG, "AE trigger request result received, but not converged");
+ mPrecaptureRequestHashCode[id] = 0;
}
break;
}
@@ -1059,6 +1073,14 @@ public class CaptureModule implements CameraModule, PhotoController,
if(id == MONO_ID && !canStartMonoPreview()) {
mCaptureSession[id].setRepeatingRequest(mPreviewRequestBuilder[id]
.build(), mCaptureCallback, mCameraHandler);
+ } else {
+ // for longshot flash, need to re-configure the preview flash mode.
+ if (mLongshotActive && isFlashOn(id)) {
+ mCaptureSession[id].stopRepeating();
+ applyFlash(mPreviewRequestBuilder[id], id);
+ mCaptureSession[id].setRepeatingRequest(mPreviewRequestBuilder[id]
+ .build(), mCaptureCallback, mCameraHandler);
+ }
}
} catch (CameraAccessException e) {
e.printStackTrace();
@@ -1068,6 +1090,7 @@ public class CaptureModule implements CameraModule, PhotoController,
if (mState[id] == STATE_WAITING_TOUCH_FOCUS) {
mCameraHandler.removeMessages(CANCEL_TOUCH_FOCUS, mCameraId[id]);
mState[id] = STATE_WAITING_AF_LOCK;
+ mLockRequestHashCode[id] = 0;
return;
}
@@ -1345,6 +1368,7 @@ public class CaptureModule implements CameraModule, PhotoController,
applySettingsForPrecapture(builder, id);
CaptureRequest request = builder.build();
mPrecaptureRequestHashCode[id] = request.hashCode();
+
mState[id] = STATE_WAITING_PRECAPTURE;
mCaptureSession[id].capture(request, mCaptureCallback, mCameraHandler);
} catch (CameraAccessException e) {
@@ -3056,6 +3080,11 @@ public class CaptureModule implements CameraModule, PhotoController,
return mSettingsManager.getValue(SettingsManager.KEY_FLASH_MODE).equals("off");
}
+ private boolean isFlashOn(int id) {
+ if (!mSettingsManager.isFlashSupported(id)) return false;
+ return mSettingsManager.getValue(SettingsManager.KEY_FLASH_MODE).equals("on");
+ }
+
private void initializePreviewConfiguration(int id) {
mPreviewRequestBuilder[id].set(CaptureRequest.CONTROL_AF_TRIGGER, CaptureRequest
.CONTROL_AF_TRIGGER_IDLE);