diff --git a/visionSamples/barcode-reader/app/src/main/java/com/google/android/gms/samples/vision/barcodereader/ui/camera/CameraSource.java b/visionSamples/barcode-reader/app/src/main/java/com/google/android/gms/samples/vision/barcodereader/ui/camera/CameraSource.java index 6ececb63..4e89ee0a 100644 --- a/visionSamples/barcode-reader/app/src/main/java/com/google/android/gms/samples/vision/barcodereader/ui/camera/CameraSource.java +++ b/visionSamples/barcode-reader/app/src/main/java/com/google/android/gms/samples/vision/barcodereader/ui/camera/CameraSource.java @@ -393,7 +393,7 @@ public CameraSource start(SurfaceHolder surfaceHolder) throws IOException { mCamera = createCamera(); mCamera.setPreviewDisplay(surfaceHolder); mCamera.startPreview(); - + mCanTakePicture = true; mProcessingThread = new Thread(mFrameProcessor); @@ -429,7 +429,7 @@ public void stop() { // clear the buffer to prevent oom exceptions mBytesToByteBuffer.clear(); - + mCanTakePicture = false; if (mCamera != null) { @@ -532,9 +532,9 @@ public int doZoom(float scale) { public void takePicture(ShutterCallback shutter, PictureCallback jpeg) { synchronized (mCameraLock) { if (mCamera != null && mCanTakePicture) { - + mCanTakePicture = false; // Preview is suspended until we're done - + PictureStartCallback startCallback = new PictureStartCallback(); startCallback.mDelegate = shutter; PictureDoneCallback doneCallback = new PictureDoneCallback(); @@ -575,8 +575,8 @@ public boolean setFocusMode(@FocusMode String mode) { synchronized (mCameraLock) { if (mCamera != null && mode != null) { Camera.Parameters parameters = mCamera.getParameters(); - final List supportedFlashModes = parameters.getSupportedFlashModes(); - if (supportedFlashModes != null && supportedFlashModes.contains(mode)) { + final List supportedFocusModes = parameters.getSupportedFlashModes(); + if (supportedFocusModes != null && supportedFocusModes.contains(mode)) { parameters.setFocusMode(mode); mCamera.setParameters(parameters); mFocusMode = mode; @@ -629,6 +629,12 @@ public boolean setFlashMode(@FlashMode String mode) { } } + public boolean isModeSupported(String mode) { + Camera.Parameters parameters = mCamera.getParameters(); + final List supportedModes = parameters.getSupportedFlashModes(); + return supportedModes != null && supportedModes.contains(mode); + } + /** * Starts camera auto-focus and registers a callback function to run when * the camera is focused. This method is only valid when preview is active @@ -828,8 +834,8 @@ private Camera createCamera() { setRotation(camera, parameters, mRequestedCameraId); if (mFocusMode != null) { - final List supportedFlashModes = parameters.getSupportedFlashModes(); - if (supportedFlashModes != null && supportedFlashModes.contains(mFocusMode)) { + final List supportedFocusModes = parameters.getSupportedFlashModes(); + if (supportedFocusModes != null && supportedFocusModes.contains(mFocusMode)) { parameters.setFocusMode(mFocusMode); } else { Log.i(TAG, "Camera focus mode: " + mFocusMode + " is not supported on this device.");