diff options
author | Chih-yu Huang <akahuang@google.com> | 2011-11-18 01:16:30 -0800 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-11-18 01:16:30 -0800 |
commit | 13c101cf7829c98da4341a39ecc142afc024cdb7 (patch) | |
tree | eb6c27244c7575f6ae3599a72ea65d821c45b111 /src | |
parent | 308eab755ffc14ec7aa754f93d88ce22dd9086a0 (diff) | |
parent | 80583a299a9c8964cf09e482380c3bda0670ad6f (diff) | |
download | LegacyCamera-13c101cf7829c98da4341a39ecc142afc024cdb7.zip LegacyCamera-13c101cf7829c98da4341a39ecc142afc024cdb7.tar.gz LegacyCamera-13c101cf7829c98da4341a39ecc142afc024cdb7.tar.bz2 |
Merge "Fix NPE in panorama when camera failed to connect." into ics-mr1
Diffstat (limited to 'src')
-rwxr-xr-x | src/com/android/camera/panorama/PanoramaActivity.java | 38 |
1 files changed, 18 insertions, 20 deletions
diff --git a/src/com/android/camera/panorama/PanoramaActivity.java b/src/com/android/camera/panorama/PanoramaActivity.java index bda0381..69fcc83 100755 --- a/src/com/android/camera/panorama/PanoramaActivity.java +++ b/src/com/android/camera/panorama/PanoramaActivity.java @@ -320,7 +320,7 @@ public class PanoramaActivity extends ActivityBase implements }; } - private void setupCamera() { + private void setupCamera() throws CameraHardwareException, CameraDisabledException { openCamera(); Parameters parameters = mCameraDevice.getParameters(); setupCaptureParams(parameters); @@ -336,18 +336,10 @@ public class PanoramaActivity extends ActivityBase implements } } - private void openCamera() { - try { - int backCameraId = CameraHolder.instance().getBackCameraId(); - mCameraDevice = Util.openCamera(this, backCameraId); - mCameraOrientation = Util.getCameraOrientation(backCameraId); - } catch (CameraHardwareException e) { - Util.showErrorAndFinish(this, R.string.cannot_connect_camera); - return; - } catch (CameraDisabledException e) { - Util.showErrorAndFinish(this, R.string.camera_disabled); - return; - } + private void openCamera() throws CameraHardwareException, CameraDisabledException { + int backCameraId = CameraHolder.instance().getBackCameraId(); + mCameraDevice = Util.openCamera(this, backCameraId); + mCameraOrientation = Util.getCameraOrientation(backCameraId); } private boolean findBestPreviewSize(List<Size> supportedSizes, boolean need4To3, @@ -994,15 +986,21 @@ public class PanoramaActivity extends ActivityBase implements mOrientationEventListener.enable(); mCaptureState = CAPTURE_STATE_VIEWFINDER; - setupCamera(); + try { + setupCamera(); - // Camera must be initialized before MosaicFrameProcessor is initialized. The preview size - // has to be decided by camera device. - initMosaicFrameProcessorIfNeeded(); - mMosaicView.onResume(); + // Camera must be initialized before MosaicFrameProcessor is initialized. + // The preview size has to be decided by camera device. + initMosaicFrameProcessorIfNeeded(); + mMosaicView.onResume(); - initThumbnailButton(); - keepScreenOnAwhile(); + initThumbnailButton(); + keepScreenOnAwhile(); + } catch (CameraHardwareException e) { + Util.showErrorAndFinish(this, R.string.cannot_connect_camera); + } catch (CameraDisabledException e) { + Util.showErrorAndFinish(this, R.string.camera_disabled); + } } /** |