4 * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved.
6 * Contact: Junghwan Song <jump.song@samsung.com>
8 * Licensed under the Apache License, Version 2.0 (the "License");
9 * you may not use this file except in compliance with the License.
10 * You may obtain a copy of the License at
12 * http://www.apache.org/licenses/LICENSE-2.0
14 * Unless required by applicable law or agreed to in writing, software
15 * distributed under the License is distributed on an "AS IS" BASIS,
16 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17 * See the License for the specific language governing permissions and
18 * limitations under the License.
27 #include <system_info.h>
30 #define TFEATURE_LOG_TAG "TFEATURE"
31 #define TFEATURE_INFO(fmt, args...) do { RLOG(LOG_INFO, TFEATURE_LOG_TAG, fmt "\n", ##args); } while (0)
32 #define TFEATURE_WARN(fmt, args...) do { RLOG(LOG_WARN, TFEATURE_LOG_TAG, fmt "\n", ##args); } while (0)
33 #define TFEATURE_ERR(fmt, args...) do { RLOG(LOG_ERROR, TFEATURE_LOG_TAG, fmt "\n", ##args); } while (0)
35 #define FEATURE_BITS (sizeof(unsigned char) * 8)
36 #define MAX_FEATURE_LIST_BYTES (FEATURE_BITS * 4)
37 #define SET_FEATURE(X) \
39 if (X < TFEATURE_MAX_VALUE) { \
40 features.feature_list[(X) / FEATURE_BITS] |= ((unsigned char) 1) << ((X) % FEATURE_BITS); \
41 TFEATURE_INFO("feature[0x%02x] is supported.", (X)); \
43 TFEATURE_ERR("invalid feature[0x%02x]", X); \
46 #define CHECK_FEATURE(X) (features.feature_list[(X) / FEATURE_BITS] & ((unsigned char) 1) << ((X) % FEATURE_BITS))
50 unsigned char feature_list[MAX_FEATURE_LIST_BYTES]; // support 255 (2 ^ FEATURE_BITS) features
53 static q_feature_info features = {FALSE, {0,} };
55 static void _tfeature_check_default_feature(void)
57 SET_FEATURE(TFEATURE_UI_NO_SVC_MANUAL_PLMN_CHECK);
58 SET_FEATURE(TFEATURE_FUNCTION_REFER_EONS_ON_MANUAL_SEARCH);
61 static void _tfeature_check_build_feature(void)
64 #ifdef TIZEN_FEATURE_CDMA
65 SET_FEATURE(TFEATURE_FUNCTION_ENABLE_CDMA);
66 #endif /* TIZEN_FEATURE_CDMA*/
68 #ifdef TIZEN_FEATURE_NO_DISPLAY_PANEL
69 SET_FEATURE(TFEATURE_DEVICE_NO_DISPLAY_PANEL);
70 #endif /* TIZEN_FEATURE_NO_DISPLAY_PANEL*/
72 #ifdef TIZEN_FEATURE_WEARABLE
73 SET_FEATURE(TFEATURE_DEVICE_WEARABLE);
74 SET_FEATURE(TFEATURE_FUNCTION_IMS_PDN_AUTO_ACTIVATE);
76 SET_FEATURE(TFEATURE_FUNCTION_MANAGER_NETWORK_NAME_ENABLE);
77 SET_FEATURE(TFEATURE_FUNCTION_IMS_PDN_AUTO_ACTIVATE);
78 #endif /* TIZEN_FEATURE_WEARABLE */
80 #ifdef TIZEN_FEATURE_CHIPSET_VENDOR_EXYNOS
81 SET_FEATURE(TFEATURE_FUNCTION_MANAGER_NETWORK_NAME_ENABLE);
82 SET_FEATURE(TFEATURE_FUNCTION_ENABLE_IPV6_RSRA);
83 SET_FEATURE(TFEATURE_FUNCTION_NET_CHECK_ECC_RAT);
84 SET_FEATURE(TFEATURE_FUNCTION_SEND_APN_INFO);
85 SET_FEATURE(TFEATURE_DEVICE_CHIPSET_VENDOR_EXYNOS);
86 #endif /* TIZEN_FEATURE_CHIPSET_VENDOR_EXYNOS*/
88 #ifdef TIZEN_FEATURE_CHIPSET_VENDOR_SPREADTRUM
89 #ifdef TIZEN_FEATURE_PROTOCOL_ATCMD
91 SET_FEATURE(TFEATURE_FUNCTION_SEND_APN_INFO);
92 SET_FEATURE(TFEATURE_FUNCTION_NET_CHECK_ECC_RAT);
97 static void _tfeature_check_platform_feature()
101 bool b_lte_supported = false;
102 bool b_gsm_supported = false;
103 bool b_umts_suported = false;
104 bool b_cdma_supported = false;
106 ret = system_info_get_platform_string("http://tizen.org/system/model_name", &model_name);
107 if (ret != SYSTEM_INFO_ERROR_NONE) {
108 TFEATURE_INFO("system_info_get_platform_string() failed!!! (%d,%s)", ret, get_error_message(ret));
112 TFEATURE_INFO("model_name[%s]", model_name);
113 if (!g_strcmp0(model_name, "TW2")) {
114 SET_FEATURE(TFEATURE_DEVICE_CHIPSET_VENDOR_EXYNOS);
115 SET_FEATURE(TFEATURE_FUNCTION_SEND_APN_INFO);
120 system_info_get_platform_bool("tizen.org/feature/network.telephony.service.cdma", &b_cdma_supported);
121 system_info_get_platform_bool("tizen.org/feature/network.telephony.service.gsm", &b_gsm_supported);
122 system_info_get_platform_bool("tizen.org/feature/network.telephony.service.umts", &b_umts_suported);
123 system_info_get_platform_bool("tizen.org/feature/network.telephony.service.lte", &b_lte_supported);
125 if (true == b_lte_supported) {
126 TFEATURE_INFO("LTE SUPPORTED");
127 SET_FEATURE(TFEATURE_DEVICE_LTE_SUPPORTED);
130 if (true == b_lte_supported && false == b_gsm_supported && false == b_umts_suported && false == b_cdma_supported) {
131 TFEATURE_INFO("LTE only model");
132 SET_FEATURE(TFEATURE_DEVICE_LTE_ONLY);
136 static void _tfeature_print_hex_dump()
138 char buf[255] = {0, };
142 g_snprintf(buf, 255, "%s%04X: ", "[FEATURE_LIST]", 0);
143 for (i = 0; i < (int)MAX_FEATURE_LIST_BYTES; i++) {
144 g_snprintf(hex, 4, "%02X ", features.feature_list[i]);
145 memcpy(buf + strlen(buf), hex, 4);
147 if ((i + 1) % 8 == 0) {
148 if ((i + 1) % 16 == 0) {
149 TFEATURE_INFO("%s", buf);
151 g_snprintf(buf, 255, "%s%04X: ", "[FEATURE_LIST]", i + 1);
153 g_strlcat(buf, " ", 255);
158 TFEATURE_INFO("%s", buf);
161 static void _tfeature_init(void)
163 _tfeature_check_default_feature();
164 _tfeature_check_build_feature();
165 _tfeature_check_platform_feature();
167 _tfeature_print_hex_dump();
168 features.valid = TRUE;
171 tfeature_support tfeature_is_supported(tfeature_name feature)
173 tfeature_support ret = TFEATURE_NOT_SUPPORTED;
175 if (!features.valid) {
177 TFEATURE_INFO("TFEATURE INITIALIZED!!!");
180 if (features.valid && feature < TFEATURE_MAX_VALUE) {
181 if (CHECK_FEATURE(feature))
182 ret = TFEATURE_SUPPORTED;
184 ret = TFEATURE_NOT_SUPPORTED;