OSDN Git Service

Fix for crash when switching cameras on KitKat (camera-haleakala)
authorGabriel Nava <gnava@google.com>
Wed, 13 May 2015 18:44:13 +0000 (11:44 -0700)
committerGabriel Nava <gnava@google.com>
Wed, 13 May 2015 18:54:46 +0000 (11:54 -0700)
- Adding null check for hardwareSpec in CameraAppUI.onChangeCamera()
- Hardware spec may not be available if call to get camera parameters hasn't finished yet

Bug: 21118170
Change-Id: I5bf1b0328f2cae7211464ff136a31ace2577630f

src/com/android/camera/app/CameraAppUI.java

index a286bcb..44b4d3b 100644 (file)
@@ -1247,25 +1247,28 @@ public class CameraAppUI implements ModeListView.ModeSwitchListener,
          * facing setting so we default to opening the camera in back facing
          * camera, and can save this flash support value again.
          */
-        if (!mController.getSettingsManager().isSet(SettingsManager.SCOPE_GLOBAL,
-                Keys.KEY_FLASH_SUPPORTED_BACK_CAMERA)) {
-            mController.getSettingsManager().set(SettingsManager.SCOPE_GLOBAL,
-                    Keys.KEY_FLASH_SUPPORTED_BACK_CAMERA,
-                    hardwareSpec.isFlashSupported());
-        }
-        /** Similar logic applies to the HDR option. */
-        String hdrSupportMode;
-        if (hardwareSpec.isHdrPlusSupported()) {
-            hdrSupportMode = getResourceString(R.string.pref_camera_hdr_supportmode_hdr_plus);
-        } else if (hardwareSpec.isHdrSupported()) {
-            hdrSupportMode = getResourceString(R.string.pref_camera_hdr_supportmode_hdr);
-        } else {
-            hdrSupportMode = getResourceString(R.string.pref_camera_hdr_supportmode_none);
-        }
-        if (!mController.getSettingsManager().isSet(SettingsManager.SCOPE_GLOBAL,
-                Keys.KEY_HDR_SUPPORT_MODE_BACK_CAMERA)) {
-            mController.getSettingsManager().set(SettingsManager.SCOPE_GLOBAL,
-                    Keys.KEY_HDR_SUPPORT_MODE_BACK_CAMERA, hdrSupportMode);
+        if (hardwareSpec != null) {
+            if (!mController.getSettingsManager().isSet(SettingsManager.SCOPE_GLOBAL,
+                    Keys.KEY_FLASH_SUPPORTED_BACK_CAMERA)) {
+                mController.getSettingsManager().set(SettingsManager.SCOPE_GLOBAL,
+                        Keys.KEY_FLASH_SUPPORTED_BACK_CAMERA,
+                        hardwareSpec.isFlashSupported());
+            }
+            /** Similar logic applies to the HDR option. */
+            if (!mController.getSettingsManager().isSet(SettingsManager.SCOPE_GLOBAL,
+                    Keys.KEY_HDR_SUPPORT_MODE_BACK_CAMERA)) {
+                String hdrSupportMode;
+                if (hardwareSpec.isHdrPlusSupported()) {
+                    hdrSupportMode = getResourceString(
+                            R.string.pref_camera_hdr_supportmode_hdr_plus);
+                } else if (hardwareSpec.isHdrSupported()) {
+                    hdrSupportMode = getResourceString(R.string.pref_camera_hdr_supportmode_hdr);
+                } else {
+                    hdrSupportMode = getResourceString(R.string.pref_camera_hdr_supportmode_none);
+                }
+                mController.getSettingsManager().set(SettingsManager.SCOPE_GLOBAL,
+                        Keys.KEY_HDR_SUPPORT_MODE_BACK_CAMERA, hdrSupportMode);
+            }
         }
 
         applyModuleSpecs(hardwareSpec, moduleController.getBottomBarSpec(),