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

This commit is contained in:
Jigar Thakkar
2022-03-22 11:10:28 +00:00
committed by Android (Google) Code Review
2 changed files with 20 additions and 1 deletions

View File

@@ -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;

View File

@@ -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;