OSDN Git Service

Set the brightness to a fixed value.
authorOwen Lin <owenlin@google.com>
Fri, 25 Dec 2009 04:50:27 +0000 (12:50 +0800)
committerOwen Lin <owenlin@google.com>
Fri, 15 Jan 2010 00:40:45 +0000 (08:40 +0800)
Bug: 2318682
Change-Id: I367fde55fab1102019accd69e69dc516c583c153

src/com/android/camera/Camera.java
src/com/android/camera/VideoCamera.java

index bb4fb99..a95c2b2 100644 (file)
@@ -48,6 +48,7 @@ import android.os.SystemClock;
 import android.os.SystemProperties;
 import android.preference.PreferenceManager;
 import android.provider.MediaStore;
+import android.provider.Settings;
 import android.util.AttributeSet;
 import android.util.Log;
 import android.view.Display;
@@ -98,6 +99,10 @@ public class Camera extends NoSearchActivity implements View.OnClickListener,
     private static final int RESTART_PREVIEW = 3;
     private static final int CLEAR_SCREEN_DELAY = 4;
 
+    // The brightness settings used when it is set to automatic in the system.
+    // The reason why it is set to 0.7 is just because 1.0 is too bright.
+    private static final float DEFAULT_CAMERA_BRIGHTNESS = 0.7f;
+
     private static final String GPS_MODE_ON = "on";
     private static final String GPS_MODE_OFF = "off";
 
@@ -913,6 +918,18 @@ public class Camera extends NoSearchActivity implements View.OnClickListener,
         super.onCreate(icicle);
 
         Window win = getWindow();
+
+        // Overright the brightness settings if it is automatic
+        int mode = Settings.System.getInt(
+                getContentResolver(),
+                Settings.System.SCREEN_BRIGHTNESS_MODE,
+                Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
+        if (mode == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC) {
+            WindowManager.LayoutParams winParams = win.getAttributes();
+            winParams.screenBrightness = DEFAULT_CAMERA_BRIGHTNESS;
+            win.setAttributes(winParams);
+        }
+
         win.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON);
         setContentView(R.layout.camera);
         mSurfaceView = (SurfaceView) findViewById(R.id.camera_preview);
index 6dbbc23..c48e0f7 100644 (file)
@@ -45,6 +45,7 @@ import android.preference.PreferenceManager;
 import android.preference.PreferenceScreen;
 import android.provider.MediaStore;
 import android.provider.MediaStore.Video;
+import android.provider.Settings;
 import android.util.Log;
 import android.view.KeyEvent;
 import android.view.LayoutInflater;
@@ -96,6 +97,10 @@ public class VideoCamera extends NoSearchActivity
 
     private static final int SCREEN_DELAY = 2 * 60 * 1000;
 
+    // The brightness settings used when it is set to automatic in the system.
+    // The reason why it is set to 0.7 is just because 1.0 is too bright.
+    private static final float DEFAULT_CAMERA_BRIGHTNESS = 0.7f;
+
     private static final long NO_STORAGE_ERROR = -1L;
     private static final long CANNOT_STAT_ERROR = -2L;
     private static final long LOW_STORAGE_THRESHOLD = 512L * 1024L;
@@ -240,6 +245,19 @@ public class VideoCamera extends NoSearchActivity
     public void onCreate(Bundle icicle) {
         super.onCreate(icicle);
 
+        Window win = getWindow();
+
+        // Overright the brightness settings if it is automatic
+        int mode = Settings.System.getInt(
+                getContentResolver(),
+                Settings.System.SCREEN_BRIGHTNESS_MODE,
+                Settings.System.SCREEN_BRIGHTNESS_MODE_MANUAL);
+        if (mode == Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC) {
+            WindowManager.LayoutParams winParams = win.getAttributes();
+            winParams.screenBrightness = DEFAULT_CAMERA_BRIGHTNESS;
+            win.setAttributes(winParams);
+        }
+
         mPreferences = PreferenceManager.getDefaultSharedPreferences(this);
         CameraSettings.upgradePreferences(mPreferences);