Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 240a70f1 authored by Lei Yu's avatar Lei Yu Committed by android-build-merger
Browse files

Merge "Write currentDuration into Parcel" into oc-mr1-dev

am: bd6ff3d3

Change-Id: Ibaf3f44a9449a4f92abf3359fba8329f1cbca245
parents 5c6c1c9c bd6ff3d3
Loading
Loading
Loading
Loading
+8 −2
Original line number Diff line number Diff line
@@ -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;
@@ -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,
@@ -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));
        }

        /**
@@ -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) {
+5 −4
Original line number Diff line number Diff line
@@ -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
@@ -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));