From ecf9310061f47da0fd9f3d604e8b20f4fcb5749c Mon Sep 17 00:00:00 2001 From: Kevin Rocard Date: Wed, 10 Jul 2013 18:28:10 +0200 Subject: Add missing subsystem policy BZ: 122982 When the PFW starts it loads subsystems using there corresponding plugin. If the requested plugin is not found, the start fails. This is a problem, as for host, the plugins are not compiled. Add a command in the public API to ignore missing subsystem. Change-Id: I7597e3fef33466638191ff70b76e7faa9f979418 Signed-off-by: Kevin Rocard Reviewed-on: http://android.intel.com:8080/118039 Reviewed-by: Centelles, Sylvain Tested-by: Barthes, FabienX Reviewed-by: cactus Tested-by: cactus --- parameter/ParameterMgr.cpp | 15 +++++++++++-- parameter/ParameterMgr.h | 27 ++++++++++++++++++++++- parameter/ParameterMgrPlatformConnector.cpp | 24 +++++++++++++++++--- parameter/include/ParameterMgrPlatformConnector.h | 21 ++++++++++++++++-- 4 files changed, 79 insertions(+), 8 deletions(-) diff --git a/parameter/ParameterMgr.cpp b/parameter/ParameterMgr.cpp index f2d30e2..927515c 100644 --- a/parameter/ParameterMgr.cpp +++ b/parameter/ParameterMgr.cpp @@ -280,7 +280,8 @@ CParameterMgr::CParameterMgr(const string& strConfigurationFilePath) : _pRemoteProcessorServer(NULL), _uiMaxCommandUsageLength(0), _pLogger(NULL), - _uiLogDepth(0) + _uiLogDepth(0), + _bFailOnMissingSubsystem(true) { // Tuning Mode Mutex bzero(&_blackboardMutex, sizeof(_blackboardMutex)); @@ -402,7 +403,8 @@ bool CParameterMgr::load(string& strError) } // Load subsystems - if (!getSystemClass()->loadSubsystems(strError, _pSubsystemPlugins)) { + if (!getSystemClass()->loadSubsystems(strError, + _pSubsystemPlugins, !_bFailOnMissingSubsystem)) { return false; } @@ -726,6 +728,15 @@ CParameterHandle* CParameterMgr::createParameterHandle(const string& strPath, st return new CParameterHandle(static_cast(pConfigurableElement), this); } +void CParameterMgr::setFailureOnMissingSubsystem(bool bFail) +{ + _bFailOnMissingSubsystem = bFail; +} + +bool CParameterMgr::getFailureOnMissingSubsystem() const +{ + return _bFailOnMissingSubsystem; +} /////////////////// Remote command parsers /// Version CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::versionCommandProcess(const IRemoteCommand& remoteCommand, string& strResult) diff --git a/parameter/ParameterMgr.h b/parameter/ParameterMgr.h index 9677303..9145c4e 100644 --- a/parameter/ParameterMgr.h +++ b/parameter/ParameterMgr.h @@ -104,7 +104,13 @@ public: // Logging void setLogger(ILogger* pLogger); - // Init + /** Load plugins, structures and settings from the config file given. + * + * @param[out] strError is a string describing the error if an error occurred + * undefined otherwise. + * + * @return true if no error occurred, false otherwise. + */ bool load(string& strError); virtual bool init(string& strError); @@ -131,6 +137,20 @@ public: // Dynamic parameter handling CParameterHandle* createParameterHandle(const string& strPath, string& strError); + /** Should start fail in case of missing subsystems. + * Will fail if called on started instance. + * + * @param[in] bFail: If set to true, parameterMgr start will fail on missing subsystems + * If set to false, missing subsystems will fallback on virtual subsystem + */ + void setFailureOnMissingSubsystem(bool bFail); + + /** Would start fail in case of missing subsystems. + * + * @return true if the subsystem will fail on missing subsystem, false otherwise. + */ + bool getFailureOnMissingSubsystem() const; + //////////// Tuning ///////////// // Tuning mode bool setTuningMode(bool bOn, string& strError); @@ -458,5 +478,10 @@ private: // Logging ILogger* _pLogger; mutable uint32_t _uiLogDepth; + + /** If set to true, missing subsystem will abort parameterMgr start. + * If set to false, missing subsystem will fallback on virtual subsystem. + */ + bool _bFailOnMissingSubsystem; }; diff --git a/parameter/ParameterMgrPlatformConnector.cpp b/parameter/ParameterMgrPlatformConnector.cpp index 0ef9053..d8b3936 100644 --- a/parameter/ParameterMgrPlatformConnector.cpp +++ b/parameter/ParameterMgrPlatformConnector.cpp @@ -28,8 +28,9 @@ #include // Construction -CParameterMgrPlatformConnector::CParameterMgrPlatformConnector(const string& strConfigurationFilePath) - : _pParameterMgr(new CParameterMgr(strConfigurationFilePath)), _bStarted(false), _pLogger(NULL) +CParameterMgrPlatformConnector::CParameterMgrPlatformConnector( + const string& strConfigurationFilePath) : + _pParameterMgr(new CParameterMgr(strConfigurationFilePath)), _bStarted(false), _pLogger(NULL) { // Logging _pParameterMgrLogger = new CParameterMgrLogger(this); @@ -58,7 +59,7 @@ ISelectionCriterionInterface* CParameterMgrPlatformConnector::createSelectionCri } // Selection criterion retrieval -ISelectionCriterionInterface* CParameterMgrPlatformConnector::getSelectionCriterion(const string& strName) +ISelectionCriterionInterface* CParameterMgrPlatformConnector::getSelectionCriterion(const string& strName) const { return _pParameterMgr->getSelectionCriterion(strName); } @@ -85,6 +86,23 @@ void CParameterMgrPlatformConnector::setLogger(CParameterMgrPlatformConnector::I _pLogger = pLogger; } +bool CParameterMgrPlatformConnector::setFailureOnMissingSubsystem(bool bFail, string &strError) +{ + if (_bStarted) { + + strError = "Can not set missing subsystem policy while running"; + return false; + } + + _pParameterMgr->setFailureOnMissingSubsystem(bFail); + return true; +} + +bool CParameterMgrPlatformConnector::getFailureOnMissingSubsystem() +{ + return _pParameterMgr->getFailureOnMissingSubsystem(); +} + // Start bool CParameterMgrPlatformConnector::start(string& strError) { diff --git a/parameter/include/ParameterMgrPlatformConnector.h b/parameter/include/ParameterMgrPlatformConnector.h index ae3e216..50c1212 100644 --- a/parameter/include/ParameterMgrPlatformConnector.h +++ b/parameter/include/ParameterMgrPlatformConnector.h @@ -21,7 +21,6 @@ */ #pragma once -#include #include "SelectionCriterionTypeInterface.h" #include "SelectionCriterionInterface.h" #include "ParameterHandle.h" @@ -51,7 +50,7 @@ public: ISelectionCriterionTypeInterface* createSelectionCriterionType(bool bIsInclusive = false); ISelectionCriterionInterface* createSelectionCriterion(const std::string& strName, const ISelectionCriterionTypeInterface* pSelectionCriterionType); // Selection criterion retrieval - ISelectionCriterionInterface* getSelectionCriterion(const std::string& strName); + ISelectionCriterionInterface* getSelectionCriterion(const std::string& strName) const; // Logging // Should be called before start @@ -71,6 +70,24 @@ public: // Must be cassed after successfull start CParameterHandle* createParameterHandle(const std::string& strPath, std::string& strError) const; + /** Should start fail in case of missing subsystems. + * + * Will fail if called on started instance. + * @param[in] bFail: If set to true, parameterMgr start will fail on missing subsystems + * If set to false, missing subsystems will fallbacks on virtual subsystem + * @param[out] strError a string describing the error if the function failed, + unmodified otherwise. + * + * @return false if unable to set, true otherwise. + */ + bool setFailureOnMissingSubsystem(bool bFail, std::string& strError); + + /** Would start fail in case of missing subsystems. + * + * @return if the subsystem load will fail on missing subsystem. + */ + bool getFailureOnMissingSubsystem(); + private: CParameterMgrPlatformConnector(const CParameterMgrPlatformConnector&); CParameterMgrPlatformConnector& operator=(const CParameterMgrPlatformConnector&); -- cgit v1.1