Make non-volatile directory platform-specific.
update_engine daemon needs to persist files (such as the progress of
the update) in a non-volatile storage and also used to store a
marker file on a volatile storage to detect when update_engine is
restarted, likelly due to a crash.
This patch moves the non-volatile directory configuration to the
Hardware interface, making it platform-specific. It also replaces the
system rebooted detection using the boot_id provided by the kernel
instead of storing a file under /tmp. This implementation works both
on Chrome OS and Android.
Bug: 24074252
Test: FEATURES=test emerge-link update_engine; `mma`; deployed and tested manually on brillo.
Change-Id: I921d767982adebfd04eb12e08d8a157d9102d1e3
diff --git a/mock_hardware.h b/mock_hardware.h
index e082a4f..ff387f4 100644
--- a/mock_hardware.h
+++ b/mock_hardware.h
@@ -51,6 +51,12 @@
ON_CALL(*this, GetPowerwashCount())
.WillByDefault(testing::Invoke(&fake_,
&FakeHardware::GetPowerwashCount));
+ ON_CALL(*this, GetNonVolatileDirectory(testing::_))
+ .WillByDefault(testing::Invoke(&fake_,
+ &FakeHardware::GetNonVolatileDirectory));
+ ON_CALL(*this, GetPowerwashSafeDirectory(testing::_))
+ .WillByDefault(testing::Invoke(&fake_,
+ &FakeHardware::GetPowerwashSafeDirectory));
}
~MockHardware() override = default;
@@ -63,6 +69,8 @@
MOCK_CONST_METHOD0(GetFirmwareVersion, std::string());
MOCK_CONST_METHOD0(GetECVersion, std::string());
MOCK_CONST_METHOD0(GetPowerwashCount, int());
+ MOCK_CONST_METHOD1(GetNonVolatileDirectory, bool(base::FilePath*));
+ MOCK_CONST_METHOD1(GetPowerwashSafeDirectory, bool(base::FilePath*));
// Returns a reference to the underlying FakeHardware.
FakeHardware& fake() {