Move IsOOBEComplete to HardwareInterface.
This patch moves the mockable IsOOBEComplete to the HardwareInterface
which already has a fake implemented. This is required as a first
step to make it available on the PolicyManager.
This patch also passes a null pointer when the timestamp isn't
required.
BUG=chromium:358269
TEST=Unittests adjusted and passing.
Change-Id: I620e0f4521832b3f2c0170811116251cdfe58f26
Reviewed-on: https://chromium-review.googlesource.com/193101
Reviewed-by: David Zeuthen <[email protected]>
Tested-by: Alex Deymo <[email protected]>
Commit-Queue: Alex Deymo <[email protected]>
diff --git a/hardware.cc b/hardware.cc
index f094d97..5d5492f 100644
--- a/hardware.cc
+++ b/hardware.cc
@@ -27,6 +27,12 @@
using std::string;
using std::vector;
+namespace {
+
+static const char kOOBECompletedMarker[] = "/home/chronos/.oobe_completed";
+
+} // namespace
+
namespace chromeos_update_engine {
Hardware::Hardware() {}
@@ -145,6 +151,21 @@
return !dev_mode;
}
+bool Hardware::IsOOBEComplete(base::Time* out_time_of_oobe) const {
+ struct stat statbuf;
+ if (stat(kOOBECompletedMarker, &statbuf) != 0) {
+ if (errno != ENOENT) {
+ PLOG(ERROR) << "Error getting information about "
+ << kOOBECompletedMarker;
+ }
+ return false;
+ }
+
+ if (out_time_of_oobe != nullptr)
+ *out_time_of_oobe = base::Time::FromTimeT(statbuf.st_mtime);
+ return true;
+}
+
static string ReadValueFromCrosSystem(const string& key) {
char value_buffer[VB_MAX_STRING_PROPERTY];