diff options
author | Wu-cheng Li <wuchengli@google.com> | 2011-06-07 02:10:02 -0700 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2011-06-07 02:10:02 -0700 |
commit | 9cd9b54a025bfd8e9be35d8c85cf1ba0e7a646b4 (patch) | |
tree | 10dcb6db0b570d507b6e2d51284f3aa3e48906c2 /src/com/android/camera | |
parent | 00a6e1fd8100198be022ed18d8d1567b289e643b (diff) | |
parent | 03eeea3750b6b540b735e0f4d5d6d76c128cbacb (diff) | |
download | LegacyCamera-9cd9b54a025bfd8e9be35d8c85cf1ba0e7a646b4.zip LegacyCamera-9cd9b54a025bfd8e9be35d8c85cf1ba0e7a646b4.tar.gz LegacyCamera-9cd9b54a025bfd8e9be35d8c85cf1ba0e7a646b4.tar.bz2 |
Merge "Fix NPE on launch if camera cannot be opened."
Diffstat (limited to 'src/com/android/camera')
-rw-r--r-- | src/com/android/camera/Camera.java | 15 | ||||
-rw-r--r-- | src/com/android/camera/VideoCamera.java | 7 |
2 files changed, 12 insertions, 10 deletions
diff --git a/src/com/android/camera/Camera.java b/src/com/android/camera/Camera.java index 36b60a3..d4d2171 100644 --- a/src/com/android/camera/Camera.java +++ b/src/com/android/camera/Camera.java @@ -155,7 +155,7 @@ public class Camera extends ActivityBase implements View.OnClickListener, private ToneGenerator mFocusToneGenerator; private GestureDetector mPopupGestureDetector; private SwitcherSet mSwitcher; - private boolean mStartPreviewFail = false; + private boolean mOpenCameraFail = false; private View mPreviewFrame; // Preview frame area. private View mPreviewBorder; @@ -389,7 +389,7 @@ public class Camera extends ActivityBase implements View.OnClickListener, // Initialize focus UI. mPreviewFrame = findViewById(R.id.camera_preview); mPreviewFrame.setOnTouchListener(this); - mPreviewBorder = (View) findViewById(R.id.preview_border); + mPreviewBorder = findViewById(R.id.preview_border); // Set the length of focus rectangle according to preview frame size. int len = Math.min(mPreviewFrame.getWidth(), mPreviewFrame.getHeight()) / 4; ViewGroup.LayoutParams layout = mFocusRectangle.getLayoutParams(); @@ -998,7 +998,7 @@ public class Camera extends ActivityBase implements View.OnClickListener, Thread startPreviewThread = new Thread(new Runnable() { public void run() { try { - mStartPreviewFail = false; + mOpenCameraFail = false; startPreview(); } catch (CameraHardwareException e) { // In eng build, we throw the exception so that test tool @@ -1006,7 +1006,7 @@ public class Camera extends ActivityBase implements View.OnClickListener, if ("eng".equals(Build.TYPE)) { throw new RuntimeException(e); } - mStartPreviewFail = true; + mOpenCameraFail = true; } } }); @@ -1036,7 +1036,7 @@ public class Camera extends ActivityBase implements View.OnClickListener, // Make sure preview is started. try { startPreviewThread.join(); - if (mStartPreviewFail) { + if (mOpenCameraFail) { showCameraErrorAndFinish(); return; } @@ -1447,15 +1447,16 @@ public class Camera extends ActivityBase implements View.OnClickListener, @Override protected void onResume() { super.onResume(); - mPausing = false; + if (mOpenCameraFail) return; + mJpegPictureCallbackTime = 0; mZoomValue = 0; mReviewImage.setVisibility(View.GONE); // Start the preview if it is not started. - if (mCameraState == PREVIEW_STOPPED && !mStartPreviewFail) { + if (mCameraState == PREVIEW_STOPPED) { resetExposureCompensation(); if (!restartPreview()) return; } diff --git a/src/com/android/camera/VideoCamera.java b/src/com/android/camera/VideoCamera.java index 08ab29a2..e002bf5 100644 --- a/src/com/android/camera/VideoCamera.java +++ b/src/com/android/camera/VideoCamera.java @@ -47,13 +47,14 @@ import android.os.Message; import android.os.ParcelFileDescriptor; import android.os.SystemClock; import android.provider.MediaStore; -import android.provider.Settings; import android.provider.MediaStore.Video; +import android.provider.Settings; import android.util.Log; import android.view.GestureDetector; import android.view.KeyEvent; import android.view.Menu; import android.view.MenuItem; +import android.view.MenuItem.OnMenuItemClickListener; import android.view.MotionEvent; import android.view.OrientationEventListener; import android.view.SurfaceHolder; @@ -62,7 +63,6 @@ import android.view.View; import android.view.ViewGroup; import android.view.Window; import android.view.WindowManager; -import android.view.MenuItem.OnMenuItemClickListener; import android.view.animation.AlphaAnimation; import android.view.animation.Animation; import android.widget.Button; @@ -833,13 +833,14 @@ public class VideoCamera extends ActivityBase protected void onResume() { super.onResume(); mPausing = false; + if (mOpenCameraFail) return; mReviewImage.setVisibility(View.GONE); // Start orientation listener as soon as possible because it takes // some time to get first orientation. mOrientationListener.enable(); - if (!mPreviewing && !mOpenCameraFail) { + if (!mPreviewing) { if (!openCamera()) return; readVideoPreferences(); resizeForPreviewAspectRatio(); |