summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChih-yu Huang <akahuang@google.com>2011-11-18 14:40:47 +0800
committerChih-yu Huang <akahuang@google.com>2011-11-18 15:02:30 +0800
commit80583a299a9c8964cf09e482380c3bda0670ad6f (patch)
tree4df06cac3dc650cbd530af10e96266d7ff427811
parent4d29bb4e32a2c0b1f58659e133caf2beaede8f55 (diff)
downloadLegacyCamera-80583a299a9c8964cf09e482380c3bda0670ad6f.zip
LegacyCamera-80583a299a9c8964cf09e482380c3bda0670ad6f.tar.gz
LegacyCamera-80583a299a9c8964cf09e482380c3bda0670ad6f.tar.bz2
Fix NPE in panorama when camera failed to connect.
bug:5637587 Change-Id: Iea275b4e3780a41f4a0c3fe0845acbfdb1e95cd1
-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 a99e7be..be0df40 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,
@@ -988,15 +980,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);
+ }
}
/**