From 1dd8e4596dcd0a5f7b8c44364c210d4ef9bf7128 Mon Sep 17 00:00:00 2001 From: sinikang Date: Fri, 10 Mar 2017 10:29:24 +0900 Subject: [PATCH] Add tfeature definition and functionality Change-Id: I3c16a554cf8ab7f702044d2a6b775fd648ac28ae --- CMakeLists.txt | 3 + feature/CMakeLists.txt | 38 ++++++++ feature/include/tfeature.h | 108 +++++++++++++++++++++++ feature/tfeature.c | 173 +++++++++++++++++++++++++++++++++++++ feature/tfeature.pc.in | 11 +++ packaging/tel-plugin-database.spec | 28 +++++- 6 files changed, 360 insertions(+), 1 deletion(-) create mode 100644 feature/CMakeLists.txt create mode 100644 feature/include/tfeature.h create mode 100644 feature/tfeature.c create mode 100644 feature/tfeature.pc.in diff --git a/CMakeLists.txt b/CMakeLists.txt index aed640d..8bb7d99 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -58,3 +58,6 @@ IF (OPERATOR_CDMA) INSTALL(FILES ${CMAKE_SOURCE_DIR}/res/cdma_mcc_sid_list.sql DESTINATION /tmp RENAME mcc_sid_list.sql) ENDIF (OPERATOR_CDMA) INSTALL(FILES ${CMAKE_SOURCE_DIR}/LICENSE DESTINATION /usr/share/license RENAME tel-plugin-database) + +### add subdirectory ### +ADD_SUBDIRECTORY(feature) diff --git a/feature/CMakeLists.txt b/feature/CMakeLists.txt new file mode 100644 index 0000000..8217bc6 --- /dev/null +++ b/feature/CMakeLists.txt @@ -0,0 +1,38 @@ +PROJECT(tfeature C) +MESSAGE("... TFEATURE ...") + +# Set required packages + +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) +SET(LIBDIR ${LIB_INSTALL_DIR}) + +INCLUDE(FindPkgConfig) +pkg_check_modules(feature_pkgs REQUIRED capi-system-info) + +FOREACH(flag ${feature_pkgs_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/include/) + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}") + +MESSAGE(${CMAKE_C_FLAGS}) +MESSAGE(${CMAKE_EXE_LINKER_FLAGS}) + +SET(SRCS + ${CMAKE_CURRENT_SOURCE_DIR}/tfeature.c +) + +# library build +ADD_LIBRARY(tfeature SHARED ${SRCS}) +TARGET_LINK_LIBRARIES(tfeature ${feature_pkgs_LDFLAGS}) +SET_TARGET_PROPERTIES(tfeature PROPERTIES PREFIX "" OUTPUT_NAME libtfeature) + +# pkgconfig file +CONFIGURE_FILE(tfeature.pc.in tfeature.pc @ONLY) + +# install +INSTALL(TARGETS tfeature LIBRARY DESTINATION ${LIBDIR}) +INSTALL(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION include/tfeature) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/tfeature.pc DESTINATION ${LIBDIR}/pkgconfig) diff --git a/feature/include/tfeature.h b/feature/include/tfeature.h new file mode 100644 index 0000000..83f8983 --- /dev/null +++ b/feature/include/tfeature.h @@ -0,0 +1,108 @@ +/* + * libtfeature + * + * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Junghwan Song + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + + +#pragma once + +#define TFEATURE_TYPE_FUNCTION 0x40 +#define TFEATURE_TYPE_UI 0x80 +#define TFEATURE_TYPE_DEVICE 0xC0 + +typedef enum { + + /* function feature : 0x41 ~ 0x7F */ + TFEATURE_FUNCTION = TFEATURE_TYPE_FUNCTION, + TFEATURE_FUNCTION_DISPLAY_CHN_SPN, + TFEATURE_FUNCTION_ENABLE_DSAC, + TFEATURE_FUNCTION_SMS_BEARER_PS_PREFERRED, + TFEATURE_FUNCTION_CNAP_UNPACK_DCS, + TFEATURE_FUNCTION_DISPLAY_RATINFO_MANUALSEARCH, + TFEATURE_FUNCTION_DISPLAY_PLMN_NAME_ONLY, + TFEATURE_FUNCTION_DISPLAY_PLMN_FAKING_4MVNO, + TFEATURE_FUNCTION_DISPLAY_LAC_NETNAME, + TFEATURE_FUNCTION_DISPLAY_LU_REJECT_CAUSE, + TFEATURE_FUNCTION_DISPLAY_DELTA_AND_SHORT_NAME, + TFEATURE_FUNCTION_REFER_EONS_ON_MANUAL_SEARCH, + TFEATURE_FUNCTION_CHECK_ACTIVATED_SIM, + TFEATURE_FUNCTION_ENABLE_ENS, + TFEATURE_FUNCTION_RTS_INDICATION, + TFEATURE_FUNCTION_HIDE_CNAP = 0x4F, + TFEATURE_FUNCTION_REFER_EONS_WITHOUT_LAC, + TFEATURE_FUNCTION_REFER_SPN_ON_MANUAL_SEARCH, + TFEATURE_FUNCTION_SKIP_EONS_INFO, + TFEATURE_FUNCTION_MANAGER_NETWORK_NAME_ENABLE, + TFEATURE_FUNCTION_SUPPORT_WB_AMR_2G, + TFEATURE_FUNCTION_SUPPORT_OVERRIDE_IPV4_ONLY, + TFEATURE_FUNCTION_PPP_AUTHENTIFICATION, + TFEATURE_FUNCTION_NOTIFY_LINE_CONTROL, + TFEATURE_FUNCTION_NET_STK_HIDE_ALPHA_ID, + TFEATURE_FUNCTION_AUTO_RESUME, + TFEATURE_FUNCTION_CS_OVERRIDE_EMERGENCY_CALL, + TFEATURE_FUNCTION_ENABLE_IPV6_RSRA, + TFEATURE_FUNCTION_ENABLE_CDMA, + TFEATURE_FUNCTION_NET_CHECK_ECC_RAT, + TFEATURE_FUNCTION_EMERGENCY_CALLBACK, + TFEATURE_FUNCTION_SEND_APN_INFO = 0x5F, + TFEATURE_FUNCTION_IMS_PDN_AUTO_ACTIVATE, + TFEATURE_FUNCTION_DUAL_NUMBER_SERVICE, + TFEATURE_FUNCTION_TWO_PHONE_SERVICE, + TFEATURE_FUNCTION_BIP_OTA_REGISTRATION, + TFEATURE_FUNCTION_SUPPORT_STK_BIP, + TFEATURE_FUNCTION_SEND_OK_FOR_SAT_DISPLAY_TEXT, + TFEATURE_FUNCTION_SUPPORT_SEND_SMS_FOR_SAT_SEND_SMS, + TFEATURE_FUNCTION_SEND_SSAC_STATUS, + TFEATURE_FUNCTION_PACKET_KEEP_ALIVE, + TFEATURE_FUNCTION_ATTACH_APN_INTERNET, + TFEATURE_FUNCTION_BACKUP_APN, + TFEATURE_FUNCTION_SUPPORT_MF_ONLY_ESIM_CARD, + TFEATURE_FUNCTION_MAX_VALUE = 0x7F, + + /* UI feature : 0x81 ~ 0xBF */ + TFEATURE_UI = TFEATURE_TYPE_UI, + TFEATURE_UI_NO_SVC_MANUAL_PLMN_CHECK, + TFEATURE_UI_CALL_LAUNCH_CS_REGISTER, + TFEATURE_UI_NITZ_TIME_UPDATE_POPUP, + TFEATURE_UI_SIM_RAISE_INVALID_SIM_POPUP, + TFEATURE_UI_DATA_ROAMING_SUB_MENU, + TFEATURE_UI_DATA_ROAMING_ALWAYS_ASK, + TFEATURE_UI_DATA_ROAMING_POPUP_ONLY_WHEN_PS_ACCEPTED, + TFEATURE_UI_LAUNCH_ACTIVATION_POPUP, + TFEATURE_UI_DISPLAY_LU_REJECT_CAUSE, + TFEATURE_UI_MAX_VALUE = 0xBF, + + /* Device feature : 0xC1 ~ 0xCF */ + TFEATURE_DEVICE = TFEATURE_TYPE_DEVICE, + TFEATURE_DEVICE_NO_DISPLAY_PANEL = 0xC1, + TFEATURE_DEVICE_WEARABLE, + TFEATURE_DEVICE_LTE_ONLY, + + TFEATURE_DEVICE_CHIPSET_VENDOR_EXYNOS, + + + TFEATURE_MAX_VALUE = 0xFF, +} tfeature_name; + +typedef enum { + TFEATURE_NOT_SUPPORTED = 0, + TFEATURE_SUPPORTED = 1, +} tfeature_support; + +EXPORT_API tfeature_support tfeature_is_supported(tfeature_name feature); diff --git a/feature/tfeature.c b/feature/tfeature.c new file mode 100644 index 0000000..762ea85 --- /dev/null +++ b/feature/tfeature.c @@ -0,0 +1,173 @@ +/* + * libtfeature + * + * Copyright (c) 2012 Samsung Electronics Co., Ltd. All rights reserved. + * + * Contact: Junghwan Song + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + + +#include "tfeature.h" + +#include +#include +#include +#include + +#define TFEATURE_LOG_TAG "TFEATURE" +#define TFEATURE_INFO(fmt,args...) do { RLOG(LOG_INFO, TFEATURE_LOG_TAG, fmt "\n", ##args); } while (0) +#define TFEATURE_WARN(fmt,args...) do { RLOG(LOG_WARN, TFEATURE_LOG_TAG, fmt "\n", ##args); } while (0) +#define TFEATURE_ERR(fmt,args...) do { RLOG(LOG_ERROR, TFEATURE_LOG_TAG, fmt "\n", ##args); } while (0) + +#define FEATURE_BITS (sizeof(unsigned char) * 8) +#define MAX_FEATURE_LIST_BYTES (FEATURE_BITS * 4) +#define SET_FEATURE(X) \ +{ \ + if (X < TFEATURE_MAX_VALUE) { \ + features.feature_list[(X) / FEATURE_BITS] |= ((unsigned char) 1) << ((X) % FEATURE_BITS); \ + TFEATURE_INFO("feature[0x%02x] is supported.", (X)); \ + } else { \ + TFEATURE_ERR("invalid feature[0x%02x]", X); \ + } \ +} +#define CHECK_FEATURE(X) (features.feature_list[(X) / FEATURE_BITS] & ((unsigned char) 1) << ((X) % FEATURE_BITS)) + +typedef struct { + gboolean valid; + unsigned char feature_list[MAX_FEATURE_LIST_BYTES]; // support 255 (2 ^ FEATURE_BITS) features +} q_feature_info; + +static q_feature_info features = {FALSE, {0,}}; + +static void _tfeature_check_default_feature(void) +{ + SET_FEATURE(TFEATURE_UI_NO_SVC_MANUAL_PLMN_CHECK); + SET_FEATURE(TFEATURE_FUNCTION_REFER_EONS_ON_MANUAL_SEARCH); +} + +static void _tfeature_check_build_feature(void) +{ +/* Build Feature */ +#ifdef TIZEN_FEATURE_CDMA + SET_FEATURE(TFEATURE_FUNCTION_ENABLE_CDMA); +#endif /* TIZEN_FEATURE_CDMA*/ + +#ifdef TIZEN_FEATURE_NO_DISPLAY_PANEL + SET_FEATURE(TFEATURE_DEVICE_NO_DISPLAY_PANEL); +#endif /* TIZEN_FEATURE_NO_DISPLAY_PANEL*/ + +#ifdef TIZEN_FEATURE_WEARABLE + SET_FEATURE(TFEATURE_DEVICE_WEARABLE); + SET_FEATURE(TFEATURE_FUNCTION_IMS_PDN_AUTO_ACTIVATE); +#else + SET_FEATURE(TFEATURE_FUNCTION_MANAGER_NETWORK_NAME_ENABLE); + SET_FEATURE(TFEATURE_FUNCTION_IMS_PDN_AUTO_ACTIVATE); +#endif /* TIZEN_FEATURE_WEARABLE */ + +#ifdef TIZEN_FEATURE_CHIPSET_VENDOR_EXYNOS + SET_FEATURE(TFEATURE_FUNCTION_MANAGER_NETWORK_NAME_ENABLE); + SET_FEATURE(TFEATURE_FUNCTION_ENABLE_IPV6_RSRA); + SET_FEATURE(TFEATURE_FUNCTION_NET_CHECK_ECC_RAT); + SET_FEATURE(TFEATURE_FUNCTION_SEND_APN_INFO); + SET_FEATURE(TFEATURE_DEVICE_CHIPSET_VENDOR_EXYNOS); +#endif /* TIZEN_FEATURE_CHIPSET_VENDOR_EXYNOS*/ + +#ifdef TIZEN_FEATURE_CHIPSET_VENDOR_SPREADTRUM + #ifdef TIZEN_FEATURE_PROTOCOL_ATCMD + #else + SET_FEATURE(TFEATURE_FUNCTION_SEND_APN_INFO); + SET_FEATURE(TFEATURE_FUNCTION_NET_CHECK_ECC_RAT); + #endif +#endif +} + +static void _tfeature_check_model_config() +{ + char *model_name; + int ret; + bool b_lte_supported = false; + bool b_gsm_supported = false; + bool b_umts_suported = false; + bool b_cdma_supported = false; + + ret = system_info_get_platform_string("http://tizen.org/system/model_name", &model_name); + if (SYSTEM_INFO_ERROR_NONE == ret && model_name) { + TFEATURE_INFO("model_name[%s]", model_name); + free(model_name); + } + system_info_get_platform_bool("tizen.org/feature/network.telephony.service.cdma", &b_cdma_supported); + system_info_get_platform_bool("tizen.org/feature/network.telephony.service.gsm", &b_gsm_supported); + system_info_get_platform_bool("tizen.org/feature/network.telephony.service.umts", &b_umts_suported); + system_info_get_platform_bool("tizen.org/feature/network.telephony.service.lte", &b_lte_supported); + + if(true == b_lte_supported && false == b_gsm_supported && false == b_umts_suported && false == b_cdma_supported){ + TFEATURE_INFO("LTE only model"); + SET_FEATURE(TFEATURE_DEVICE_LTE_ONLY); + } +} + +static void _tfeature_print_hex_dump() +{ + char buf[255] = {0, }; + char hex[4] = {0, }; + int i = 0; + + g_snprintf(buf, 255, "%s%04X: ", "[FEATURE_LIST]", 0); + for (i = 0; i < (int)MAX_FEATURE_LIST_BYTES; i++) { + g_snprintf(hex, 4, "%02X ", features.feature_list[i]); + memcpy(buf + strlen(buf), hex, 4); + + if ((i + 1) % 8 == 0) { + if ((i + 1) % 16 == 0) { + TFEATURE_INFO("%s", buf); + memset(buf, 0, 255); + g_snprintf(buf, 255, "%s%04X: ", "[FEATURE_LIST]", i + 1); + } else { + g_strlcat (buf, " ", 255); + } + } + } + + TFEATURE_INFO("%s", buf); +} + +static void _tfeature_init(void) +{ + _tfeature_check_default_feature(); + _tfeature_check_build_feature(); + _tfeature_check_model_config(); + + _tfeature_print_hex_dump(); + features.valid = TRUE; +} + +tfeature_support tfeature_is_supported(tfeature_name feature) +{ + tfeature_support ret = TFEATURE_NOT_SUPPORTED; + + if (!features.valid) { + _tfeature_init(); + } + + if (features.valid && feature < TFEATURE_MAX_VALUE) { + if (CHECK_FEATURE(feature)) + ret = TFEATURE_SUPPORTED; + else + ret = TFEATURE_NOT_SUPPORTED; + } + + return ret; +} diff --git a/feature/tfeature.pc.in b/feature/tfeature.pc.in new file mode 100644 index 0000000..5944209 --- /dev/null +++ b/feature/tfeature.pc.in @@ -0,0 +1,11 @@ +prefix=@PREFIX@ +exec_prefix=${prefix} +libdir=@LIBDIR@ +includedir=${prefix}/include + +Name: tfeature +Description: Telephony Feature Library +Version: 1.0 +Requires: glib-2.0 +Libs: -L${libdir} -ltfeature +Cflags: -I${includedir}/tfeature diff --git a/packaging/tel-plugin-database.spec b/packaging/tel-plugin-database.spec index 395d212..05202e0 100644 --- a/packaging/tel-plugin-database.spec +++ b/packaging/tel-plugin-database.spec @@ -1,6 +1,6 @@ %define major 0 %define minor 1 -%define patchlevel 30 +%define patchlevel 31 Name: tel-plugin-database Version: %{major}.%{minor}.%{patchlevel} @@ -14,12 +14,28 @@ BuildRequires: pkgconfig(db-util) BuildRequires: pkgconfig(glib-2.0) BuildRequires: pkgconfig(tcore) BuildRequires: pkgconfig(libtzplatform-config) +BuildRequires: pkgconfig(capi-system-info) Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig %description Telephony DataBase storage plugin +%package -n libtfeature +Summary: Telephony Feature Library +Group: Development/Libraries + +%description -n libtfeature +Telephony Feature Library + +%package -n libtfeature-devel +Summary: Telephony Feature Library (devel) +Group: Development/Libraries +Requires: libtfeature + +%description -n libtfeature-devel +Telephony Feature Library (devel) + %prep %setup -q @@ -78,3 +94,13 @@ mkdir -p %{buildroot}%{_datadir}/license %{_libdir}/telephony/plugins/db-plugin* %{_datadir}/upgrade/scripts/500.mcc_mnc_oper_list_upgrade_24_30.sh %{_datadir}/license/tel-plugin-database + + +%files -n libtfeature +%defattr(644,root,root,-) +%{_libdir}/*.so + +%files -n libtfeature-devel +%defattr(644,root,root,-) +%{_libdir}/pkgconfig/*.pc +%{_includedir}/tfeature/*.h -- 2.7.4