Skip to content
This repository has been archived by the owner on Nov 15, 2022. It is now read-only.

Commit

Permalink
Merge "Fix NPE in panorama when camera failed to connect." into ics-mr1
Browse files Browse the repository at this point in the history
  • Loading branch information
Chih-yu Huang authored and Android (Google) Code Review committed Nov 18, 2011
2 parents 308eab7 + 80583a2 commit 13c101c
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions src/com/android/camera/panorama/PanoramaActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ public void run() {
};
}

private void setupCamera() {
private void setupCamera() throws CameraHardwareException, CameraDisabledException {
openCamera();
Parameters parameters = mCameraDevice.getParameters();
setupCaptureParams(parameters);
Expand All @@ -336,18 +336,10 @@ private void releaseCamera() {
}
}

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,
Expand Down Expand Up @@ -994,15 +986,21 @@ protected void doOnResume() {
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);
}
}

/**
Expand Down

0 comments on commit 13c101c

Please sign in to comment.