PFW: Add resync mechanism if a subsystem needs resync

BZ: 76267

In the case of a hw subsystems reset, it's possible that its
parameter managed by the PFW may not be aligned with the PFW
blackboard.
A re-synchronization mechanism is implemented to ensure that the
subsystem is re-synchronized on the next configurations application.

Change-Id: I032150955d25a7020cf494e69456897b4c157916
Signed-off-by: Guillaume Denneulin <guillaume.denneulin@intel.com>
Reviewed-on: http://android.intel.com:8080/83015
Reviewed-by: Rocard, KevinX <kevinx.rocard@intel.com>
Reviewed-by: Centelles, Sylvain <sylvain.centelles@intel.com>
Tested-by: Dixon, CharlesX <charlesx.dixon@intel.com>
Reviewed-by: cactus <cactus@intel.com>
Tested-by: cactus <cactus@intel.com>
diff --git a/parameter/ParameterMgr.cpp b/parameter/ParameterMgr.cpp
index 5244199..4116dbe 100644
--- a/parameter/ParameterMgr.cpp
+++ b/parameter/ParameterMgr.cpp
@@ -355,9 +355,8 @@
     // We need to ensure all domains are valid
     pConfigurableDomains->validate(_pMainParameterBlackboard);
 
-    // Ensure application of currently selected configurations
-    // Force-apply configurations
-    pConfigurableDomains->apply(_pMainParameterBlackboard, true);
+    // At initialization, check subsystems that need resync
+    doApplyConfigurations(true);
 
     // Start remote processor server if appropriate
     return handleRemoteProcessingInterface(strError);
@@ -559,7 +558,7 @@
     return getSelectionCriteria()->getSelectionCriterion(strName);
 }
 
-// Selection criteria changed event
+// Configuration application
 void CParameterMgr::applyConfigurations()
 {
     CAutoLog autoLog(this, "Configuration application request");
@@ -570,11 +569,7 @@
     if (!_bTuningModeIsOn) {
 
         // Apply configuration(s)
-        getConfigurableDomains()->apply(_pMainParameterBlackboard, false);
-
-        // Reset the modified status of the current criteria to indicate that a new configuration has been applied
-        getSelectionCriteria()->resetModifiedStatus();
-
+        doApplyConfigurations(false);
     } else {
 
         log_warning("Configurations were not applied because the TuningMode is on");
@@ -1335,7 +1330,7 @@
 
         // Ensure application of currently selected configurations
         // Force-apply configurations
-        getConfigurableDomains()->apply(_pMainParameterBlackboard, true);
+        doApplyConfigurations(true);
 
         // Turn auto sync back on
         _bAutoSyncOn = true;
@@ -1908,8 +1903,22 @@
     return static_cast<const CConfigurableDomains*>(getChild(EConfigurableDomains));
 }
 
-/// GUI commands functions
+// Apply configurations
+void CParameterMgr::doApplyConfigurations(bool bForce)
+{
+    CSyncerSet syncerSet;
 
+    // Check subsystems that need resync
+    getSystemClass()->checkForSubsystemsToResync(syncerSet);
+
+    // Ensure application of currently selected configurations
+    getConfigurableDomains()->apply(_pMainParameterBlackboard, syncerSet, bForce);
+
+    // Reset the modified status of the current criteria to indicate that a new configuration has been applied
+    getSelectionCriteria()->resetModifiedStatus();
+}
+
+/// GUI commands functions
 bool CParameterMgr::getDomainsXMLString(string& strResult, bool bWithSettings)
 {