Fix crash when trying to reopen the camera.

In this case, another app is using the Camera, such that the camera.open will
hit an exception. We should show an dialog here.

bug:11258139

Change-Id: I0bd2d05fe4d4d9c5e4b87b39f3ef48910cfb7111
diff --git a/src/com/android/camera/AndroidCameraManagerImpl.java b/src/com/android/camera/AndroidCameraManagerImpl.java
index ac9b7eb..e26b6a9 100644
--- a/src/com/android/camera/AndroidCameraManagerImpl.java
+++ b/src/com/android/camera/AndroidCameraManagerImpl.java
@@ -329,8 +329,14 @@
                     }
                     mCamera = null;
                 } else if (mCamera == null) {
-                  Log.w(TAG, "Cannot handle message, mCamera is null.");
-                  return;
+                    if (msg.what == OPEN_CAMERA) {
+                        if (msg.obj != null) {
+                            ((CameraOpenErrorCallback) msg.obj).onDeviceOpenFailure(msg.arg1);
+                        }
+                    } else {
+                        Log.w(TAG, "Cannot handle message, mCamera is null.");
+                    }
+                    return;
                 }
                 throw e;
             }
diff --git a/src/com/android/camera/PhotoModule.java b/src/com/android/camera/PhotoModule.java
index aeca3dd..2d82b57 100644
--- a/src/com/android/camera/PhotoModule.java
+++ b/src/com/android/camera/PhotoModule.java
@@ -1466,7 +1466,7 @@
 
     // This can only be called by UI Thread.
     private void startPreview() {
-        if (mPaused) {
+        if (mPaused || mCameraDevice == null) {
             return;
         }
         SurfaceTexture st = mUI.getSurfaceTexture();