Add 10 minute random fuzz to automatic update check event schedule.
Schedules the initial check at 7 minutes and periodic checks at 45 minutes
with +/- 5 minute fuzz.
BUG=5983
TEST=unit tests, gmerged on device, inspected logs, observed checks
Change-Id: Ifd38574c4265fec78f6e330f965c2b1054b2dddb
Review URL: http://codereview.chromium.org/3173041
diff --git a/utils.cc b/utils.cc
index cf1c3f5..246bfaa 100644
--- a/utils.cc
+++ b/utils.cc
@@ -20,6 +20,7 @@
#include "base/file_path.h"
#include "base/file_util.h"
+#include "base/rand_util.h"
#include "base/string_util.h"
#include "base/logging.h"
#include "update_engine/file_writer.h"
@@ -457,6 +458,12 @@
return static_cast<int>(priority_rhs) - static_cast<int>(priority_lhs);
}
+int FuzzInt(int value, unsigned int range) {
+ int min = value - range / 2;
+ int max = value + range - range / 2;
+ return base::RandInt(min, max);
+}
+
const char* const kStatefulPartition = "/mnt/stateful_partition";
} // namespace utils