summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChih-yu Huang <akahuang@google.com>2011-11-18 01:16:30 -0800
committerAndroid (Google) Code Review <android-gerrit@google.com>2011-11-18 01:16:30 -0800
commit13c101cf7829c98da4341a39ecc142afc024cdb7 (patch)
treeeb6c27244c7575f6ae3599a72ea65d821c45b111
parent308eab755ffc14ec7aa754f93d88ce22dd9086a0 (diff)
parent80583a299a9c8964cf09e482380c3bda0670ad6f (diff)
downloadLegacyCamera-13c101cf7829c98da4341a39ecc142afc024cdb7.zip
LegacyCamera-13c101cf7829c98da4341a39ecc142afc024cdb7.tar.gz
LegacyCamera-13c101cf7829c98da4341a39ecc142afc024cdb7.tar.bz2
Merge "Fix NPE in panorama when camera failed to connect." into ics-mr1
-rwxr-xr-xsrc/com/android/camera/panorama/PanoramaActivity.java38
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);
+ }
}
/**