Special interval value to always run benchmarks.

When interval is set of 0, always run benchmarks after every fstrim
pass, which is roughly daily.  We don't actually track the last
benchmark time for internal storage, so this is the best way we have
to enable this.

Also disable benchmarking completely when interval is set to -1.

Bug: 23942769
Change-Id: I11edfda063aac6e927c6cce56567169ebe83cb71
This commit is contained in:
Jeff Sharkey
2015-09-09 14:53:38 -07:00
parent ebd1465885
commit e83d8a993d

View File

@@ -368,11 +368,17 @@ class MountService extends IMountService.Stub
private boolean shouldBenchmark() {
final long benchInterval = Settings.Global.getLong(mContext.getContentResolver(),
Settings.Global.STORAGE_BENCHMARK_INTERVAL, DateUtils.WEEK_IN_MILLIS);
if (benchInterval == -1) {
return false;
} else if (benchInterval == 0) {
return true;
}
synchronized (mLock) {
for (int i = 0; i < mVolumes.size(); i++) {
final VolumeInfo vol = mVolumes.valueAt(i);
final VolumeRecord rec = mRecords.get(vol.fsUuid);
if (vol.isMountedReadable() && rec != null) {
if (vol.isMountedWritable() && rec != null) {
final long benchAge = System.currentTimeMillis() - rec.lastBenchMillis;
if (benchAge >= benchInterval) {
return true;