diff options
Diffstat (limited to 'src/com/android/camera/one/v2/OneCameraZslImpl.java')
-rw-r--r-- | src/com/android/camera/one/v2/OneCameraZslImpl.java | 58 |
1 files changed, 48 insertions, 10 deletions
diff --git a/src/com/android/camera/one/v2/OneCameraZslImpl.java b/src/com/android/camera/one/v2/OneCameraZslImpl.java index 7a4da7461..4d5fdef39 100644 --- a/src/com/android/camera/one/v2/OneCameraZslImpl.java +++ b/src/com/android/camera/one/v2/OneCameraZslImpl.java @@ -183,12 +183,15 @@ public class OneCameraZslImpl extends AbstractOneCamera { private MeteringRectangle[] mAERegions = ZERO_WEIGHT_3A_REGION; /** - * Ready state depends on two things:<br> + * Ready state (typically displayed by the UI shutter-button) depends on two + * things:<br> * <ol> * <li>{@link #mCaptureManager} must be ready.</li> * <li>We must not be in the process of capturing a single, high-quality, * image.</li> * </ol> + * See {@link ConjunctionListenerMux} and {@link #mReadyStateManager} for + * details of how this is managed. */ private static enum ReadyStateRequirement { CAPTURE_MANAGER_READY, @@ -201,7 +204,12 @@ public class OneCameraZslImpl extends AbstractOneCamera { */ private final ConjunctionListenerMux<ReadyStateRequirement> mReadyStateManager = new ConjunctionListenerMux<ReadyStateRequirement>( - ReadyStateRequirement.class); + ReadyStateRequirement.class, new ConjunctionListenerMux.OutputChangeListener() { + @Override + public void onOutputChange(boolean state) { + broadcastReadyState(state); + } + }); /** * An {@link ImageCaptureListener} which will compress and save an image to @@ -286,13 +294,6 @@ public class OneCameraZslImpl extends AbstractOneCamera { } }); - mReadyStateManager.addListener(new ConjunctionListenerMux.OutputChangeListener() { - @Override - public void onOutputChange(boolean state) { - broadcastReadyState(state); - } - }); - // Listen for changes to auto focus state and dispatch to // mFocusStateListener. mCaptureManager.addMetadataChangeListener(CaptureResult.CONTROL_AF_STATE, @@ -308,6 +309,11 @@ public class OneCameraZslImpl extends AbstractOneCamera { // Allocate the image reader to store all images received from the // camera. + if (pictureSize == null) { + // TODO The default should be selected by the caller, and + // pictureSize should never be null. + pictureSize = getDefaultPictureSize(); + } mCaptureImageReader = ImageReader.newInstance(pictureSize.getWidth(), pictureSize.getHeight(), sCaptureImageFormat, MAX_CAPTURE_IMAGES); @@ -316,6 +322,30 @@ public class OneCameraZslImpl extends AbstractOneCamera { } /** + * @return The largest supported picture size. + */ + public Size getDefaultPictureSize() { + StreamConfigurationMap configs = mCharacteristics.get( + CameraCharacteristics.SCALER_STREAM_CONFIGURATION_MAP); + android.util.Size[] supportedSizes = configs.getOutputSizes(sCaptureImageFormat); + + // Find the largest supported size. + android.util.Size largestSupportedSize = supportedSizes[0]; + long largestSupportedSizePixels = largestSupportedSize.getWidth() + * largestSupportedSize.getHeight(); + for (int i = 0; i < supportedSizes.length; i++) { + long numPixels = supportedSizes[i].getWidth() * supportedSizes[i].getHeight(); + if (numPixels > largestSupportedSizePixels) { + largestSupportedSize = supportedSizes[i]; + largestSupportedSizePixels = numPixels; + } + } + + return new Size(largestSupportedSize.getWidth(), + largestSupportedSize.getHeight()); + } + + /** * Take a picture. */ @Override @@ -615,6 +645,9 @@ public class OneCameraZslImpl extends AbstractOneCamera { mCropRegion = cropRegionForZoom(mZoomValue); boolean success = sendRepeatingCaptureRequest(); if (success) { + mReadyStateManager.setInput(ReadyStateRequirement.CAPTURE_NOT_IN_PROGRESS, + true); + mReadyStateManager.notifyListeners(); listener.onReadyForCapture(); } else { listener.onSetupFailed(); @@ -935,7 +968,7 @@ public class OneCameraZslImpl extends AbstractOneCamera { // Waits Settings3A.getFocusHoldMillis() milliseconds before sending // a request for a regular preview stream to resume. mCameraHandler.postAtTime(new Runnable() { - @Override + @Override public void run() { mAERegions = ZERO_WEIGHT_3A_REGION; mAFRegions = ZERO_WEIGHT_3A_REGION; @@ -963,6 +996,11 @@ public class OneCameraZslImpl extends AbstractOneCamera { @Override public Size pickPreviewSize(Size pictureSize, Context context) { + if (pictureSize == null) { + // TODO The default should be selected by the caller, and + // pictureSize should never be null. + pictureSize = getDefaultPictureSize(); + } float pictureAspectRatio = pictureSize.getWidth() / (float) pictureSize.getHeight(); return CaptureModuleUtil.getOptimalPreviewSize(context, getSupportedSizes(), pictureAspectRatio); |