dbushelper: drop obsolete parameter from interface

Signed-off-by: Patrick Venture <venture@google.com>
Change-Id: Idebae41e021f54c3670cc22aa6c784549a361c23
diff --git a/dbus/dbusactiveread.cpp b/dbus/dbusactiveread.cpp
index b21922c..689a85d 100644
--- a/dbus/dbusactiveread.cpp
+++ b/dbus/dbusactiveread.cpp
@@ -31,7 +31,7 @@
     struct SensorProperties settings;
     double value;
 
-    _helper->getProperties(_bus, _service, _path, &settings);
+    _helper->getProperties(_service, _path, &settings);
 
     value = settings.value * pow(10, settings.scale);
 
diff --git a/dbus/dbusconfiguration.cpp b/dbus/dbusconfiguration.cpp
index 341a204..bcdea89 100644
--- a/dbus/dbusconfiguration.cpp
+++ b/dbus/dbusconfiguration.cpp
@@ -392,12 +392,12 @@
         const std::string& path = sensorConfig[info.inputs.front()].readPath;
 
         DbusHelper helper(sdbusplus::bus::new_system());
-        std::string service = helper.getService(bus, interface, path);
+        std::string service = helper.getService(interface, path);
         double reading = 0;
         try
         {
-            helper.getProperty(bus, service, path, interface,
-                               *thresholdProperty, reading);
+            helper.getProperty(service, path, interface, *thresholdProperty,
+                               reading);
         }
         catch (const sdbusplus::exception::SdBusError& ex)
         {
diff --git a/dbus/dbushelper.cpp b/dbus/dbushelper.cpp
index f8f087d..f7dbe41 100644
--- a/dbus/dbushelper.cpp
+++ b/dbus/dbushelper.cpp
@@ -39,8 +39,7 @@
 /* TODO(venture): Basically all phosphor apps need this, maybe it should be a
  * part of sdbusplus.  There is an old version in libmapper.
  */
-std::string DbusHelper::getService(sdbusplus::bus::bus& bus,
-                                   const std::string& intf,
+std::string DbusHelper::getService(const std::string& intf,
                                    const std::string& path)
 {
     auto mapper =
@@ -74,8 +73,7 @@
     return response.begin()->first;
 }
 
-void DbusHelper::getProperties(sdbusplus::bus::bus& bus,
-                               const std::string& service,
+void DbusHelper::getProperties(const std::string& service,
                                const std::string& path,
                                struct SensorProperties* prop)
 {
@@ -136,8 +134,7 @@
     return;
 }
 
-bool DbusHelper::thresholdsAsserted(sdbusplus::bus::bus& bus,
-                                    const std::string& service,
+bool DbusHelper::thresholdsAsserted(const std::string& service,
                                     const std::string& path)
 {
 
diff --git a/dbus/dbushelper.hpp b/dbus/dbushelper.hpp
index 0831bd4..b4d3aa0 100644
--- a/dbus/dbushelper.hpp
+++ b/dbus/dbushelper.hpp
@@ -29,20 +29,18 @@
     DbusHelper(DbusHelper&&) = default;
     DbusHelper& operator=(DbusHelper&&) = default;
 
-    std::string getService(sdbusplus::bus::bus& bus, const std::string& intf,
+    std::string getService(const std::string& intf,
                            const std::string& path) override;
 
-    void getProperties(sdbusplus::bus::bus& bus, const std::string& service,
-                       const std::string& path,
+    void getProperties(const std::string& service, const std::string& path,
                        struct SensorProperties* prop) override;
 
-    bool thresholdsAsserted(sdbusplus::bus::bus& bus,
-                            const std::string& service,
+    bool thresholdsAsserted(const std::string& service,
                             const std::string& path) override;
 
     template <typename T>
-    void getProperty(sdbusplus::bus::bus& bus, const std::string& service,
-                     const std::string& path, const std::string& interface,
+    void getProperty(const std::string& service, const std::string& path,
+                     const std::string& interface,
                      const std::string& propertyName, T& prop)
     {
         namespace log = phosphor::logging;
diff --git a/dbus/dbushelper_interface.hpp b/dbus/dbushelper_interface.hpp
index c7c2c90..4dbf00c 100644
--- a/dbus/dbushelper_interface.hpp
+++ b/dbus/dbushelper_interface.hpp
@@ -1,7 +1,5 @@
 #pragma once
 
-#include <sdbusplus/bus.hpp>
-
 #include <cstdint>
 #include <string>
 
@@ -26,8 +24,7 @@
      *
      * @warning Throws exception on dbus failure.
      */
-    virtual std::string getService(sdbusplus::bus::bus& bus,
-                                   const std::string& intf,
+    virtual std::string getService(const std::string& intf,
                                    const std::string& path) = 0;
 
     /** @brief Get all Sensor.Value properties for a service and path.
@@ -39,8 +36,7 @@
      *
      * @warning Throws exception on dbus failure.
      */
-    virtual void getProperties(sdbusplus::bus::bus& bus,
-                               const std::string& service,
+    virtual void getProperties(const std::string& service,
                                const std::string& path,
                                struct SensorProperties* prop) = 0;
 
@@ -50,8 +46,7 @@
      * @param[in] service - The service providing the interface.
      * @param[in] path - The dbus path.
      */
-    virtual bool thresholdsAsserted(sdbusplus::bus::bus& bus,
-                                    const std::string& service,
+    virtual bool thresholdsAsserted(const std::string& service,
                                     const std::string& path) = 0;
 };
 
diff --git a/dbus/dbuspassive.cpp b/dbus/dbuspassive.cpp
index 84d1f93..ea47122 100644
--- a/dbus/dbuspassive.cpp
+++ b/dbus/dbuspassive.cpp
@@ -47,8 +47,6 @@
     }
 
     /* Need to get the scale and initial value */
-    auto tempBus = sdbusplus::bus::new_system();
-
     /* service == busname */
     std::string path = getSensorPath(type, id);
 
@@ -57,10 +55,10 @@
 
     try
     {
-        std::string service = helper->getService(tempBus, sensorintf, path);
+        std::string service = helper->getService(sensorintf, path);
 
-        helper->getProperties(tempBus, service, path, &settings);
-        failed = helper->thresholdsAsserted(tempBus, service, path);
+        helper->getProperties(service, path, &settings);
+        failed = helper->thresholdsAsserted(service, path);
     }
     catch (const std::exception& e)
     {
diff --git a/dbus/dbuswrite.cpp b/dbus/dbuswrite.cpp
index a6b2835..288cb1a 100644
--- a/dbus/dbuswrite.cpp
+++ b/dbus/dbuswrite.cpp
@@ -38,12 +38,11 @@
     const std::string& path, int64_t min, int64_t max,
     std::unique_ptr<DbusHelperInterface> helper)
 {
-    auto tempBus = sdbusplus::bus::new_system();
     std::string connectionName;
 
     try
     {
-        connectionName = helper->getService(tempBus, pwmInterface, path);
+        connectionName = helper->getService(pwmInterface, path);
     }
     catch (const std::exception& e)
     {
@@ -93,12 +92,11 @@
                                int64_t max,
                                std::unique_ptr<DbusHelperInterface> helper)
 {
-    auto tempBus = sdbusplus::bus::new_system();
     std::string connectionName;
 
     try
     {
-        connectionName = helper->getService(tempBus, pwmInterface, path);
+        connectionName = helper->getService(pwmInterface, path);
     }
     catch (const std::exception& e)
     {
diff --git a/test/dbus_active_unittest.cpp b/test/dbus_active_unittest.cpp
index 3fb1dc6..6c640f8 100644
--- a/test/dbus_active_unittest.cpp
+++ b/test/dbus_active_unittest.cpp
@@ -41,10 +41,10 @@
     std::string path = "/asdf";
     std::string service = "asdfasdf.asdfasdf";
 
-    EXPECT_CALL(*helper, getProperties(_, service, path, NotNull()))
+    EXPECT_CALL(*helper, getProperties(service, path, NotNull()))
         .WillOnce(
-            Invoke([&](sdbusplus::bus::bus& bus, const std::string& service,
-                       const std::string& path, struct SensorProperties* prop) {
+            Invoke([&](const std::string& service, const std::string& path,
+                       struct SensorProperties* prop) {
                 prop->scale = -3;
                 prop->value = 10000;
                 prop->unit = "x";
diff --git a/test/dbus_passive_unittest.cpp b/test/dbus_passive_unittest.cpp
index 8eb3416..a04b4ec 100644
--- a/test/dbus_passive_unittest.cpp
+++ b/test/dbus_passive_unittest.cpp
@@ -71,21 +71,21 @@
         bus_mock(std::move(sdbusplus::get_mocked_new(&sdbus_mock))),
         helper(std::make_unique<DbusHelperMock>())
     {
-        EXPECT_CALL(*helper, getService(_, StrEq(SensorIntf), StrEq(path)))
+        EXPECT_CALL(*helper, getService(StrEq(SensorIntf), StrEq(path)))
             .WillOnce(Return("asdf"));
 
         EXPECT_CALL(*helper,
-                    getProperties(_, StrEq("asdf"), StrEq(path), NotNull()))
-            .WillOnce(Invoke(
-                [&](sdbusplus::bus::bus& bus, const std::string& service,
-                    const std::string& path, struct SensorProperties* prop) {
+                    getProperties(StrEq("asdf"), StrEq(path), NotNull()))
+            .WillOnce(
+                Invoke([&](const std::string& service, const std::string& path,
+                           struct SensorProperties* prop) {
                     prop->scale = _scale;
                     prop->value = _value;
                     prop->unit = "x";
                     prop->min = 0;
                     prop->max = 0;
                 }));
-        EXPECT_CALL(*helper, thresholdsAsserted(_, StrEq("asdf"), StrEq(path)))
+        EXPECT_CALL(*helper, thresholdsAsserted(StrEq("asdf"), StrEq(path)))
             .WillOnce(Return(false));
 
         auto info = conf::SensorConfig();
@@ -436,8 +436,8 @@
     EXPECT_EQ(failed, false);
 }
 
-void GetPropertiesMax3k(sdbusplus::bus::bus& bus, const std::string& service,
-                        const std::string& path, SensorProperties* prop)
+void GetPropertiesMax3k(const std::string& service, const std::string& path,
+                        SensorProperties* prop)
 {
     prop->scale = -3;
     prop->value = 10;
@@ -446,9 +446,8 @@
     prop->max = 3000;
 }
 
-using GetPropertiesFunction =
-    std::function<void(sdbusplus::bus::bus&, const std::string&,
-                       const std::string&, SensorProperties*)>;
+using GetPropertiesFunction = std::function<void(
+    const std::string&, const std::string&, SensorProperties*)>;
 
 // TODO: There is definitely a cleaner way to do this.
 class DbusPassiveTest3kMaxObj : public ::testing::Test
@@ -459,13 +458,13 @@
         bus_mock(std::move(sdbusplus::get_mocked_new(&sdbus_mock))),
         helper(std::make_unique<DbusHelperMock>())
     {
-        EXPECT_CALL(*helper, getService(_, StrEq(SensorIntf), StrEq(path)))
+        EXPECT_CALL(*helper, getService(StrEq(SensorIntf), StrEq(path)))
             .WillOnce(Return("asdf"));
 
         EXPECT_CALL(*helper,
-                    getProperties(_, StrEq("asdf"), StrEq(path), NotNull()))
+                    getProperties(StrEq("asdf"), StrEq(path), NotNull()))
             .WillOnce(_getProps);
-        EXPECT_CALL(*helper, thresholdsAsserted(_, StrEq("asdf"), StrEq(path)))
+        EXPECT_CALL(*helper, thresholdsAsserted(StrEq("asdf"), StrEq(path)))
             .WillOnce(Return(false));
 
         auto info = conf::SensorConfig();
@@ -503,13 +502,13 @@
         bus_mock(std::move(sdbusplus::get_mocked_new(&sdbus_mock))),
         helper(std::make_unique<DbusHelperMock>())
     {
-        EXPECT_CALL(*helper, getService(_, StrEq(SensorIntf), StrEq(path)))
+        EXPECT_CALL(*helper, getService(StrEq(SensorIntf), StrEq(path)))
             .WillOnce(Return("asdf"));
 
         EXPECT_CALL(*helper,
-                    getProperties(_, StrEq("asdf"), StrEq(path), NotNull()))
+                    getProperties(StrEq("asdf"), StrEq(path), NotNull()))
             .WillOnce(_getProps);
-        EXPECT_CALL(*helper, thresholdsAsserted(_, StrEq("asdf"), StrEq(path)))
+        EXPECT_CALL(*helper, thresholdsAsserted(StrEq("asdf"), StrEq(path)))
             .WillOnce(Return(false));
 
         auto info = conf::SensorConfig();
diff --git a/test/dbushelper_mock.hpp b/test/dbushelper_mock.hpp
index 6ce63c8..44b3bea 100644
--- a/test/dbushelper_mock.hpp
+++ b/test/dbushelper_mock.hpp
@@ -2,8 +2,6 @@
 
 #include "util.hpp"
 
-#include <sdbusplus/bus.hpp>
-
 #include <string>
 
 #include <gmock/gmock.h>
@@ -16,16 +14,13 @@
   public:
     virtual ~DbusHelperMock() = default;
 
-    MOCK_METHOD3(getService,
-                 std::string(sdbusplus::bus::bus&, const std::string&,
-                             const std::string&));
-    MOCK_METHOD4(getProperties,
-                 void(sdbusplus::bus::bus&, const std::string&,
-                      const std::string&, struct SensorProperties*));
+    MOCK_METHOD2(getService,
+                 std::string(const std::string&, const std::string&));
+    MOCK_METHOD3(getProperties, void(const std::string&, const std::string&,
+                                     struct SensorProperties*));
 
-    MOCK_METHOD3(thresholdsAsserted,
-                 bool(sdbusplus::bus::bus& bus, const std::string& service,
-                      const std::string& path));
+    MOCK_METHOD2(thresholdsAsserted,
+                 bool(const std::string& service, const std::string& path));
 };
 
 } // namespace pid_control