From 749682fa2c27556f50bf02ff79ccb35282e5e9be Mon Sep 17 00:00:00 2001 From: Alan Newberger Date: Wed, 1 Oct 2014 16:52:56 -0700 Subject: Trap camera close exceptions on pause Bug: 17759456 Change-Id: I5e5fd39829bd0ebf3f37b354ca380cf6396bef55 (cherry picked from commit 48d4c8f1856503d88f4e2e42fa729f2556173694) --- src/com/android/camera/CameraActivity.java | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/com/android/camera/CameraActivity.java b/src/com/android/camera/CameraActivity.java index 25735ed81..5fac0a803 100644 --- a/src/com/android/camera/CameraActivity.java +++ b/src/com/android/camera/CameraActivity.java @@ -1638,8 +1638,6 @@ public class CameraActivity extends Activity performDeletion(); mCurrentModule.pause(); mOrientationManager.pause(); - // Close the camera and wait for the operation done. - mCameraController.closeCamera(true); mPanoramaViewHelper.onPause(); mLocalImagesObserver.setForegroundChangeListener(null); @@ -1652,6 +1650,17 @@ public class CameraActivity extends Activity UsageStatistics.instance().backgrounded(); + // Close the camera and wait for the operation done. But if we time out + // via RuntimeException, just continue pausing, and request a finish(). + try { + mCameraController.closeCamera(true); + } catch (RuntimeException e) { + Log.e(TAG, "Exception while closing camera", e); + if (!isFinishing()) { + finish(); + } + } + super.onPause(); } -- cgit v1.2.3