[PFW] Fix issue when setting a parameter of a configuration not applicable

BZ: 93374

This patch aims to fix an issue when using the command setConfigurationParameter
to update the value of a parameter of a configuration.
The autosync shall be turned off when updating the value of a parameter in a
configuration that is not currently applicable.

Change-Id: I12f9d37e544dc7b54f1bed0470783fdfc8568b7c
Signed-off-by: Frédéric Boisnard <fredericx.boisnard@intel.com>
Reviewed-on: http://android.intel.com:8080/96832
Reviewed-by: cactus <cactus@intel.com>
Reviewed-by: Gonzalve, Sebastien <sebastien.gonzalve@intel.com>
Reviewed-by: Denneulin, Guillaume <guillaume.denneulin@intel.com>
Reviewed-by: De Chivre, Renaud <renaud.de.chivre@intel.com>
Reviewed-by: Benavoli, Patrick <patrick.benavoli@intel.com>
Tested-by: Dixon, CharlesX <charlesx.dixon@intel.com>
Reviewed-by: buildbot <buildbot@intel.com>
Tested-by: buildbot <buildbot@intel.com>
diff --git a/parameter/ParameterAccessContext.cpp b/parameter/ParameterAccessContext.cpp
index 05e3cc3..61d54a3 100644
--- a/parameter/ParameterAccessContext.cpp
+++ b/parameter/ParameterAccessContext.cpp
@@ -26,22 +26,30 @@
 
 #define base CErrorContext
 
-CParameterAccessContext::CParameterAccessContext(string& strError, CParameterBlackboard* pParameterBlackboard, bool bValueSpaceIsRaw, bool bOutputRawFormatIsHex, uint32_t uiBaseOffset)
+CParameterAccessContext::CParameterAccessContext(string& strError,
+                                                 CParameterBlackboard* pParameterBlackboard,
+                                                 bool bValueSpaceIsRaw,
+                                                 bool bOutputRawFormatIsHex,
+                                                 uint32_t uiBaseOffset)
     : base(strError), _pParameterBlackboard(pParameterBlackboard),
     _bValueSpaceIsRaw(bValueSpaceIsRaw), _bOutputRawFormatIsHex(bOutputRawFormatIsHex),
-    _bBigEndianSubsystem(false), _bAutoSync(true), _uiBaseOffset(uiBaseOffset)
+    _bBigEndianSubsystem(false), _bAutoSync(false), _uiBaseOffset(uiBaseOffset)
 {
 }
 
-CParameterAccessContext::CParameterAccessContext(string& strError, bool bBigEndianSubsystem, CParameterBlackboard* pParameterBlackboard, uint32_t uiBaseOffset)
+CParameterAccessContext::CParameterAccessContext(string& strError,
+                                                 bool bBigEndianSubsystem,
+                                                 CParameterBlackboard* pParameterBlackboard,
+                                                 uint32_t uiBaseOffset)
     : base(strError), _pParameterBlackboard(pParameterBlackboard), _bValueSpaceIsRaw(false),
-    _bOutputRawFormatIsHex(false), _bBigEndianSubsystem(bBigEndianSubsystem), _bAutoSync(true), _uiBaseOffset(uiBaseOffset)
+    _bOutputRawFormatIsHex(false), _bBigEndianSubsystem(bBigEndianSubsystem), _bAutoSync(false),
+    _uiBaseOffset(uiBaseOffset)
 {
 }
 
 CParameterAccessContext::CParameterAccessContext(string& strError)
     : base(strError), _pParameterBlackboard(NULL), _bValueSpaceIsRaw(false),
-    _bOutputRawFormatIsHex(false), _bBigEndianSubsystem(false), _bAutoSync(true), _uiBaseOffset(0)
+    _bOutputRawFormatIsHex(false), _bBigEndianSubsystem(false), _bAutoSync(false), _uiBaseOffset(0)
 {
 }
 
diff --git a/parameter/ParameterAccessContext.h b/parameter/ParameterAccessContext.h
index f0ca74f..72982f8 100644
--- a/parameter/ParameterAccessContext.h
+++ b/parameter/ParameterAccessContext.h
@@ -32,8 +32,15 @@
 class CParameterAccessContext : public CErrorContext
 {
 public:
-    CParameterAccessContext(string& strError, CParameterBlackboard* pParameterBlackboard, bool bValueSpaceIsRaw, bool bOutputRawFormatIsHex = false, uint32_t uiOffsetBase = 0);
-    CParameterAccessContext(string& strError, bool bBigEndianSubsystem, CParameterBlackboard* pParameterBlackboard, uint32_t uiOffsetBase = 0);
+    CParameterAccessContext(string& strError,
+                            CParameterBlackboard* pParameterBlackboard,
+                            bool bValueSpaceIsRaw,
+                            bool bOutputRawFormatIsHex = false,
+                            uint32_t uiOffsetBase = 0);
+    CParameterAccessContext(string& strError,
+                            bool bBigEndianSubsystem,
+                            CParameterBlackboard* pParameterBlackboard,
+                            uint32_t uiOffsetBase = 0);
     CParameterAccessContext(string& strError);
 
     // ParameterBlackboard
diff --git a/parameter/ParameterMgr.cpp b/parameter/ParameterMgr.cpp
index e8ab863..092a496 100644
--- a/parameter/ParameterMgr.cpp
+++ b/parameter/ParameterMgr.cpp
@@ -1333,6 +1333,12 @@
     // Define context
     CParameterAccessContext parameterAccessContext(strError, _pMainParameterBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex);
 
+    // Activate the auto synchronization with the hardware
+    if (bSet) {
+
+        parameterAccessContext.setAutoSync(_bAutoSyncOn);
+    }
+
     return accessValue(parameterAccessContext, strPath, strValue, bSet, strError);
 }
 
@@ -1366,7 +1372,7 @@
 
     /// Update the Configuration Blackboard
 
-    // Define Configuration context using Base Offset
+    // Define Configuration context using Base Offset and keep Auto Sync off to prevent access to HW
     CParameterAccessContext parameterAccessContext(strError, pConfigurationBlackboard, _bValueSpaceIsRaw, _bOutputRawFormatIsHex, uiBaseOffset);
 
     // Access Value in the Configuration Blackboard
@@ -1382,6 +1388,12 @@
         // Define Main context
         parameterAccessContext.setParameterBlackboard(_pMainParameterBlackboard);
 
+        // Activate the auto synchronization with the hardware
+        if (bSet) {
+
+            parameterAccessContext.setAutoSync(_bAutoSyncOn);
+        }
+
         // Access Value in the Main Blackboard
         return accessValue(parameterAccessContext, strPath, strValue, bSet, strError);
     }
@@ -1403,12 +1415,6 @@
         return false;
     }
 
-    // Auto Sync
-    if (bSet) {
-
-        parameterAccessContext.setAutoSync(_bAutoSyncOn);
-    }
-
     // Do the get
     return getConstSystemClass()->accessValue(pathNavigator, strValue, bSet, parameterAccessContext);
 }