Skip to content

Commit d3e803a

Browse files
author
Jean-Baptiste Queru
committed
Revert "Shutdown when capacity is 0% and no charging or when battery is dead"
This reverts commit fd04143. This break most automated tests because with this change, if the device is fully charged, it will simply turn off the screen, regardless if USB is connected to hsot PC or not; so for our tests, most of them are always connected to host PC, and fully charged 99% of the time, as soon as the screen turns off, the front-end test Activity will be suspended. Change-Id: I1e6590611af43812f1bac223dd31570d1d90cfc5
1 parent 12dbee8 commit d3e803a

File tree

1 file changed

+4
-16
lines changed

1 file changed

+4
-16
lines changed

services/java/com/android/server/BatteryService.java

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -136,13 +136,7 @@ public BatteryService(Context context) {
136136

137137
final boolean isPowered() {
138138
// assume we are powered if battery state is unknown so the "stay on while plugged in" option will work.
139-
// Do not look at the plug status to check if we are powered.
140-
// Charger can be plugged but not charging because of i.e. USB suspend,
141-
// battery temperature reasons etc. We are powered only if battery is
142-
// being charged. This function fill return false if charger is
143-
// connected and battery is reported full.
144-
return (mBatteryStatus == BatteryManager.BATTERY_STATUS_CHARGING ||
145-
mBatteryStatus == BatteryManager.BATTERY_STATUS_UNKNOWN);
139+
return (mAcOnline || mUsbOnline || mBatteryStatus == BatteryManager.BATTERY_STATUS_UNKNOWN);
146140
}
147141

148142
final boolean isPowered(int plugTypeSet) {
@@ -154,13 +148,11 @@ final boolean isPowered(int plugTypeSet) {
154148
if (plugTypeSet == 0) {
155149
return false;
156150
}
157-
158-
// we are not powered when plug is connected and not charging
159151
int plugTypeBit = 0;
160-
if (mAcOnline && mBatteryStatus == BatteryManager.BATTERY_STATUS_CHARGING) {
152+
if (mAcOnline) {
161153
plugTypeBit |= BatteryManager.BATTERY_PLUGGED_AC;
162154
}
163-
if (mUsbOnline && mBatteryStatus == BatteryManager.BATTERY_STATUS_CHARGING) {
155+
if (mUsbOnline) {
164156
plugTypeBit |= BatteryManager.BATTERY_PLUGGED_USB;
165157
}
166158
return (plugTypeSet & plugTypeBit) != 0;
@@ -191,11 +183,7 @@ void systemReady() {
191183
private final void shutdownIfNoPower() {
192184
// shut down gracefully if our battery is critically low and we are not powered.
193185
// wait until the system has booted before attempting to display the shutdown dialog.
194-
// Also shutdown if battery is reported to be 'dead' independent of
195-
// battery level and power supply.
196-
if (((mBatteryLevel == 0 && !isPowered()) ||
197-
mBatteryHealth == BatteryManager.BATTERY_HEALTH_DEAD) &&
198-
ActivityManagerNative.isSystemReady()) {
186+
if (mBatteryLevel == 0 && !isPowered() && ActivityManagerNative.isSystemReady()) {
199187
Intent intent = new Intent(Intent.ACTION_REQUEST_SHUTDOWN);
200188
intent.putExtra(Intent.EXTRA_KEY_CONFIRM, false);
201189
intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK);

0 commit comments

Comments
 (0)