am 156c9cc2: Merge "Disable screensavers if below first battery warning level." into jb-mr1-dev
* commit '156c9cc2bfda211132a6c3a6d990702e1f317a8f': Disable screensavers if below first battery warning level.
This commit is contained in:
@@ -204,6 +204,11 @@ public class BatteryService extends Binder {
|
||||
return mBatteryLevel;
|
||||
}
|
||||
|
||||
// true if battery level is below the first warning threshold
|
||||
public final boolean isBatteryLow() {
|
||||
return mBatteryPresent && mBatteryLevel <= mLowBatteryWarningLevel;
|
||||
}
|
||||
|
||||
void systemReady() {
|
||||
// check our power situation now that it is safe to display the shutdown dialog.
|
||||
shutdownIfNoPower();
|
||||
|
||||
@@ -1137,7 +1137,7 @@ public final class PowerManagerService extends IPowerManager.Stub
|
||||
*/
|
||||
private void updateDreamLocked(int dirty) {
|
||||
if ((dirty & (DIRTY_WAKEFULNESS | DIRTY_SETTINGS
|
||||
| DIRTY_IS_POWERED | DIRTY_STAY_ON)) != 0) {
|
||||
| DIRTY_IS_POWERED | DIRTY_STAY_ON | DIRTY_BATTERY_STATE)) != 0) {
|
||||
scheduleSandmanLocked();
|
||||
}
|
||||
}
|
||||
@@ -1163,13 +1163,13 @@ public final class PowerManagerService extends IPowerManager.Stub
|
||||
boolean startDreaming = false;
|
||||
synchronized (mLock) {
|
||||
mSandmanScheduled = false;
|
||||
|
||||
boolean canDream = canDreamLocked();
|
||||
if (DEBUG_SPEW) {
|
||||
Log.d(TAG, "handleSandman: canDream=" + canDreamLocked()
|
||||
Log.d(TAG, "handleSandman: canDream=" + canDream
|
||||
+ ", mWakefulness=" + wakefulnessToString(mWakefulness));
|
||||
}
|
||||
|
||||
if (canDreamLocked() && mWakefulness == WAKEFULNESS_NAPPING) {
|
||||
if (canDream && mWakefulness == WAKEFULNESS_NAPPING) {
|
||||
startDreaming = true;
|
||||
}
|
||||
}
|
||||
@@ -1253,8 +1253,11 @@ public final class PowerManagerService extends IPowerManager.Stub
|
||||
* assuming there has been no recent user activity and no wake locks are held.
|
||||
*/
|
||||
private boolean canDreamLocked() {
|
||||
return mIsPowered && mDreamsSupportedConfig
|
||||
&& mDreamsEnabledSetting && mDreamsActivateOnSleepSetting;
|
||||
return mIsPowered
|
||||
&& mDreamsSupportedConfig
|
||||
&& mDreamsEnabledSetting
|
||||
&& mDreamsActivateOnSleepSetting
|
||||
&& !mBatteryService.isBatteryLow();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user