From 9218dc38da07cbfe48d64897d67472028644fea1 Mon Sep 17 00:00:00 2001 From: Pengchong Jin Date: Fri, 15 May 2015 13:07:10 -0700 Subject: Workaround of the face detection failure on L and N5 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 --- .../camera/one/v2/initialization/PreviewStarter.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/com/android/camera/one/v2/initialization/PreviewStarter.java b/src/com/android/camera/one/v2/initialization/PreviewStarter.java index bba0f54b2..99c34a348 100644 --- a/src/com/android/camera/one/v2/initialization/PreviewStarter.java +++ b/src/com/android/camera/one/v2/initialization/PreviewStarter.java @@ -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 startPreview(final Surface surface) { // When we have the preview surface, start the capture session. - List surfaceList = new ArrayList(mOutputSurfaces); - surfaceList.add(surface); + List 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 sessionFuture = mCaptureSessionCreator.createCaptureSession(surfaceList); -- cgit v1.2.3