diff options
author | Wei Huang <weih@google.com> | 2011-11-07 11:07:14 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-11-07 11:07:14 -0800 |
commit | 8a71639b8a106021327f9d03798e617609103d56 (patch) | |
tree | 4d6453c753f96e3d399416e820afa96734d3fa08 /src | |
parent | d15320b1223598eed4e6c78d3386ef082a0db548 (diff) | |
parent | f78664a2246e7eac2b3c948b79b9d51a7de62965 (diff) | |
download | LegacyCamera-8a71639b8a106021327f9d03798e617609103d56.zip LegacyCamera-8a71639b8a106021327f9d03798e617609103d56.tar.gz LegacyCamera-8a71639b8a106021327f9d03798e617609103d56.tar.bz2 |
Merge "Prevent starting face detection twice." into ics-mr1
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/camera/Camera.java | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java index 9c7bbfe..1fad8a8 100644 --- a/src/com/android/camera/Camera.java +++ b/src/com/android/camera/Camera.java @@ -143,6 +143,7 @@ public class Camera extends ActivityBase implements FocusManager.Listener, private GestureDetector mPopupGestureDetector; private boolean mOpenCameraFail = false; private boolean mCameraDisabled = false; + private boolean mFaceDetectionStarted = false; private View mPreviewPanel; // The container of PreviewFrameLayout. private PreviewFrameLayout mPreviewFrameLayout; @@ -520,7 +521,9 @@ public class Camera extends ActivityBase implements FocusManager.Listener, @Override public void startFaceDetection() { + if (mFaceDetectionStarted || mCameraState != IDLE) return; if (mParameters.getMaxNumDetectedFaces() > 0) { + mFaceDetectionStarted = true; mFaceView = (FaceView) findViewById(R.id.face_view); mFaceView.clear(); mFaceView.setVisibility(View.VISIBLE); @@ -535,7 +538,9 @@ public class Camera extends ActivityBase implements FocusManager.Listener, @Override public void stopFaceDetection() { + if (!mFaceDetectionStarted) return; if (mParameters.getMaxNumDetectedFaces() > 0) { + mFaceDetectionStarted = false; mCameraDevice.setFaceDetectionListener(null); mCameraDevice.stopFaceDetection(); if (mFaceView != null) mFaceView.clear(); @@ -982,6 +987,7 @@ public class Camera extends ActivityBase implements FocusManager.Listener, mCameraDevice.takePicture(mShutterCallback, mRawPictureCallback, mPostViewPictureCallback, new JpegPictureCallback(loc)); + mFaceDetectionStarted = false; setCameraState(SNAPSHOT_IN_PROGRESS); return true; } @@ -1461,7 +1467,7 @@ public class Camera extends ActivityBase implements FocusManager.Listener, initializeCapabilities(); resetExposureCompensation(); startPreview(); - if (mFirstTimeInitialized) startFaceDetection(); + startFaceDetection(); } catch (CameraHardwareException e) { Util.showErrorAndFinish(this, R.string.cannot_connect_camera); return; @@ -1683,7 +1689,7 @@ public class Camera extends ActivityBase implements FocusManager.Listener, // display rotation in onCreate may not be what we want. if (mCameraState == PREVIEW_STOPPED) { startPreview(); - if (mFirstTimeInitialized) startFaceDetection(); + startFaceDetection(); } else { if (Util.getDisplayRotation(this) != mDisplayRotation) { setDisplayOrientation(); @@ -1717,6 +1723,7 @@ public class Camera extends ActivityBase implements FocusManager.Listener, private void closeCamera() { if (mCameraDevice != null) { CameraHolder.instance().release(); + mFaceDetectionStarted = false; mCameraDevice.setZoomChangeListener(null); mCameraDevice.setFaceDetectionListener(null); mCameraDevice.setErrorCallback(null); @@ -1795,6 +1802,7 @@ public class Camera extends ActivityBase implements FocusManager.Listener, Log.v(TAG, "stopPreview"); mCameraDevice.cancelAutoFocus(); // Reset the focus. mCameraDevice.stopPreview(); + mFaceDetectionStarted = false; } setCameraState(PREVIEW_STOPPED); mFocusManager.onPreviewStopped(); |