summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorLinux Build Service Account <lnxbuild@localhost>2018-11-30 10:12:58 -0800
committerGerrit - the friendly Code Review server <code-review@localhost>2018-11-30 10:12:58 -0800
commit28eef35cdf89d3ea7ea1e63d1d45a3c032216579 (patch)
treec4334aa6ded56d56a676325388fcf5f19f2ae629 /src
parent16d576746d71d91a4a479c51c20bb97f732d5fe1 (diff)
parent9edabb542d384f40f7383f77a290d6f827badfa5 (diff)
downloadandroid_packages_apps_Snap-28eef35cdf89d3ea7ea1e63d1d45a3c032216579.tar.gz
android_packages_apps_Snap-28eef35cdf89d3ea7ea1e63d1d45a3c032216579.tar.bz2
android_packages_apps_Snap-28eef35cdf89d3ea7ea1e63d1d45a3c032216579.zip
Merge "SnapdragonCamera: Add AE_PRECAPTURE_TRIGGER_CANCEL in touch focus" into camera-SnapdragonCamera.lnx.2.0
Diffstat (limited to 'src')
-rwxr-xr-xsrc/com/android/camera/CaptureModule.java66
1 files changed, 52 insertions, 14 deletions
diff --git a/src/com/android/camera/CaptureModule.java b/src/com/android/camera/CaptureModule.java
index cd7956c9e..6a684a7fb 100755
--- a/src/com/android/camera/CaptureModule.java
+++ b/src/com/android/camera/CaptureModule.java
@@ -470,6 +470,13 @@ public class CaptureModule implements CameraModule, PhotoController,
private boolean mSaveRaw = false;
private boolean mSupportZoomCapture = true;
+ private int mLastAeState = -1;
+ private int mLastAfState = -1;
+ private boolean mIsCanceled = false;
+ private boolean mIsAutoFocusStarted = false;
+ private boolean mIsAutoFlash = false;
+ private int mSetAePrecaptureTriggerIdel = 0;
+
/**
* A {@link CameraCaptureSession } for camera preview.
*/
@@ -1001,13 +1008,13 @@ public class CaptureModule implements CameraModule, PhotoController,
};
private void updateCaptureStateMachine(int id, CaptureResult result) {
+ Integer afState = result.get(CaptureResult.CONTROL_AF_STATE);
+ Integer aeState = result.get(CaptureResult.CONTROL_AE_STATE);
switch (mState[id]) {
case STATE_PREVIEW: {
break;
}
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_AF_LOCK id: " + id + " afState:" + afState + " aeState:" + aeState);
// AF_PASSIVE is added for continous auto focus mode
@@ -1044,8 +1051,6 @@ public class CaptureModule implements CameraModule, PhotoController,
}
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 + " afState: " + afState + " aeState:" + aeState);
if (aeState == null ||
aeState == CaptureResult.CONTROL_AE_STATE_PRECAPTURE ||
@@ -1071,8 +1076,6 @@ public class CaptureModule implements CameraModule, PhotoController,
}
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_AE_LOCK id: " + id + " afState: " + afState + " aeState:" + aeState);
if (aeState == null || aeState == CaptureResult.CONTROL_AE_STATE_LOCKED) {
checkAfAeStatesAndCapture(id);
@@ -1080,15 +1083,44 @@ public class CaptureModule implements CameraModule, PhotoController,
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: {
- Integer afState = result.get(CaptureResult.CONTROL_AF_STATE);
- Integer aeState = result.get(CaptureResult.CONTROL_AE_STATE);
Log.d(TAG, "STATE_WAITING_TOUCH_FOCUS id: " + id + " afState:" + afState + " aeState:" + aeState);
+ try {
+ if (mIsAutoFocusStarted) {
+ if (mIsCanceled && mSetAePrecaptureTriggerIdel == 1) {
+ Log.i(TAG, "STATE_WAITING_TOUCH_FOCUS SET CONTROL_AE_PRECAPTURE_TRIGGER_IDLE");
+ mPreviewRequestBuilder[id].set(
+ CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER,
+ CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER_IDLE);
+ mCaptureSession[id].setRepeatingRequest(
+ mPreviewRequestBuilder[id].build(), mCaptureCallback,
+ mCameraHandler);
+ mSetAePrecaptureTriggerIdel = 0;
+ }
+ if (mPreviewRequestBuilder[id] != null && mLastAeState != -1
+ && (mLastAeState == CaptureResult.CONTROL_AE_STATE_PRECAPTURE
+ && (aeState == CaptureResult.CONTROL_AE_STATE_FLASH_REQUIRED
+ || aeState == CaptureResult.CONTROL_AE_STATE_CONVERGED))
+ && mIsAutoFlash
+ && !mIsCanceled) {
+
+ Log.i(TAG, "SET CONTROL_AE_PRECAPTURE_TRIGGER_CANCEL START");
+ mPreviewRequestBuilder[id].set(CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER,
+ CaptureRequest.CONTROL_AE_PRECAPTURE_TRIGGER_CANCEL);
+ mCaptureSession[id].setRepeatingRequest(mPreviewRequestBuilder[id].build(),
+ mCaptureCallback, mCameraHandler);
+ mSetAePrecaptureTriggerIdel++;
+ mIsCanceled = true;
+ Log.i(TAG, "SET CONTROL_AE_PRECAPTURE_TRIGGER_CANCEL END");
+
+ }
+ }
+ } catch (CameraAccessException e) {
+ e.printStackTrace();
+ }
break;
}
case STATE_WAITING_AF_LOCKING: {
@@ -1096,18 +1128,14 @@ public class CaptureModule implements CameraModule, PhotoController,
break;
}
case STATE_WAITING_AF_AE_LOCK: {
- Integer afState = result.get(CaptureResult.CONTROL_AF_STATE);
- Integer aeState = result.get(CaptureResult.CONTROL_AE_STATE);
Log.d(TAG, "STATE_WAITING_AF_AE_LOCK id: " + id + " afState: " + afState +
" aeState:" + aeState);
-
if ((aeState == null || aeState == CaptureResult.CONTROL_AE_STATE_CONVERGED)) {
if (isFlashOn(id)) {
// if flash is on and AE state is CONVERGED then lock AE
lockExposure(id);
}
}
-
if ((CaptureResult.CONTROL_AF_STATE_FOCUSED_LOCKED == afState ||
CaptureResult.CONTROL_AF_STATE_NOT_FOCUSED_LOCKED == afState) &&
(aeState == null || aeState == CaptureResult.CONTROL_AE_STATE_LOCKED)) {
@@ -1116,6 +1144,7 @@ public class CaptureModule implements CameraModule, PhotoController,
break;
}
}
+ mLastAeState = aeState;
}
private void checkAfAeStatesAndCapture(int id) {
@@ -2098,6 +2127,8 @@ public class CaptureModule implements CameraModule, PhotoController,
addPreviewSurface(builder, null, id);
mControlAFMode = CaptureRequest.CONTROL_AF_MODE_AUTO;
+ mIsAutoFocusStarted = true;
+ mIsCanceled = false;
applySettingsForAutoFocus(builder, id);
builder.set(CaptureRequest.CONTROL_AF_MODE, CaptureRequest.CONTROL_AF_MODE_AUTO);
mState[id] = STATE_WAITING_TOUCH_FOCUS;
@@ -2831,6 +2862,7 @@ public class CaptureModule implements CameraModule, PhotoController,
});
}
mControlAFMode = CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE;
+ mIsAutoFocusStarted = false;
applyFlash(mPreviewRequestBuilder[id], id);
applySettingsForUnlockExposure(mPreviewRequestBuilder[id], id);
if (mSettingsManager.isDeveloperEnabled()) {
@@ -4541,6 +4573,7 @@ public class CaptureModule implements CameraModule, PhotoController,
mCameraHandler.removeMessages(CANCEL_TOUCH_FOCUS, mCameraId[cameraId]);
mState[cameraId] = STATE_PREVIEW;
mControlAFMode = CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE;
+ mIsAutoFocusStarted = false;
closePreviewSession();
mFrameProcessor.onClose();
@@ -6320,6 +6353,7 @@ public class CaptureModule implements CameraModule, PhotoController,
private void applyFlash(CaptureRequest.Builder request, String value) {
if(DEBUG) Log.d(TAG, "applyFlash: " + value);
String redeye = mSettingsManager.getValue(SettingsManager.KEY_REDEYE_REDUCTION);
+ mIsAutoFlash = false;
if (redeye != null && redeye.equals("on") && !mLongshotActive) {
request.set(CaptureRequest.CONTROL_AE_MODE,
CaptureRequest.CONTROL_AE_MODE_ON_AUTO_FLASH_REDEYE);
@@ -6336,6 +6370,7 @@ public class CaptureModule implements CameraModule, PhotoController,
}
break;
case "auto":
+ mIsAutoFlash = true;
if (isCaptureBrust) {
// When long shot is active, turn off the flash in auto mode
request.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON);
@@ -6370,6 +6405,7 @@ public class CaptureModule implements CameraModule, PhotoController,
String value = mSettingsManager.getValue(SettingsManager.KEY_FLASH_MODE);
boolean isCaptureBrust = isCaptureBrustMode();
+ mIsAutoFlash = false;
switch (value) {
case "on":
if (isCaptureBrust) {
@@ -6381,6 +6417,7 @@ public class CaptureModule implements CameraModule, PhotoController,
}
break;
case "auto":
+ mIsAutoFlash = true;
if (isCaptureBrust) {
// When long shot is active, turn off the flash in auto mode
request.set(CaptureRequest.CONTROL_AE_MODE, CaptureRequest.CONTROL_AE_MODE_ON);
@@ -6519,6 +6556,7 @@ public class CaptureModule implements CameraModule, PhotoController,
mInTAF = false;
mState[id] = STATE_PREVIEW;
mControlAFMode = CaptureRequest.CONTROL_AF_MODE_CONTINUOUS_PICTURE;
+ mIsAutoFocusStarted = false;
setAFModeToPreview(id, mControlAFMode);
}