PFW: Enhance subsytem libraries load mechanism

BZ: 24093

If a subsystem library depends on another one, the libraries have to be loaded
in a predefined order.

the previous recovery mechanism on PFW was: When a subsystem library does not
load because of a missing dependency, it tries to load all the other subsystems
before trying one more time to load the failing library.

Unfortunately, Android linker does not allow several try when loading a
library.

In consequence, this patch implements a new mechanism to load its subsystem
libraries.
For this new mechanism, the PFW will load the subsystem libraries in the order
they are disposed in the file ParameterFrameworkConfiguration.xml

Change-Id: I39b97e33c77a6b4392c3813cd3d780e10e3b60f8
Signed-off-by: Guillaume Denneulin <guillaumex.denneulin@intel.com>
Reviewed-on: http://android.intel.com:8080/35903
Reviewed-by: Barthes, FabienX <fabienx.barthes@intel.com>
Tested-by: Barthes, FabienX <fabienx.barthes@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 6ef37bb..3b6447a 100644
--- a/parameter/ParameterMgr.cpp
+++ b/parameter/ParameterMgr.cpp
@@ -54,6 +54,8 @@
 #include "XmlFileIncluderElement.h"
 #include "ParameterFrameworkConfiguration.h"
 #include "FrameworkConfigurationGroup.h"
+#include "PluginLocation.h"
+#include "SubsystemPlugins.h"
 #include "FrameworkConfigurationLocation.h"
 #include "ConfigurableDomains.h"
 #include "ConfigurableDomain.h"
@@ -182,6 +184,7 @@
     _pMainParameterBlackboard(new CParameterBlackboard),
     _pElementLibrarySet(new CElementLibrarySet),
     _strXmlConfigurationFilePath(strConfigurationFilePath),
+    _pSubsystemPlugins(NULL),
     _uiStructureChecksum(0),
     _pRemoteProcessorServer(NULL),
     _uiMaxCommandUsageLength(0),
@@ -307,7 +310,7 @@
     }
 
     // Load subsystems
-    if (!getSystemClass()->loadSubsystems(strError, _astrPluginFolderPaths)) {
+    if (!getSystemClass()->loadSubsystems(strError, _pSubsystemPlugins)) {
 
         return false;
     }
@@ -373,33 +376,15 @@
     getSystemClass()->setName(getConstFrameworkConfiguration()->getSystemClassName());
     getConfigurableDomains()->setName(getConstFrameworkConfiguration()->getSystemClassName());
 
-    // Get subsystem plugins folders element
-    const CFrameworkConfigurationGroup* pSubsystemPluginFolders = static_cast<const CFrameworkConfigurationGroup*>(getConstFrameworkConfiguration()->findChild("SubsystemPluginFolders"));
+    // Get subsystem plugins elements
+    _pSubsystemPlugins = static_cast<const CSubsystemPlugins*>(getConstFrameworkConfiguration()->findChild("SubsystemPlugins"));
 
-    if (!pSubsystemPluginFolders) {
+    if (!_pSubsystemPlugins) {
 
-        strError = "Parameter Framework Configuration: couldn't find SubsystemPluginFolders element";
+        strError = "Parameter Framework Configuration: couldn't find SubsystemPlugins element";
 
         return false;
     }
-    // Get plugin locations
-    uint32_t uiPluginFolderLocation;
-    uint32_t uiNbPluginFolderLocations = pSubsystemPluginFolders->getNbChildren();
-
-    if (!uiNbPluginFolderLocations) {
-
-        strError = "Parameter Framework Configuration: couldn't find any PluginFolderLocation element";
-
-        return false;
-    }
-
-    // Collect plugin paths
-    for (uiPluginFolderLocation = 0; uiPluginFolderLocation < uiNbPluginFolderLocations; uiPluginFolderLocation++) {
-
-        const CFrameworkConfigurationLocation* pSubsystemPluginLocation = static_cast<const CFrameworkConfigurationLocation*>(pSubsystemPluginFolders->getChild(uiPluginFolderLocation));
-
-        _astrPluginFolderPaths.push_back(pSubsystemPluginLocation->getFilePath(_strXmlConfigurationFilePath));
-    }
 
     // Log tuning availability
     log("Tuning %s", getConstFrameworkConfiguration()->isTuningAllowed() ? "allowed" : "prohibited");
@@ -1736,8 +1721,8 @@
     CElementLibrary* pFrameworkConfigurationLibrary = new CElementLibrary;
 
     pFrameworkConfigurationLibrary->addElementBuilder(new TElementBuilderTemplate<CParameterFrameworkConfiguration>("ParameterFrameworkConfiguration"));
-    pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationGroup>("SubsystemPluginFolders"));
-    pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("PluginFolderLocation"));
+    pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CSubsystemPlugins>("SubsystemPlugins"));
+    pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CPluginLocation>("Location"));
     pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("StructureDescriptionFileLocation"));
     pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationGroup>("SettingsConfiguration"));
     pFrameworkConfigurationLibrary->addElementBuilder(new TKindElementBuilderTemplate<CFrameworkConfigurationLocation>("ConfigurableDomainsFileLocation"));