Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2012 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | package com.android.camera; |
| 18 | |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 19 | import android.graphics.Rect; |
| 20 | import android.graphics.RectF; |
| 21 | import android.hardware.Camera.Area; |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 22 | import android.os.Handler; |
| 23 | import android.os.Looper; |
| 24 | import android.os.Message; |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 25 | |
Erin Dahlgren | 6190c36 | 2014-06-13 14:12:08 -0700 | [diff] [blame] | 26 | import com.android.camera.app.AppController; |
Kevin Gabayan | fb33336 | 2014-06-02 14:48:20 -0700 | [diff] [blame] | 27 | import com.android.camera.app.MotionManager; |
Angus Kong | 5596b4c | 2014-03-11 16:27:30 -0700 | [diff] [blame] | 28 | import com.android.camera.debug.Log; |
Andy Huibers | b868274 | 2014-08-27 15:28:42 -0700 | [diff] [blame] | 29 | import com.android.camera.one.Settings3A; |
Erin Dahlgren | 6190c36 | 2014-06-13 14:12:08 -0700 | [diff] [blame] | 30 | import com.android.camera.settings.Keys; |
Erin Dahlgren | 357b767 | 2013-11-20 17:38:14 -0800 | [diff] [blame] | 31 | import com.android.camera.settings.SettingsManager; |
Doris Liu | 482de02 | 2013-12-18 19:18:16 -0800 | [diff] [blame] | 32 | import com.android.camera.ui.PreviewStatusListener; |
Andy Huibers | b7c7d9a | 2014-06-18 22:26:14 -0700 | [diff] [blame] | 33 | import com.android.camera.ui.TouchCoordinate; |
Alan Newberger | a8923a7 | 2014-12-09 11:28:45 -0800 | [diff] [blame] | 34 | import com.android.camera.util.ApiHelper; |
Paul Rohde | 987ee64 | 2014-12-05 12:17:15 -0800 | [diff] [blame] | 35 | import com.android.camera.ui.focus.CameraCoordinateTransformer; |
| 36 | import com.android.camera.ui.focus.FocusRing; |
Angus Kong | b50b5cb | 2013-08-09 14:55:20 -0700 | [diff] [blame] | 37 | import com.android.camera.util.CameraUtil; |
Andy Huibers | b660538 | 2014-06-24 10:46:36 -0700 | [diff] [blame] | 38 | import com.android.camera.util.UsageStatistics; |
Sol Boucher | 5a34496 | 2014-06-17 14:05:08 -0700 | [diff] [blame] | 39 | import com.android.ex.camera2.portability.CameraCapabilities; |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 40 | |
Sascha Haeberling | 375f9d1 | 2014-10-17 19:05:12 -0700 | [diff] [blame] | 41 | import java.lang.ref.WeakReference; |
Sascha Haeberling | 638e6f0 | 2013-09-18 14:28:51 -0700 | [diff] [blame] | 42 | import java.util.ArrayList; |
| 43 | import java.util.List; |
| 44 | |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 45 | /* A class that handles everything about focus in still picture mode. |
| 46 | * This also handles the metering area because it is the same as focus area. |
| 47 | * |
| 48 | * The test cases: |
| 49 | * (1) The camera has continuous autofocus. Move the camera. Take a picture when |
| 50 | * CAF is not in progress. |
| 51 | * (2) The camera has continuous autofocus. Move the camera. Take a picture when |
| 52 | * CAF is in progress. |
| 53 | * (3) The camera has face detection. Point the camera at some faces. Hold the |
| 54 | * shutter. Release to take a picture. |
| 55 | * (4) The camera has face detection. Point the camera at some faces. Single tap |
| 56 | * the shutter to take a picture. |
| 57 | * (5) The camera has autofocus. Single tap the shutter to take a picture. |
| 58 | * (6) The camera has autofocus. Hold the shutter. Release to take a picture. |
| 59 | * (7) The camera has no autofocus. Single tap the shutter and take a picture. |
| 60 | * (8) The camera has autofocus and supports focus area. Touch the screen to |
| 61 | * trigger autofocus. Take a picture. |
| 62 | * (9) The camera has autofocus and supports focus area. Touch the screen to |
| 63 | * trigger autofocus. Wait until it times out. |
| 64 | * (10) The camera has no autofocus and supports metering area. Touch the screen |
| 65 | * to change metering area. |
| 66 | */ |
Kevin Gabayan | fb33336 | 2014-06-02 14:48:20 -0700 | [diff] [blame] | 67 | public class FocusOverlayManager implements PreviewStatusListener.PreviewAreaChangedListener, |
| 68 | MotionManager.MotionListener { |
Angus Kong | 5596b4c | 2014-03-11 16:27:30 -0700 | [diff] [blame] | 69 | private static final Log.Tag TAG = new Log.Tag("FocusOverlayMgr"); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 70 | |
| 71 | private static final int RESET_TOUCH_FOCUS = 0; |
Andy Huibers | e2f5fdd | 2014-08-26 11:16:59 -0700 | [diff] [blame] | 72 | |
Andy Huibers | b868274 | 2014-08-27 15:28:42 -0700 | [diff] [blame] | 73 | private static final int RESET_TOUCH_FOCUS_DELAY_MILLIS = Settings3A.getFocusHoldMillis(); |
| 74 | |
| 75 | public static final float AF_REGION_BOX = Settings3A.getAutoFocusRegionWidth(); |
| 76 | public static final float AE_REGION_BOX = Settings3A.getMeteringRegionWidth(); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 77 | |
| 78 | private int mState = STATE_IDLE; |
| 79 | private static final int STATE_IDLE = 0; // Focus is not active. |
| 80 | private static final int STATE_FOCUSING = 1; // Focus is in progress. |
| 81 | // Focus is in progress and the camera should take a picture after focus finishes. |
| 82 | private static final int STATE_FOCUSING_SNAP_ON_FINISH = 2; |
| 83 | private static final int STATE_SUCCESS = 3; // Focus finishes and succeeds. |
| 84 | private static final int STATE_FAIL = 4; // Focus finishes and fails. |
| 85 | |
| 86 | private boolean mInitialized; |
| 87 | private boolean mFocusAreaSupported; |
| 88 | private boolean mMeteringAreaSupported; |
| 89 | private boolean mLockAeAwbNeeded; |
| 90 | private boolean mAeAwbLock; |
Paul Rohde | 987ee64 | 2014-12-05 12:17:15 -0800 | [diff] [blame] | 91 | private CameraCoordinateTransformer mCoordinateTransformer; |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 92 | |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 93 | private boolean mMirror; // true if the camera is front-facing. |
| 94 | private int mDisplayOrientation; |
Sascha Haeberling | a63dbb6 | 2013-11-22 11:55:32 -0800 | [diff] [blame] | 95 | private List<Area> mFocusArea; // focus area in driver format |
| 96 | private List<Area> mMeteringArea; // metering area in driver format |
Angus Kong | 831347d | 2014-06-16 16:07:28 -0700 | [diff] [blame] | 97 | private CameraCapabilities.FocusMode mFocusMode; |
| 98 | private final List<CameraCapabilities.FocusMode> mDefaultFocusModes; |
| 99 | private CameraCapabilities.FocusMode mOverrideFocusMode; |
Angus Kong | 8828904 | 2014-04-22 16:39:42 -0700 | [diff] [blame] | 100 | private CameraCapabilities mCapabilities; |
Erin Dahlgren | 6190c36 | 2014-06-13 14:12:08 -0700 | [diff] [blame] | 101 | private final AppController mAppController; |
Sascha Haeberling | a63dbb6 | 2013-11-22 11:55:32 -0800 | [diff] [blame] | 102 | private final SettingsManager mSettingsManager; |
| 103 | private final Handler mHandler; |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 104 | Listener mListener; |
Michael Kolb | e3de722 | 2013-02-18 15:16:44 -0800 | [diff] [blame] | 105 | private boolean mPreviousMoving; |
Paul Rohde | 987ee64 | 2014-12-05 12:17:15 -0800 | [diff] [blame] | 106 | private final FocusRing mFocusRing; |
Doris Liu | 36ebcb1 | 2013-10-28 14:44:24 -0700 | [diff] [blame] | 107 | private final Rect mPreviewRect = new Rect(0, 0, 0, 0); |
Kevin Gabayan | fb33336 | 2014-06-02 14:48:20 -0700 | [diff] [blame] | 108 | private boolean mFocusLocked; |
Michael Kolb | d6954f3 | 2013-03-08 20:43:01 -0800 | [diff] [blame] | 109 | |
Andy Huibers | b7c7d9a | 2014-06-18 22:26:14 -0700 | [diff] [blame] | 110 | /** Manual tap to focus parameters */ |
| 111 | private TouchCoordinate mTouchCoordinate; |
| 112 | private long mTouchTime; |
| 113 | |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 114 | public interface Listener { |
| 115 | public void autoFocus(); |
| 116 | public void cancelAutoFocus(); |
| 117 | public boolean capture(); |
| 118 | public void startFaceDetection(); |
| 119 | public void stopFaceDetection(); |
| 120 | public void setFocusParameters(); |
| 121 | } |
| 122 | |
Sascha Haeberling | 375f9d1 | 2014-10-17 19:05:12 -0700 | [diff] [blame] | 123 | /** |
| 124 | * TODO: Refactor this so that we either don't need a handler or make |
| 125 | * mListener not be the activity. |
| 126 | */ |
| 127 | private static class MainHandler extends Handler { |
| 128 | /** |
| 129 | * The outer mListener at the moment is actually the CameraActivity, |
| 130 | * which we would leak if we didn't break the GC path here using a |
| 131 | * WeakReference. |
| 132 | */ |
| 133 | final WeakReference<FocusOverlayManager> mManager; |
| 134 | public MainHandler(FocusOverlayManager manager, Looper looper) { |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 135 | super(looper); |
Sascha Haeberling | 375f9d1 | 2014-10-17 19:05:12 -0700 | [diff] [blame] | 136 | mManager = new WeakReference<FocusOverlayManager>(manager); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 137 | } |
| 138 | |
| 139 | @Override |
| 140 | public void handleMessage(Message msg) { |
Sascha Haeberling | 375f9d1 | 2014-10-17 19:05:12 -0700 | [diff] [blame] | 141 | FocusOverlayManager manager = mManager.get(); |
| 142 | if (manager == null) { |
| 143 | return; |
| 144 | } |
| 145 | |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 146 | switch (msg.what) { |
| 147 | case RESET_TOUCH_FOCUS: { |
Sascha Haeberling | 375f9d1 | 2014-10-17 19:05:12 -0700 | [diff] [blame] | 148 | manager.cancelAutoFocus(); |
| 149 | manager.mListener.startFaceDetection(); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 150 | break; |
| 151 | } |
| 152 | } |
| 153 | } |
| 154 | } |
| 155 | |
Erin Dahlgren | 6190c36 | 2014-06-13 14:12:08 -0700 | [diff] [blame] | 156 | public FocusOverlayManager(AppController appController, |
Angus Kong | 831347d | 2014-06-16 16:07:28 -0700 | [diff] [blame] | 157 | List<CameraCapabilities.FocusMode> defaultFocusModes, CameraCapabilities capabilities, |
Paul Rohde | 987ee64 | 2014-12-05 12:17:15 -0800 | [diff] [blame] | 158 | Listener listener, boolean mirror, Looper looper, FocusRing focusRing) { |
Erin Dahlgren | 6190c36 | 2014-06-13 14:12:08 -0700 | [diff] [blame] | 159 | mAppController = appController; |
| 160 | mSettingsManager = appController.getSettingsManager(); |
Sascha Haeberling | 375f9d1 | 2014-10-17 19:05:12 -0700 | [diff] [blame] | 161 | mHandler = new MainHandler(this, looper); |
Sascha Haeberling | ee36c5f | 2014-07-29 17:05:43 -0700 | [diff] [blame] | 162 | mDefaultFocusModes = new ArrayList<CameraCapabilities.FocusMode>(defaultFocusModes); |
Angus Kong | 831347d | 2014-06-16 16:07:28 -0700 | [diff] [blame] | 163 | updateCapabilities(capabilities); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 164 | mListener = listener; |
| 165 | setMirror(mirror); |
Paul Rohde | 987ee64 | 2014-12-05 12:17:15 -0800 | [diff] [blame] | 166 | mFocusRing = focusRing; |
Kevin Gabayan | fb33336 | 2014-06-02 14:48:20 -0700 | [diff] [blame] | 167 | mFocusLocked = false; |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 168 | } |
| 169 | |
Angus Kong | 831347d | 2014-06-16 16:07:28 -0700 | [diff] [blame] | 170 | public void updateCapabilities(CameraCapabilities capabilities) { |
Andy Huibers | 09e1340 | 2014-06-27 17:29:23 -0700 | [diff] [blame] | 171 | // capabilities can only be null when onConfigurationChanged is called |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 172 | // before camera is open. We will just return in this case, because |
Andy Huibers | 09e1340 | 2014-06-27 17:29:23 -0700 | [diff] [blame] | 173 | // capabilities will be set again later with the right capabilities after |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 174 | // camera is open. |
Andy Huibers | 09e1340 | 2014-06-27 17:29:23 -0700 | [diff] [blame] | 175 | if (capabilities == null) { |
Sascha Haeberling | e3f9ce2 | 2014-06-25 11:12:22 -0700 | [diff] [blame] | 176 | return; |
| 177 | } |
Angus Kong | 8828904 | 2014-04-22 16:39:42 -0700 | [diff] [blame] | 178 | mCapabilities = capabilities; |
| 179 | mFocusAreaSupported = mCapabilities.supports(CameraCapabilities.Feature.FOCUS_AREA); |
| 180 | mMeteringAreaSupported = mCapabilities.supports(CameraCapabilities.Feature.METERING_AREA); |
| 181 | mLockAeAwbNeeded = (mCapabilities.supports(CameraCapabilities.Feature.AUTO_EXPOSURE_LOCK) |
| 182 | || mCapabilities.supports(CameraCapabilities.Feature.AUTO_WHITE_BALANCE_LOCK)); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 183 | } |
| 184 | |
Doris Liu | 36ebcb1 | 2013-10-28 14:44:24 -0700 | [diff] [blame] | 185 | /** This setter should be the only way to mutate mPreviewRect. */ |
| 186 | public void setPreviewRect(Rect previewRect) { |
| 187 | if (!mPreviewRect.equals(previewRect)) { |
| 188 | mPreviewRect.set(previewRect); |
Paul Rohde | 987ee64 | 2014-12-05 12:17:15 -0800 | [diff] [blame] | 189 | resetCoordinateTransformer(); |
| 190 | mInitialized = true; |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 191 | } |
| 192 | } |
| 193 | |
Doris Liu | 482de02 | 2013-12-18 19:18:16 -0800 | [diff] [blame] | 194 | @Override |
Angus Kong | 2bacca7 | 2014-03-06 12:57:29 -0800 | [diff] [blame] | 195 | public void onPreviewAreaChanged(RectF previewArea) { |
Doris Liu | a1ec04a | 2014-01-13 17:29:40 -0800 | [diff] [blame] | 196 | setPreviewRect(CameraUtil.rectFToRect(previewArea)); |
Doris Liu | 482de02 | 2013-12-18 19:18:16 -0800 | [diff] [blame] | 197 | } |
| 198 | |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 199 | public void setMirror(boolean mirror) { |
| 200 | mMirror = mirror; |
Paul Rohde | 987ee64 | 2014-12-05 12:17:15 -0800 | [diff] [blame] | 201 | resetCoordinateTransformer(); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 202 | } |
| 203 | |
| 204 | public void setDisplayOrientation(int displayOrientation) { |
| 205 | mDisplayOrientation = displayOrientation; |
Paul Rohde | 987ee64 | 2014-12-05 12:17:15 -0800 | [diff] [blame] | 206 | resetCoordinateTransformer(); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 207 | } |
| 208 | |
Paul Rohde | 987ee64 | 2014-12-05 12:17:15 -0800 | [diff] [blame] | 209 | private void resetCoordinateTransformer() { |
| 210 | if (mPreviewRect.width() > 0 && mPreviewRect.height() > 0) { |
| 211 | mCoordinateTransformer = new CameraCoordinateTransformer(mMirror, mDisplayOrientation, |
| 212 | CameraUtil.rectToRectF(mPreviewRect)); |
| 213 | } else { |
| 214 | Log.w(TAG, "The coordinate transformer could not be built because the preview rect" |
| 215 | + "did not have a width and height"); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 216 | } |
| 217 | } |
| 218 | |
Paul Rohde | 987ee64 | 2014-12-05 12:17:15 -0800 | [diff] [blame] | 219 | |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 220 | private void lockAeAwbIfNeeded() { |
| 221 | if (mLockAeAwbNeeded && !mAeAwbLock) { |
| 222 | mAeAwbLock = true; |
| 223 | mListener.setFocusParameters(); |
| 224 | } |
| 225 | } |
| 226 | |
| 227 | private void unlockAeAwbIfNeeded() { |
| 228 | if (mLockAeAwbNeeded && mAeAwbLock && (mState != STATE_FOCUSING_SNAP_ON_FINISH)) { |
| 229 | mAeAwbLock = false; |
| 230 | mListener.setFocusParameters(); |
| 231 | } |
| 232 | } |
| 233 | |
Angus Kong | 831347d | 2014-06-16 16:07:28 -0700 | [diff] [blame] | 234 | public void onShutterUp(CameraCapabilities.FocusMode currentFocusMode) { |
Sascha Haeberling | e3f9ce2 | 2014-06-25 11:12:22 -0700 | [diff] [blame] | 235 | if (!mInitialized) { |
| 236 | return; |
| 237 | } |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 238 | |
Angus Kong | 831347d | 2014-06-16 16:07:28 -0700 | [diff] [blame] | 239 | if (needAutoFocusCall(currentFocusMode)) { |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 240 | // User releases half-pressed focus key. |
| 241 | if (mState == STATE_FOCUSING || mState == STATE_SUCCESS |
| 242 | || mState == STATE_FAIL) { |
| 243 | cancelAutoFocus(); |
| 244 | } |
| 245 | } |
| 246 | |
| 247 | // Unlock AE and AWB after cancelAutoFocus. Camera API does not |
| 248 | // guarantee setParameters can be called during autofocus. |
| 249 | unlockAeAwbIfNeeded(); |
| 250 | } |
| 251 | |
Angus Kong | 831347d | 2014-06-16 16:07:28 -0700 | [diff] [blame] | 252 | public void focusAndCapture(CameraCapabilities.FocusMode currentFocusMode) { |
Sascha Haeberling | e3f9ce2 | 2014-06-25 11:12:22 -0700 | [diff] [blame] | 253 | if (!mInitialized) { |
| 254 | return; |
| 255 | } |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 256 | |
Angus Kong | 831347d | 2014-06-16 16:07:28 -0700 | [diff] [blame] | 257 | if (!needAutoFocusCall(currentFocusMode)) { |
Angus Kong | eaaf56d | 2014-02-20 11:59:10 -0800 | [diff] [blame] | 258 | // Focus is not needed. |
| 259 | capture(); |
| 260 | } else if (mState == STATE_SUCCESS || mState == STATE_FAIL) { |
| 261 | // Focus is done already. |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 262 | capture(); |
| 263 | } else if (mState == STATE_FOCUSING) { |
Angus Kong | eaaf56d | 2014-02-20 11:59:10 -0800 | [diff] [blame] | 264 | // Still focusing and will not trigger snap upon finish. |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 265 | mState = STATE_FOCUSING_SNAP_ON_FINISH; |
| 266 | } else if (mState == STATE_IDLE) { |
Angus Kong | eaaf56d | 2014-02-20 11:59:10 -0800 | [diff] [blame] | 267 | autoFocusAndCapture(); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 268 | } |
| 269 | } |
| 270 | |
| 271 | public void onAutoFocus(boolean focused, boolean shutterButtonPressed) { |
| 272 | if (mState == STATE_FOCUSING_SNAP_ON_FINISH) { |
| 273 | // Take the picture no matter focus succeeds or fails. No need |
| 274 | // to play the AF sound if we're about to play the shutter |
| 275 | // sound. |
| 276 | if (focused) { |
| 277 | mState = STATE_SUCCESS; |
| 278 | } else { |
| 279 | mState = STATE_FAIL; |
| 280 | } |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 281 | capture(); |
| 282 | } else if (mState == STATE_FOCUSING) { |
| 283 | // This happens when (1) user is half-pressing the focus key or |
| 284 | // (2) touch focus is triggered. Play the focus tone. Do not |
| 285 | // take the picture now. |
| 286 | if (focused) { |
| 287 | mState = STATE_SUCCESS; |
| 288 | } else { |
| 289 | mState = STATE_FAIL; |
| 290 | } |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 291 | // If this is triggered by touch focus, cancel focus after a |
| 292 | // while. |
Michael Kolb | b057943 | 2013-07-11 13:48:15 -0700 | [diff] [blame] | 293 | if (mFocusArea != null) { |
Kevin Gabayan | fb33336 | 2014-06-02 14:48:20 -0700 | [diff] [blame] | 294 | mFocusLocked = true; |
Andy Huibers | b868274 | 2014-08-27 15:28:42 -0700 | [diff] [blame] | 295 | mHandler.sendEmptyMessageDelayed(RESET_TOUCH_FOCUS, RESET_TOUCH_FOCUS_DELAY_MILLIS); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 296 | } |
| 297 | if (shutterButtonPressed) { |
| 298 | // Lock AE & AWB so users can half-press shutter and recompose. |
| 299 | lockAeAwbIfNeeded(); |
| 300 | } |
| 301 | } else if (mState == STATE_IDLE) { |
| 302 | // User has released the focus key before focus completes. |
| 303 | // Do nothing. |
| 304 | } |
| 305 | } |
| 306 | |
| 307 | public void onAutoFocusMoving(boolean moving) { |
Sascha Haeberling | e3f9ce2 | 2014-06-25 11:12:22 -0700 | [diff] [blame] | 308 | if (!mInitialized) { |
| 309 | return; |
| 310 | } |
Michael Kolb | d6954f3 | 2013-03-08 20:43:01 -0800 | [diff] [blame] | 311 | |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 312 | // Ignore if we have requested autofocus. This method only handles |
| 313 | // continuous autofocus. |
Sascha Haeberling | e3f9ce2 | 2014-06-25 11:12:22 -0700 | [diff] [blame] | 314 | if (mState != STATE_IDLE) { |
| 315 | return; |
| 316 | } |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 317 | |
Michael Kolb | e3de722 | 2013-02-18 15:16:44 -0800 | [diff] [blame] | 318 | // animate on false->true trasition only b/8219520 |
| 319 | if (moving && !mPreviousMoving) { |
Doris Liu | ca4a566 | 2014-01-02 17:40:12 -0800 | [diff] [blame] | 320 | // Auto focus at the center of the preview. |
Paul Rohde | 987ee64 | 2014-12-05 12:17:15 -0800 | [diff] [blame] | 321 | mFocusRing.startPassiveFocus(); |
| 322 | } else if (!moving && mFocusRing.isPassiveFocusRunning()) { |
| 323 | mFocusRing.stopFocusAnimations(); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 324 | } |
Michael Kolb | e3de722 | 2013-02-18 15:16:44 -0800 | [diff] [blame] | 325 | mPreviousMoving = moving; |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 326 | } |
| 327 | |
Andy Huibers | e2f5fdd | 2014-08-26 11:16:59 -0700 | [diff] [blame] | 328 | /** Returns width of auto focus region in pixels. */ |
Paul Rohde | 987ee64 | 2014-12-05 12:17:15 -0800 | [diff] [blame] | 329 | private int getAFRegionSizePx() { |
Andy Huibers | e2f5fdd | 2014-08-26 11:16:59 -0700 | [diff] [blame] | 330 | return (int) (Math.min(mPreviewRect.width(), mPreviewRect.height()) * AF_REGION_BOX); |
| 331 | } |
| 332 | |
| 333 | /** Returns width of metering region in pixels. */ |
Paul Rohde | 987ee64 | 2014-12-05 12:17:15 -0800 | [diff] [blame] | 334 | private int getAERegionSizePx() { |
Andy Huibers | b868274 | 2014-08-27 15:28:42 -0700 | [diff] [blame] | 335 | return (int) (Math.min(mPreviewRect.width(), mPreviewRect.height()) * AE_REGION_BOX); |
Andy Huibers | e2f5fdd | 2014-08-26 11:16:59 -0700 | [diff] [blame] | 336 | } |
| 337 | |
Michael Kolb | 0718d48 | 2013-02-16 13:13:47 -0800 | [diff] [blame] | 338 | private void initializeFocusAreas(int x, int y) { |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 339 | if (mFocusArea == null) { |
Sascha Haeberling | a63dbb6 | 2013-11-22 11:55:32 -0800 | [diff] [blame] | 340 | mFocusArea = new ArrayList<Area>(); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 341 | mFocusArea.add(new Area(new Rect(), 1)); |
| 342 | } |
| 343 | |
| 344 | // Convert the coordinates to driver format. |
Paul Rohde | 987ee64 | 2014-12-05 12:17:15 -0800 | [diff] [blame] | 345 | mFocusArea.get(0).rect = computeCameraRectFromPreviewCoordinates(x, y, getAFRegionSizePx()); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 346 | } |
| 347 | |
Michael Kolb | 0718d48 | 2013-02-16 13:13:47 -0800 | [diff] [blame] | 348 | private void initializeMeteringAreas(int x, int y) { |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 349 | if (mMeteringArea == null) { |
Sascha Haeberling | a63dbb6 | 2013-11-22 11:55:32 -0800 | [diff] [blame] | 350 | mMeteringArea = new ArrayList<Area>(); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 351 | mMeteringArea.add(new Area(new Rect(), 1)); |
| 352 | } |
| 353 | |
| 354 | // Convert the coordinates to driver format. |
Paul Rohde | 987ee64 | 2014-12-05 12:17:15 -0800 | [diff] [blame] | 355 | mMeteringArea.get(0).rect = computeCameraRectFromPreviewCoordinates(x, y, getAERegionSizePx()); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 356 | } |
| 357 | |
| 358 | public void onSingleTapUp(int x, int y) { |
Sascha Haeberling | e3f9ce2 | 2014-06-25 11:12:22 -0700 | [diff] [blame] | 359 | if (!mInitialized || mState == STATE_FOCUSING_SNAP_ON_FINISH) { |
| 360 | return; |
| 361 | } |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 362 | |
| 363 | // Let users be able to cancel previous touch focus. |
Michael Kolb | b057943 | 2013-07-11 13:48:15 -0700 | [diff] [blame] | 364 | if ((mFocusArea != null) && (mState == STATE_FOCUSING || |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 365 | mState == STATE_SUCCESS || mState == STATE_FAIL)) { |
| 366 | cancelAutoFocus(); |
| 367 | } |
Sascha Haeberling | e3f9ce2 | 2014-06-25 11:12:22 -0700 | [diff] [blame] | 368 | if (mPreviewRect.width() == 0 || mPreviewRect.height() == 0) { |
| 369 | return; |
| 370 | } |
Michael Kolb | b057943 | 2013-07-11 13:48:15 -0700 | [diff] [blame] | 371 | // Initialize variables. |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 372 | // Initialize mFocusArea. |
| 373 | if (mFocusAreaSupported) { |
Michael Kolb | 0718d48 | 2013-02-16 13:13:47 -0800 | [diff] [blame] | 374 | initializeFocusAreas(x, y); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 375 | } |
| 376 | // Initialize mMeteringArea. |
| 377 | if (mMeteringAreaSupported) { |
Michael Kolb | 0718d48 | 2013-02-16 13:13:47 -0800 | [diff] [blame] | 378 | initializeMeteringAreas(x, y); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 379 | } |
| 380 | |
Paul Rohde | 987ee64 | 2014-12-05 12:17:15 -0800 | [diff] [blame] | 381 | mFocusRing.startActiveFocus(); |
| 382 | mFocusRing.setFocusLocation(x, y); |
| 383 | |
Andy Huibers | b7c7d9a | 2014-06-18 22:26:14 -0700 | [diff] [blame] | 384 | // Log manual tap to focus. |
| 385 | mTouchCoordinate = new TouchCoordinate(x, y, mPreviewRect.width(), mPreviewRect.height()); |
| 386 | mTouchTime = System.currentTimeMillis(); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 387 | |
| 388 | // Stop face detection because we want to specify focus and metering area. |
| 389 | mListener.stopFaceDetection(); |
| 390 | |
| 391 | // Set the focus area and metering area. |
| 392 | mListener.setFocusParameters(); |
| 393 | if (mFocusAreaSupported) { |
| 394 | autoFocus(); |
| 395 | } else { // Just show the indicator in all other cases. |
Kevin Gabayan | d4a68ca | 2014-03-24 14:13:12 -0700 | [diff] [blame] | 396 | // Reset the metering area in 4 seconds. |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 397 | mHandler.removeMessages(RESET_TOUCH_FOCUS); |
Andy Huibers | b868274 | 2014-08-27 15:28:42 -0700 | [diff] [blame] | 398 | mHandler.sendEmptyMessageDelayed(RESET_TOUCH_FOCUS, RESET_TOUCH_FOCUS_DELAY_MILLIS); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 399 | } |
| 400 | } |
| 401 | |
| 402 | public void onPreviewStarted() { |
| 403 | mState = STATE_IDLE; |
Alan Newberger | a8923a7 | 2014-12-09 11:28:45 -0800 | [diff] [blame] | 404 | // Avoid resetting touch focus if N4, b/18681082. |
| 405 | if (!ApiHelper.IS_NEXUS_4) { |
| 406 | resetTouchFocus(); |
| 407 | } |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 408 | } |
| 409 | |
| 410 | public void onPreviewStopped() { |
| 411 | // If auto focus was in progress, it would have been stopped. |
| 412 | mState = STATE_IDLE; |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 413 | } |
| 414 | |
| 415 | public void onCameraReleased() { |
| 416 | onPreviewStopped(); |
| 417 | } |
| 418 | |
Kevin Gabayan | fb33336 | 2014-06-02 14:48:20 -0700 | [diff] [blame] | 419 | @Override |
| 420 | public void onMoving() { |
| 421 | if (mFocusLocked) { |
| 422 | Log.d(TAG, "onMoving: Early focus unlock."); |
| 423 | cancelAutoFocus(); |
| 424 | } |
| 425 | } |
| 426 | |
Angus Kong | eaaf56d | 2014-02-20 11:59:10 -0800 | [diff] [blame] | 427 | /** |
| 428 | * Triggers the autofocus and sets the specified state. |
| 429 | * |
| 430 | * @param focusingState The state to use when focus is in progress. |
| 431 | */ |
| 432 | private void autoFocus(int focusingState) { |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 433 | mListener.autoFocus(); |
Angus Kong | eaaf56d | 2014-02-20 11:59:10 -0800 | [diff] [blame] | 434 | mState = focusingState; |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 435 | mHandler.removeMessages(RESET_TOUCH_FOCUS); |
| 436 | } |
| 437 | |
Angus Kong | eaaf56d | 2014-02-20 11:59:10 -0800 | [diff] [blame] | 438 | /** |
| 439 | * Triggers the autofocus and set the state to indicate the focus is in |
| 440 | * progress. |
| 441 | */ |
| 442 | private void autoFocus() { |
| 443 | autoFocus(STATE_FOCUSING); |
| 444 | } |
| 445 | |
| 446 | /** |
| 447 | * Triggers the autofocus and set the state to which a capture will happen |
| 448 | * in the following autofocus callback. |
| 449 | */ |
| 450 | private void autoFocusAndCapture() { |
| 451 | autoFocus(STATE_FOCUSING_SNAP_ON_FINISH); |
| 452 | } |
| 453 | |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 454 | private void cancelAutoFocus() { |
Kevin Gabayan | 516c11a | 2014-06-13 20:49:48 +0000 | [diff] [blame] | 455 | Log.v(TAG, "Cancel autofocus."); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 456 | // Reset the tap area before calling mListener.cancelAutofocus. |
| 457 | // Otherwise, focus mode stays at auto and the tap area passed to the |
| 458 | // driver is not reset. |
| 459 | resetTouchFocus(); |
| 460 | mListener.cancelAutoFocus(); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 461 | mState = STATE_IDLE; |
Kevin Gabayan | fb33336 | 2014-06-02 14:48:20 -0700 | [diff] [blame] | 462 | mFocusLocked = false; |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 463 | mHandler.removeMessages(RESET_TOUCH_FOCUS); |
| 464 | } |
| 465 | |
| 466 | private void capture() { |
| 467 | if (mListener.capture()) { |
| 468 | mState = STATE_IDLE; |
| 469 | mHandler.removeMessages(RESET_TOUCH_FOCUS); |
| 470 | } |
| 471 | } |
| 472 | |
Angus Kong | 831347d | 2014-06-16 16:07:28 -0700 | [diff] [blame] | 473 | public CameraCapabilities.FocusMode getFocusMode( |
| 474 | final CameraCapabilities.FocusMode currentFocusMode) { |
| 475 | if (mOverrideFocusMode != null) { |
Alan Newberger | ec4a3fc | 2014-07-24 15:55:37 -0700 | [diff] [blame] | 476 | Log.v(TAG, "returning override focus: " + mOverrideFocusMode); |
Angus Kong | 831347d | 2014-06-16 16:07:28 -0700 | [diff] [blame] | 477 | return mOverrideFocusMode; |
| 478 | } |
| 479 | if (mCapabilities == null) { |
Alan Newberger | ec4a3fc | 2014-07-24 15:55:37 -0700 | [diff] [blame] | 480 | Log.v(TAG, "no capabilities, returning default AUTO focus mode"); |
Angus Kong | 831347d | 2014-06-16 16:07:28 -0700 | [diff] [blame] | 481 | return CameraCapabilities.FocusMode.AUTO; |
| 482 | } |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 483 | |
Michael Kolb | b057943 | 2013-07-11 13:48:15 -0700 | [diff] [blame] | 484 | if (mFocusAreaSupported && mFocusArea != null) { |
Alan Newberger | ec4a3fc | 2014-07-24 15:55:37 -0700 | [diff] [blame] | 485 | Log.v(TAG, "in tap to focus, returning AUTO focus mode"); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 486 | // Always use autofocus in tap-to-focus. |
Angus Kong | 831347d | 2014-06-16 16:07:28 -0700 | [diff] [blame] | 487 | mFocusMode = CameraCapabilities.FocusMode.AUTO; |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 488 | } else { |
Alan Newberger | ec4a3fc | 2014-07-24 15:55:37 -0700 | [diff] [blame] | 489 | String focusSetting = mSettingsManager.getString(mAppController.getCameraScope(), |
| 490 | Keys.KEY_FOCUS_MODE); |
| 491 | Log.v(TAG, "stored focus setting for camera: " + focusSetting); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 492 | // The default is continuous autofocus. |
Alan Newberger | ec4a3fc | 2014-07-24 15:55:37 -0700 | [diff] [blame] | 493 | mFocusMode = mCapabilities.getStringifier().focusModeFromString(focusSetting); |
| 494 | Log.v(TAG, "focus mode resolved from setting: " + mFocusMode); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 495 | // Try to find a supported focus mode from the default list. |
| 496 | if (mFocusMode == null) { |
Angus Kong | 831347d | 2014-06-16 16:07:28 -0700 | [diff] [blame] | 497 | for (CameraCapabilities.FocusMode mode : mDefaultFocusModes) { |
| 498 | if (mCapabilities.supports(mode)) { |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 499 | mFocusMode = mode; |
Alan Newberger | ec4a3fc | 2014-07-24 15:55:37 -0700 | [diff] [blame] | 500 | Log.v(TAG, "selected supported focus mode from default list" + mode); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 501 | break; |
| 502 | } |
| 503 | } |
| 504 | } |
| 505 | } |
Angus Kong | 831347d | 2014-06-16 16:07:28 -0700 | [diff] [blame] | 506 | if (!mCapabilities.supports(mFocusMode)) { |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 507 | // For some reasons, the driver does not support the current |
| 508 | // focus mode. Fall back to auto. |
Angus Kong | 831347d | 2014-06-16 16:07:28 -0700 | [diff] [blame] | 509 | if (mCapabilities.supports(CameraCapabilities.FocusMode.AUTO)) { |
Alan Newberger | ec4a3fc | 2014-07-24 15:55:37 -0700 | [diff] [blame] | 510 | Log.v(TAG, "no supported focus mode, falling back to AUTO"); |
Angus Kong | 831347d | 2014-06-16 16:07:28 -0700 | [diff] [blame] | 511 | mFocusMode = CameraCapabilities.FocusMode.AUTO; |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 512 | } else { |
Alan Newberger | ec4a3fc | 2014-07-24 15:55:37 -0700 | [diff] [blame] | 513 | Log.v(TAG, "no supported focus mode, falling back to current: " + currentFocusMode); |
Angus Kong | 831347d | 2014-06-16 16:07:28 -0700 | [diff] [blame] | 514 | mFocusMode = currentFocusMode; |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 515 | } |
| 516 | } |
| 517 | return mFocusMode; |
| 518 | } |
| 519 | |
Sascha Haeberling | a63dbb6 | 2013-11-22 11:55:32 -0800 | [diff] [blame] | 520 | public List<Area> getFocusAreas() { |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 521 | return mFocusArea; |
| 522 | } |
| 523 | |
Sascha Haeberling | a63dbb6 | 2013-11-22 11:55:32 -0800 | [diff] [blame] | 524 | public List<Area> getMeteringAreas() { |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 525 | return mMeteringArea; |
| 526 | } |
| 527 | |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 528 | public void resetTouchFocus() { |
Sascha Haeberling | e3f9ce2 | 2014-06-25 11:12:22 -0700 | [diff] [blame] | 529 | if (!mInitialized) { |
| 530 | return; |
| 531 | } |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 532 | |
Michael Kolb | b057943 | 2013-07-11 13:48:15 -0700 | [diff] [blame] | 533 | mFocusArea = null; |
| 534 | mMeteringArea = null; |
Andy Huibers | bd9b80b | 2014-08-26 16:21:15 -0700 | [diff] [blame] | 535 | // This will cause current module to call getFocusAreas() and |
| 536 | // getMeteringAreas() and send updated regions to camera. |
| 537 | mListener.setFocusParameters(); |
Andy Huibers | b7c7d9a | 2014-06-18 22:26:14 -0700 | [diff] [blame] | 538 | |
| 539 | if (mTouchCoordinate != null) { |
| 540 | UsageStatistics.instance().tapToFocus(mTouchCoordinate, |
| 541 | 0.001f * (System.currentTimeMillis() - mTouchTime)); |
| 542 | mTouchCoordinate = null; |
| 543 | } |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 544 | } |
| 545 | |
Paul Rohde | 987ee64 | 2014-12-05 12:17:15 -0800 | [diff] [blame] | 546 | private Rect computeCameraRectFromPreviewCoordinates(int x, int y, int size) { |
Andy Huibers | e2f5fdd | 2014-08-26 11:16:59 -0700 | [diff] [blame] | 547 | int left = CameraUtil.clamp(x - size / 2, mPreviewRect.left, |
| 548 | mPreviewRect.right - size); |
| 549 | int top = CameraUtil.clamp(y - size / 2, mPreviewRect.top, |
| 550 | mPreviewRect.bottom - size); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 551 | |
Andy Huibers | e2f5fdd | 2014-08-26 11:16:59 -0700 | [diff] [blame] | 552 | RectF rectF = new RectF(left, top, left + size, top + size); |
Paul Rohde | 987ee64 | 2014-12-05 12:17:15 -0800 | [diff] [blame] | 553 | return CameraUtil.rectFToRect(mCoordinateTransformer.toCameraSpace(rectF)); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 554 | } |
| 555 | |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 556 | /* package */ int getFocusState() { |
| 557 | return mState; |
| 558 | } |
| 559 | |
| 560 | public boolean isFocusCompleted() { |
| 561 | return mState == STATE_SUCCESS || mState == STATE_FAIL; |
| 562 | } |
| 563 | |
| 564 | public boolean isFocusingSnapOnFinish() { |
| 565 | return mState == STATE_FOCUSING_SNAP_ON_FINISH; |
| 566 | } |
| 567 | |
| 568 | public void removeMessages() { |
| 569 | mHandler.removeMessages(RESET_TOUCH_FOCUS); |
| 570 | } |
| 571 | |
Angus Kong | 831347d | 2014-06-16 16:07:28 -0700 | [diff] [blame] | 572 | public void overrideFocusMode(CameraCapabilities.FocusMode focusMode) { |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 573 | mOverrideFocusMode = focusMode; |
| 574 | } |
| 575 | |
| 576 | public void setAeAwbLock(boolean lock) { |
| 577 | mAeAwbLock = lock; |
| 578 | } |
| 579 | |
| 580 | public boolean getAeAwbLock() { |
| 581 | return mAeAwbLock; |
| 582 | } |
| 583 | |
Angus Kong | 831347d | 2014-06-16 16:07:28 -0700 | [diff] [blame] | 584 | private boolean needAutoFocusCall(CameraCapabilities.FocusMode focusMode) { |
| 585 | return !(focusMode == CameraCapabilities.FocusMode.INFINITY |
| 586 | || focusMode == CameraCapabilities.FocusMode.FIXED |
| 587 | || focusMode == CameraCapabilities.FocusMode.EXTENDED_DOF); |
Michael Kolb | 8872c23 | 2013-01-29 10:33:22 -0800 | [diff] [blame] | 588 | } |
| 589 | } |