OSDN Git Service

Hide no active camera NPE by defaulting to camera device -1
authorPaul Rohde <codelogic@google.com>
Mon, 11 May 2015 18:29:21 +0000 (11:29 -0700)
committerPaul Rohde <codelogic@google.com>
Mon, 11 May 2015 18:34:42 +0000 (11:34 -0700)
NPE's can occur if no camera device is currently active. It's
not feasable to rewire all parts of the codebase for this
release to properly access the target camera device. This
fix may lead to inconsistent setting persistance if in places
where a NPE would otherwise occur.

Bug: 21026362

Change-Id: I76c5b5fab429f61238a1ba91c0c52e839a431573

src/com/android/camera/CameraActivity.java
src/com/android/camera/app/CameraController.java

index 3aa3558..08b3ba9 100644 (file)
@@ -102,6 +102,7 @@ import com.android.camera.data.VideoDataFactory;
 import com.android.camera.data.VideoItemFactory;
 import com.android.camera.debug.Log;
 import com.android.camera.device.ActiveCameraDeviceTracker;
+import com.android.camera.device.CameraId;
 import com.android.camera.filmstrip.FilmstripContentPanel;
 import com.android.camera.filmstrip.FilmstripController;
 import com.android.camera.module.ModuleController;
@@ -1050,8 +1051,14 @@ public class CameraActivity extends QuickActivity
         // this could cause user issues, so log a stack trace noting the call path
         // which resulted in this scenario.
 
-        return SettingsManager.getCameraSettingScope(
-                mCameraController.getCurrentCameraId().getValue());
+        CameraId cameraId =  mCameraController.getCurrentCameraId();
+
+        if(cameraId == null) {
+            Log.e(TAG,  "Retrieving Camera Setting Scope with -1");
+            return SettingsManager.getCameraSettingScope("-1");
+        }
+
+        return SettingsManager.getCameraSettingScope(cameraId.getValue());
     }
 
     @Override
index 2c4353e..7921335 100644 (file)
@@ -113,6 +113,7 @@ public class CameraController implements CameraAgent.CameraOpenCallback, CameraP
     }
 
     @Override
+    @Deprecated
     public CameraId getCurrentCameraId() {
         return mActiveCameraDeviceTracker.getActiveOrPreviousCamera();
     }