diff options
author | Android (Google) Code Review <android-gerrit@google.com> | 2009-10-16 12:29:15 -0400 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2009-10-16 12:29:15 -0400 |
commit | f55aa972f9911c6aafc9fbdb736bdec11e004542 (patch) | |
tree | d4d21e41c1a633672e1bd520f5fcd69599bb674a /services | |
parent | 39e6773431e6010c5066c0e13facfd943c932c7e (diff) | |
parent | dc3494e3d8e17aeb0dbbe41953a5ef763d95ff78 (diff) | |
download | frameworks_base-f55aa972f9911c6aafc9fbdb736bdec11e004542.zip frameworks_base-f55aa972f9911c6aafc9fbdb736bdec11e004542.tar.gz frameworks_base-f55aa972f9911c6aafc9fbdb736bdec11e004542.tar.bz2 |
Merge change I01935be3 into eclair
* changes:
Remove PowerManager.setAutoBrightness()
Diffstat (limited to 'services')
-rw-r--r-- | services/java/com/android/server/PowerManagerService.java | 36 |
1 files changed, 25 insertions, 11 deletions
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 android.view.WindowManagerPolicy; 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 @@ class PowerManagerService extends IPowerManager.Stub 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 @@ class PowerManagerService extends IPowerManager.Stub // DIM_SCREEN //mDimScreen = getInt(DIM_SCREEN) != 0; + // SCREEN_BRIGHTNESS_MODE + setScreenBrightnessMode(getInt(SCREEN_BRIGHTNESS_MODE)); + // recalculate everything setScreenOffTimeoutsLocked(); } @@ -415,12 +421,17 @@ class PowerManagerService extends IPowerManager.Stub 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 @@ class PowerManagerService extends IPowerManager.Stub // 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 @@ class PowerManagerService extends IPowerManager.Stub } } + 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 @@ class PowerManagerService extends IPowerManager.Stub } } - 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()); |