diff options
author | Senpo Hu <senpo@google.com> | 2014-09-29 18:49:10 -0700 |
---|---|---|
committer | The Android Automerger <android-build@android.com> | 2014-09-30 12:20:27 -0700 |
commit | 4f222c4204471236180445e99dbe21b5c147b118 (patch) | |
tree | 53b4911bbdff332c1517f44b4b8d56f0061b7aef | |
parent | 4a04cfa03c6803bb14727487178fccffb6b2c2d3 (diff) | |
download | android_packages_apps_Camera2-4f222c4204471236180445e99dbe21b5c147b118.tar.gz android_packages_apps_Camera2-4f222c4204471236180445e99dbe21b5c147b118.tar.bz2 android_packages_apps_Camera2-4f222c4204471236180445e99dbe21b5c147b118.zip |
Stability: call stopPreview() before switching off video module.
If the preview is not stopped, the following camera operations posted
by other modules such as "apply settings" will turn camera object
in turmoil. The camera object could start throwing exception and eventually
hang.
Bug: 16300704
Bug: 17403384
Change-Id: Idd2360869d51b9dfc06309f8ac185a65add8d0c9
-rw-r--r-- | src/com/android/camera/VideoModule.java | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/src/com/android/camera/VideoModule.java b/src/com/android/camera/VideoModule.java index f855d952c..73e5548ec 100644 --- a/src/com/android/camera/VideoModule.java +++ b/src/com/android/camera/VideoModule.java @@ -699,7 +699,9 @@ public class VideoModule extends CameraModule startVideoRecording(); } mAppController.setShutterEnabled(false); - mFocusManager.onShutterUp(mCameraSettings.getCurrentFocusMode()); + if (mCameraSettings != null) { + mFocusManager.onShutterUp(mCameraSettings.getCurrentFocusMode()); + } // Keep the shutter button disabled when in video capture intent // mode and recording is stopped. It'll be re-enabled when @@ -950,9 +952,16 @@ public class VideoModule extends CameraModule @Override public void stopPreview() { - if (!mPreviewing || mCameraDevice == null) { + if (!mPreviewing) { + Log.v(TAG, "Skip stopPreview since it's not mPreviewing"); + return; + } + if (mCameraDevice == null) { + Log.v(TAG, "Skip stopPreview since mCameraDevice is null"); return; } + + Log.v(TAG, "stopPreview"); mCameraDevice.stopPreview(); if (mFocusManager != null) { mFocusManager.onPreviewStopped(); @@ -1400,14 +1409,14 @@ public class VideoModule extends CameraModule } private boolean stopVideoRecording() { - Log.i(TAG, "stopVideoRecording"); - // Do nothing if camera device is still capturing photo. Monkey test can trigger app crashes // (b/17313985) without this check. Crash could also be reproduced by continuously tapping // on shutter button and preview with two fingers. if (mSnapshotInProgress) { + Log.v(TAG, "Skip stopVideoRecording since snapshot in progress"); return true; } + Log.v(TAG, "stopVideoRecording"); mUI.setSwipingEnabled(true); mUI.showFocusUI(true); @@ -1438,6 +1447,10 @@ public class VideoModule extends CameraModule // during recording. Release the camera as soon as possible because // face unlock or other applications may need to use the camera. if (mPaused) { + // b/16300704: Monkey is fast so it could pause the module while recording. + // stopPreview should definitely be called before switching off. + stopPreview(); + closeCamera(); } |