diff options
author | Pengchong Jin <pengchong@google.com> | 2015-05-13 00:41:34 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-05-13 00:41:34 +0000 |
commit | 49f0d8846a84e23207dd547ab320c5fa0ee4078a (patch) | |
tree | 6be4c4b0b728a3ab34d0802b5553611a4c62f662 /src | |
parent | f51a30f89aeab87a3f163e306aa7a51b886d2920 (diff) | |
parent | 7e39f8b015985fc0e539e14c193286065b5e51d4 (diff) | |
download | android_packages_apps_Camera2-49f0d8846a84e23207dd547ab320c5fa0ee4078a.tar.gz android_packages_apps_Camera2-49f0d8846a84e23207dd547ab320c5fa0ee4078a.tar.bz2 android_packages_apps_Camera2-49f0d8846a84e23207dd547ab320c5fa0ee4078a.zip |
Merge "WAR of the face detection failure" into ub-camera-haleakala
Diffstat (limited to 'src')
5 files changed, 67 insertions, 16 deletions
diff --git a/src/com/android/camera/app/CameraAppUI.java b/src/com/android/camera/app/CameraAppUI.java index 2b1ca12d7..a286bcba0 100644 --- a/src/com/android/camera/app/CameraAppUI.java +++ b/src/com/android/camera/app/CameraAppUI.java @@ -505,7 +505,8 @@ public class CameraAppUI implements ModeListView.ModeSwitchListener, private final static int COVER_HIDDEN = 0; private final static int COVER_SHOWN = 1; private final static int COVER_WILL_HIDE_AT_NEXT_FRAME = 2; - private static final int COVER_WILL_HIDE_AT_NEXT_TEXTURE_UPDATE = 3; + private final static int COVER_WILL_HIDE_AFTER_NEXT_TEXTURE_UPDATE = 3; + private final static int COVER_WILL_HIDE_AT_NEXT_TEXTURE_UPDATE = 4; /** * Preview down-sample rate when taking a screenshot. @@ -1433,7 +1434,15 @@ public class CameraAppUI implements ModeListView.ModeSwitchListener, public void onPreviewStarted() { Log.v(TAG, "onPreviewStarted"); if (mModeCoverState == COVER_SHOWN) { - mModeCoverState = COVER_WILL_HIDE_AT_NEXT_TEXTURE_UPDATE; + // This is a work around of the face detection failure in b/20724126. + // In particular, we need to drop the first preview frame in order to + // make face detection work and also need to hide this preview frame to + // avoid potential janks. We do this only for L, Nexus 6 and Haleakala. + if (ApiHelper.isLorLMr1() && ApiHelper.IS_NEXUS_6) { + mModeCoverState = COVER_WILL_HIDE_AFTER_NEXT_TEXTURE_UPDATE; + } else { + mModeCoverState = COVER_WILL_HIDE_AT_NEXT_TEXTURE_UPDATE; + } } enableModeOptions(); } @@ -1725,7 +1734,13 @@ public class CameraAppUI implements ModeListView.ModeSwitchListener, if (mPreviewStatusListener != null) { mPreviewStatusListener.onSurfaceTextureUpdated(surface); } - if (mModeCoverState == COVER_WILL_HIDE_AT_NEXT_TEXTURE_UPDATE) { + // Do not show the first preview frame. Due to the bug b/20724126, we need to have + // a WAR to request a preview frame followed by 5-frame ZSL burst before the repeating + // preview and ZSL streams. Need to hide the first preview frame since it is janky. + // We do this only for L, Nexus 6 and Haleakala. + if (mModeCoverState == COVER_WILL_HIDE_AFTER_NEXT_TEXTURE_UPDATE) { + mModeCoverState = COVER_WILL_HIDE_AT_NEXT_TEXTURE_UPDATE; + } else if (mModeCoverState == COVER_WILL_HIDE_AT_NEXT_TEXTURE_UPDATE){ Log.v(TAG, "hiding cover via onSurfaceTextureUpdated"); CameraPerformanceTracker.onEvent(CameraPerformanceTracker.FIRST_PREVIEW_FRAME); hideModeCover(); diff --git a/src/com/android/camera/one/v2/ZslOneCameraFactory.java b/src/com/android/camera/one/v2/ZslOneCameraFactory.java index 25e2c48e8..050462fb1 100644 --- a/src/com/android/camera/one/v2/ZslOneCameraFactory.java +++ b/src/com/android/camera/one/v2/ZslOneCameraFactory.java @@ -197,14 +197,22 @@ public class ZslOneCameraFactory implements OneCameraFactory { // Create the request builder used by all camera operations. // Streams, ResponseListeners, and Parameters added to // this will be applied to *all* requests sent to the camera. - // By default, only the minimal number of streams are configured. - RequestTemplate zslTemplate = new RequestTemplate( - new CameraDeviceRequestBuilderFactory(device)); - zslTemplate.addResponseListener(sharedImageReaderFactory - .provideGlobalResponseListener()); + RequestTemplate rootTemplate = new RequestTemplate( + new CameraDeviceRequestBuilderFactory(device)); + rootTemplate.addResponseListener(sharedImageReaderFactory + .provideGlobalResponseListener()); + rootTemplate.addResponseListener(ResponseListeners + .forFinalMetadata(metadataCallback)); + + // Create the request builder for the preview warmup in order to workaround + // the face detection failure. This is a work around of the HAL face detection + // failure in b/20724126. + RequestTemplate previewWarmupTemplate = new RequestTemplate(rootTemplate); + previewWarmupTemplate.addStream(new SimpleCaptureStream(previewSurface)); + + // Create the request builder for the ZSL stream + RequestTemplate zslTemplate = new RequestTemplate(rootTemplate); zslTemplate.addStream(sharedImageReaderFactory.provideZSLStream()); - zslTemplate.addResponseListener( - ResponseListeners.forFinalMetadata(metadataCallback)); // Create the request builder that will be used by most camera // operations. @@ -225,7 +233,9 @@ public class ZslOneCameraFactory implements OneCameraFactory { ephemeralFrameServer, zslAndPreviewTemplate, cameraCommandExecutor, - new ZslPreviewCommandFactory(ephemeralFrameServer, zslTemplate), + new ZslPreviewCommandFactory(ephemeralFrameServer, + previewWarmupTemplate, + zslTemplate), flashSetting, exposureSetting, zoomState, diff --git a/src/com/android/camera/one/v2/commands/ZslPreviewCommand.java b/src/com/android/camera/one/v2/commands/ZslPreviewCommand.java index 54318efd4..59a3953cb 100644 --- a/src/com/android/camera/one/v2/commands/ZslPreviewCommand.java +++ b/src/com/android/camera/one/v2/commands/ZslPreviewCommand.java @@ -19,12 +19,12 @@ package com.android.camera.one.v2.commands; import android.hardware.camera2.CameraAccessException; import com.android.camera.one.v2.camera2proxy.CameraCaptureSessionClosedException; -import com.android.camera.one.v2.commands.CameraCommand; import com.android.camera.one.v2.core.FrameServer; import com.android.camera.one.v2.core.FrameServer.RequestType; import com.android.camera.one.v2.core.Request; import com.android.camera.one.v2.core.RequestBuilder; import com.android.camera.one.v2.core.ResourceAcquisitionFailedException; +import com.android.camera.util.ApiHelper; import java.util.ArrayList; import java.util.Arrays; @@ -37,6 +37,8 @@ import java.util.concurrent.atomic.AtomicBoolean; */ public class ZslPreviewCommand implements CameraCommand { private final FrameServer mFrameServer; + private final RequestBuilder.Factory mPreviewWarmupRequestBuilder; + private final int mPreviewWarmupRequestType; private final RequestBuilder.Factory mZslRequestBuilder; private final int mZslRequestType; private final RequestBuilder.Factory mZslAndPreviewRequestBuilder; @@ -51,12 +53,16 @@ public class ZslPreviewCommand implements CameraCommand { * viewfinder surface. */ public ZslPreviewCommand(FrameServer frameServer, + RequestBuilder.Factory previewWarmupRequestBuilder, + int previewWarmupRequestType, RequestBuilder.Factory zslRequestBuilder, int zslRequestType, RequestBuilder.Factory zslAndPreviewRequestBuilder, int zslAndPreviewRequestType, int warmupBurstSize) { mFrameServer = frameServer; + mPreviewWarmupRequestBuilder = previewWarmupRequestBuilder; + mPreviewWarmupRequestType = previewWarmupRequestType; mZslRequestBuilder = zslRequestBuilder; mZslRequestType = zslRequestType; mZslAndPreviewRequestBuilder = zslAndPreviewRequestBuilder; @@ -68,9 +74,18 @@ public class ZslPreviewCommand implements CameraCommand { public void run() throws InterruptedException, CameraAccessException, CameraCaptureSessionClosedException, ResourceAcquisitionFailedException { try (FrameServer.Session session = mFrameServer.createExclusiveSession()) { - - // Only run a warmup burst the first time this command is executed. if (mIsFirstRun.getAndSet(false)) { + if (ApiHelper.isLorLMr1() && ApiHelper.IS_NEXUS_6) { + // This is the work around of the face detection failure in b/20724126. + // We need to request a single preview frame followed by a burst of 5-frame ZSL + // before requesting the repeating preview and ZSL requests. We do it only for + // L, Nexus 6 and Haleakala. + List<Request> previewWarming = createWarmupBurst(mPreviewWarmupRequestBuilder, + mPreviewWarmupRequestType, 1); + session.submitRequest(previewWarming, RequestType.NON_REPEATING); + } + + // Only run a warmup burst the first time this command is executed. List<Request> zslWarmingBurst = createWarmupBurst(mZslRequestBuilder, mZslRequestType, mWarmupBurstSize); session.submitRequest(zslWarmingBurst, RequestType.NON_REPEATING); diff --git a/src/com/android/camera/one/v2/commands/ZslPreviewCommandFactory.java b/src/com/android/camera/one/v2/commands/ZslPreviewCommandFactory.java index a5dfaadd3..434d548be 100644 --- a/src/com/android/camera/one/v2/commands/ZslPreviewCommandFactory.java +++ b/src/com/android/camera/one/v2/commands/ZslPreviewCommandFactory.java @@ -24,18 +24,24 @@ import com.android.camera.one.v2.core.RequestBuilder; */ public class ZslPreviewCommandFactory implements PreviewCommandFactory { private final FrameServer mFrameServer; + private final RequestBuilder.Factory mPreviewWarmupRequestBuilder; private final RequestBuilder.Factory mZslRequestBuilder; + private static final int ZSL_WARMUP_BURST_SIZE = 5; public ZslPreviewCommandFactory( FrameServer frameServer, + RequestBuilder.Factory previewWarmupRequestBuilder, RequestBuilder.Factory zslRequestBuilder) { mFrameServer = frameServer; + mPreviewWarmupRequestBuilder = previewWarmupRequestBuilder; mZslRequestBuilder = zslRequestBuilder; } @Override public CameraCommand get(RequestBuilder.Factory previewRequestBuilder, int templateType) { - return new ZslPreviewCommand(mFrameServer, mZslRequestBuilder, templateType, - previewRequestBuilder, templateType, 5 /* warmupBurstSize */); + return new ZslPreviewCommand(mFrameServer, + mPreviewWarmupRequestBuilder, templateType, + mZslRequestBuilder, templateType, + previewRequestBuilder, templateType, ZSL_WARMUP_BURST_SIZE); } } diff --git a/src/com/android/camera/util/ApiHelper.java b/src/com/android/camera/util/ApiHelper.java index 0ac72f0c0..6aadc6250 100644 --- a/src/com/android/camera/util/ApiHelper.java +++ b/src/com/android/camera/util/ApiHelper.java @@ -107,4 +107,9 @@ public class ApiHelper { public static boolean isLMr1OrHigher() { return Build.VERSION.SDK_INT > Build.VERSION_CODES.LOLLIPOP; } + + public static boolean isLorLMr1() { + return Build.VERSION.SDK_INT == Build.VERSION_CODES.LOLLIPOP + || Build.VERSION.SDK_INT == 22; // Lollipop MR1 + } } |