diff options
Diffstat (limited to 'services/java/com/android/server/BatteryService.java')
-rw-r--r-- | services/java/com/android/server/BatteryService.java | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/services/java/com/android/server/BatteryService.java b/services/java/com/android/server/BatteryService.java index 5cf61bd..e6c32d9 100644 --- a/services/java/com/android/server/BatteryService.java +++ b/services/java/com/android/server/BatteryService.java @@ -210,9 +210,6 @@ class BatteryService extends Binder { boolean logOutlier = false; long dischargeDuration = 0; - shutdownIfNoPower(); - shutdownIfOverTemp(); - mBatteryLevelCritical = mBatteryLevel <= CRITICAL_BATTERY_LEVEL; if (mAcOnline) { mPlugType = BatteryManager.BATTERY_PLUGGED_AC; @@ -221,6 +218,19 @@ class BatteryService extends Binder { } else { mPlugType = BATTERY_PLUGGED_NONE; } + + // Let the battery stats keep track of the current level. + try { + mBatteryStats.setBatteryState(mBatteryStatus, mBatteryHealth, + mPlugType, mBatteryLevel, mBatteryTemperature, + mBatteryVoltage); + } catch (RemoteException e) { + // Should never happen. + } + + shutdownIfNoPower(); + shutdownIfOverTemp(); + if (mBatteryStatus != mLastBatteryStatus || mBatteryHealth != mLastBatteryHealth || mBatteryPresent != mLastBatteryPresent || @@ -263,16 +273,6 @@ class BatteryService extends Binder { EventLog.writeEvent(EventLogTags.BATTERY_LEVEL, mBatteryLevel, mBatteryVoltage, mBatteryTemperature); } - if (mBatteryLevel != mLastBatteryLevel && mPlugType == BATTERY_PLUGGED_NONE) { - // If the battery level has changed and we are on battery, update the current level. - // This is used for discharge cycle tracking so this shouldn't be updated while the - // battery is charging. - try { - mBatteryStats.recordCurrentLevel(mBatteryLevel); - } catch (RemoteException e) { - // Should never happen. - } - } if (mBatteryLevelCritical && !mLastBatteryLevelCritical && mPlugType == BATTERY_PLUGGED_NONE) { // We want to make sure we log discharge cycle outliers @@ -342,11 +342,6 @@ class BatteryService extends Binder { Intent intent = new Intent(Intent.ACTION_BATTERY_CHANGED); intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY | Intent.FLAG_RECEIVER_REPLACE_PENDING); - try { - mBatteryStats.setOnBattery(mPlugType == BATTERY_PLUGGED_NONE, mBatteryLevel); - } catch (RemoteException e) { - // Should never happen. - } int icon = getIcon(mBatteryLevel); |