Make the dbushelper own its own bus handle.

The dbushelper implements an interface that should not be sdbusplus
specific. By making the implementation own the sdbusplus aspects, an
alternate implementation can be swapped in.

Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: I4109772499421e2e6497a0fcad663ebbd1210a7c
diff --git a/sensors/builder.cpp b/sensors/builder.cpp
index 39e35f2..de7e020 100644
--- a/sensors/builder.cpp
+++ b/sensors/builder.cpp
@@ -16,6 +16,7 @@
 
 #include <iostream>
 #include <map>
+#include <memory>
 #include <string>
 
 /* Configuration. */
@@ -40,7 +41,6 @@
 {
 
 static constexpr bool deferSignals = true;
-static DbusHelper helper;
 
 SensorManager
     buildSensors(const std::map<std::string, struct conf::SensorConfig>& config,
@@ -81,14 +81,18 @@
                 if (info->type == "fan")
                 {
                     ri = DbusPassive::createDbusPassive(
-                        passiveListeningBus, info->type, name, &helper, info,
-                        redundancy);
+                        passiveListeningBus, info->type, name,
+                        std::make_unique<DbusHelper>(
+                            sdbusplus::bus::new_system()),
+                        info, redundancy);
                 }
                 else
                 {
-                    ri = DbusPassive::createDbusPassive(passiveListeningBus,
-                                                        info->type, name,
-                                                        &helper, info, nullptr);
+                    ri = DbusPassive::createDbusPassive(
+                        passiveListeningBus, info->type, name,
+                        std::make_unique<DbusHelper>(
+                            sdbusplus::bus::new_system()),
+                        info, nullptr);
                 }
                 if (ri == nullptr)
                 {
@@ -129,12 +133,16 @@
                     if (info->max > 0)
                     {
                         wi = DbusWritePercent::createDbusWrite(
-                            info->writePath, info->min, info->max, helper);
+                            info->writePath, info->min, info->max,
+                            std::make_unique<DbusHelper>(
+                                sdbusplus::bus::new_system()));
                     }
                     else
                     {
                         wi = DbusWrite::createDbusWrite(
-                            info->writePath, info->min, info->max, helper);
+                            info->writePath, info->min, info->max,
+                            std::make_unique<DbusHelper>(
+                                sdbusplus::bus::new_system()));
                     }
 
                     if (wi == nullptr)