diff options
author | Igor Murashkin <iam@google.com> | 2013-10-17 10:52:49 -0700 |
---|---|---|
committer | The Android Automerger <android-build@google.com> | 2013-10-17 16:40:15 -0700 |
commit | 0ab100671fdff8675ea1f74f15627f09c7f7506f (patch) | |
tree | f512caf7612123fe7067bf3608810cb7deaafca2 | |
parent | e444c661c53b942eea0daa120b3e5dcc58a0bdbe (diff) | |
download | android_frameworks_ex-0ab100671fdff8675ea1f74f15627f09c7f7506f.tar.gz android_frameworks_ex-0ab100671fdff8675ea1f74f15627f09c7f7506f.tar.bz2 android_frameworks_ex-0ab100671fdff8675ea1f74f15627f09c7f7506f.zip |
camera2: Harden AutoFocusStateMachine against null values in callbacks
Bug: 11269834
Change-Id: Id3cb85eb3e9aaaf6714fd81a5d53811d4cbfefa9
-rw-r--r-- | camera2/public/src/com/android/ex/camera2/pos/AutoFocusStateMachine.java | 24 |
1 files changed, 24 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 cb636ea..5b11c2b 100644 --- a/camera2/public/src/com/android/ex/camera2/pos/AutoFocusStateMachine.java +++ b/camera2/public/src/com/android/ex/camera2/pos/AutoFocusStateMachine.java @@ -16,6 +16,7 @@ package com.android.ex.camera2.pos; import android.hardware.camera2.CameraDevice; +import android.hardware.camera2.CameraMetadata.Key; import android.hardware.camera2.CaptureRequest; import android.hardware.camera2.CaptureResult; import android.util.Log; @@ -90,6 +91,29 @@ public class AutoFocusStateMachine { */ public synchronized void onCaptureCompleted(CaptureResult result) { + /** + * Work-around for b/11269834 + * Although these should never-ever happen, harden for ship + */ + if (result == null) { + Log.w(TAG, "onCaptureCompleted - missing result, skipping AF update"); + return; + } + + Key<Integer> keyAfState = CaptureResult.CONTROL_AF_STATE; + if (keyAfState == null) { + Log.e(TAG, "onCaptureCompleted - missing android.control.afState key, " + + "skipping AF update"); + return; + } + + Key<Integer> keyAfMode = CaptureResult.CONTROL_AF_MODE; + if (keyAfMode == null) { + Log.e(TAG, "onCaptureCompleted - missing android.control.afMode key, " + + "skipping AF update"); + return; + } + Integer afState = result.get(CaptureResult.CONTROL_AF_STATE); Integer afMode = result.get(CaptureResult.CONTROL_AF_MODE); |