PFW: Fix the useless subsystem resync on PFW load

BZ: 97808

The PFW used to resynchronise some subsystems at start before
back/forward syncronisation. Which was useless.

Reset subsystems 'needToResync' flag during PFW start before sync to
avoid this dummy resync.

Change-Id: Id0c0bb786f10e2724222fc18f2085164e95f963f
Signed-off-by: Kevin Rocard <kevinx.rocard@intel.com>
Reviewed-on: http://android.intel.com:8080/98452
Reviewed-by: cactus <cactus@intel.com>
Reviewed-by: Denneulin, Guillaume <guillaume.denneulin@intel.com>
Reviewed-by: De Chivre, Renaud <renaud.de.chivre@intel.com>
Tested-by: Dixon, CharlesX <charlesx.dixon@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
diff --git a/parameter/ParameterMgr.cpp b/parameter/ParameterMgr.cpp
index 092a496..646e7af 100644
--- a/parameter/ParameterMgr.cpp
+++ b/parameter/ParameterMgr.cpp
@@ -362,6 +362,9 @@
         log_table(false, lstrSelectionCriteron);
     }
 
+    // Subsystem can not ask for resync as they have not been synced yet
+    getSystemClass()->cleanSubsystemsNeedToResync();
+
     // At initialization, check subsystems that need resync
     doApplyConfigurations(true);
 
diff --git a/parameter/SystemClass.cpp b/parameter/SystemClass.cpp
index bf98cb1..ae0c25f 100644
--- a/parameter/SystemClass.cpp
+++ b/parameter/SystemClass.cpp
@@ -232,7 +232,6 @@
     return _pSubsystemLibrary;
 }
 
-// Fill syncer-set with syncers from subsytems that need resync
 void CSystemClass::checkForSubsystemsToResync(CSyncerSet& syncerSet)
 {
     uint32_t uiNbChildren = getNbChildren();
@@ -252,6 +251,20 @@
     }
 }
 
+void CSystemClass::cleanSubsystemsNeedToResync()
+{
+    uint32_t uiNbChildren = getNbChildren();
+    uint32_t uiChild;
+
+    for (uiChild = 0; uiChild < uiNbChildren; uiChild++) {
+
+        CSubsystem* pSubsystem = static_cast<CSubsystem*>(getChild(uiChild));
+
+        // Consume the need for a resync
+        pSubsystem->needResync(true);
+    }
+}
+
 bool CSystemClass::init(string& strError)
 {
     return base::init(strError);
diff --git a/parameter/SystemClass.h b/parameter/SystemClass.h
index a522a33..5bc9006 100644
--- a/parameter/SystemClass.h
+++ b/parameter/SystemClass.h
@@ -41,9 +41,20 @@
     // Subsystem factory
     const CSubsystemLibrary* getSubsystemLibrary() const;
 
-    // Fill syncer-set with syncers from subsytems that need resync
+    /**
+      * Look for subsystems that need to be resynchronized.
+      * Consume the need to be resynchronized
+      * and fill a syncer set with all syncers that need to be resynchronized
+      *
+      * @param[out] syncerSet The syncer set to fill
+      */
     void checkForSubsystemsToResync(CSyncerSet& syncerSet);
 
+    /**
+      * Reset subsystems need to resync flag.
+      */
+    void cleanSubsystemsNeedToResync();
+
     // base
     virtual bool init(string& strError);
     virtual string getKind() const;