OSDN Git Service

Workaround of the face detection failure on L and N5
authorPengchong Jin <pengchong@google.com>
Fri, 15 May 2015 20:07:10 +0000 (13:07 -0700)
committerPengchong Jin <pengchong@google.com>
Fri, 15 May 2015 20:10:54 +0000 (13:10 -0700)
This patch is a workaround of the face detection failure on L
and Nexus 5. For Nexus 5 on L, the current FD only works when
the preview stream is configured as the first stream before the
JPEG stream. This change lock the order by creating a capture
session with the preview stream first, and then creating the
normal capture session with preview and JPEG.

Bug: b/21039466

Change-Id: Icb7f1f758bc9d7ca428c7a4748223072d39dd57f

src/com/android/camera/one/v2/initialization/PreviewStarter.java

index bba0f54..99c34a3 100644 (file)
@@ -20,6 +20,7 @@ import android.view.Surface;
 
 import com.android.camera.one.OneCamera;
 import com.android.camera.one.v2.camera2proxy.CameraCaptureSessionProxy;
+import com.android.camera.util.ApiHelper;
 import com.google.common.util.concurrent.AsyncFunction;
 import com.google.common.util.concurrent.Futures;
 import com.google.common.util.concurrent.ListenableFuture;
@@ -63,8 +64,20 @@ class PreviewStarter {
      */
     public ListenableFuture<Void> startPreview(final Surface surface) {
         // When we have the preview surface, start the capture session.
-        List<Surface> surfaceList = new ArrayList<Surface>(mOutputSurfaces);
-        surfaceList.add(surface);
+        List<Surface> surfaceList = new ArrayList<>();
+
+        // Workaround of the face detection failure on Nexus 5 and L. (b/21039466)
+        // Need to create a capture session with the single preview stream first
+        // to lock it as the first stream. Then resend the another session with preview
+        // and JPEG stream.
+        if (ApiHelper.isLorLMr1() && ApiHelper.IS_NEXUS_5) {
+            surfaceList.add(surface);
+            mCaptureSessionCreator.createCaptureSession(surfaceList);
+            surfaceList.addAll(mOutputSurfaces);
+        } else {
+            surfaceList.addAll(mOutputSurfaces);
+            surfaceList.add(surface);
+        }
 
         final ListenableFuture<CameraCaptureSessionProxy> sessionFuture =
                 mCaptureSessionCreator.createCaptureSession(surfaceList);