Add an option to continue on failed setting load

BZ: 122982

When the PFW starts it loads the configurable domains, if the load
fails, it used to abort the parameterMgr global load.

Add an option to continue on failed setting load, as if there were none.

Change-Id: Ifd3cd859ad0eaef266be4c9245ebd28c9e9c0a74
Signed-off-by: Kevin Rocard <kevinx.rocard@intel.com>
Reviewed-on: http://android.intel.com:8080/119924
Reviewed-by: Centelles, Sylvain <sylvain.centelles@intel.com>
Tested-by: Barthes, FabienX <fabienx.barthes@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 927515c..59dc057 100644
--- a/parameter/ParameterMgr.cpp
+++ b/parameter/ParameterMgr.cpp
@@ -281,7 +281,8 @@
     _uiMaxCommandUsageLength(0),
     _pLogger(NULL),
     _uiLogDepth(0),
-    _bFailOnMissingSubsystem(true)
+    _bFailOnMissingSubsystem(true),
+    _bFailOnFailedSettingsLoad(true)
 {
     // Tuning Mode Mutex
     bzero(&_blackboardMutex, sizeof(_blackboardMutex));
@@ -537,6 +538,27 @@
 
 bool CParameterMgr::loadSettings(string& strError)
 {
+    string strLoadError;
+    bool success = loadSettingsFromConfigFile(strLoadError);
+
+    if (!success && !_bFailOnFailedSettingsLoad) {
+        // Load can not fail, ie continue but log the load errors
+        log_info(strLoadError);
+        log_info("Failed to load settings, continue without domains.");
+        success = true;
+    }
+
+    if (!success) {
+        // Propagate the litteral error only if the function fails
+        strError = strLoadError;
+        return false;
+    }
+
+    return true;
+}
+
+bool CParameterMgr::loadSettingsFromConfigFile(string& strError)
+{
     CAutoLog autoLog(this, "Loading settings");
 
     // Get settings configuration element
@@ -567,7 +589,7 @@
         strError = "No ConfigurableDomainsFileLocation element found for SystemClass " + getSystemClass()->getName();
 
         return false;
-    }    
+    }
     // Get destination root element
     CConfigurableDomains* pConfigurableDomains = getConfigurableDomains();
 
@@ -737,6 +759,15 @@
 {
     return _bFailOnMissingSubsystem;
 }
+
+void CParameterMgr::setFailureOnFailedSettingsLoad(bool bFail)
+{
+    _bFailOnFailedSettingsLoad = bFail;
+}
+bool CParameterMgr::getFailureOnFailedSettingsLoad()
+{
+    return _bFailOnFailedSettingsLoad;
+}
 /////////////////// Remote command parsers
 /// Version
 CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::versionCommandProcess(const IRemoteCommand& remoteCommand, string& strResult)