Add skipping PropertiesChanged signal on init

Prevents sending initial PropertiesChanged for report when new report is
created. Information about initial values is already present in signal
InterfacesAdded. Signals about actual updates are correctly send.

Tested:
  - Verified that signal is not send during AddReport
  - Verified that signal is still being send when properties are updated

Signed-off-by: Krzysztof Grobelny <krzysztof.grobelny@intel.com>
Change-Id: I19d6aee431a947ca52ca79af738e2a571a16b694
diff --git a/src/report.cpp b/src/report.cpp
index 77189c1..7aef423 100644
--- a/src/report.cpp
+++ b/src/report.cpp
@@ -41,76 +41,8 @@
             });
         });
 
-    reportIface = objServer->add_unique_interface(
-        path, reportIfaceName, [this](auto& dbusIface) {
-            dbusIface.register_property_rw(
-                "Interval", static_cast<uint64_t>(interval.count()),
-                sdbusplus::vtable::property_::emits_change,
-                [this](uint64_t newVal, auto&) {
-                    std::chrono::milliseconds newValT(newVal);
-                    if (newValT < ReportManager::minInterval)
-                    {
-                        return false;
-                    }
-                    interval = newValT;
-                    return true;
-                },
-                [this](const auto&) {
-                    return static_cast<uint64_t>(interval.count());
-                });
-            persistency = storeConfiguration();
-            dbusIface.register_property_rw(
-                "Persistency", persistency,
-                sdbusplus::vtable::property_::emits_change,
-                [this](bool newVal, const auto&) {
-                    if (newVal == persistency)
-                    {
-                        return true;
-                    }
-                    if (newVal)
-                    {
-                        persistency = storeConfiguration();
-                    }
-                    else
-                    {
-                        reportStorage.remove(fileName);
-                        persistency = false;
-                    }
-                    return true;
-                },
-                [this](const auto&) { return persistency; });
-
-            auto readingsFlag = sdbusplus::vtable::property_::none;
-            if (emitsReadingsUpdate)
-            {
-                readingsFlag = sdbusplus::vtable::property_::emits_change;
-            }
-            dbusIface.register_property_r(
-                "Readings", readings, readingsFlag,
-                [this](const auto&) { return readings; });
-            dbusIface.register_property_r(
-                "ReportingType", reportingType,
-                sdbusplus::vtable::property_::const_,
-                [this](const auto&) { return reportingType; });
-            dbusIface.register_property_r(
-                "ReadingParameters", readingParameters,
-                sdbusplus::vtable::property_::const_,
-                [this](const auto&) { return readingParameters; });
-            dbusIface.register_property_r(
-                "EmitsReadingsUpdate", emitsReadingsUpdate,
-                sdbusplus::vtable::property_::const_,
-                [this](const auto&) { return emitsReadingsUpdate; });
-            dbusIface.register_property_r(
-                "LogToMetricReportsCollection", logToMetricReportsCollection,
-                sdbusplus::vtable::property_::const_,
-                [this](const auto&) { return logToMetricReportsCollection; });
-            dbusIface.register_method("Update", [this] {
-                if (reportingType == "OnRequest")
-                {
-                    updateReadings();
-                }
-            });
-        });
+    persistency = storeConfiguration();
+    reportIface = makeReportInterface();
 
     if (reportingType == "Periodic")
     {
@@ -123,6 +55,77 @@
     }
 }
 
+std::unique_ptr<sdbusplus::asio::dbus_interface> Report::makeReportInterface()
+{
+    auto dbusIface = objServer->add_unique_interface(path, reportIfaceName);
+    dbusIface->register_property_rw(
+        "Interval", static_cast<uint64_t>(interval.count()),
+        sdbusplus::vtable::property_::emits_change,
+        [this](uint64_t newVal, auto&) {
+            std::chrono::milliseconds newValT(newVal);
+            if (newValT < ReportManager::minInterval)
+            {
+                return false;
+            }
+            interval = newValT;
+            return true;
+        },
+        [this](const auto&) {
+            return static_cast<uint64_t>(interval.count());
+        });
+    dbusIface->register_property_rw(
+        "Persistency", persistency, sdbusplus::vtable::property_::emits_change,
+        [this](bool newVal, const auto&) {
+            if (newVal == persistency)
+            {
+                return true;
+            }
+            if (newVal)
+            {
+                persistency = storeConfiguration();
+            }
+            else
+            {
+                reportStorage.remove(fileName);
+                persistency = false;
+            }
+            return true;
+        },
+        [this](const auto&) { return persistency; });
+
+    auto readingsFlag = sdbusplus::vtable::property_::none;
+    if (emitsReadingsUpdate)
+    {
+        readingsFlag = sdbusplus::vtable::property_::emits_change;
+    }
+    dbusIface->register_property_r("Readings", readings, readingsFlag,
+                                   [this](const auto&) { return readings; });
+    dbusIface->register_property_r(
+        "ReportingType", reportingType, sdbusplus::vtable::property_::const_,
+        [this](const auto&) { return reportingType; });
+    dbusIface->register_property_r(
+        "ReadingParameters", readingParameters,
+        sdbusplus::vtable::property_::const_,
+        [this](const auto&) { return readingParameters; });
+    dbusIface->register_property_r(
+        "EmitsReadingsUpdate", emitsReadingsUpdate,
+        sdbusplus::vtable::property_::const_,
+        [this](const auto&) { return emitsReadingsUpdate; });
+    dbusIface->register_property_r(
+        "LogToMetricReportsCollection", logToMetricReportsCollection,
+        sdbusplus::vtable::property_::const_,
+        [this](const auto&) { return logToMetricReportsCollection; });
+    dbusIface->register_method("Update", [this] {
+        if (reportingType == "OnRequest")
+        {
+            updateReadings();
+        }
+    });
+    constexpr bool skipPropertiesChangedSignal = true;
+    dbusIface->initialize(skipPropertiesChangedSignal);
+    return dbusIface;
+}
+
 void Report::timerProc(boost::system::error_code ec, Report& self)
 {
     if (ec)
diff --git a/src/report.hpp b/src/report.hpp
index 97afe03..d9ecb33 100644
--- a/src/report.hpp
+++ b/src/report.hpp
@@ -47,6 +47,7 @@
     bool storeConfiguration() const;
 
   private:
+    std::unique_ptr<sdbusplus::asio::dbus_interface> makeReportInterface();
     static void timerProc(boost::system::error_code, Report& self);
     void scheduleTimer(std::chrono::milliseconds interval);
 
@@ -57,7 +58,7 @@
     bool emitsReadingsUpdate;
     bool logToMetricReportsCollection;
     ReadingParameters readingParameters;
-    bool persistency;
+    bool persistency = false;
     Readings readings = {};
     std::shared_ptr<sdbusplus::asio::object_server> objServer;
     std::unique_ptr<sdbusplus::asio::dbus_interface> reportIface;