summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorIgor Murashkin <iam@google.com>2013-11-05 00:42:51 (GMT)
committerIgor Murashkin <iam@google.com>2013-11-05 00:50:19 (GMT)
commit2d8e55f45e52ac0b18c0e46de602e6a6d5ab1001 (patch)
treec2352b2e531ecdb327ee5aaf4bbd594457b4a476
parent1e125c7179c4226702a0c5d7943380529187f989 (diff)
downloadandroid_frameworks_ex-2d8e55f45e52ac0b18c0e46de602e6a6d5ab1001.zip
android_frameworks_ex-2d8e55f45e52ac0b18c0e46de602e6a6d5ab1001.tar.gz
android_frameworks_ex-2d8e55f45e52ac0b18c0e46de602e6a6d5ab1001.tar.bz2
camera2: Add tracing to AutoFocusStateMachine (lens-locking actions only)
Bug: 11071158 Change-Id: I6a1d0130b6ca36c853f539ef3f1afb363a70df24
-rw-r--r--camera2/public/src/com/android/ex/camera2/pos/AutoFocusStateMachine.java35
1 files changed, 35 insertions, 0 deletions
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 5b11c2b..ce66285 100644
--- a/camera2/public/src/com/android/ex/camera2/pos/AutoFocusStateMachine.java
+++ b/camera2/public/src/com/android/ex/camera2/pos/AutoFocusStateMachine.java
@@ -21,6 +21,8 @@ import android.hardware.camera2.CaptureRequest;
import android.hardware.camera2.CaptureResult;
import android.util.Log;
+import com.android.ex.camera2.utils.SysTrace;
+
/**
* Manage the auto focus state machine for CameraDevice.
*
@@ -72,6 +74,10 @@ public class AutoFocusStateMachine {
private int mCurrentAfMode = AF_UNINITIALIZED;
private int mCurrentAfTrigger = AF_UNINITIALIZED;
+ private int mCurrentAfCookie = AF_UNINITIALIZED;
+ private String mCurrentAfTrace = "";
+ private int mLastAfCookie = 0;
+
public AutoFocusStateMachine(AutoFocusStateListener listener) {
if (listener == null) {
throw new IllegalArgumentException("listener should not be null");
@@ -146,9 +152,11 @@ public class AutoFocusStateMachine {
switch (afState) {
case CaptureResult.CONTROL_AF_STATE_FOCUSED_LOCKED:
mListener.onAutoFocusSuccess(result, /*locked*/true);
+ endTraceAsync();
break;
case CaptureResult.CONTROL_AF_STATE_NOT_FOCUSED_LOCKED:
mListener.onAutoFocusFail(result, /*locked*/true);
+ endTraceAsync();
break;
case CaptureResult.CONTROL_AF_STATE_PASSIVE_FOCUSED:
mListener.onAutoFocusSuccess(result, /*locked*/false);
@@ -195,6 +203,8 @@ public class AutoFocusStateMachine {
throw new IllegalStateException("AF mode was not enabled");
}
+ beginTraceAsync("AFSM_lockAutoFocus");
+
mCurrentAfTrigger = CaptureRequest.CONTROL_AF_TRIGGER_START;
repeatingBuilder.set(CaptureRequest.CONTROL_AF_MODE, mCurrentAfMode);
@@ -275,6 +285,8 @@ public class AutoFocusStateMachine {
CaptureRequest.Builder requestBuilder) {
if (VERBOSE_LOGGING) Log.v(TAG, "setActiveAutoFocus");
+ beginTraceAsync("AFSM_setActiveAutoFocus");
+
mCurrentAfMode = CaptureRequest.CONTROL_AF_MODE_AUTO;
repeatingBuilder.set(CaptureRequest.CONTROL_AF_MODE, mCurrentAfMode);
@@ -311,4 +323,27 @@ public class AutoFocusStateMachine {
repeatingBuilder.set(CaptureRequest.CONTROL_AF_MODE, mCurrentAfMode);
}
+
+ private synchronized void beginTraceAsync(String sectionName) {
+ if (mCurrentAfCookie != AF_UNINITIALIZED) {
+ // Terminate any currently active async sections before beginning another section
+ SysTrace.endSectionAsync(mCurrentAfTrace, mCurrentAfCookie);
+ }
+
+ mLastAfCookie++;
+ mCurrentAfCookie = mLastAfCookie;
+ mCurrentAfTrace = sectionName;
+
+ SysTrace.beginSectionAsync(sectionName, mCurrentAfCookie);
+ }
+
+ private synchronized void endTraceAsync() {
+ if (mCurrentAfCookie == AF_UNINITIALIZED) {
+ Log.w(TAG, "endTraceAsync - no current trace active");
+ return;
+ }
+
+ SysTrace.endSectionAsync(mCurrentAfTrace, mCurrentAfCookie);
+ mCurrentAfCookie = AF_UNINITIALIZED;
+ }
}