[ITC][telephony][Non-ACR][DPTTIZEN-2007 Modified to check cellular state]
authorAmritanshu Pandia <a.pandia1@samsung.com>
Thu, 9 Jun 2016 11:49:31 +0000 (17:19 +0530)
committerAmritanshu Pandia <a.pandia1@samsung.com>
Thu, 9 Jun 2016 11:49:31 +0000 (17:19 +0530)
Change-Id: I83ff521b40d659bda27cc97e57ec4891d5ae140d
Signed-off-by: Amritanshu Pandia <a.pandia1@samsung.com>
packaging/itc/native-telephony-itc.spec
packaging/itc/native-telephony-itc.xml
src/itc/telephony/CMakeLists.txt
src/itc/telephony/ITs-telephony-call.c
src/itc/telephony/ITs-telephony-common.c
src/itc/telephony/ITs-telephony-common.h
src/itc/telephony/ITs-telephony-network.c
src/itc/telephony/ITs-telephony-sim.c
src/itc/telephony/ITs-telephony.c

index 7a8d18b..9f46993 100755 (executable)
@@ -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})
index 26c2baa..c872549 100755 (executable)
@@ -8,5 +8,8 @@
        <privileges>
     <privilege>http://tizen.org/privilege/telephony</privilege>
     <privilege>http://tizen.org/privilege/location.coarse</privilege>
+       <privilege>http://tizen.org/privilege/network.profile</privilege>
+       <privilege>http://tizen.org/privilege/network.get</privilege>
+       <privilege>http://tizen.org/privilege/network.set</privilege>
     </privileges>
 </manifest>
index c6421c2..ecc5942 100755 (executable)
@@ -19,6 +19,7 @@ PKG_CHECK_MODULES(${CAPI_LIB} REQUIRED
        glib-2.0
        capi-system-info
        dlog elementary
+       capi-network-connection
 )
 
 INCLUDE_DIRECTORIES(
index 90f3f87..d4db3af 100755 (executable)
@@ -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
index c2b0c56..58a58d5 100755 (executable)
@@ -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
index 0ee2b90..8657ae5 100755 (executable)
@@ -18,6 +18,8 @@
 
 #include "tct_common.h"
 #include <telephony.h>
+#include <net_connection.h>
+
 /** @addtogroup itc-telephony
 *  @ingroup itc
 *  @{
 #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_
index a03a59b..38d482b 100755 (executable)
@@ -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
index 7e27723..459161d 100755 (executable)
@@ -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
index d772fea..2d24a8f 100755 (executable)
@@ -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