OSDN Git Service

Do not set WB or effect if driver does not support it.
authorWu-cheng Li <wuchengli@google.com>
Tue, 15 Dec 2009 04:29:25 +0000 (12:29 +0800)
committerWu-cheng Li <wuchengli@google.com>
Tue, 15 Dec 2009 04:43:07 +0000 (12:43 +0800)
The app should always check if camera driver support the parameter
before setting it. Otherwise, the app will always crash if parameter
string changes.

b/2323831

src/com/android/camera/VideoCamera.java

index b3ddb19..6dbbc23 100644 (file)
@@ -1413,19 +1413,24 @@ public class VideoCamera extends NoSearchActivity
         }
 
         // Set white balance parameter.
-        String whiteBalance = Parameters.WHITE_BALANCE_AUTO;
-        if (mParameters.getSupportedWhiteBalance() != null) {
-            whiteBalance = mPreferences.getString(
-                    CameraSettings.KEY_WHITE_BALANCE,
-                    getString(R.string.pref_camera_whitebalance_default));
+        String whiteBalance = mPreferences.getString(
+                CameraSettings.KEY_WHITE_BALANCE,
+                getString(R.string.pref_camera_whitebalance_default));
+        if (isSupported(whiteBalance,
+                mParameters.getSupportedWhiteBalance())) {
             mParameters.setWhiteBalance(whiteBalance);
+        } else {
+            whiteBalance = mParameters.getWhiteBalance();
+            if (whiteBalance == null) {
+                whiteBalance = Parameters.WHITE_BALANCE_AUTO;
+            }
         }
 
         // Set color effect parameter.
-        if (mParameters.getSupportedColorEffects() != null) {
-            String colorEffect = mPreferences.getString(
-                    CameraSettings.KEY_COLOR_EFFECT,
-                    getString(R.string.pref_camera_coloreffect_default));
+        String colorEffect = mPreferences.getString(
+                CameraSettings.KEY_COLOR_EFFECT,
+                getString(R.string.pref_camera_coloreffect_default));
+        if (isSupported(colorEffect, mParameters.getSupportedColorEffects())) {
             mParameters.setColorEffect(colorEffect);
         }