summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorImre Sunyi <imre.sunyi@sonyericsson.com>2010-08-30 13:28:16 -0700
committerAndroid Git Automerger <android-git-automerger@android.com>2010-08-30 13:28:16 -0700
commitec959a7e38d4a6551bb18e096a912ff8c75c50b3 (patch)
tree31b372d59925a148239f02fd83864bebf007b298 /services
parent7dff1a72146ba549d51649ad786a0e1cc8b6897c (diff)
parent1429f465f42bb9e3ef3ecfd1ee9af214901fc999 (diff)
downloadframeworks_base-ec959a7e38d4a6551bb18e096a912ff8c75c50b3.zip
frameworks_base-ec959a7e38d4a6551bb18e096a912ff8c75c50b3.tar.gz
frameworks_base-ec959a7e38d4a6551bb18e096a912ff8c75c50b3.tar.bz2
am 1429f465: am fd04143a: Shutdown when capacity is 0% and no charging or when battery is dead
Merge commit '1429f465f42bb9e3ef3ecfd1ee9af214901fc999' * commit '1429f465f42bb9e3ef3ecfd1ee9af214901fc999': Shutdown when capacity is 0% and no charging or when battery is dead
Diffstat (limited to 'services')
-rw-r--r--services/java/com/android/server/BatteryService.java20
1 files changed, 16 insertions, 4 deletions
diff --git a/services/java/com/android/server/BatteryService.java b/services/java/com/android/server/BatteryService.java
index e6c32d9..1b22236 100644
--- a/services/java/com/android/server/BatteryService.java
+++ b/services/java/com/android/server/BatteryService.java
@@ -136,7 +136,13 @@ class BatteryService extends Binder {
final boolean isPowered() {
// assume we are powered if battery state is unknown so the "stay on while plugged in" option will work.
- return (mAcOnline || mUsbOnline || mBatteryStatus == BatteryManager.BATTERY_STATUS_UNKNOWN);
+ // Do not look at the plug status to check if we are powered.
+ // Charger can be plugged but not charging because of i.e. USB suspend,
+ // battery temperature reasons etc. We are powered only if battery is
+ // being charged. This function fill return false if charger is
+ // connected and battery is reported full.
+ return (mBatteryStatus == BatteryManager.BATTERY_STATUS_CHARGING ||
+ mBatteryStatus == BatteryManager.BATTERY_STATUS_UNKNOWN);
}
final boolean isPowered(int plugTypeSet) {
@@ -148,11 +154,13 @@ class BatteryService extends Binder {
if (plugTypeSet == 0) {
return false;
}
+
+ // we are not powered when plug is connected and not charging
int plugTypeBit = 0;
- if (mAcOnline) {
+ if (mAcOnline && mBatteryStatus == BatteryManager.BATTERY_STATUS_CHARGING) {
plugTypeBit |= BatteryManager.BATTERY_PLUGGED_AC;
}
- if (mUsbOnline) {
+ if (mUsbOnline && mBatteryStatus == BatteryManager.BATTERY_STATUS_CHARGING) {
plugTypeBit |= BatteryManager.BATTERY_PLUGGED_USB;
}
return (plugTypeSet & plugTypeBit) != 0;
@@ -183,7 +191,11 @@ class BatteryService extends Binder {
private final void shutdownIfNoPower() {
// shut down gracefully if our battery is critically low and we are not powered.
// wait until the system has booted before attempting to display the shutdown dialog.
- if (mBatteryLevel == 0 && !isPowered() && ActivityManagerNative.isSystemReady()) {
+ // Also shutdown if battery is reported to be 'dead' independent of
+ // battery level and power supply.
+ if (((mBatteryLevel == 0 && !isPowered()) ||
+ mBatteryHealth == BatteryManager.BATTERY_HEALTH_DEAD) &&
+ ActivityManagerNative.isSystemReady()) {
Intent intent = new Intent(Intent.ACTION_REQUEST_SHUTDOWN);
intent.putExtra(Intent.EXTRA_KEY_CONFIRM, false);
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);