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;
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,
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));
}
/**
*
* 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) {
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
// 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));