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

Commit 15d9e170 authored by Jigar Thakkar's avatar Jigar Thakkar Committed by Android (Google) Code Review
Browse files

Merge "Fix BatteryStatsHistoryTest for low ram devices" into tm-dev

parents ace23e0e 4f195150
Loading
Loading
Loading
Loading
+7 −1
Original line number Diff line number Diff line
@@ -45,7 +45,13 @@ import org.mockito.MockitoAnnotations;
public class BatteryStatsHistoryTest {
    private static final String TAG = "BatteryStatsHistoryTest";
    private static final int MAX_HISTORY_FILES = 32;
    private final BatteryStatsImpl mBatteryStatsImpl = new MockBatteryStatsImpl();
    private static final int MAX_HISTORY_BUFFER_KB = 128;

    // Initializing max history files and buffer to the default values of non-low-ram device
    // to maintain consistency in the tests
    private final BatteryStatsImpl mBatteryStatsImpl = new MockBatteryStatsImpl()
            .setMaxHistoryFiles(MAX_HISTORY_FILES)
            .setMaxHistoryBuffer(MAX_HISTORY_BUFFER_KB * 1024);
    private final Parcel mHistoryBuffer = Parcel.obtain();
    private File mSystemDir;
    private File mHistoryDir;
+13 −0
Original line number Diff line number Diff line
@@ -26,6 +26,7 @@ import android.net.NetworkStats;
import android.os.Handler;
import android.os.Looper;

import com.android.internal.annotations.GuardedBy;
import com.android.internal.os.KernelCpuUidTimeReader.KernelCpuUidActiveTimeReader;
import com.android.internal.os.KernelCpuUidTimeReader.KernelCpuUidClusterTimeReader;
import com.android.internal.os.KernelCpuUidTimeReader.KernelCpuUidFreqTimeReader;
@@ -193,6 +194,18 @@ public class MockBatteryStatsImpl extends BatteryStatsImpl {
        return this;
    }

    @GuardedBy("this")
    public MockBatteryStatsImpl setMaxHistoryFiles(int maxHistoryFiles) {
        mConstants.MAX_HISTORY_FILES = maxHistoryFiles;
        return this;
    }

    @GuardedBy("this")
    public MockBatteryStatsImpl setMaxHistoryBuffer(int maxHistoryBuffer) {
        mConstants.MAX_HISTORY_BUFFER = maxHistoryBuffer;
        return this;
    }

    public int getAndClearExternalStatsSyncFlags() {
        final int flags = mExternalStatsSync.flags;
        mExternalStatsSync.flags = 0;