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
diff --git a/core/java/android/os/BatteryStats.java b/core/java/android/os/BatteryStats.java
index 17594d4..91fc783 100644
--- a/core/java/android/os/BatteryStats.java
+++ b/core/java/android/os/BatteryStats.java
@@ -472,15 +472,16 @@
     public abstract long getBatteryRealtime(long curTime);
     
     /**
-     * Returns the battery percentage level at the last time the device was unplugged from power, 
-     * or the last time it was booted while unplugged.
+     * Returns the battery percentage level at the last time the device was unplugged from power, or
+     * the last time it booted on battery power. 
      */
-    public abstract int getUnpluggedStartLevel();
+    public abstract int getDischargeStartLevel();
     
     /**
-     * Returns the battery percentage level at the last time the device was plugged into power.
+     * Returns the current battery percentage level if we are in a discharge cycle, otherwise
+     * returns the level at the last plug event.
      */
-    public abstract int getPluggedStartLevel();
+    public abstract int getDischargeCurrentLevel();
 
     /**
      * Returns the total, last, or current battery uptime in microseconds.
@@ -774,8 +775,8 @@
         dumpLine(pw, 0 /* uid */, category, DATA_CONNECTION_COUNT_DATA, args);
         
         if (which == STATS_UNPLUGGED) {
-            dumpLine(pw, 0 /* uid */, category, BATTERY_DATA, getUnpluggedStartLevel(), 
-                    getPluggedStartLevel());
+            dumpLine(pw, 0 /* uid */, category, BATTERY_DATA, getDischargeStartLevel(), 
+                    getDischargeCurrentLevel());
         }
         
         for (int iu = 0; iu < NU; iu++) {
@@ -1059,13 +1060,15 @@
             if (getIsOnBattery()) {
                 pw.println(prefix + "  Device is currently unplugged");
                 pw.println(prefix + "    Discharge cycle start level: " + 
-                        getUnpluggedStartLevel());
+                        getDischargeStartLevel());
+                pw.println(prefix + "    Discharge cycle current level: " +
+                        getDischargeCurrentLevel());
             } else {
                 pw.println(prefix + "  Device is currently plugged into power");
                 pw.println(prefix + "    Last discharge cycle start level: " + 
-                        getUnpluggedStartLevel());
+                        getDischargeStartLevel());
                 pw.println(prefix + "    Last discharge cycle end level: " + 
-                        getPluggedStartLevel());
+                        getDischargeCurrentLevel());
             }
             pw.println(" ");
         }