util::dbus: Make common the autorebootEnabled code

Move the code for checking autoreboot property from attention handler
specific code to common utility dbus code.

Signed-off-by: Ben Tyner <ben.tyner@ibm.com>
Change-Id: Ia2b5e4bd3d7baa57ca46600cb5ed150144d5728e
diff --git a/util/dbus.cpp b/util/dbus.cpp
index 968a44f..e9526df 100644
--- a/util/dbus.cpp
+++ b/util/dbus.cpp
@@ -197,6 +197,34 @@
     }
 }
 
+/** @brief Read state of autoreboot propertyi via dbus */
+bool autoRebootEnabled()
+{
+    bool autoReboot = false; // assume autoreboot attribute not available
+
+    constexpr auto interface = "xyz.openbmc_project.Control.Boot.RebootPolicy";
+
+    DBusService service;
+    DBusPath path;
+
+    // find a dbus object and path that implements the interface
+    if (0 == find(interface, path, service))
+    {
+        DBusValue value;
+
+        // autoreboot policy is implemented as a property
+        constexpr auto property = "AutoReboot";
+
+        if (0 == getProperty(interface, path, service, property, value))
+        {
+            // return value is a variant, autoreboot policy is boolean
+            autoReboot = std::get<bool>(value);
+        }
+    }
+
+    return autoReboot;
+}
+
 } // namespace dbus
 
 } // namespace util