From 1e9cd7cc51dc99c41c329f953492aeaa30fc4412 Mon Sep 17 00:00:00 2001 From: Amritanshu Pandia Date: Thu, 9 Jun 2016 17:19:31 +0530 Subject: [PATCH] [ITC][telephony][Non-ACR][DPTTIZEN-2007 Modified to check cellular state] Change-Id: I83ff521b40d659bda27cc97e57ec4891d5ae140d Signed-off-by: Amritanshu Pandia --- packaging/itc/native-telephony-itc.spec | 1 + packaging/itc/native-telephony-itc.xml | 3 ++ src/itc/telephony/CMakeLists.txt | 1 + src/itc/telephony/ITs-telephony-call.c | 56 +++++++++++++++++++++++++++++++ src/itc/telephony/ITs-telephony-common.c | 32 ++++++++++++++++++ src/itc/telephony/ITs-telephony-common.h | 7 ++++ src/itc/telephony/ITs-telephony-network.c | 56 +++++++++++++++++++++++++++++++ src/itc/telephony/ITs-telephony-sim.c | 56 +++++++++++++++++++++++++++++++ src/itc/telephony/ITs-telephony.c | 56 +++++++++++++++++++++++++++++++ 9 files changed, 268 insertions(+) diff --git a/packaging/itc/native-telephony-itc.spec b/packaging/itc/native-telephony-itc.spec index 7a8d18b..9f46993 100755 --- a/packaging/itc/native-telephony-itc.spec +++ b/packaging/itc/native-telephony-itc.spec @@ -15,6 +15,7 @@ BuildRequires: pkgconfig(glib-2.0) BuildRequires: cmake BuildRequires: pkgconfig(bundle) BuildRequires: pkgconfig(capi-system-info) +BuildRequires: pkgconfig(capi-network-connection) %description Native API Integration TC (%{name}) diff --git a/packaging/itc/native-telephony-itc.xml b/packaging/itc/native-telephony-itc.xml index 26c2baa..c872549 100755 --- a/packaging/itc/native-telephony-itc.xml +++ b/packaging/itc/native-telephony-itc.xml @@ -8,5 +8,8 @@ http://tizen.org/privilege/telephony http://tizen.org/privilege/location.coarse + http://tizen.org/privilege/network.profile + http://tizen.org/privilege/network.get + http://tizen.org/privilege/network.set diff --git a/src/itc/telephony/CMakeLists.txt b/src/itc/telephony/CMakeLists.txt index c6421c2..ecc5942 100755 --- a/src/itc/telephony/CMakeLists.txt +++ b/src/itc/telephony/CMakeLists.txt @@ -19,6 +19,7 @@ PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED glib-2.0 capi-system-info dlog elementary + capi-network-connection ) INCLUDE_DIRECTORIES( diff --git a/src/itc/telephony/ITs-telephony-call.c b/src/itc/telephony/ITs-telephony-call.c index 90f3f87..d4db3af 100755 --- a/src/itc/telephony/ITs-telephony-call.c +++ b/src/itc/telephony/ITs-telephony-call.c @@ -78,7 +78,63 @@ void ITs_telephony_call_startup(void) g_bTelephonyInit = false; return; } + + bool bWifiFeatureSupported = TCTCheckSystemInfoFeatureSupported(WIFI_FEATURE, API_NAMESPACE); + bool bEthernetFeatureSupported = TCTCheckSystemInfoFeatureSupported(ETHERNET_FEATURE, API_NAMESPACE); + bool bBtFeatureSupported = TCTCheckSystemInfoFeatureSupported(TETHERING_BLUETOOTH_FEATURE, API_NAMESPACE); + + connection_h hConenctionHandle = NULL; + connection_cellular_state_e eState; + + nRet = connection_create(&hConenctionHandle); + if ( false == g_bTelephonyIssupportedFeature && false == bWifiFeatureSupported && false == bBtFeatureSupported && false == bEthernetFeatureSupported ) + { + if ( nRet != TIZEN_ERROR_NOT_SUPPORTED ) + { + FPRINTF("[Line: %d][%s] connection_create API call returned mismatch %s error for unsupported telephony feature\\n", __LINE__, API_NAMESPACE, ConnectionGetError(nRet)); + g_bTelephonySkipExecutionWithFail = true; + } + else + { + FPRINTF("[Line: %d][%s] connection_create API call correctly returned %s error for unsupported telephony feature\\n", __LINE__, API_NAMESPACE, ConnectionGetError(nRet)); + g_bTelephonySkipExecutionWithPass = true; + } + return; + } + + if ( nRet != CONNECTION_ERROR_NONE ) + { + FPRINTF("[Line: %d][%s] Startup failed on connection create API returned error %s\\n", __LINE__, API_NAMESPACE, ConnectionGetError(nRet)); + g_bTelephonyInit = false; + return; + } + + if ( hConenctionHandle == NULL ) + { + FPRINTF("[Line: %d][%s] Startup failed on connection create returned handle = NULL\\n", __LINE__, API_NAMESPACE); + g_bTelephonyInit = false; + return; + } + + nRet = connection_get_cellular_state(hConenctionHandle, &eState); + if ( nRet != CONNECTION_ERROR_NONE ) + { + FPRINTF("[Line: %d][%s] Startup failed on get cellular state\\n", __LINE__, API_NAMESPACE); + g_bTelephonyInit = false; + return; + } + if (eState == CONNECTION_CELLULAR_STATE_OUT_OF_SERVICE) + { + FPRINTF("[Line: %d][%s] Cellular state is out of service\\n", __LINE__, API_NAMESPACE); + g_bTelephonySkipExecutionWithPass = true; + return; + } + if ( hConenctionHandle != NULL ) + { + connection_destroy(hConenctionHandle); + } + #if DEBUG FPRINTF("[Line : %d][%s] telephony_init successful in startup\\n", __LINE__, API_NAMESPACE); #endif diff --git a/src/itc/telephony/ITs-telephony-common.c b/src/itc/telephony/ITs-telephony-common.c index c2b0c56..58a58d5 100755 --- a/src/itc/telephony/ITs-telephony-common.c +++ b/src/itc/telephony/ITs-telephony-common.c @@ -47,6 +47,38 @@ char *TelephonyGetError(int nRet) } /** +* @function ConnectionGetError +* @description Maps error enums to string values +* @parameter nRet : error code returned +* @return error string +*/ +char* ConnectionGetError(connection_error_e nRet) +{ + char *szErrorVal = NULL; + switch ( nRet ) + { + case CONNECTION_ERROR_NONE : szErrorVal = "CONNECTION_ERROR_NONE"; break;/**< Successful */ + case CONNECTION_ERROR_INVALID_PARAMETER : szErrorVal = "CONNECTION_ERROR_INVALID_PARAMETER"; break;/**< Invalid parameter */ + case CONNECTION_ERROR_OUT_OF_MEMORY: szErrorVal = "CONNECTION_ERROR_OUT_OF_MEMORY"; break;/**< Out of memory error */ + case CONNECTION_ERROR_INVALID_OPERATION : szErrorVal = "CONNECTION_ERROR_INVALID_OPERATION"; break;/**< Invalid Operation */ + case CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED : szErrorVal = "CONNECTION_ERROR_ADDRESS_FAMILY_NOT_SUPPORTED"; break;/**< Address family not supported */ + case CONNECTION_ERROR_OPERATION_FAILED : szErrorVal = "CONNECTION_ERROR_OPERATION_FAILED"; break;/**< Operation failed */ + case CONNECTION_ERROR_ITERATOR_END : szErrorVal = "CONNECTION_ERROR_ITERATOR_END"; break;/**< End of iteration */ + case CONNECTION_ERROR_NO_CONNECTION : szErrorVal = "CONNECTION_ERROR_NO_CONNECTION"; break;/**< There is no connection */ + case CONNECTION_ERROR_NOW_IN_PROGRESS : szErrorVal = "CONNECTION_ERROR_NOW_IN_PROGRESS"; break;/** Now in progress */ + case CONNECTION_ERROR_ALREADY_EXISTS : szErrorVal = "CONNECTION_ERROR_ALREADY_EXISTS"; break;/**< Already exists */ + case CONNECTION_ERROR_OPERATION_ABORTED : szErrorVal = "CONNECTION_ERROR_OPERATION_ABORTED"; break;/**< Operation is aborted */ + case CONNECTION_ERROR_DHCP_FAILED : szErrorVal = "CONNECTION_ERROR_DHCP_FAILED"; break;/**< DHCP failed */ + case CONNECTION_ERROR_INVALID_KEY : szErrorVal = "CONNECTION_ERROR_INVALID_KEY"; break;/**< Invalid key */ + case CONNECTION_ERROR_NO_REPLY : szErrorVal = "CONNECTION_ERROR_NO_REPLY"; break;/**< No reply */ + case CONNECTION_ERROR_PERMISSION_DENIED : szErrorVal = "CONNECTION_ERROR_PERMISSION_DENIED"; break;/**< Permission denied */ + case CONNECTION_ERROR_NOT_SUPPORTED : szErrorVal = "CONNECTION_ERROR_NOT_SUPPORTED"; break;/**< Not supported */ + default : szErrorVal = "Unknown Error"; break; + } + return szErrorVal; +} + +/** * @function TelephonyGetServiceState * @description Maps enums values to string values * @parameter eRet : service state diff --git a/src/itc/telephony/ITs-telephony-common.h b/src/itc/telephony/ITs-telephony-common.h index 0ee2b90..8657ae5 100755 --- a/src/itc/telephony/ITs-telephony-common.h +++ b/src/itc/telephony/ITs-telephony-common.h @@ -18,6 +18,8 @@ #include "tct_common.h" #include +#include + /** @addtogroup itc-telephony * @ingroup itc * @{ @@ -29,6 +31,10 @@ #define GMAINTIMEOUT 2000 #define API_NAMESPACE "TELEPHONY_ITC" #define TELEPHONY_FEATURE "http://tizen.org/feature/network.telephony" +#define WIFI_FEATURE "http://tizen.org/feature/network.wifi" +#define TETHERING_BLUETOOTH_FEATURE "http://tizen.org/feature/network.tethering.bluetooth" +#define TELEPHONY_FEATURE "http://tizen.org/feature/network.telephony" +#define ETHERNET_FEATURE "http://tizen.org/feature/network.ethernet" //Add helper function declarations here @@ -77,5 +83,6 @@ char *TelephonyGetNetworkType(telephony_network_type_e eRet); char *TelephonyGetState(telephony_state_e eRet); bool TelephonyGetSimHandle(int nSlotCount); char *TelephonyGetNetworkSelMode(telephony_network_selection_mode_e eRet); +char* ConnectionGetError(connection_error_e nRet); /** @} */ #endif //_ITS_TELEPHONY_COMMON_H_ diff --git a/src/itc/telephony/ITs-telephony-network.c b/src/itc/telephony/ITs-telephony-network.c index a03a59b..38d482b 100755 --- a/src/itc/telephony/ITs-telephony-network.c +++ b/src/itc/telephony/ITs-telephony-network.c @@ -79,6 +79,62 @@ void ITs_telephony_network_startup(void) return; } + bool bWifiFeatureSupported = TCTCheckSystemInfoFeatureSupported(WIFI_FEATURE, API_NAMESPACE); + bool bEthernetFeatureSupported = TCTCheckSystemInfoFeatureSupported(ETHERNET_FEATURE, API_NAMESPACE); + bool bBtFeatureSupported = TCTCheckSystemInfoFeatureSupported(TETHERING_BLUETOOTH_FEATURE, API_NAMESPACE); + + connection_h hConenctionHandle = NULL; + connection_cellular_state_e eState; + + nRet = connection_create(&hConenctionHandle); + if ( false == g_bTelephonyIssupportedFeature && false == bWifiFeatureSupported && false == bBtFeatureSupported && false == bEthernetFeatureSupported ) + { + if ( nRet != TIZEN_ERROR_NOT_SUPPORTED ) + { + FPRINTF("[Line: %d][%s] connection_create API call returned mismatch %s error for unsupported telephony feature\\n", __LINE__, API_NAMESPACE, ConnectionGetError(nRet)); + g_bTelephonySkipExecutionWithFail = true; + } + else + { + FPRINTF("[Line: %d][%s] connection_create API call correctly returned %s error for unsupported telephony feature\\n", __LINE__, API_NAMESPACE, ConnectionGetError(nRet)); + g_bTelephonySkipExecutionWithPass = true; + } + return; + } + + if ( nRet != CONNECTION_ERROR_NONE ) + { + FPRINTF("[Line: %d][%s] Startup failed on connection create API returned error %s\\n", __LINE__, API_NAMESPACE, ConnectionGetError(nRet)); + g_bTelephonyInit = false; + return; + } + + if ( hConenctionHandle == NULL ) + { + FPRINTF("[Line: %d][%s] Startup failed on connection create returned handle = NULL\\n", __LINE__, API_NAMESPACE); + g_bTelephonyInit = false; + return; + } + + nRet = connection_get_cellular_state(hConenctionHandle, &eState); + if ( nRet != CONNECTION_ERROR_NONE ) + { + FPRINTF("[Line: %d][%s] Startup failed on get cellular state\\n", __LINE__, API_NAMESPACE); + g_bTelephonyInit = false; + return; + } + if (eState == CONNECTION_CELLULAR_STATE_OUT_OF_SERVICE) + { + FPRINTF("[Line: %d][%s] Cellular state is out of service\\n", __LINE__, API_NAMESPACE); + g_bTelephonySkipExecutionWithPass = true; + return; + } + + if ( hConenctionHandle != NULL ) + { + connection_destroy(hConenctionHandle); + } + #if DEBUG FPRINTF("[Line : %d][%s] telephony_init successful in startup\\n", __LINE__, API_NAMESPACE); #endif diff --git a/src/itc/telephony/ITs-telephony-sim.c b/src/itc/telephony/ITs-telephony-sim.c index 7e27723..459161d 100755 --- a/src/itc/telephony/ITs-telephony-sim.c +++ b/src/itc/telephony/ITs-telephony-sim.c @@ -79,6 +79,62 @@ void ITs_telephony_sim_startup(void) return; } + bool bWifiFeatureSupported = TCTCheckSystemInfoFeatureSupported(WIFI_FEATURE, API_NAMESPACE); + bool bEthernetFeatureSupported = TCTCheckSystemInfoFeatureSupported(ETHERNET_FEATURE, API_NAMESPACE); + bool bBtFeatureSupported = TCTCheckSystemInfoFeatureSupported(TETHERING_BLUETOOTH_FEATURE, API_NAMESPACE); + + connection_h hConenctionHandle = NULL; + connection_cellular_state_e eState; + + nRet = connection_create(&hConenctionHandle); + if ( false == g_bTelephonyIssupportedFeature && false == bWifiFeatureSupported && false == bBtFeatureSupported && false == bEthernetFeatureSupported ) + { + if ( nRet != TIZEN_ERROR_NOT_SUPPORTED ) + { + FPRINTF("[Line: %d][%s] connection_create API call returned mismatch %s error for unsupported telephony feature\\n", __LINE__, API_NAMESPACE, ConnectionGetError(nRet)); + g_bTelephonySkipExecutionWithFail = true; + } + else + { + FPRINTF("[Line: %d][%s] connection_create API call correctly returned %s error for unsupported telephony feature\\n", __LINE__, API_NAMESPACE, ConnectionGetError(nRet)); + g_bTelephonySkipExecutionWithPass = true; + } + return; + } + + if ( nRet != CONNECTION_ERROR_NONE ) + { + FPRINTF("[Line: %d][%s] Startup failed on connection create API returned error %s\\n", __LINE__, API_NAMESPACE, ConnectionGetError(nRet)); + g_bTelephonyInit = false; + return; + } + + if ( hConenctionHandle == NULL ) + { + FPRINTF("[Line: %d][%s] Startup failed on connection create returned handle = NULL\\n", __LINE__, API_NAMESPACE); + g_bTelephonyInit = false; + return; + } + + nRet = connection_get_cellular_state(hConenctionHandle, &eState); + if ( nRet != CONNECTION_ERROR_NONE ) + { + FPRINTF("[Line: %d][%s] Startup failed on get cellular state\\n", __LINE__, API_NAMESPACE); + g_bTelephonyInit = false; + return; + } + if (eState == CONNECTION_CELLULAR_STATE_OUT_OF_SERVICE) + { + FPRINTF("[Line: %d][%s] Cellular state is out of service\\n", __LINE__, API_NAMESPACE); + g_bTelephonySkipExecutionWithPass = true; + return; + } + + if ( hConenctionHandle != NULL ) + { + connection_destroy(hConenctionHandle); + } + #if DEBUG FPRINTF("[Line : %d][%s] telephony_init successful in startup\\n", __LINE__, API_NAMESPACE); #endif diff --git a/src/itc/telephony/ITs-telephony.c b/src/itc/telephony/ITs-telephony.c index d772fea..2d24a8f 100755 --- a/src/itc/telephony/ITs-telephony.c +++ b/src/itc/telephony/ITs-telephony.c @@ -89,6 +89,62 @@ void ITs_telephony_startup(void) return; } + bool bWifiFeatureSupported = TCTCheckSystemInfoFeatureSupported(WIFI_FEATURE, API_NAMESPACE); + bool bEthernetFeatureSupported = TCTCheckSystemInfoFeatureSupported(ETHERNET_FEATURE, API_NAMESPACE); + bool bBtFeatureSupported = TCTCheckSystemInfoFeatureSupported(TETHERING_BLUETOOTH_FEATURE, API_NAMESPACE); + + connection_h hConenctionHandle = NULL; + connection_cellular_state_e eState; + + nRet = connection_create(&hConenctionHandle); + if ( false == g_bTelephonyIssupportedFeature && false == bWifiFeatureSupported && false == bBtFeatureSupported && false == bEthernetFeatureSupported ) + { + if ( nRet != TIZEN_ERROR_NOT_SUPPORTED ) + { + FPRINTF("[Line: %d][%s] connection_create API call returned mismatch %s error for unsupported telephony feature\\n", __LINE__, API_NAMESPACE, ConnectionGetError(nRet)); + g_bTelephonySkipExecutionWithFail = true; + } + else + { + FPRINTF("[Line: %d][%s] connection_create API call correctly returned %s error for unsupported telephony feature\\n", __LINE__, API_NAMESPACE, ConnectionGetError(nRet)); + g_bTelephonySkipExecutionWithPass = true; + } + return; + } + + if ( nRet != CONNECTION_ERROR_NONE ) + { + FPRINTF("[Line: %d][%s] Startup failed on connection create API returned error %s\\n", __LINE__, API_NAMESPACE, ConnectionGetError(nRet)); + g_bTelephonyInit = false; + return; + } + + if ( hConenctionHandle == NULL ) + { + FPRINTF("[Line: %d][%s] Startup failed on connection create returned handle = NULL\\n", __LINE__, API_NAMESPACE); + g_bTelephonyInit = false; + return; + } + + nRet = connection_get_cellular_state(hConenctionHandle, &eState); + if ( nRet != CONNECTION_ERROR_NONE ) + { + FPRINTF("[Line: %d][%s] Startup failed on get cellular state\\n", __LINE__, API_NAMESPACE); + g_bTelephonyInit = false; + return; + } + if (eState == CONNECTION_CELLULAR_STATE_OUT_OF_SERVICE) + { + FPRINTF("[Line: %d][%s] Cellular state is out of service\\n", __LINE__, API_NAMESPACE); + g_bTelephonySkipExecutionWithPass = true; + return; + } + + if ( hConenctionHandle != NULL ) + { + connection_destroy(hConenctionHandle); + } + #if DEBUG FPRINTF("[Line : %d][%s] telephony_init successful in startup\\n", __LINE__, API_NAMESPACE); #endif -- 2.7.4