Implement ResetTimeRemaining Method
A dbus method was recently added that supports performing the watchdog
reset and enable in a single action to reduce the amount of the dbus
congestion and improve reliability of watchdog resets. Support this
method as the build would be broken otherwise.
Change-Id: Iac00fc2cf15d4ba06fb67a98e2c29fc3c31b3272
Signed-off-by: William A. Kennington III <wak@google.com>
diff --git a/watchdog.cpp b/watchdog.cpp
index 2bfd9b7..5ba0836 100644
--- a/watchdog.cpp
+++ b/watchdog.cpp
@@ -14,6 +14,15 @@
constexpr auto SYSTEMD_ROOT = "/org/freedesktop/systemd1";
constexpr auto SYSTEMD_INTERFACE = "org.freedesktop.systemd1.Manager";
+void Watchdog::resetTimeRemaining(bool enableWatchdog)
+{
+ timeRemaining(interval());
+ if (enableWatchdog)
+ {
+ enabled(true);
+ }
+}
+
// Enable or disable watchdog
bool Watchdog::enabled(bool value)
{
diff --git a/watchdog.hpp b/watchdog.hpp
index 7603689..e28a751 100644
--- a/watchdog.hpp
+++ b/watchdog.hpp
@@ -66,6 +66,13 @@
tryFallbackOrDisable();
}
+ /** @brief Resets the TimeRemaining to the configured Interval
+ * Optionally enables the watchdog.
+ *
+ * @param[in] enableWatchdog - Should the call enable the watchdog
+ */
+ void resetTimeRemaining(bool enableWatchdog) override;
+
/** @brief Since we are overriding the setter-enabled but not the
* getter-enabled, we need to have this using in order to
* allow passthrough usage of the getter-enabled.