AI 144333: Change the way the battery level tracking code works in BatteryStats. Before we simply kept track of the last

2 levels as recorded at plug and unplug events. During charge cycles this would be useful because it would tell us
  what the start and end levels were in the last discharge cycle. However during a discharge cycle this information could
  be misleading as it would give you the level at the last unplug event (beginning the the discharge cycle) and last plug
  event (end of the previous discharge cycle).
  Now we are still keeping track of 2 values, but they are "discharge cycle start level" and "discharge cycle current level".
  During a discharge cycle this will give you the level the current discharge cycle started at, and the current level. During
  a charge cycle the same data will be supplied as before (the start/end of the last discharge cycle).
  B=144249

Automated import of CL 144333
This commit is contained in:
Evan Millar
2009-04-02 16:36:33 -07:00
committed by The Android Open Source Project
parent 655434763f
commit 633a1740ce
5 changed files with 55 additions and 32 deletions

View File

@ -229,6 +229,16 @@ class BatteryService extends Binder {
EventLog.writeEvent(LOG_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