Loading core/java/com/android/internal/os/BatteryStatsImpl.java +8 −2 Original line number Diff line number Diff line Loading @@ -119,7 +119,7 @@ public class BatteryStatsImpl extends BatteryStats { private static final int MAGIC = 0xBA757475; // 'BATSTATS' // Current on-disk Parcel version private static final int VERSION = 164 + (USE_OLD_HISTORY ? 1000 : 0); private static final int VERSION = 165 + (USE_OLD_HISTORY ? 1000 : 0); // Maximum number of items we will record in the history. private static final int MAX_HISTORY_ITEMS; Loading Loading @@ -1827,6 +1827,7 @@ public class BatteryStatsImpl extends BatteryStats { super(clocks, uid, type, timerPool, timeBase, in); mMaxDurationMs = in.readLong(); mTotalDurationMs = in.readLong(); mCurrentDurationMs = in.readLong(); } public DurationTimer(Clocks clocks, Uid uid, int type, ArrayList<StopwatchTimer> timerPool, Loading @@ -1838,7 +1839,8 @@ public class BatteryStatsImpl extends BatteryStats { public void writeToParcel(Parcel out, long elapsedRealtimeUs) { super.writeToParcel(out, elapsedRealtimeUs); out.writeLong(getMaxDurationMsLocked(elapsedRealtimeUs / 1000)); out.writeLong(getTotalDurationMsLocked(elapsedRealtimeUs / 1000)); out.writeLong(mTotalDurationMs); out.writeLong(getCurrentDurationMsLocked(elapsedRealtimeUs / 1000)); } /** Loading Loading @@ -1969,6 +1971,10 @@ public class BatteryStatsImpl extends BatteryStats { * * Note that this time is NOT split between the timers in the timer group that * this timer is attached to. It is the TOTAL time. * * Note that if running timer is parceled and unparceled, this method will return * current duration value at the time of parceling even though timer may not be * currently running. */ @Override public long getCurrentDurationMsLocked(long elapsedRealtimeMs) { Loading core/tests/coretests/src/com/android/internal/os/BatteryStatsDurationTimerTest.java +5 −4 Original line number Diff line number Diff line Loading @@ -134,7 +134,8 @@ public class BatteryStatsDurationTimerTest extends TestCase { null, BatteryStats.WAKE_TYPE_PARTIAL, null, timeBase); summary.startRunningLocked(3100); summary.readSummaryFromParcelLocked(summaryParcel); // The new one shouldn't be running, and therefore 0 for current time // The new one shouldn't be running, and therefore 0 for current time if using // summary parcel assertFalse(summary.isRunningLocked()); assertEquals(0, summary.getCurrentDurationMsLocked(6300)); // The new one should have the max and total durations that we had when we wrote it Loading @@ -149,10 +150,10 @@ public class BatteryStatsDurationTimerTest extends TestCase { // Read full - Should be the same as the summary as far as DurationTimer is concerned. final BatteryStatsImpl.DurationTimer full = new BatteryStatsImpl.DurationTimer(clocks, null, BatteryStats.WAKE_TYPE_PARTIAL, null, timeBase, fullParcel); // The new one shouldn't be running, and therefore 0 for current time // The new one shouldn't be running assertFalse(full.isRunningLocked()); assertEquals(0, full.getCurrentDurationMsLocked(6300)); // The new one should have the max and total durations that we had when we wrote it // The new one should have the current, max and total durations that we had when we wrote it assertEquals(1200, full.getCurrentDurationMsLocked(6300)); assertEquals(1200, full.getMaxDurationMsLocked(6301)); assertEquals(1200, full.getTotalDurationMsLocked(6302)); Loading Loading
core/java/com/android/internal/os/BatteryStatsImpl.java +8 −2 Original line number Diff line number Diff line Loading @@ -119,7 +119,7 @@ public class BatteryStatsImpl extends BatteryStats { private static final int MAGIC = 0xBA757475; // 'BATSTATS' // Current on-disk Parcel version private static final int VERSION = 164 + (USE_OLD_HISTORY ? 1000 : 0); private static final int VERSION = 165 + (USE_OLD_HISTORY ? 1000 : 0); // Maximum number of items we will record in the history. private static final int MAX_HISTORY_ITEMS; Loading Loading @@ -1827,6 +1827,7 @@ public class BatteryStatsImpl extends BatteryStats { super(clocks, uid, type, timerPool, timeBase, in); mMaxDurationMs = in.readLong(); mTotalDurationMs = in.readLong(); mCurrentDurationMs = in.readLong(); } public DurationTimer(Clocks clocks, Uid uid, int type, ArrayList<StopwatchTimer> timerPool, Loading @@ -1838,7 +1839,8 @@ public class BatteryStatsImpl extends BatteryStats { public void writeToParcel(Parcel out, long elapsedRealtimeUs) { super.writeToParcel(out, elapsedRealtimeUs); out.writeLong(getMaxDurationMsLocked(elapsedRealtimeUs / 1000)); out.writeLong(getTotalDurationMsLocked(elapsedRealtimeUs / 1000)); out.writeLong(mTotalDurationMs); out.writeLong(getCurrentDurationMsLocked(elapsedRealtimeUs / 1000)); } /** Loading Loading @@ -1969,6 +1971,10 @@ public class BatteryStatsImpl extends BatteryStats { * * Note that this time is NOT split between the timers in the timer group that * this timer is attached to. It is the TOTAL time. * * Note that if running timer is parceled and unparceled, this method will return * current duration value at the time of parceling even though timer may not be * currently running. */ @Override public long getCurrentDurationMsLocked(long elapsedRealtimeMs) { Loading
core/tests/coretests/src/com/android/internal/os/BatteryStatsDurationTimerTest.java +5 −4 Original line number Diff line number Diff line Loading @@ -134,7 +134,8 @@ public class BatteryStatsDurationTimerTest extends TestCase { null, BatteryStats.WAKE_TYPE_PARTIAL, null, timeBase); summary.startRunningLocked(3100); summary.readSummaryFromParcelLocked(summaryParcel); // The new one shouldn't be running, and therefore 0 for current time // The new one shouldn't be running, and therefore 0 for current time if using // summary parcel assertFalse(summary.isRunningLocked()); assertEquals(0, summary.getCurrentDurationMsLocked(6300)); // The new one should have the max and total durations that we had when we wrote it Loading @@ -149,10 +150,10 @@ public class BatteryStatsDurationTimerTest extends TestCase { // Read full - Should be the same as the summary as far as DurationTimer is concerned. final BatteryStatsImpl.DurationTimer full = new BatteryStatsImpl.DurationTimer(clocks, null, BatteryStats.WAKE_TYPE_PARTIAL, null, timeBase, fullParcel); // The new one shouldn't be running, and therefore 0 for current time // The new one shouldn't be running assertFalse(full.isRunningLocked()); assertEquals(0, full.getCurrentDurationMsLocked(6300)); // The new one should have the max and total durations that we had when we wrote it // The new one should have the current, max and total durations that we had when we wrote it assertEquals(1200, full.getCurrentDurationMsLocked(6300)); assertEquals(1200, full.getMaxDurationMsLocked(6301)); assertEquals(1200, full.getTotalDurationMsLocked(6302)); Loading