From ba7f02549047afd96f033eda9729592a7668e039 Mon Sep 17 00:00:00 2001 From: Igor Murashkin Date: Tue, 15 Oct 2013 14:01:23 -0700 Subject: camera2: Skip AF state updates when afMode/afState are missing * Workaround for hal3 sometimes dropping afMode/afState (rarely) - don't update AF states, instead just skip this frame, safer and adds 1 frame of latency very rarely sometimes. * Assumes request is repeating, since otherwise we wouldn't get future af transition results Bug: 11238865 Change-Id: Ic793d8c6d44873f6a7983e84e4510b8587a148a0 --- .../android/ex/camera2/pos/AutoFocusStateMachine.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 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 b2a55e4..cb636ea 100644 --- a/camera2/public/src/com/android/ex/camera2/pos/AutoFocusStateMachine.java +++ b/camera2/public/src/com/android/ex/camera2/pos/AutoFocusStateMachine.java @@ -90,8 +90,20 @@ public class AutoFocusStateMachine { */ public synchronized void onCaptureCompleted(CaptureResult result) { - int afState = result.get(CaptureResult.CONTROL_AF_STATE); - int afMode = result.get(CaptureResult.CONTROL_AF_MODE); + Integer afState = result.get(CaptureResult.CONTROL_AF_STATE); + Integer afMode = result.get(CaptureResult.CONTROL_AF_MODE); + + /** + * Work-around for b/11238865 + * This is a HAL bug as these fields should be there always. + */ + if (afState == null) { + Log.w(TAG, "onCaptureCompleted - missing android.control.afState !"); + return; + } else if (afMode == null) { + Log.w(TAG, "onCaptureCompleted - missing android.control.afMode !"); + return; + } if (DEBUG_LOGGING) Log.d(TAG, "onCaptureCompleted - new AF mode = " + afMode + " new AF state = " + afState); -- cgit v1.2.3