summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSanket Khidkikar <sanketk@codeaurora.org>2012-05-25 13:14:31 -0700
committerSanket Khidkikar <sanketk@codeaurora.org>2012-06-04 15:20:13 -0700
commitce48ea32ee8422fcf677e54cab4c3515c554b7bf (patch)
treec45c4f8eba09e34cd705538e52704d4aecaf86a7
parentcd20ec712b4f59ae7a7ce5a88eb00d0c04add114 (diff)
downloadandroid_external_connectivity-ce48ea32ee8422fcf677e54cab4c3515c554b7bf.tar.gz
android_external_connectivity-ce48ea32ee8422fcf677e54cab4c3515c554b7bf.tar.bz2
android_external_connectivity-ce48ea32ee8422fcf677e54cab4c3515c554b7bf.zip
Add API to check whether a Cne feature is enabled.
Native class CneFeatureConfig provides API which is used to check whether a specific feature (as defined in class header) is enabled or disabled on build. Change-Id: I44c4ed7a123c5bc6cbbf7520dce5bcd47d30019a
-rw-r--r--cnefeatureconfig/Android.mk23
-rw-r--r--cnefeatureconfig/inc/CneFeatureConfig.h102
-rw-r--r--cnefeatureconfig/src/CneFeatureConfig.cpp156
3 files changed, 281 insertions, 0 deletions
diff --git a/cnefeatureconfig/Android.mk b/cnefeatureconfig/Android.mk
new file mode 100644
index 0000000..1ec969b
--- /dev/null
+++ b/cnefeatureconfig/Android.mk
@@ -0,0 +1,23 @@
+LOCAL_PATH:= $(call my-dir)
+include $(CLEAR_VARS)
+LOCAL_ARM_MODE := arm
+
+LOCAL_SRC_FILES:= \
+ src/CneFeatureConfig.cpp\
+
+LOCAL_MODULE:= libcnefeatureconfig
+LOCAL_MODULE_TAGS := optional
+
+LOCAL_SHARED_LIBRARIES := libc libcutils libstlport \
+
+LOCAL_C_INCLUDES := \
+ external/connectivity/cnefeatureconfig/inc \
+ external/connectivity/stlport/stlport \
+
+LOCAL_REQUIRED_MODULES := \
+ external/connectivity/stlport
+
+LOCAL_PRELINK_MODULE := false
+
+include $(BUILD_SHARED_LIBRARY)
+
diff --git a/cnefeatureconfig/inc/CneFeatureConfig.h b/cnefeatureconfig/inc/CneFeatureConfig.h
new file mode 100644
index 0000000..7cab2b2
--- /dev/null
+++ b/cnefeatureconfig/inc/CneFeatureConfig.h
@@ -0,0 +1,102 @@
+#ifndef CneFeatureConfig_H
+#define CneFeatureConfig_H
+
+/*=========================================================================
+ Copyright (c) 2012, Code Aurora Forum. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of Code Aurora Forum, Inc. nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+=========================================================================*/
+
+/* Enum Feature represents values to be used to
+* query whether a feature is enabled.
+*/
+
+enum Feature {
+ CNE = 1,
+ FMC = 2,
+ WQE = 3,
+ NSRM = 4,
+};
+
+#define CNE_FEATURE_PROP "persist.cne.feature"
+
+#ifdef __cplusplus
+extern "C"
+#endif /*__cplusplus*/
+/* Provide C function to be used by JNI and other C/C++ modules.
+ * Parameter should be one of the following values:
+ * CNE
+ * FMC,
+ * WQE,
+ * NSRM
+*/
+bool isFeatureEnabled(int f);
+
+#ifdef __cplusplus
+/* Allow clients to query what features of CNE are
+ * enabled.
+ */
+class CneFeatureConfig {
+private:
+ bool bCne;
+ bool bFmc;
+ bool bWqe;
+ bool bNsrm;
+ /* Reads the CNE_FEATURE_PROP to determine which features
+ are currently enabled.*/
+ void readFeature(void);
+
+ /* Enum FeatureProperty values represents all permissible feature values.
+ * CNE_FEATURE_PROP must have one of these values:
+ * CNE_ONLY --> bCne set true
+ * FMC_CNE --> bCne & bFmc set true
+ * WQE_CNE --> bFmc & bCne set true
+ * NSRM_CNE --> bNsrm & bCne set true
+ * FMC_NSRM_CNE --> bFmc, bNsrm, bCne set true
+ * WQE_NSRM_CNE --> bWqe, bNsrm, bCne set true
+ * Any other value will return false. By default
+ * LinkManager used if CNE disabled.
+ */
+ enum FeatureProperty {
+ LINK_MGR = 0, /* Link Manager - no CNE features enabled */
+ CNE_ONLY = 1, /* CNE only */
+ FMC_CNE = 2, /* CNE feature is prerequisite */
+ WQE_CNE = 3, /* CNE feature is prerequisite */
+ NSRM_CNE = 4, /* CNE feature is prerequisite */
+ FMC_NSRM_CNE = 5, /* CNE feature is prerequisite */
+ WQE_NSRM_CNE = 6, /* CNE feature is prerequisite */
+ };
+
+public:
+ bool isEnabled(Feature f);
+ CneFeatureConfig();
+ ~CneFeatureConfig();
+};
+
+#endif /*__cplusplus*/
+
+#endif /*CneFeatureConfig_H*/
+
diff --git a/cnefeatureconfig/src/CneFeatureConfig.cpp b/cnefeatureconfig/src/CneFeatureConfig.cpp
new file mode 100644
index 0000000..f25774b
--- /dev/null
+++ b/cnefeatureconfig/src/CneFeatureConfig.cpp
@@ -0,0 +1,156 @@
+/*==============================================================================
+Copyright (c) 2012, Code Aurora Forum. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are
+met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+ copyright notice, this list of conditions and the following
+ disclaimer in the documentation and/or other materials provided
+ with the distribution.
+ * Neither the name of Code Aurora Forum, Inc. nor the names of its
+ contributors may be used to endorse or promote products derived
+ from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED "AS IS" AND ANY EXPRESS OR IMPLIED
+WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT
+ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS
+BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
+BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
+OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN
+IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+==============================================================================*/
+
+/*------------------------------------------------------------------------------
+* Include Files
+* ---------------------------------------------------------------------------*/
+#include <cutils/properties.h>
+#include<cstring>
+#include "CneFeatureConfig.h"
+#include <stdlib.h>
+#include <cutils/log.h>
+
+/*------------------------------------------------------------------------------
+* Preprocessor Definitions and Constants
+* ---------------------------------------------------------------------------*/
+#undef LOG_TAG
+#define LOG_TAG "CNEFEATURECONFIG"
+
+/*-----------------------------------------------------------------------------
+ * Global functions
+ * --------------------------------------------------------------------------*/
+bool isFeatureEnabled(int f)
+{
+ bool bEnabled = false;
+ CneFeatureConfig *cneFeature = new CneFeatureConfig;
+
+ if (NULL != cneFeature) {
+ bEnabled = cneFeature->isEnabled((Feature) f);
+ delete cneFeature;
+ } else {
+ LOGE("Failed to instantiate CneFeatureConfig! Default = disabled");
+ }
+
+ return bEnabled;
+}
+
+/*-----------------------------------------------------------------------------
+ * Class methods
+ * --------------------------------------------------------------------------*/
+CneFeatureConfig::CneFeatureConfig():bCne(false),
+ bFmc(false),
+ bWqe(false),
+ bNsrm(false)
+{
+}
+
+CneFeatureConfig::~CneFeatureConfig()
+{
+}
+
+/* Read the currently set feature property value.
+*/
+void CneFeatureConfig::readFeature(void) {
+ FeatureProperty val;
+ char prop_value_feature[PROPERTY_VALUE_MAX] = {'\0'};
+ property_get(CNE_FEATURE_PROP, prop_value_feature, "0");
+ val = (FeatureProperty) atoi(prop_value_feature);
+
+ switch (val) {
+ case LINK_MGR: // 0 --> Use Link Manager. Cne is completely disabled.
+ {
+ // do nothing
+ break;
+ }
+ case CNE_ONLY: // 1--> Only Cne default behavior enabled.
+ {
+ bCne = true;
+ break;
+ }
+ case FMC_CNE: // 2--> CNE enabled. FMC mode
+ {
+ bCne = true;
+ bFmc = true;
+ break;
+ }
+ case NSRM_CNE: // 3--> CNE enabled. NSRM mode.
+ {
+ bCne = true;
+ bNsrm = true;
+ break;
+ }
+ case WQE_CNE: // 4--> CNE enabled. WQE mode.
+ {
+ bCne = true;
+ bWqe = true;
+ break;
+ }
+ case FMC_NSRM_CNE: //5 --> CNE enabled. FMC & NSRM mode.
+ {
+ bCne = true;
+ bFmc = true;
+ bNsrm = true;
+ break;
+ }
+ case WQE_NSRM_CNE: //6 --> CNE enabled. WQE & NSRM mode.
+ {
+ bCne = true;
+ bWqe = true;
+ bNsrm = true;
+ break;
+ }
+ default:
+ LOGW("Unknown feature value in property. Features disabled by default");
+ }
+}
+
+bool CneFeatureConfig::isEnabled(Feature f) {
+ readFeature();
+ switch(f){
+ case CNE:
+ return bCne;
+ break;
+ case FMC:
+ return bFmc;
+ break;
+ case NSRM:
+ return bNsrm;
+ break;
+ case WQE:
+ return bWqe;
+ break;
+ default:
+ LOGW("Feature %d not known, returning default", f);
+ return false;
+ }
+
+ return false;
+}
+