From 7d1e2245d443faaf833c19e7e9c837112d618c68 Mon Sep 17 00:00:00 2001 From: Igor Murashkin Date: Wed, 6 Nov 2013 12:09:53 -0800 Subject: camera2: Add #resetState to AutoFocusStateMachine Bug: 11071158 Change-Id: I24bc2d771703bb502dcbb676b6262954f2017630 --- .../ex/camera2/pos/AutoFocusStateMachine.java | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/camera2/public/src/com/android/ex/camera2/pos/AutoFocusStateMachine.java b/camera2/public/src/com/android/ex/camera2/pos/AutoFocusStateMachine.java index ce66285..23959e4 100644 --- a/camera2/public/src/com/android/ex/camera2/pos/AutoFocusStateMachine.java +++ b/camera2/public/src/com/android/ex/camera2/pos/AutoFocusStateMachine.java @@ -31,6 +31,10 @@ import com.android.ex.camera2.utils.SysTrace; */ public class AutoFocusStateMachine { + /** + * Observe state AF state transitions triggered by + * {@link AutoFocusStateMachine#onCaptureCompleted onCaptureCompleted}. + */ public interface AutoFocusStateListener { /** * The camera is currently focused (either active or passive). @@ -176,6 +180,22 @@ public class AutoFocusStateMachine { } } + /** + * Reset the current AF state. + * + *

+ * When dropping capture results (by not invoking {@link #onCaptureCompleted} when a new + * {@link CaptureResult} is available), call this function to reset the state. Otherwise + * the next time a new state is observed this class may incorrectly consider it as the same + * state as before, and not issue any callbacks by {@link AutoFocusStateListener}. + *

+ */ + public synchronized void resetState() { + if (VERBOSE_LOGGING) Log.v(TAG, "resetState - last state was " + mLastAfState); + + mLastAfState = AF_UNINITIALIZED; + } + /** * Lock the lens from moving. Typically used before taking a picture. * -- cgit v1.2.3 From 301ff06a565c55404e472433c46f506e5bef2ee7 Mon Sep 17 00:00:00 2001 From: Zhijun He Date: Tue, 29 Oct 2013 19:07:56 -0700 Subject: camera2: Add updateCaptureRequest method It can be used to update repeating request with current auto focus mode. Bug: 10649854 Change-Id: I5e92218c61dea04990581d37f92bf25a1f8dbe91 --- .../ex/camera2/pos/AutoFocusStateMachine.java | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/camera2/public/src/com/android/ex/camera2/pos/AutoFocusStateMachine.java b/camera2/public/src/com/android/ex/camera2/pos/AutoFocusStateMachine.java index 23959e4..500fb12 100644 --- a/camera2/public/src/com/android/ex/camera2/pos/AutoFocusStateMachine.java +++ b/camera2/public/src/com/android/ex/camera2/pos/AutoFocusStateMachine.java @@ -366,4 +366,25 @@ public class AutoFocusStateMachine { SysTrace.endSectionAsync(mCurrentAfTrace, mCurrentAfCookie); mCurrentAfCookie = AF_UNINITIALIZED; } + + /** + * Update the repeating request with current focus mode. + * + *

This is typically used when a new repeating request is created to update preview with + * new metadata (i.e. crop region). The current auto focus mode needs to be carried over for + * correct auto focus behavior.

+ * + * @param repeatingBuilder Builder for a repeating request. + */ + public synchronized void updateCaptureRequest(CaptureRequest.Builder repeatingBuilder) { + if (repeatingBuilder == null) { + throw new IllegalArgumentException("repeatingBuilder shouldn't be null"); + } + + if (mCurrentAfMode == AF_UNINITIALIZED) { + throw new IllegalStateException("AF mode was not enabled"); + } + + repeatingBuilder.set(CaptureRequest.CONTROL_AF_MODE, mCurrentAfMode); + } } -- cgit v1.2.3