am f55aa972: Merge change I01935be3 into eclair
Merge commit 'f55aa972f9911c6aafc9fbdb736bdec11e004542' into eclair-mr2
* commit 'f55aa972f9911c6aafc9fbdb736bdec11e004542':
Remove PowerManager.setAutoBrightness()
diff --git a/core/java/android/os/IPowerManager.aidl b/core/java/android/os/IPowerManager.aidl
index 189335e..5ac543d 100644
--- a/core/java/android/os/IPowerManager.aidl
+++ b/core/java/android/os/IPowerManager.aidl
@@ -34,7 +34,4 @@
// sets the brightness of the backlights (screen, keyboard, button) 0-255
void setBacklightBrightness(int brightness);
-
- // enables or disables automatic brightness mode
- void setAutoBrightness(boolean on);
}
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index fd67bb4..456181c 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -1081,6 +1081,18 @@
public static final String SCREEN_BRIGHTNESS_MODE = "screen_brightness_mode";
/**
+ * SCREEN_BRIGHTNESS_MODE value for manual mode.
+ * @hide
+ */
+ public static final int SCREEN_BRIGHTNESS_MODE_MANUAL = 0;
+
+ /**
+ * SCREEN_BRIGHTNESS_MODE value for manual mode.
+ * @hide
+ */
+ public static final int SCREEN_BRIGHTNESS_MODE_AUTOMATIC = 1;
+
+ /**
* Control whether the process CPU usage meter should be shown.
*/
public static final String SHOW_PROCESSES = "show_processes";
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java
index 3b91a38..153a5ea 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsHelper.java
@@ -45,7 +45,6 @@
private boolean mSilent;
private boolean mVibrate;
- private boolean mHasAutoBrightness;
public SettingsHelper(Context context) {
mContext = context;
@@ -54,9 +53,6 @@
mContentService = ContentResolver.getContentService();
mPowerManager = IPowerManager.Stub.asInterface(
ServiceManager.getService("power"));
-
- mHasAutoBrightness = context.getResources().getBoolean(
- com.android.internal.R.bool.config_automatic_brightness_available);
}
/**
@@ -71,18 +67,6 @@
public boolean restoreValue(String name, String value) {
if (Settings.System.SCREEN_BRIGHTNESS.equals(name)) {
setBrightness(Integer.parseInt(value));
- } else if (Settings.System.SCREEN_BRIGHTNESS_MODE.equals(name)) {
- if (mHasAutoBrightness) {
- // When setting auto-brightness, must reset the brightness afterwards
- try {
- int curBrightness = Settings.System.getInt(mContext.getContentResolver(),
- Settings.System.SCREEN_BRIGHTNESS);
- setAutoBrightness(Integer.parseInt(value) != 0);
- setBrightness(curBrightness);
- } catch (Settings.SettingNotFoundException e) {
- // no brightness setting at all? weird. skip this then.
- }
- }
} else if (Settings.System.SOUND_EFFECTS_ENABLED.equals(name)) {
setSoundEffects(Integer.parseInt(value) == 1);
} else if (Settings.Secure.LOCATION_PROVIDERS_ALLOWED.equals(name)) {
@@ -92,16 +76,6 @@
return true;
}
- private void setAutoBrightness(boolean value) {
- if (mPowerManager != null) {
- try {
- mPowerManager.setAutoBrightness(value);
- } catch (RemoteException e) {
- // unable to reach the power manager; skip
- }
- }
- }
-
private void setGpsLocation(String value) {
final String GPS = LocationManager.GPS_PROVIDER;
boolean enabled =
diff --git a/services/java/com/android/server/PowerManagerService.java b/services/java/com/android/server/PowerManagerService.java
index e1bea37..a1220b6 100644
--- a/services/java/com/android/server/PowerManagerService.java
+++ b/services/java/com/android/server/PowerManagerService.java
@@ -53,6 +53,7 @@
import static android.provider.Settings.System.DIM_SCREEN;
import static android.provider.Settings.System.SCREEN_BRIGHTNESS;
import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE;
+import static android.provider.Settings.System.SCREEN_BRIGHTNESS_MODE_AUTOMATIC;
import static android.provider.Settings.System.SCREEN_OFF_TIMEOUT;
import static android.provider.Settings.System.STAY_ON_WHILE_PLUGGED_IN;
@@ -199,6 +200,8 @@
private long mScreenOnStartTime;
private boolean mPreventScreenOn;
private int mScreenBrightnessOverride = -1;
+ private boolean mHasHardwareAutoBrightness;
+ private boolean mAutoBrightessEnabled;
// Used when logging number and duration of touch-down cycles
private long mTotalTouchDownTime;
@@ -344,6 +347,9 @@
// DIM_SCREEN
//mDimScreen = getInt(DIM_SCREEN) != 0;
+ // SCREEN_BRIGHTNESS_MODE
+ setScreenBrightnessMode(getInt(SCREEN_BRIGHTNESS_MODE));
+
// recalculate everything
setScreenOffTimeoutsLocked();
}
@@ -415,12 +421,17 @@
mScreenOffIntent = new Intent(Intent.ACTION_SCREEN_OFF);
mScreenOffIntent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY);
- ContentResolver resolver = mContext.getContentResolver();
+ mHasHardwareAutoBrightness = mContext.getResources().getBoolean(
+ com.android.internal.R.bool.config_hardware_automatic_brightness_available);
+
+ ContentResolver resolver = mContext.getContentResolver();
Cursor settingsCursor = resolver.query(Settings.System.CONTENT_URI, null,
"(" + Settings.System.NAME + "=?) or ("
+ Settings.System.NAME + "=?) or ("
+ + Settings.System.NAME + "=?) or ("
+ Settings.System.NAME + "=?)",
- new String[]{STAY_ON_WHILE_PLUGGED_IN, SCREEN_OFF_TIMEOUT, DIM_SCREEN},
+ new String[]{STAY_ON_WHILE_PLUGGED_IN, SCREEN_OFF_TIMEOUT, DIM_SCREEN,
+ SCREEN_BRIGHTNESS_MODE},
null);
mSettings = new ContentQueryMap(settingsCursor, Settings.System.NAME, true, mHandler);
SettingsObserver settingsObserver = new SettingsObserver();
@@ -444,10 +455,6 @@
// turn everything on
setPowerState(ALL_BRIGHT);
- // set auto brightness mode to user setting
- boolean brightnessMode = Settings.System.getInt(resolver, SCREEN_BRIGHTNESS_MODE, 1) != 0;
- mHardware.setAutoBrightness_UNCHECKED(brightnessMode);
-
synchronized (mHandlerThread) {
mInitComplete = true;
mHandlerThread.notifyAll();
@@ -1885,6 +1892,18 @@
}
}
+ private void setScreenBrightnessMode(int mode) {
+ mAutoBrightessEnabled = (mode == SCREEN_BRIGHTNESS_MODE_AUTOMATIC);
+
+ if (mHasHardwareAutoBrightness) {
+ // When setting auto-brightness, must reset the brightness afterwards
+ mHardware.setAutoBrightness_UNCHECKED(mAutoBrightessEnabled);
+ setBacklightBrightness((int)mScreenBrightness.curValue);
+ } else {
+ // not yet implemented
+ }
+ }
+
/** Sets the screen off timeouts:
* mKeylightDelay
* mDimDelay
@@ -2098,11 +2117,6 @@
}
}
- public void setAutoBrightness(boolean on) {
- mContext.enforceCallingOrSelfPermission(android.Manifest.permission.DEVICE_POWER, null);
- mHardware.setAutoBrightness_UNCHECKED(on);
- }
-
private SensorManager getSensorManager() {
if (mSensorManager == null) {
mSensorManager = new SensorManager(mHandlerThread.getLooper());