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

Commit d591e540 authored by Dmitri Plotnikov's avatar Dmitri Plotnikov
Browse files

Initialize max history buffer size when reading checkin file

Bug: 270174129
Test: reboot phone, "adb shell dumpsys batterystats --checkin --proto", check logcat
Change-Id: Ib127c12a17eceba721b250ad47f97814cb68a1c6
parent a2041360
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -330,7 +330,10 @@ public class BatteryStatsHistory {
        }
    }

    public BatteryStatsHistory(HistoryStepDetailsCalculator stepDetailsCalculator, Clock clock) {
    public BatteryStatsHistory(int maxHistoryFiles, int maxHistoryBufferSize,
            HistoryStepDetailsCalculator stepDetailsCalculator, Clock clock) {
        mMaxHistoryFiles = maxHistoryFiles;
        mMaxHistoryBufferSize = maxHistoryBufferSize;
        mStepDetailsCalculator = stepDetailsCalculator;
        mTracer = new TraceDelegate();
        mClock = clock;
+8 −4
Original line number Diff line number Diff line
@@ -1743,7 +1743,8 @@ public class BatteryStatsImpl extends BatteryStats {
        if (historyDirectory == null) {
            mCheckinFile = null;
            mStatsFile = null;
            mHistory = new BatteryStatsHistory(mStepDetailsCalculator, mClock);
            mHistory = new BatteryStatsHistory(mConstants.MAX_HISTORY_FILES,
                    mConstants.MAX_HISTORY_BUFFER, mStepDetailsCalculator, mClock);
        } else {
            mCheckinFile = new AtomicFile(new File(historyDirectory, "batterystats-checkin.bin"));
            mStatsFile = new AtomicFile(new File(historyDirectory, "batterystats.bin"));
@@ -10881,14 +10882,17 @@ public class BatteryStatsImpl extends BatteryStats {
        if (systemDir == null) {
            mStatsFile = null;
            mHistory = new BatteryStatsHistory(mStepDetailsCalculator, mClock);
            mCheckinFile = null;
            mDailyFile = null;
            mHistory = new BatteryStatsHistory(mConstants.MAX_HISTORY_FILES,
                    mConstants.MAX_HISTORY_BUFFER, mStepDetailsCalculator, mClock);
        } else {
            mStatsFile = new AtomicFile(new File(systemDir, "batterystats.bin"));
            mCheckinFile = new AtomicFile(new File(systemDir, "batterystats-checkin.bin"));
            mDailyFile = new AtomicFile(new File(systemDir, "batterystats-daily.xml"));
            mHistory = new BatteryStatsHistory(systemDir, mConstants.MAX_HISTORY_FILES,
                    mConstants.MAX_HISTORY_BUFFER, mStepDetailsCalculator, mClock);
        }
        mCheckinFile = new AtomicFile(new File(systemDir, "batterystats-checkin.bin"));
        mDailyFile = new AtomicFile(new File(systemDir, "batterystats-daily.xml"));
        mStartCount++;
        initTimersAndCounters();
        mOnBattery = mOnBatteryInternal = false;