diff options
author | Dianne Hackborn <hackbod@google.com> | 2014-06-10 23:13:02 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2014-06-11 10:34:26 -0700 |
commit | 14272302a8b635bd8e9267c1411d0a7ef11bff45 (patch) | |
tree | 7d77f5ef5ca90889f4afed32bdf27e668b1afac6 /services/core/java/com/android/server/power | |
parent | 95981dc8ad08002bab932cefcb6b07c6944491f5 (diff) | |
download | frameworks_base-14272302a8b635bd8e9267c1411d0a7ef11bff45.zip frameworks_base-14272302a8b635bd8e9267c1411d0a7ef11bff45.tar.gz frameworks_base-14272302a8b635bd8e9267c1411d0a7ef11bff45.tar.bz2 |
Implement control of auto power save mode.
Follow the setting for auto power save mode in both
battery service and battery UI. Default level is 15 when
setting is not set; otherwise it is whatever the setting
gives, with 0 meaning auto battery save is off.
Change how we define the "turn off warn" level to be
an adjustment from the warn level, so we can have a good
value for whatever auto setting is set.
Fix power manager to never go in to power save mode when
plugged in, even if the user has manually turned it on.
Add new delete option to settings command, because I needed
it for testing.
Change-Id: I512b691df84399d50b8e751fd50732c6093ebe85
Diffstat (limited to 'services/core/java/com/android/server/power')
-rw-r--r-- | services/core/java/com/android/server/power/PowerManagerService.java | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java index d8671d9..fb4b8f0 100644 --- a/services/core/java/com/android/server/power/PowerManagerService.java +++ b/services/core/java/com/android/server/power/PowerManagerService.java @@ -409,6 +409,9 @@ public final class PowerManagerService extends com.android.server.SystemService // Current state of the low power mode setting. private boolean mLowPowerModeSetting; + // Current state of whether the settings are allowing auto low power mode. + private boolean mAutoLowPowerModeEnabled; + // True if the battery level is currently considered low. private boolean mBatteryLevelLow; @@ -558,6 +561,9 @@ public final class PowerManagerService extends com.android.server.SystemService resolver.registerContentObserver(Settings.Global.getUriFor( Settings.Global.LOW_POWER_MODE), false, mSettingsObserver, UserHandle.USER_ALL); + resolver.registerContentObserver(Settings.Global.getUriFor( + Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL), + false, mSettingsObserver, UserHandle.USER_ALL); // Go. readConfigurationLocked(); updateSettingsLocked(); @@ -645,8 +651,12 @@ public final class PowerManagerService extends com.android.server.SystemService final boolean lowPowerModeEnabled = Settings.Global.getInt(resolver, Settings.Global.LOW_POWER_MODE, 0) != 0; - if (lowPowerModeEnabled != mLowPowerModeSetting) { + final boolean autoLowPowerModeEnabled = Settings.Global.getInt(resolver, + Settings.Global.LOW_POWER_MODE_TRIGGER_LEVEL, 15) != 0; + if (lowPowerModeEnabled != mLowPowerModeSetting + || autoLowPowerModeEnabled != mAutoLowPowerModeEnabled) { mLowPowerModeSetting = lowPowerModeEnabled; + mAutoLowPowerModeEnabled = autoLowPowerModeEnabled; updateLowPowerModeLocked(); } @@ -654,7 +664,8 @@ public final class PowerManagerService extends com.android.server.SystemService } void updateLowPowerModeLocked() { - final boolean lowPowerModeEnabled = mLowPowerModeSetting || mBatteryLevelLow; + final boolean lowPowerModeEnabled = !mIsPowered + && (mLowPowerModeSetting || (mAutoLowPowerModeEnabled && mBatteryLevelLow)); if (mLowPowerModeEnabled != lowPowerModeEnabled) { mLowPowerModeEnabled = lowPowerModeEnabled; powerHintInternal(POWER_HINT_LOW_POWER_MODE, lowPowerModeEnabled ? 1 : 0); @@ -1197,7 +1208,7 @@ public final class PowerManagerService extends com.android.server.SystemService } } - if (oldLevelLow != mBatteryLevelLow) { + if (wasPowered != mIsPowered || oldLevelLow != mBatteryLevelLow) { updateLowPowerModeLocked(); } } @@ -2168,6 +2179,8 @@ public final class PowerManagerService extends com.android.server.SystemService pw.println(" mRequestWaitForNegativeProximity=" + mRequestWaitForNegativeProximity); pw.println(" mSandmanScheduled=" + mSandmanScheduled); pw.println(" mSandmanSummoned=" + mSandmanSummoned); + pw.println(" mLowPowerModeEnabled=" + mLowPowerModeEnabled); + pw.println(" mBatteryLevelLow=" + mBatteryLevelLow); pw.println(" mLastWakeTime=" + TimeUtils.formatUptime(mLastWakeTime)); pw.println(" mLastSleepTime=" + TimeUtils.formatUptime(mLastSleepTime)); pw.println(" mLastUserActivityTime=" + TimeUtils.formatUptime(mLastUserActivityTime)); @@ -2204,6 +2217,8 @@ public final class PowerManagerService extends com.android.server.SystemService pw.println(" mDreamsEnabledSetting=" + mDreamsEnabledSetting); pw.println(" mDreamsActivateOnSleepSetting=" + mDreamsActivateOnSleepSetting); pw.println(" mDreamsActivateOnDockSetting=" + mDreamsActivateOnDockSetting); + pw.println(" mLowPowerModeSetting=" + mLowPowerModeSetting); + pw.println(" mAutoLowPowerModeEnabled=" + mAutoLowPowerModeEnabled); pw.println(" mMinimumScreenOffTimeoutConfig=" + mMinimumScreenOffTimeoutConfig); pw.println(" mMaximumScreenDimDurationConfig=" + mMaximumScreenDimDurationConfig); pw.println(" mMaximumScreenDimRatioConfig=" + mMaximumScreenDimRatioConfig); |