diff options
author | Dianne Hackborn <hackbod@google.com> | 2009-09-22 17:27:53 -0700 |
---|---|---|
committer | Dianne Hackborn <hackbod@google.com> | 2009-09-22 18:59:35 -0700 |
commit | 99f7eb453cee23e13f3ac8a4fa0632dd28f3a4b8 (patch) | |
tree | 5e76417979d27834989332e4539aa60090ad6ec1 /services/java | |
parent | df5862173c03f0d9595a2a5cb56c4af407d893dd (diff) | |
download | frameworks_base-99f7eb453cee23e13f3ac8a4fa0632dd28f3a4b8.zip frameworks_base-99f7eb453cee23e13f3ac8a4fa0632dd28f3a4b8.tar.gz frameworks_base-99f7eb453cee23e13f3ac8a4fa0632dd28f3a4b8.tar.bz2 |
Dock screen on config can now select AC or USB.
Change-Id: Ifae9af4eb0295ba8e46c65879440b0da543b18e6
Diffstat (limited to 'services/java')
-rw-r--r-- | services/java/com/android/server/BatteryService.java | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/services/java/com/android/server/BatteryService.java b/services/java/com/android/server/BatteryService.java index d78d886..53edf31 100644 --- a/services/java/com/android/server/BatteryService.java +++ b/services/java/com/android/server/BatteryService.java @@ -267,6 +267,20 @@ class BatteryService extends Binder { logOutlier = true; } + final boolean plugged = mPlugType != BATTERY_PLUGGED_NONE; + final boolean oldPlugged = mLastPlugType != BATTERY_PLUGGED_NONE; + + /* The ACTION_BATTERY_LOW broadcast is sent in these situations: + * - is just un-plugged (previously was plugged) and battery level is under WARNING, or + * - is not plugged and battery level crosses the WARNING boundary (becomes < 15). + */ + final boolean sendBatteryLow = !plugged + && mBatteryStatus != BatteryManager.BATTERY_STATUS_UNKNOWN + && mBatteryLevel < BATTERY_LEVEL_WARNING + && (oldPlugged || mLastBatteryLevel >= BATTERY_LEVEL_WARNING); + + sendIntent(); + // Separate broadcast is sent for power connected / not connected // since the standard intent will not wake any applications and some // applications may want to have smart behavior based on this. @@ -281,28 +295,6 @@ class BatteryService extends Binder { mContext.sendBroadcast(statusIntent); } - final boolean plugged = mPlugType != BATTERY_PLUGGED_NONE; - final boolean oldPlugged = mLastPlugType != BATTERY_PLUGGED_NONE; - - /* The ACTION_BATTERY_LOW broadcast is sent in these situations: - * - is just un-plugged (previously was plugged) and battery level is under WARNING, or - * - is not plugged and battery level crosses the WARNING boundary (becomes < 15). - */ - final boolean sendBatteryLow = !plugged - && mBatteryStatus != BatteryManager.BATTERY_STATUS_UNKNOWN - && mBatteryLevel < BATTERY_LEVEL_WARNING - && (oldPlugged || mLastBatteryLevel >= BATTERY_LEVEL_WARNING); - - mLastBatteryStatus = mBatteryStatus; - mLastBatteryHealth = mBatteryHealth; - mLastBatteryPresent = mBatteryPresent; - mLastBatteryLevel = mBatteryLevel; - mLastPlugType = mPlugType; - mLastBatteryVoltage = mBatteryVoltage; - mLastBatteryTemperature = mBatteryTemperature; - mLastBatteryLevelCritical = mBatteryLevelCritical; - - sendIntent(); if (sendBatteryLow) { mSentLowBatteryBroadcast = true; statusIntent.setAction(Intent.ACTION_BATTERY_LOW); @@ -317,6 +309,15 @@ class BatteryService extends Binder { if (logOutlier && dischargeDuration != 0) { logOutlier(dischargeDuration); } + + mLastBatteryStatus = mBatteryStatus; + mLastBatteryHealth = mBatteryHealth; + mLastBatteryPresent = mBatteryPresent; + mLastBatteryLevel = mBatteryLevel; + mLastPlugType = mPlugType; + mLastBatteryVoltage = mBatteryVoltage; + mLastBatteryTemperature = mBatteryTemperature; + mLastBatteryLevelCritical = mBatteryLevelCritical; } } |