summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick Benavoli <patrickx.benavoli@intel.com>2011-10-27 14:18:00 +0200
committerDavid Wagner <david.wagner@intel.com>2014-02-10 17:14:57 +0100
commit4bed9212041d94d52e55e624bd081fcbf01ee04e (patch)
tree038feec5bb0749ff31674eb7198dbdafe8cb1cf9
parent63499d4763e42d76bfd39b79871f611381d2d164 (diff)
downloadexternal_parameter-framework-4bed9212041d94d52e55e624bd081fcbf01ee04e.zip
external_parameter-framework-4bed9212041d94d52e55e624bd081fcbf01ee04e.tar.gz
external_parameter-framework-4bed9212041d94d52e55e624bd081fcbf01ee04e.tar.bz2
PFW: Dynamic parameter access
BZ: 13272 Added dynamic parameter setting / getting interface for hosting platforms This new API allows: - getting any parameter - setting any parameter as long as it is rogue (attached to no domains) Passed parameter values are in the form of strings. Change-Id: I01a34597fcb4dafb225519cbc01dfffb22b5d52a Signed-off-by: Patrick Benavoli <patrickx.benavoli@intel.com> Reviewed-on: http://android.intel.com:8080/22629 Reviewed-by: Centelles, Sylvain <sylvain.centelles@intel.com> Tested-by: Barthes, FabienX <fabienx.barthes@intel.com> Reviewed-by: buildbot <buildbot@intel.com> Tested-by: buildbot <buildbot@intel.com> Reviewed-on: http://android.intel.com:8080/26781 Reviewed-by: Barthes, FabienX <fabienx.barthes@intel.com>
-rw-r--r--parameter-connector-test/ExamplePlatform.cpp10
-rw-r--r--parameter-connector-test/ExamplePlatform.h4
-rw-r--r--parameter-connector-test/main.cpp33
-rw-r--r--parameter/ArrayParameter.cpp15
-rw-r--r--parameter/BaseParameter.cpp27
-rw-r--r--parameter/BaseParameter.h3
-rw-r--r--parameter/ConfigurableElement.cpp6
-rw-r--r--parameter/ConfigurableElement.h3
-rw-r--r--parameter/DomainConfiguration.cpp15
-rw-r--r--parameter/ParameterAccessContext.cpp17
-rw-r--r--parameter/ParameterAccessContext.h6
-rw-r--r--parameter/ParameterMgr.cpp158
-rw-r--r--parameter/ParameterMgr.h8
-rw-r--r--parameter/ParameterMgrPlatformConnector.cpp13
-rw-r--r--parameter/ParameterMgrPlatformConnector.h10
15 files changed, 244 insertions, 84 deletions
diff --git a/parameter-connector-test/ExamplePlatform.cpp b/parameter-connector-test/ExamplePlatform.cpp
index 5d60880..fd66654 100644
--- a/parameter-connector-test/ExamplePlatform.cpp
+++ b/parameter-connector-test/ExamplePlatform.cpp
@@ -124,3 +124,13 @@ bool CExamplePlatform::setState(CExamplePlatform::State eState, string& strError
return _pParameterMgrPlatformConnector->applyConfigurations(strError);
}
+// Dynamic parameter access
+bool CExamplePlatform::setValue(const string& strPath, const string& strValue, string& strError)
+{
+ return _pParameterMgrPlatformConnector->setValue(strPath, strValue, strError);
+}
+
+bool CExamplePlatform::getValue(const string& strPath, string& strValue, string& strError) const
+{
+ return _pParameterMgrPlatformConnector->getValue(strPath, strValue, strError);
+}
diff --git a/parameter-connector-test/ExamplePlatform.h b/parameter-connector-test/ExamplePlatform.h
index 1249c7f..0e907a4 100644
--- a/parameter-connector-test/ExamplePlatform.h
+++ b/parameter-connector-test/ExamplePlatform.h
@@ -60,6 +60,10 @@ public:
// State
bool setState(State eState, string& strError);
+ // Dynamic parameter access
+ bool setValue(const string& strPath, const string& strValue, string& strError);
+ bool getValue(const string& strPath, string& strValue, string& strError) const;
+
private:
// The connector
CParameterMgrPlatformConnector* _pParameterMgrPlatformConnector;
diff --git a/parameter-connector-test/main.cpp b/parameter-connector-test/main.cpp
index a756426..5ead71e 100644
--- a/parameter-connector-test/main.cpp
+++ b/parameter-connector-test/main.cpp
@@ -34,6 +34,9 @@
using namespace std;
+const char* gpcParameter = "/Audio/MSIC/SOUND_CARD/PLAYBACK_ROGUE/HEADPHONE/VOLUME";
+const char* gpcParameterValue = "51 53";
+
int main(int argc, char *argv[])
{
if (argc < 2) {
@@ -56,6 +59,36 @@ int main(int argc, char *argv[])
return -1;
}
+ // Get parameter
+ string strValue;
+
+ if (!examplePlatform.getValue(gpcParameter, strValue, strError)) {
+
+ cerr << "Unable to get parameter: " << strError << endl;
+
+ return -1;
+ }
+ cout << gpcParameter << " = " << strValue << endl;
+
+ // Change parameter
+ cout << "Setting " << gpcParameter << " to " << gpcParameterValue << endl;
+
+ if (!examplePlatform.setValue(gpcParameter, gpcParameterValue, strError)) {
+
+ cerr << "Unable to set parameter: " << strError << endl;
+
+ return -1;
+ }
+
+ // Check parameter
+ if (!examplePlatform.getValue(gpcParameter, strValue, strError)) {
+
+ cerr << "Unable to get parameter: " << strError << endl;
+
+ return -1;
+ }
+ cout << gpcParameter << " = " << strValue << endl;
+
// Change criteria
// Block here
diff --git a/parameter/ArrayParameter.cpp b/parameter/ArrayParameter.cpp
index e8d351d..e777c61 100644
--- a/parameter/ArrayParameter.cpp
+++ b/parameter/ArrayParameter.cpp
@@ -104,6 +104,12 @@ bool CArrayParameter::setValue(CPathNavigator& pathNavigator, const string& strV
return false;
}
+ // Check for dynamic access
+ if (!checkForDynamicAccess(parameterContext)) {
+
+ return false;
+ }
+
if (uiStartIndex == (uint32_t)-1) {
// No index provided, start with 0
@@ -136,6 +142,13 @@ bool CArrayParameter::getValue(CPathNavigator& pathNavigator, string& strValue,
return false;
}
+
+ // Check for dynamic access
+ if (!checkForDynamicAccess(parameterContext)) {
+
+ return false;
+ }
+
if (uiIndex == (uint32_t)-1) {
// Whole array requested
@@ -275,6 +288,8 @@ void CArrayParameter::getValues(uint32_t uiBaseOffset, string& strValues, CParam
uint32_t uiOffset = getOffset() - uiBaseOffset;
uint32_t uiArrayLength = getArrayLength();
+ strValues.clear();
+
bool bFirst = true;
for (uiValueIndex = 0; uiValueIndex < uiArrayLength; uiValueIndex++) {
diff --git a/parameter/BaseParameter.cpp b/parameter/BaseParameter.cpp
index 67349d4..b4b0780 100644
--- a/parameter/BaseParameter.cpp
+++ b/parameter/BaseParameter.cpp
@@ -88,6 +88,12 @@ bool CBaseParameter::setValue(CPathNavigator& pathNavigator, const string& strVa
return false;
}
+ // Check for dynamic access
+ if (!checkForDynamicAccess(parameterContext)) {
+
+ return false;
+ }
+
// Set Value
if (!doSetValue(strValue, getOffset(), parameterContext)) {
@@ -115,8 +121,29 @@ bool CBaseParameter::getValue(CPathNavigator& pathNavigator, string& strValue, C
return false;
}
+ // Check for dynamic access
+ if (!checkForDynamicAccess(parameterContext)) {
+
+ return false;
+ }
+
// Get Value
doGetValue(strValue, getOffset(), parameterContext);
return true;
}
+
+// Dynamic access checking
+bool CBaseParameter::checkForDynamicAccess(CParameterAccessContext& parameterAccessContext) const
+{
+ // Check for dynamic access
+ if (parameterAccessContext.isDynamicAccess() && !isRogue()) {
+
+ // Parameter is not rogue
+ parameterAccessContext.setError("Parameter " + getPath() + " is not rogue");
+
+ return false;
+ }
+
+ return true;
+}
diff --git a/parameter/BaseParameter.h b/parameter/BaseParameter.h
index e8f82ed..2e3598d 100644
--- a/parameter/BaseParameter.h
+++ b/parameter/BaseParameter.h
@@ -53,4 +53,7 @@ protected:
// Actual value access (to be implemented by derived)
virtual bool doSetValue(const string& strValue, uint32_t uiOffset, CParameterAccessContext& parameterAccessContext) const = 0;
virtual void doGetValue(string& strValue, uint32_t uiOffset, CParameterAccessContext& parameterAccessContext) const = 0;
+
+ // Dynamic access checking
+ bool checkForDynamicAccess(CParameterAccessContext& parameterAccessContext) const;
};
diff --git a/parameter/ConfigurableElement.cpp b/parameter/ConfigurableElement.cpp
index f439ebf..b11b84f 100644
--- a/parameter/ConfigurableElement.cpp
+++ b/parameter/ConfigurableElement.cpp
@@ -353,6 +353,12 @@ void CConfigurableElement::listRogueElements(string& strResult) const
}
}
+// Belonging to no domains
+bool CConfigurableElement::isRogue() const
+{
+ return !getBelongingDomainCount();
+}
+
// Footprint as string
string CConfigurableElement::getFootprintAsString() const
{
diff --git a/parameter/ConfigurableElement.h b/parameter/ConfigurableElement.h
index 1f5498c..61a8bda 100644
--- a/parameter/ConfigurableElement.h
+++ b/parameter/ConfigurableElement.h
@@ -79,6 +79,9 @@ public:
// Elements with no domains
void listRogueElements(string& strResult) const;
+ // Belonging to no domains
+ bool isRogue() const;
+
// Footprint as string
string getFootprintAsString() const;
diff --git a/parameter/DomainConfiguration.cpp b/parameter/DomainConfiguration.cpp
index a5ac27c..b30c8e3 100644
--- a/parameter/DomainConfiguration.cpp
+++ b/parameter/DomainConfiguration.cpp
@@ -439,20 +439,7 @@ CAreaConfiguration* CDomainConfiguration::getAreaConfiguration(const CConfigurab
// AreaConfiguration retrieval from present area configurations
CAreaConfiguration* CDomainConfiguration::findAreaConfiguration(const string& strConfigurableElementPath) const
{
- AreaConfigurationListIterator it;
-
- for (it = _areaConfigurationList.begin(); it != _areaConfigurationList.end(); ++it) {
-
- CAreaConfiguration* pAreaConfiguration = *it;
-
- if (pAreaConfiguration->getConfigurableElement()->getPath() == strConfigurableElementPath) {
-
- return pAreaConfiguration;
- }
- }
-
- // Not found
- return NULL;
+ return findAreaConfiguration(strConfigurableElementPath, _areaConfigurationList);
}
// AreaConfiguration retrieval from given area configuration list
diff --git a/parameter/ParameterAccessContext.cpp b/parameter/ParameterAccessContext.cpp
index e296d23..769565a 100644
--- a/parameter/ParameterAccessContext.cpp
+++ b/parameter/ParameterAccessContext.cpp
@@ -35,13 +35,13 @@
CParameterAccessContext::CParameterAccessContext(string& strError, CParameterBlackboard* pParameterBlackboard, bool bValueSpaceIsRaw, bool bOutputRawFormatIsHex) :
base(strError), _pParameterBlackboard(pParameterBlackboard),
_bValueSpaceIsRaw(bValueSpaceIsRaw), _bOutputRawFormatIsHex(bOutputRawFormatIsHex),
- _bBigEndianSubsystem(false), _bAutoSync(true)
+ _bBigEndianSubsystem(false), _bAutoSync(true), _bDynamicAccess(false)
{
}
CParameterAccessContext::CParameterAccessContext(string& strError) :
base(strError), _pParameterBlackboard(NULL), _bValueSpaceIsRaw(false),
- _bOutputRawFormatIsHex(false), _bBigEndianSubsystem(false), _bAutoSync(true)
+ _bOutputRawFormatIsHex(false), _bBigEndianSubsystem(false), _bAutoSync(true), _bDynamicAccess(false)
{
}
@@ -97,5 +97,16 @@ void CParameterAccessContext::setAutoSync(bool bAutoSync)
bool CParameterAccessContext::getAutoSync() const
{
- return _bAutoSync;
+ return _bAutoSync || _bDynamicAccess;
+}
+
+// Dynamic access
+void CParameterAccessContext::setDynamicAccess(bool bDynamicAccess)
+{
+ _bDynamicAccess = bDynamicAccess;
+}
+
+bool CParameterAccessContext::isDynamicAccess() const
+{
+ return _bDynamicAccess;
}
diff --git a/parameter/ParameterAccessContext.h b/parameter/ParameterAccessContext.h
index cfdca7f..af6f1b7 100644
--- a/parameter/ParameterAccessContext.h
+++ b/parameter/ParameterAccessContext.h
@@ -60,6 +60,10 @@ public:
void setAutoSync(bool bAutoSync);
bool getAutoSync() const;
+ // Dynamic access
+ void setDynamicAccess(bool bDynamicAccess);
+ bool isDynamicAccess() const;
+
private:
// Blackboard
CParameterBlackboard* _pParameterBlackboard;
@@ -71,5 +75,7 @@ private:
bool _bBigEndianSubsystem;
// Automatic synchronization to HW
bool _bAutoSync;
+ // Dynamic access
+ bool _bDynamicAccess;
};
diff --git a/parameter/ParameterMgr.cpp b/parameter/ParameterMgr.cpp
index 0fcd4e2..768a5c5 100644
--- a/parameter/ParameterMgr.cpp
+++ b/parameter/ParameterMgr.cpp
@@ -617,6 +617,19 @@ bool CParameterMgr::applyConfigurations(string& strError)
return true;
}
+// Dynamic parameter handling
+bool CParameterMgr::setValue(const string& strPath, const string& strValue, bool bRawValueSpace, string& strError)
+{
+ // Delegate to low level functionality
+ return doSetValue(strPath, strValue, bRawValueSpace, true, strError);
+}
+
+bool CParameterMgr::getValue(const string& strPath, string& strValue, bool bRawValueSpace, bool bHexOutputRawFormat, string& strError) const
+{
+ // Delegate to low level functionality
+ return doGetValue(strPath, strValue, bRawValueSpace, bHexOutputRawFormat, true, strError);
+}
+
/////////////////// Remote command parsers
/// Version
CParameterMgr::CCommandHandler::CommandStatus CParameterMgr::versionCommandProcess(const IRemoteCommand& remoteCommand, string& strResult)
@@ -1219,73 +1232,14 @@ bool CParameterMgr::setValue(const string& strPath, const string& strValue, stri
return false;
}
- CPathNavigator pathNavigator(strPath);
-
- if (!pathNavigator.isPathValid()) {
-
- strError = "Path not well formed";
-
- return false;
- }
-
- string* pStrChildName = pathNavigator.next();
-
- if (!pStrChildName) {
-
- strError = "Non settable element";
-
- return false;
- }
-
- if (*pStrChildName != getSystemClass()->getName()) {
-
- strError = "Path not found";
-
- return false;
- }
-
- // Define context
- CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex);
-
- // Set auto sync
- parameterAccessContext.setAutoSync(_bAutoSyncOn);
-
- // Do the set
- return getSystemClass()->setValue(pathNavigator, strValue, parameterAccessContext);
+ // Delegate to low level functionality
+ return doSetValue(strPath, strValue, _bValueSpaceIsRaw, false, strError);
}
bool CParameterMgr::getValue(const string& strPath, string& strValue, string& strError) const
{
- CPathNavigator pathNavigator(strPath);
-
- if (!pathNavigator.isPathValid()) {
-
- strError = "Path not well formed";
-
- return false;
- }
-
- string* pStrChildName = pathNavigator.next();
-
- if (!pStrChildName) {
-
- strError = "Non settable element";
-
- return false;
- }
-
- if (*pStrChildName != getConstSystemClass()->getName()) {
-
- strError = "Path not found";
-
- return false;
- }
-
- // Define context
- CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex);
-
- // Do the get
- return getConstSystemClass()->getValue(pathNavigator, strValue, parameterAccessContext);
+ // Delegate to low level functionality
+ return doGetValue(strPath, strValue, _bValueSpaceIsRaw, _bOutputRawFormatIsHex, false, strError);
}
// Tuning mode
@@ -1692,6 +1646,84 @@ bool CParameterMgr::checkTuningModeOn(string& strError) const
return true;
}
+// Parameter access
+bool CParameterMgr::doSetValue(const string& strPath, const string& strValue, bool bRawValueSpace, bool bDynamicAccess, string& strError)
+{
+ CPathNavigator pathNavigator(strPath);
+
+ if (!pathNavigator.isPathValid()) {
+
+ strError = "Path not well formed";
+
+ return false;
+ }
+
+ string* pStrChildName = pathNavigator.next();
+
+ if (!pStrChildName) {
+
+ strError = "Non settable element";
+
+ return false;
+ }
+
+ if (*pStrChildName != getSystemClass()->getName()) {
+
+ strError = "Path not found";
+
+ return false;
+ }
+
+ // Define context
+ CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, bRawValueSpace, false);
+
+ // Set auto sync
+ parameterAccessContext.setAutoSync(_bAutoSyncOn);
+
+ // Set dynamic access
+ parameterAccessContext.setDynamicAccess(bDynamicAccess);
+
+ // Do the set
+ return getSystemClass()->setValue(pathNavigator, strValue, parameterAccessContext);
+}
+
+bool CParameterMgr::doGetValue(const string& strPath, string& strValue, bool bRawValueSpace, bool bHexOutputRawFormat, bool bDynamicAccess, string& strError) const
+{
+ CPathNavigator pathNavigator(strPath);
+
+ if (!pathNavigator.isPathValid()) {
+
+ strError = "Path not well formed";
+
+ return false;
+ }
+
+ string* pStrChildName = pathNavigator.next();
+
+ if (!pStrChildName) {
+
+ strError = "Non settable element";
+
+ return false;
+ }
+
+ if (*pStrChildName != getConstSystemClass()->getName()) {
+
+ strError = "Path not found";
+
+ return false;
+ }
+
+ // Define context
+ CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, bRawValueSpace, bHexOutputRawFormat);
+
+ // Set dynamic access
+ parameterAccessContext.setDynamicAccess(bDynamicAccess);
+
+ // Do the get
+ return getConstSystemClass()->getValue(pathNavigator, strValue, parameterAccessContext);
+}
+
// Dynamic creation library feeding
void CParameterMgr::feedElementLibraries()
{
diff --git a/parameter/ParameterMgr.h b/parameter/ParameterMgr.h
index ef2bd90..857034a 100644
--- a/parameter/ParameterMgr.h
+++ b/parameter/ParameterMgr.h
@@ -110,6 +110,10 @@ public:
// Configuration application
bool applyConfigurations(string& strError);
+ // Dynamic parameter handling
+ bool setValue(const string& strPath, const string& strValue, bool bRawValueSpace, string& strError);
+ bool getValue(const string& strPath, string& strValue, bool bRawValueSpace, bool bHexOutputRawFormat, string& strError) const;
+
//////////// Tuning /////////////
// Tuning mode
bool setTuningMode(bool bOn, string& strError);
@@ -238,6 +242,10 @@ private:
// For tuning, check we're in tuning mode
bool checkTuningModeOn(string& strError) const;
+ // Parameter access
+ bool doSetValue(const string& strPath, const string& strValue, bool bRawValueSpace, bool bDynamicAccess, string& strError);
+ bool doGetValue(const string& strPath, string& strValue, bool bRawValueSpace, bool bHexOutputRawFormat, bool bDynamicAccess, string& strError) const;
+
// Framework global configuration loading
bool loadFrameworkConfiguration(string& strError);
diff --git a/parameter/ParameterMgrPlatformConnector.cpp b/parameter/ParameterMgrPlatformConnector.cpp
index ae6c038..6fe5c65 100644
--- a/parameter/ParameterMgrPlatformConnector.cpp
+++ b/parameter/ParameterMgrPlatformConnector.cpp
@@ -34,7 +34,7 @@
#include <assert.h>
#ifdef SIMULATION
-const char* gpcParameterFrameworkConfigurationFolderPath = "/home/pat/Documents/gingerbread3/hardware/intel/PRIVATE/parameter-framework/XML";
+const char* gpcParameterFrameworkConfigurationFolderPath = "/home/pat/Documents/gingerbread2/hardware/intel/PRIVATE/parameter-framework/XML";
#else
const char* gpcParameterFrameworkConfigurationFolderPath = "/etc/parameter-framework";
#endif
@@ -83,6 +83,17 @@ bool CParameterMgrPlatformConnector::applyConfigurations(string& strError)
return _pParameterMgr->applyConfigurations(strError);
}
+// Dynamic parameter handling
+bool CParameterMgrPlatformConnector::setValue(const string& strPath, const string& strValue, string& strError, bool bRawValueSpace)
+{
+ return _pParameterMgr->setValue(strPath, strValue, bRawValueSpace, strError);
+}
+
+bool CParameterMgrPlatformConnector::getValue(const string& strPath, string& strValue, string& strError, bool bRawValueSpace, bool bHexOutputRawFormat) const
+{
+ return _pParameterMgr->getValue(strPath, strValue, bRawValueSpace, bHexOutputRawFormat, strError);
+}
+
// Logging
void CParameterMgrPlatformConnector::setLogger(CParameterMgrPlatformConnector::ILogger* pLogger)
{
diff --git a/parameter/ParameterMgrPlatformConnector.h b/parameter/ParameterMgrPlatformConnector.h
index 43a5c95..518fd92 100644
--- a/parameter/ParameterMgrPlatformConnector.h
+++ b/parameter/ParameterMgrPlatformConnector.h
@@ -49,9 +49,6 @@ public:
// Selection criterion retrieval
ISelectionCriterionInterface* getSelectionCriterion(const std::string& strName);
- // Configuration application
- bool applyConfigurations(std::string& strError);
-
// Logging
// Should be called before start
void setLogger(ILogger* pLogger);
@@ -59,6 +56,13 @@ public:
// Start
bool start(std::string& strError);
+ // Configuration application
+ bool applyConfigurations(std::string& strError);
+
+ // Dynamic parameter handling
+ bool setValue(const std::string& strPath, const std::string& strValue, std::string& strError, bool bRawValueSpace = false);
+ bool getValue(const std::string& strPath, std::string& strValue, std::string& strError, bool bRawValueSpace = false, bool bHexOutputRawFormat = false) const;
+
private:
// Private logging
void doLog(const std::string& strLog);