[Bugfix][T108][bug-view-1641] serving cell info need be reported once per 5 second if registered

    Only Configure: No
    Affected branch: unknown
    Affected module: network
    Is it affected on both ZXIC and ASR: only ASR
    Self-test: yes
    Doc Update: no

Change-Id: I31e42137e64597d1ec30417daad0e7258a5a4109
diff --git a/mbtk/libgsw_lib/gsw_nw_interface.c b/mbtk/libgsw_lib/gsw_nw_interface.c
index 76cff99..7be4b24 100755
--- a/mbtk/libgsw_lib/gsw_nw_interface.c
+++ b/mbtk/libgsw_lib/gsw_nw_interface.c
@@ -3,8 +3,12 @@
 #include <time.h>

 #include <pthread.h>

 #include "gsw_nw_interface.h"

+#include "gsw_log_interface.h"

+

 #define SIG_TIMER 5

 #define MODEM_TIMER 5

+#define SERVING_TIMER 5

+

 

 //mbtk include

 #define LYNQ_AIR_PLANE_MODE_OFF      1    //at+cfun = 1

@@ -361,99 +365,8 @@
 bool (*str_empty)(const void *str);

 

 

-static void (*mbtk_log)(int level, const char *format, ...);

-static void (*mbtk_log_init)(char *path, char *tag);

-

-#ifndef LOG_ERR_LEVEL

-#define LOG_ERR_LEVEL  3      /* error conditions */

-#endif

-#ifndef LOG_WARN_LEVEL

-#define LOG_WARN_LEVEL 4   /* warning conditions */

-#endif

-#ifndef LOG_INFO_LEVEL

-#define LOG_INFO_LEVEL 6      /* informational */

-#endif

-#ifndef LOG_DEBUG_LEVEL

-#define LOG_DEBUG_LEVEL 7     /* debug-level messages */

-#endif

-#ifndef LOG_VERBOSE_LEVEL

-#define LOG_VERBOSE_LEVEL 8

-#endif

-

 #define GSW_NW "[HAL][GSW_NW]"

 

-#define LOGV(fmt, args ...) \

-    do{ \

-        char *file_ptr_1001 = __FILE__; \

-        char *ptr_1001 = file_ptr_1001 + strlen(file_ptr_1001) - 1;   \

-        char line_1001[10] = {0}; \

-        sprintf(line_1001, "%d", __LINE__); \

-        while(ptr_1001 >= file_ptr_1001 && *ptr_1001){ \

-            if(*ptr_1001 == '/') \

-                 break; \

-            ptr_1001--; \

-        } \

-        mbtk_log(LOG_VERBOSE_LEVEL, "%s#%s: "GSW_NW"" fmt, ptr_1001 + 1, line_1001, ##args); \

-    } while(0)

-

-#define LOGI(fmt, args...) \

-    do{ \

-        char *file_ptr_1001 = __FILE__; \

-        char *ptr_1001 = file_ptr_1001 + strlen(file_ptr_1001) - 1;   \

-        char line_1001[10] = {0}; \

-        sprintf(line_1001, "%d", __LINE__); \

-        while(ptr_1001 >= file_ptr_1001 && *ptr_1001){ \

-            if(*ptr_1001 == '/') \

-                 break; \

-            ptr_1001--; \

-        } \

-        mbtk_log(LOG_INFO_LEVEL, "%s#%s: "GSW_NW"" fmt, ptr_1001 + 1, line_1001, ##args); \

-    } while(0)

-

-#define LOGD(fmt, args...) \

-    do{ \

-        char *file_ptr_1001 = __FILE__; \

-        char *ptr_1001 = file_ptr_1001 + strlen(file_ptr_1001) - 1;   \

-        char line_1001[10] = {0}; \

-        sprintf(line_1001, "%d", __LINE__); \

-        while(ptr_1001 >= file_ptr_1001 && *ptr_1001){ \

-            if(*ptr_1001 == '/') \

-                 break; \

-            ptr_1001--; \

-        } \

-        mbtk_log(LOG_DEBUG_LEVEL, "%s#%s: "GSW_NW"" fmt, ptr_1001 + 1, line_1001, ##args); \

-    } while(0)

-

-#define LOGW(fmt, args...) \

-    do{ \

-        char *file_ptr_1001 = __FILE__; \

-        char *ptr_1001 = file_ptr_1001 + strlen(file_ptr_1001) - 1;   \

-        char line_1001[10] = {0}; \

-        sprintf(line_1001, "%d", __LINE__); \

-        while(ptr_1001 >= file_ptr_1001 && *ptr_1001){ \

-            if(*ptr_1001 == '/') \

-                 break; \

-            ptr_1001--; \

-        } \

-        mbtk_log(LOG_WARN_LEVEL, "%s#%s: "GSW_NW"" fmt, ptr_1001 + 1, line_1001, ##args); \

-    } while(0)

-

-#define LOGE(fmt, args...) \

-    do{ \

-        char *file_ptr_1001 = __FILE__; \

-        char *ptr_1001 = file_ptr_1001 + strlen(file_ptr_1001) - 1;   \

-        char line_1001[10] = {0}; \

-        sprintf(line_1001, "%d", __LINE__); \

-        while(ptr_1001 >= file_ptr_1001 && *ptr_1001){ \

-            if(*ptr_1001 == '/') \

-                 break; \

-            ptr_1001--; \

-        } \

-        mbtk_log(LOG_ERR_LEVEL, "%s#%s: "GSW_NW"" fmt, ptr_1001 + 1, line_1001, ##args); \

-    } while(0)

-

-

-

 typedef struct

 {

     char *lynq_operator_l;

@@ -497,156 +410,144 @@
     {

         return GSW_HAL_NORMAL_FAIL;

     }

-

-    mbtk_log_init = (void (*)(char *path, char *tag))dlsym(dlHandle_mbtk, "mbtk_log_init");

-    if (mbtk_log_init == NULL) 

-    {

-        return GSW_HAL_NORMAL_FAIL;

-    }

-

-    mbtk_log = (void (*)(int level, const char *format, ...))dlsym(dlHandle_mbtk, "mbtk_log");

-    if (mbtk_log == NULL) 

-    {

-        return GSW_HAL_NORMAL_FAIL;

-    }

-

+    

     mbtk_info_handle_get = (mbtk_info_handle_t* (*)(void))dlsym(dlHandle_mbtk, "mbtk_info_handle_get");

     if (mbtk_info_handle_get == NULL) 

     {

-        LOGE("mbtk_info_handle_get dlsym fail\n");

+        LOGE(GSW_NW,"mbtk_info_handle_get dlsym fail\n");

         return GSW_HAL_NORMAL_FAIL;

     }

 

     mbtk_info_handle_free = (int (*)(mbtk_info_handle_t** handle))dlsym(dlHandle_mbtk, "mbtk_info_handle_free");

     if (mbtk_info_handle_free == NULL) 

     {

-        LOGE("mbtk_info_handle_free dlsym fail\n");

+        LOGE(GSW_NW,"mbtk_info_handle_free dlsym fail\n");

         return GSW_HAL_NORMAL_FAIL;

     }

 

     mbtk_net_sel_mode_get = (int (*)(mbtk_info_handle_t* handle, mbtk_net_info_t *net))dlsym(dlHandle_mbtk, "mbtk_net_sel_mode_get");

     if (mbtk_net_sel_mode_get == NULL) 

     {

-        LOGE("mbtk_net_sel_mode_get dlsym fail\n");

+        LOGE(GSW_NW,"mbtk_net_sel_mode_get dlsym fail\n");

         return GSW_HAL_NORMAL_FAIL;

     }

 

     mbtk_net_reg_get = (int (*)(mbtk_info_handle_t* handle, mbtk_net_reg_info_t *reg))dlsym(dlHandle_mbtk, "mbtk_net_reg_get");

     if (mbtk_net_reg_get == NULL) 

     {

-        LOGE("mbtk_net_reg_get dlsym fail\n");

+        LOGE(GSW_NW,"mbtk_net_reg_get dlsym fail\n");

         return GSW_HAL_NORMAL_FAIL;

     }

 

     mbtk_get_modem_fun = (int (*)(mbtk_info_handle_t* handle, int* fun))dlsym(dlHandle_mbtk, "mbtk_get_modem_fun");

     if (mbtk_get_modem_fun == NULL) 

     {

-        LOGE("mbtk_get_modem_fun dlsym fail\n");

+        LOGE(GSW_NW,"mbtk_get_modem_fun dlsym fail\n");

         return GSW_HAL_NORMAL_FAIL;

     }

 

     mbtk_set_modem_fun = (int (*)(mbtk_info_handle_t* handle, mbtk_modem_info_t *info))dlsym(dlHandle_mbtk, "mbtk_set_modem_fun");

     if (mbtk_set_modem_fun == NULL) 

     {

-        LOGE("mbtk_set_modem_fun dlsym fail\n");

+        LOGE(GSW_NW,"mbtk_set_modem_fun dlsym fail\n");

         return GSW_HAL_NORMAL_FAIL;

     }

 

     mbtk_current_band_get = (int (*)(mbtk_info_handle_t* handle, mbtk_band_info_t *band))dlsym(dlHandle_mbtk, "mbtk_current_band_get");

     if (mbtk_current_band_get == NULL) 

     {

-        LOGE("mbtk_current_band_get dlsym fail\n");

+        LOGE(GSW_NW,"mbtk_current_band_get dlsym fail\n");

         return GSW_HAL_NORMAL_FAIL;

     }

 

     mbtk_current_band_set = (int (*)(mbtk_info_handle_t* handle, const mbtk_band_info_t *band))dlsym(dlHandle_mbtk, "mbtk_current_band_set");

     if (mbtk_current_band_set == NULL) 

     {

-        LOGE("mbtk_current_band_set dlsym fail\n");

+        LOGE(GSW_NW,"mbtk_current_band_set dlsym fail\n");

         return GSW_HAL_NORMAL_FAIL;

     }

 

     mbtk_net_signal_get = (int (*)(mbtk_info_handle_t* handle, mbtk_signal_info_t *signal))dlsym(dlHandle_mbtk, "mbtk_net_signal_get");

     if (mbtk_net_signal_get == NULL) 

     {

-        LOGE("mbtk_net_signal_get dlsym fail\n");

+        LOGE(GSW_NW,"mbtk_net_signal_get dlsym fail\n");

         return GSW_HAL_NORMAL_FAIL;

     }

 

     mbtk_wakeup_state_set = (int (*)(mbtk_info_handle_t* handle, uint32 wakeup_state))dlsym(dlHandle_mbtk, "mbtk_wakeup_state_set");

     if (mbtk_wakeup_state_set == NULL) 

     {

-        LOGE("mbtk_wakeup_state_set dlsym fail\n");

+        LOGE(GSW_NW,"mbtk_wakeup_state_set dlsym fail\n");

         return GSW_HAL_NORMAL_FAIL;

     }

 

     mbtk_cell_get = (int (*)(mbtk_info_handle_t* handle, mbtk_cell_type_enum *type, list_node_t **cell_list))dlsym(dlHandle_mbtk, "mbtk_cell_get");

     if (mbtk_cell_get == NULL) 

     {

-        LOGE("mbtk_cell_get dlsym fail\n");

+        LOGE(GSW_NW,"mbtk_cell_get dlsym fail\n");

         return GSW_HAL_NORMAL_FAIL;

     }

 

     mbtk_signal_state_change_cb_reg = (int (*)(mbtk_info_handle_t* handle, mbtk_info_callback_func cb))dlsym(dlHandle_mbtk, "mbtk_signal_state_change_cb_reg");

     if (mbtk_signal_state_change_cb_reg == NULL) 

     {

-        LOGE("mbtk_signal_state_change_cb_reg dlsym fail\n");

+        LOGE(GSW_NW,"mbtk_signal_state_change_cb_reg dlsym fail\n");

         return GSW_HAL_NORMAL_FAIL;

     }

 

     mbtk_net_state_change_cb_reg = (int (*)(mbtk_info_handle_t* handle, mbtk_info_callback_func cb))dlsym(dlHandle_mbtk, "mbtk_net_state_change_cb_reg");

     if (mbtk_net_state_change_cb_reg == NULL) 

     {

-        LOGE("mbtk_net_state_change_cb_reg dlsym fail\n");

+        LOGE(GSW_NW,"mbtk_net_state_change_cb_reg dlsym fail\n");

         return GSW_HAL_NORMAL_FAIL;

     }

 

     mbtk_fplmn_get = (int(*)(mbtk_info_handle_t *handle, void *fplmn))dlsym(dlHandle_mbtk, "mbtk_fplmn_get");

     if (mbtk_fplmn_get == NULL) 

     {

-        LOGE("mbtk_fplmn_get dlsym fail\n");

+        LOGE(GSW_NW,"mbtk_fplmn_get dlsym fail\n");

         return GSW_HAL_NORMAL_FAIL;

     }

 

     mbtk_fplmn_set = (int(*)(mbtk_info_handle_t *handle, void *fplmn))dlsym(dlHandle_mbtk, "mbtk_fplmn_set");

     if (mbtk_fplmn_set == NULL) 

     {

-        LOGE("mbtk_fplmn_get dlsym fail\n");

+        LOGE(GSW_NW,"mbtk_fplmn_get dlsym fail\n");

         return GSW_HAL_NORMAL_FAIL;

     }

 

     mbtk_radio_state_change_cb_reg = (int (*)(mbtk_info_handle_t* handle, mbtk_info_callback_func cb))dlsym(dlHandle_mbtk, "mbtk_radio_state_change_cb_reg");

     if (mbtk_radio_state_change_cb_reg == NULL) 

     {

-        LOGE("mbtk_radio_state_change_cb_reg dlsym fail\n");

+        LOGE(GSW_NW,"mbtk_radio_state_change_cb_reg dlsym fail\n");

         return GSW_HAL_NORMAL_FAIL;

     }

 

     mbtk_oos_get = (int (*)(mbtk_info_handle_t* handle, mbtk_oos_info *oos))dlsym(dlHandle_mbtk, "mbtk_oos_get");

     if (mbtk_oos_get == NULL) 

     {

-        LOGE("mbtk_oos_get dlsym fail\n");

+        LOGE(GSW_NW,"mbtk_oos_get dlsym fail\n");

         return GSW_HAL_NORMAL_FAIL;

     }

 

     mbtk_oos_set = (int (*)(mbtk_info_handle_t* handle, mbtk_oos_info *oos))dlsym(dlHandle_mbtk, "mbtk_oos_set");

     if (mbtk_oos_set == NULL) 

     {

-        LOGE("mbtk_oos_set dlsym fail\n");

+        LOGE(GSW_NW,"mbtk_oos_set dlsym fail\n");

         return GSW_HAL_NORMAL_FAIL;

     }

   

     mbtk_imei_get = (int (*)(mbtk_info_handle_t* handle, void *imei))dlsym(dlHandle_mbtk, "mbtk_imei_get");

    if (mbtk_imei_get == NULL) 

    {

-       LOGE("mbtk_imei_get dlsym fail\n");

+       LOGE(GSW_NW,"mbtk_imei_get dlsym fail\n");

        return GSW_HAL_NORMAL_FAIL;

    }

    

    str_empty = (bool (*)(const void *str))dlsym(dlHandle_mbtk, "str_empty");

    if (str_empty == NULL) 

    {

-       LOGE("str_empty dlsym fail\n");

+       LOGE(GSW_NW,"str_empty dlsym fail\n");

        return GSW_HAL_NORMAL_FAIL;

    }

 

@@ -666,16 +567,16 @@
     if (list) {

         list_arraynode_t *node = list->cur_array_data;

         if (node) {

-            LOGE("node is not null\n");

+            LOGE(GSW_NW,"node is not null\n");

             list->cur_array_data = list->cur_array_data->next;

             list->cur_index++;

             return node->data;

         } else {

-            LOGE("node is null\n");

+            LOGE(GSW_NW,"node is null\n");

             return NULL;

         }

     } else {

-        LOGE("list is null\n");

+        LOGE(GSW_NW,"list is null\n");

         return NULL;

     }

 }

@@ -907,7 +808,7 @@
 

 static int convert_reg_state(int reg_state_t)

 {

-    LOGD("reg_state_t = %d\n",reg_state_t);

+    LOGD(GSW_NW,"reg_state_t = %d\n",reg_state_t);

     int reg_state = 0;

 

     switch (reg_state_t)

@@ -960,7 +861,7 @@
 

 static int convert_net_mode(int net_mode)

 {

-    LOGD("net_mode = %d\n",net_mode);

+    LOGD(GSW_NW,"net_mode = %d\n",net_mode);

     switch(net_mode)

     {

         case MBTK_RADIO_TECH_GSM:

@@ -1038,7 +939,7 @@
 static int convert_gsw_net_config(int config)

 {

     int net_config = -1;

-    LOGD("config = %d\n",config);

+    LOGD(GSW_NW,"config = %d\n",config);

 

     switch (config)

     {

@@ -1093,7 +994,7 @@
 

     memmove(entry + 2, entry + 3, ENTRY_LENGTH - 2);

 

-    LOGE("after transform_fplmn_str_to_plmn: %s\n", entry);

+    LOGE(GSW_NW,"after transform_fplmn_str_to_plmn: %s\n", entry);

 

     //valid fplmn

     fplmn_index++;

@@ -1106,13 +1007,13 @@
     strncpy(mnc,entry + 3,2);

     mnc[2] = '\0';

 

-    LOGE("entry = %s, mcc = %s, mnc = %s\n", entry, mcc, mnc);

+    LOGE(GSW_NW,"entry = %s, mcc = %s, mnc = %s\n", entry, mcc, mnc);

 }

 

 

 static void update_fplmn_list(char *fplmn_str)

 {

-    LOGE("fplmn_str = %s\n",fplmn_str);

+    LOGE(GSW_NW,"fplmn_str = %s\n",fplmn_str);

     char temp_fplmn_array[FPLMN_ARRAY_SIZE][7];

     memset(fplmn_array, 0, sizeof(fplmn_array));

     memset(temp_fplmn_array, 0, sizeof(temp_fplmn_array));

@@ -1131,10 +1032,10 @@
     }

 

     for (int i = 0; i < array_length; i++) {

-        LOGE("array[%d] = %s\n", i, temp_fplmn_array[i]);

+        LOGE(GSW_NW,"array[%d] = %s\n", i, temp_fplmn_array[i]);

         transform_fplmn_str_to_plmn(temp_fplmn_array[i]);

         strncpy(fplmn_array[i], temp_fplmn_array[i], ENTRY_LENGTH);

-        LOGE("fplmn_array[%d] = %s\n", i, fplmn_array[i]);

+        LOGE(GSW_NW,"fplmn_array[%d] = %s\n", i, fplmn_array[i]);

     }

 

 }

@@ -1142,7 +1043,7 @@
 static void format_plmn(char *result, char *plmn_entry)

 {

     strncpy(result, plmn_entry, strlen(plmn_entry));

-    LOGE("result = %s, numStr = %s\n",result, plmn_entry);

+    LOGE(GSW_NW,"result = %s, numStr = %s\n",result, plmn_entry);

 

     if (strlen(result) >= 2) {

         char temp = result[0];

@@ -1150,14 +1051,14 @@
         result[1] = temp;

     }

     

-    LOGE("1.result = %s\n",result);

+    LOGE(GSW_NW,"1.result = %s\n",result);

 

     if (strlen(result) >= 3) {

         memmove(&result[3], &result[2], strlen(result) - 2 + 1);

         result[2] = 'F';

     }

 

-    LOGE("2.result = %s\n",result);

+    LOGE(GSW_NW,"2.result = %s\n",result);

 

     if (strlen(result) >= 2) {

         char temp = result[strlen(result) - 1];

@@ -1165,7 +1066,7 @@
         result[strlen(result) - 2] = temp;

     }

 

-    LOGE("3.result = %s\n",result);

+    LOGE(GSW_NW,"3.result = %s\n",result);

 }

 

 

@@ -1192,9 +1093,9 @@
         temp_fplmn_str[(6 * fplmn_max_length)] = '\0';

     }

 

-    LOGE("%s\n", temp_fplmn_str);

+    LOGE(GSW_NW,"%s\n", temp_fplmn_str);

     strncpy(fplmn_str, temp_fplmn_str, strlen(temp_fplmn_str));

-    LOGE("fplmn_str = %s\n", fplmn_str);

+    LOGE(GSW_NW,"fplmn_str = %s\n", fplmn_str);

 }

 

 static int check_index(char *mcc, char *mnc)

@@ -1205,12 +1106,12 @@
     {

         if(strncmp(fplmn_array[i], mcc, 3) == 0 && strncmp(fplmn_array[i] + 3, mnc, 2) == 0)

         {

-            LOGE("index = %d\n", i);

+            LOGE(GSW_NW,"index = %d\n", i);

             return i;

         }

     }

 

-    LOGE("not find\n");

+    LOGE(GSW_NW,"not find\n");

     return -1;

 }

 

@@ -1227,13 +1128,13 @@
 

 static void convert_mbtk_sig_info_to_gsw_sig_info(const mbtk_signal_info_t* signal, signalStrength_t* sig_strength)

 {

-    LOGD("signal->type=%d", signal->type);

+    LOGD(GSW_NW,"signal->type=%d", signal->type);

     memset(sig_strength,0,sizeof (signalStrength_t));

     switch(signal->type)

     {

         case MBTK_RADIO_TECH_E_UTRAN:

         {

-            LOGI("rsrp = %d",signal->rsrp);

+            LOGI(GSW_NW,"rsrp = %d",signal->rsrp);

             sig_strength->lte_sig_valid = 1;

             sig_strength->rsrp = rsrp_convert_to_minus_dBm(signal->rsrp);

             sig_strength->rsrq = rsrq_convert_to_minus_dB(signal->rsrq);

@@ -1247,7 +1148,7 @@
         case MBTK_RADIO_TECH_UTRAN_HSDPA_HSUPA:

         case MBTK_RADIO_TECH_UTRAN_HSPA:

         {

-            LOGI("rscp = %d",signal->rscp);

+            LOGI(GSW_NW,"rscp = %d",signal->rscp);

             sig_strength->wcdma_sig_valid = 1;

             sig_strength->rscp = rscp_convert_to_minus_dBm(signal->rscp);

             sig_strength->ecno = ecno_convert_to_minus_10_times_dB(signal->ecno);

@@ -1258,38 +1159,38 @@
         case MBTK_RADIO_TECH_GSM_COMPACT:

         case MBTK_RADIO_TECH_GSM_EGPRS:

         {

-            LOGI("g rxlev = %d",signal->rxlev);

+            LOGI(GSW_NW,"g rxlev = %d",signal->rxlev);

             sig_strength->gw_sig_valid = 1;

             sig_strength->rssi = rxlev_convert_to_rssi_dBm(signal->rxlev);

             break;

         }

         default:

         {

-            LOGE("[%s] unknown reg type.[%d]", __func__, signal->type);

+            LOGE(GSW_NW,"[%s] unknown reg type.[%d]", __func__, signal->type);

         }

     }

 

 }

 

 /*

-typedef enum{

-    MBTK_READY_INIT = -1,

-    MBTK_READY_SUCCESS,

-    MBTK_READY_MODEM_FAIL,

-    MBTK_READY_RESPONSE_FAIL,

-    MBTK_READY_SOCKET_FAIL,

-    MBTK_READY_RIL_FAIL

+typedef enum{
+    MBTK_READY_INIT = -1,
+    MBTK_READY_SUCCESS,
+    MBTK_READY_MODEM_FAIL,
+    MBTK_READY_RESPONSE_FAIL,
+    MBTK_READY_SOCKET_FAIL,
+    MBTK_READY_RIL_FAIL
 }mbtk_ready_status_type;

 

-typedef enum gsw_hal_nw_mode_state_type

-{

-    GSW_MODEM_STATE_UNKNOWN = 0,

-    GSW_MODEM_STATE_ONLINE,

-    GSW_MODEM_STATE_OFFLINE,

-    GSW_SDK_STATE_SERVICE_DOWN,

-    GSW_SDK_STATE_SERVICE_UP,// service down->up 需要routectl 重启

-    GSW_SDK_STATE_GPS_DOWN,

-    GSW_SDK_STATE_GPS_UP,

+typedef enum gsw_hal_nw_mode_state_type
+{
+    GSW_MODEM_STATE_UNKNOWN = 0,
+    GSW_MODEM_STATE_ONLINE,
+    GSW_MODEM_STATE_OFFLINE,
+    GSW_SDK_STATE_SERVICE_DOWN,
+    GSW_SDK_STATE_SERVICE_UP,// service down->up 需要routectl 重启
+    GSW_SDK_STATE_GPS_DOWN,
+    GSW_SDK_STATE_GPS_UP,
 } gsw_mode_state_e;

 

 */

@@ -1309,125 +1210,130 @@
     return;

 }

 

-

-

-

-

-

 static void gsw_serving_info_callback_thread()

 {

-    GSW_NW_SERVING_INFO *serving_info = (GSW_NW_SERVING_INFO*)malloc(sizeof(GSW_NW_SERVING_INFO));

-    memset(serving_info, 0x0, sizeof(GSW_NW_SERVING_INFO));

-    int ret = -1;

-    ret = gsw_get_nwinfo(serving_info);

+    GSW_NW_SERVING_INFO serving_info;

+    int ret = gsw_get_nwinfo(&serving_info);

     if(ret != 0)

     {

-        LOGE("gsw_get_nwinfo failed\n");

-        free(serving_info);

+        LOGE(GSW_NW,"cb gsw_get_nwinfo failed");

         return; 

     }

 

-    if(serving_cb)

+    if(serving_cb!=NULL)

     {

-        serving_cb(*serving_info);

-        free(serving_info);

+        LOGE(GSW_NW,"serving cb called");

+        serving_cb(serving_info);

+    }    

+    else

+    {

+        LOGE(GSW_NW,"serving cb is NULL");

     }

 }

 

 static void gsw_serving_info_callback(const void* data, int data_len)

-{

-    LOGE("gsw_serving_info_callback start\n");

-

-    if(data && data_len > 0)

+{    

+    if (nw_init_flag == 0)

     {

-        pthread_t thread;

-        pthread_create(&thread, NULL, (void*)gsw_serving_info_callback_thread, NULL);

-    }

-

-    else

-    {

-        LOGE("data is NULL\n");

+        printf("%s, nw not init\n",__func__);

         return;

     }

-

+    

+    pthread_t thread;

+    int ret=pthread_create(&thread, NULL, (void*)gsw_serving_info_callback_thread, NULL);

+    if(ret==0)

+    {

+        pthread_detach(thread);

+    }

+    else

+    {

+         LOGE(GSW_NW,"create thread fail, ret is %d",ret);

+    }

 }

 

+

 /*typedef struct

-{

+{
 0    mbtk_radio_technology_enum type : 8; // mbtk_radio_technology_enum

 1    uint8 rssi; // 0: 113 dBm or less

-                // 1: 111 dBm

-                // 2��30: 109��53 dBm

-                // 31: 51 dBm or greater

-                // 99: not known or not detectable

+                // 1: 111 dBm
+                // 2��30: 109��53 dBm
+                // 31: 51 dBm or greater
+                // 99: not known or not detectable
 2    uint8 rxlev;// 0:rssi < -110 dBm

-                // 1: -110 dBm �� rssi < -109 dBm

-                // 2: -109 dBm �� rssi < -108 dBm

-                // ......

-                // 61: -50 dBm �� rssi < -49 dBm

-                // 62: -49 dBm �� rssi < -48 dBm

-                // 63: -48 dBm �� rssi

-                // 99: not known or not detectable

+                // 1: -110 dBm �� rssi < -109 dBm
+                // 2: -109 dBm �� rssi < -108 dBm
+                // ......
+                // 61: -50 dBm �� rssi < -49 dBm
+                // 62: -49 dBm �� rssi < -48 dBm
+                // 63: -48 dBm �� rssi
+                // 99: not known or not detectable
 3    uint8 ber;  // 0...7 as RXQUAL values in the table in 3GPP TS 45.008 [20] subclause 8.2.4

-                // 99 not known or not detectable

+                // 99 not known or not detectable
 4    uint8 rscp; // 0: rscp < -120 dBm

-                // 1: -120 dBm �� rscp < -119 dBm

-                // 2: -119 dBm �� rscp < -118 dBm

-                // ......

-                // 94: -27 dBm �� rscp < -26 dBm

-                // 95: -26 dBm �� rscp < -25 dBm

-                // 96: - 25 dBm �� rscp

-                // 255: not known or not detectable

+                // 1: -120 dBm �� rscp < -119 dBm
+                // 2: -119 dBm �� rscp < -118 dBm
+                // ......
+                // 94: -27 dBm �� rscp < -26 dBm
+                // 95: -26 dBm �� rscp < -25 dBm
+                // 96: - 25 dBm �� rscp
+                // 255: not known or not detectable
 5    uint8 ecno; // 0: Ec/Io < -24 dB

-                // 1: -24 dB �� Ec/Io < -23.5 dB

-                // 2: -23.5 dB �� Ec/Io < -23 dB

-                // ......

-                // 47: -1 dB �� Ec/Io < -0.5 dB

-                // 48: -0.5 dB �� Ec/Io < 0 dB

-                // 49: 0 dB �� Ec/Io

-                // 255: not known or not detectable

+                // 1: -24 dB �� Ec/Io < -23.5 dB
+                // 2: -23.5 dB �� Ec/Io < -23 dB
+                // ......
+                // 47: -1 dB �� Ec/Io < -0.5 dB
+                // 48: -0.5 dB �� Ec/Io < 0 dB
+                // 49: 0 dB �� Ec/Io
+                // 255: not known or not detectable
 6    uint8 rsrq; // 0: rsrq < -19.5 dB

-                // 1: -19.5 dB �� rsrq < -19 dB

-                // 2: -19 dB �� rsrq < -18.5 dB

-                // ......

-                // 32: -4 dB �� rsrq < -3.5 dB

-                // 33: -3.5 dB �� rsrq < -3 dB

-                // 34: -3 dB �� rsrq

-                // 255: not known or not detectable

+                // 1: -19.5 dB �� rsrq < -19 dB
+                // 2: -19 dB �� rsrq < -18.5 dB
+                // ......
+                // 32: -4 dB �� rsrq < -3.5 dB
+                // 33: -3.5 dB �� rsrq < -3 dB
+                // 34: -3 dB �� rsrq
+                // 255: not known or not detectable
 7    uint8 rsrp; // 0: rsrp < -140 dBm

-                // 1: -140 dBm �� rsrp < -139 dBm

-                // 2: -139 dBm �� rsrp < -138 dBm

-                // ......

-                // 95: -46 dBm �� rsrp < -45 dBm

-                // 96: -45 dBm �� rsrp < -44 dBm

-                // 97: -44 dBm �� rsrp

-                // 255: not known or not detectable

+                // 1: -140 dBm �� rsrp < -139 dBm
+                // 2: -139 dBm �� rsrp < -138 dBm
+                // ......
+                // 95: -46 dBm �� rsrp < -45 dBm
+                // 96: -45 dBm �� rsrp < -44 dBm
+                // 97: -44 dBm �� rsrp
+                // 255: not known or not detectable
 8    uint8 ss_rsrq; // 0: ss_rsrq < -43 dB

-                   // 1: -43 dB <= ss_rsrq < -42.5 dB

-                   // 2: -42.5 dB <= ss_rsrq < -42 dB

-                   // ......

-                   // 125: 19 dB <= ss_rsrq < 19.5 dB

-                   // 126: 19.5 dB <= ss_rsrq < 20 dB

-                   // 255: not known or not detectable

-    uint8 ss_rsrp; // 0: ss_rsrp < -156 dBm

-                   // 1: -156 dBm <= ss_rsrp < -155 dBm

-                   // 2: -155 dBm <= ss_rsrp < -154 dBm

-                   // ......

-                   // 125: -32 dBm <= ss_rsrp < -31 dBm

-                   // 126: -31 dBm <= ss_rsrp

-                   // 255: not known or not detectable

-    uint8 ss_sinr; // 0: ss_sinr < -23 dB

-                   // 1: -23 dB  ss_sinr < -22.5 dB

-                   // 2: -22.5 dB  ss_sinr < -22 dB

-                   // ......

-                   // 125: 39 dB  ss_sinr < 39.5 dBm

-                   // 126: 39.5 dB  ss_sinr < 40 dB

-                   // 127: 40 dB  ss_sinr

-                   // 255: not known or not detectable

+                   // 1: -43 dB <= ss_rsrq < -42.5 dB
+                   // 2: -42.5 dB <= ss_rsrq < -42 dB
+                   // ......
+                   // 125: 19 dB <= ss_rsrq < 19.5 dB
+                   // 126: 19.5 dB <= ss_rsrq < 20 dB
+                   // 255: not known or not detectable
+    uint8 ss_rsrp; // 0: ss_rsrp < -156 dBm
+                   // 1: -156 dBm <= ss_rsrp < -155 dBm
+                   // 2: -155 dBm <= ss_rsrp < -154 dBm
+                   // ......
+                   // 125: -32 dBm <= ss_rsrp < -31 dBm
+                   // 126: -31 dBm <= ss_rsrp
+                   // 255: not known or not detectable
+    uint8 ss_sinr; // 0: ss_sinr < -23 dB
+                   // 1: -23 dB  ss_sinr < -22.5 dB
+                   // 2: -22.5 dB  ss_sinr < -22 dB
+                   // ......
+                   // 125: 39 dB  ss_sinr < 39.5 dBm
+                   // 126: 39.5 dB  ss_sinr < 40 dB
+                   // 127: 40 dB  ss_sinr
+                   // 255: not known or not detectable
 } __attribute__((packed)) mbtk_signal_info_t;

 */

 static void gsw_sig_info_callback(const void* data, int data_len)

 {

+    if (nw_init_flag == 0)

+     {

+         printf("%s, nw not init\n",__func__);

+         return;

+     }

+

     if(data && (data_len >= sizeof (mbtk_signal_info_t)))

     {

         signalStrength_t sig_strength;

@@ -1440,19 +1346,25 @@
     }

     else

     {

-        LOGE("data is NULL or data len %d error",data_len);

+        LOGE(GSW_NW,"data is NULL or data len %d error",data_len);

     }

 }

 

 static void gsw_operating_mode_event_callback(const void* data, int data_len)

 {

-    LOGE("gsw_operating_mode_event_callback start\n");

+    if (nw_init_flag == 0)

+    {

+        printf("%s nw not init\n",__func__);

+        return;

+    }

+     

+    LOGE(GSW_NW,"gsw_operating_mode_event_callback start\n");

 

  

     if(data && data_len > 0)

     {

         const uint8 *cfun_state = (const uint8*)data;

-        LOGE("gsw_operating_mode_event_callback,data = %d\n", *cfun_state);

+        LOGE(GSW_NW,"gsw_operating_mode_event_callback,data = %d\n", *cfun_state);

         if(airplane_cb != NULL)

         {

             airplane_cb(*cfun_state);

@@ -1464,27 +1376,42 @@
 

 static void gsw_reject_callback(GSW_NW_RADIO_ACCESS_TECH_E rat, GSW_SERVICE_DOMAIN_E domain, int cause)

 {

-    LOGE("gsw_reject_callback start,rat = %d,domain = %d,cause = %d\n",rat,domain,cause);

+   if (nw_init_flag == 0)

+    {

+        printf("%s nw not init\n",__func__);

+        return;

+    }

 

-    GSW_NW_REJ_CAUSE_E *rej_cause = (GSW_NW_REJ_CAUSE_E*)malloc(sizeof(GSW_NW_REJ_CAUSE_E));

-    memset(rej_cause, 0x0, sizeof(GSW_NW_REJ_CAUSE_E));

-    

-    rej_cause->rej_cause = cause;

-    rej_cause->rej_rat = rat;

-    rej_cause->rej_domain = domain;

+    LOGE(GSW_NW,"gsw_reject_callback start,rat = %d,domain = %d,cause = %d\n",rat,domain,cause);

 

     if(reject_cb != NULL)

     {

-        LOGE("reject_cb is not NULL\n");

-        reject_cb(rej_cause);

+        GSW_NW_REJ_CAUSE_E rej_cause;

+        rej_cause.rej_cause = cause;

+        rej_cause.rej_rat = rat;

+        rej_cause.rej_domain = domain;

+         

+        LOGE(GSW_NW,"reject_cb called\n");

+        reject_cb(&rej_cause);

     }

     else

     {

-        LOGE("reject_cb is NULL\n");

+        LOGE(GSW_NW,"reject_cb is NULL\n");

+    }

+}

+

+void gsw_serving_info_timer()

+{

+    if(nw_init_flag == 0 || nw_info_handle == NULL)

+    {

+        return;

     }

 

-    free(rej_cause);

-    LOGE("gsw_reject_callback end\n");

+    while(nw_init_flag)

+    {   

+         gsw_serving_info_callback_thread();

+         sleep(SERVING_TIMER);

+    }

 }

 

 void gsw_sig_info_timer()

@@ -1502,7 +1429,7 @@
         int ret = mbtk_net_signal_get(nw_info_handle, &signal);

         if(ret != 0)

         {

-            LOGE("mbtk_net_signal_get fail, ret is %d\n",ret);

+            LOGE(GSW_NW,"mbtk_net_signal_get fail, ret is %d\n",ret);

            

         }

         else

@@ -1523,18 +1450,18 @@
     FILE *fp = popen(SDK_READY_CMD, "r");

     if(NULL == fp)

     {

-        LOGE("popen sdk ready fail");

+        LOGE(GSW_NW,"popen sdk ready fail");

         return -1;

     }

     memset(buffer,0,sizeof(buffer));

     if(fgets(buffer, sizeof(buffer), fp) == NULL)

     {

         pclose(fp);

-        LOGE("fgets failed:");

+        LOGE(GSW_NW,"fgets failed:");

         return -1;

     }

     pclose(fp);

-    LOGE("get_sdk_ready:%s",buffer);

+    LOGE(GSW_NW,"get_sdk_ready:%s",buffer);

     return atoi(buffer);

 }

 

@@ -1564,7 +1491,7 @@
             }

             else if(state!=g_mode_state)

             {

-                LOGE("modem state changed from %d to %d",g_mode_state,state);

+                LOGE(GSW_NW,"modem state changed from %d to %d",g_mode_state,state);

                 g_mode_state=state;

                 modem_cb(state);

             }

@@ -1588,16 +1515,25 @@
         return GSW_HAL_NORMAL_FAIL;

     }

 

+    void* cb_func;

     if(handle_ptr == NULL)

     {

-        LOGE("handle_ptr is NULL\n");

+        LOGE(GSW_NW,"serving info handle_ptr is NULL\n");

+        cb_func=NULL;

+    }

+    else

+    {   

+        cb_func=(void*) gsw_serving_info_callback;

+    }

+    

+    int ret = mbtk_net_state_change_cb_reg(nw_info_handle, cb_func);

+    if (ret != 0)

+    {

+        LOGW(GSW_NW,"mbtk_net_state_change_cb_reg fail, ret is %d",ret);

         return GSW_HAL_NORMAL_FAIL;

     }

-

-    serving_cb = handle_ptr;

-

+    serving_cb=handle_ptr;

     return GSW_HAL_SUCCESS;

-

 }

 

 

@@ -1614,11 +1550,23 @@
         return GSW_HAL_NORMAL_FAIL;

     }

 

+    void* cb_func;

     if(handle_ptr == NULL)

     {

-        LOGE("handle_ptr is NULL\n");

-        sig_cb=NULL;

-        return GSW_HAL_SUCCESS;

+        LOGE(GSW_NW,"serving info handle_ptr is NULL\n");

+        cb_func=NULL;

+    }

+    else

+    {   

+        cb_func=(void*) gsw_sig_info_callback;

+    }

+

+    int ret = mbtk_signal_state_change_cb_reg(nw_info_handle, cb_func);

+

+    if (ret != 0)

+    {

+        LOGE(GSW_NW,"mbtk_signal_state_change_cb_reg fail, ret is %d", ret);

+        return GSW_HAL_NORMAL_FAIL;

     }

 

     sig_cb = handle_ptr;

@@ -1643,8 +1591,7 @@
 

     if(handle_ptr == NULL)

     {

-        LOGE("handle_ptr is NULL\n");

-        return GSW_HAL_NORMAL_FAIL;

+        LOGE(GSW_NW,"rej cause handle_ptr is NULL\n");

     }

 

     reject_cb = handle_ptr;

@@ -1680,7 +1627,7 @@
 

     if (nw_info_handle == NULL)

     {

-        LOGE("mbtk_info_handle_get fail\n");

+        LOGE(GSW_NW,"mbtk_info_handle_get fail\n");

         return GSW_HAL_NORMAL_FAIL;

     }

 

@@ -1688,32 +1635,19 @@
     ret = mbtk_fplmn_get(nw_info_handle, fplmn);

     if(ret != 0)

     {

-        LOGE("mbtk_fplmn_get failed : %d\n",ret);

+        LOGE(GSW_NW,"mbtk_fplmn_get failed : %d\n",ret);

         return GSW_HAL_NORMAL_FAIL;

     }

     fplmn_max_length = (strlen(fplmn)/6);

-    LOGE("fplmn = %s, fplmn_max_length = %d\n",fplmn,fplmn_max_length);

-    ret = mbtk_signal_state_change_cb_reg(nw_info_handle, gsw_sig_info_callback);

-

-    if (ret != 0)

-    {

-        LOGE("mbtk_signal_state_change_cb_reg fail\n");

-        return GSW_HAL_NORMAL_FAIL;

-    }

-

-    ret = mbtk_net_state_change_cb_reg(nw_info_handle, gsw_serving_info_callback);

-    if (ret != 0)

-    {

-        LOGE("mbtk_net_state_change_cb_reg fail\n");

-        return GSW_HAL_NORMAL_FAIL;

-    }

+    LOGE(GSW_NW,"fplmn = %s, fplmn_max_length = %d\n",fplmn,fplmn_max_length);

+   

 

     nw_init_flag = 1;

 

     ret = pthread_create(&nw_info_thread, NULL, (void*)gsw_sig_info_timer, NULL);

     if (ret != 0)

     {

-        LOGE("pthread_create fail,ret is %d", ret);

+        LOGE(GSW_NW,"pthread_create fail 1,ret is %d", ret);

         nw_init_flag = 0;

         return GSW_HAL_ERROR_GNSS_NO_THRESHOLDS;

     }

@@ -1722,7 +1656,15 @@
     ret = pthread_create(&nw_info_thread, NULL, (void*)gsw_modem_state_timer, NULL);

     if (ret != 0)

     {

-        LOGE("pthread_create fail 2,ret is %d", ret);

+        LOGE(GSW_NW,"pthread_create fail 2,ret is %d", ret);

+        nw_init_flag = 0;

+        return GSW_HAL_ERROR_GNSS_NO_THRESHOLDS;

+    }

+

+    ret = pthread_create(&nw_info_thread, NULL, (void*)gsw_serving_info_timer, NULL);

+    if (ret != 0)

+    {

+        LOGE(GSW_NW,"pthread_create fail 3,ret is %d", ret);

         nw_init_flag = 0;

         return GSW_HAL_ERROR_GNSS_NO_THRESHOLDS;

     }

@@ -1749,7 +1691,7 @@
     ret = mbtk_info_handle_free(&nw_info_handle);

     if(ret != GSW_HAL_SUCCESS)

     {

-        LOGE("mbtk_info_handle_free fail\n");

+        LOGE(GSW_NW,"mbtk_info_handle_free fail\n");

         return GSW_HAL_NORMAL_FAIL;

     }

 

@@ -1779,24 +1721,23 @@
         return GSW_HAL_NORMAL_FAIL;

     }

 

-    LOGE("mbtk_net_reg_get start \n");

+    LOGE(GSW_NW,"mbtk_net_reg_get start \n");

     //regstate

     mbtk_net_reg_info_t reg;

-    memset(&reg, 0x0, sizeof(mbtk_net_reg_info_t));

     ret = mbtk_net_reg_get(nw_info_handle, &reg);

     if(ret)

     {

-        LOGE("mbtk_net_reg_get fail\n");

+        LOGE(GSW_NW,"mbtk_net_reg_get fail\n");

         return GSW_HAL_NORMAL_FAIL;

     }

 

-    LOGE("convert_cs_reg_state\n");

+    LOGE(GSW_NW,"convert_cs_reg_state\n");

     //cs_state

     serving_info->reg_state = convert_reg_state(reg.call_state);

-    LOGE("convert_ps_reg_state\n");

+    LOGE(GSW_NW,"convert_ps_reg_state\n");

     //ps_state

     serving_info->ps_state = convert_reg_state(reg.data_state);

-    LOGE("convert_rat_mode\n");

+    LOGE(GSW_NW,"convert_rat_mode\n");

     //reg_rat

     serving_info->reg_rat = convert_net_mode(reg.type);

     //srv_domain

@@ -1825,7 +1766,7 @@
         serving_info->reg_rat = GSW_NETWORK_RADIO_NO_SVC;

     }

 

-    LOGD("roaming_ind\n");

+    LOGD(GSW_NW,"roaming_ind\n");

     //roaming_ind

     if(serving_info->ps_state == GSW_NETWORK_REG_REGISTRATION_ROAMING)

     {

@@ -1836,31 +1777,30 @@
         serving_info->roaming_ind = GSW_NETWORK_ROAMING_OFF;

     }

 

-    LOGD("reject\n");

+    LOGD(GSW_NW,"reject\n");

     //reject

     if(serving_info->ps_state == GSW_NETWORK_REG_REGISTRATION_DENIED || serving_info->reg_state == GSW_NETWORK_REG_REGISTRATION_DENIED)

     {

-        LOGD("reject_callback\n");

+        LOGD(GSW_NW,"reject_callback\n");

         gsw_reject_callback(serving_info->reg_rat,serving_info->srv_domain,99);

     }

 

-    LOGD("reg_plmn / operator name\n");

+    LOGD(GSW_NW,"reg_plmn / operator name\n");

     //reg_plmn / operator name

     mbtk_net_info_t net;

-    memset(&net, 0x0, sizeof(mbtk_net_info_t));

-    LOGD("mbtk_net_sel_mode_get start \n");

+    LOGD(GSW_NW,"mbtk_net_sel_mode_get start \n");

     ret = mbtk_net_sel_mode_get(nw_info_handle, &net);

-    LOGD("mbtk_net_sel_mode_get end \n");

+    LOGD(GSW_NW,"mbtk_net_sel_mode_get end \n");

     if(ret == 0 && net.plmn > 0)

     {

         int i = 0;

 

-        LOGD("start to find mcc");

+        LOGD(GSW_NW,"start to find mcc");

         while(i < ARRAY_SIZE(lynq_operator_mcc_mnc))

         {

             if(lynq_operator_mcc_mnc[i].lynq_mcc_mnc == net.plmn)

             {

-                LOGD("find mcc\n");

+                LOGD(GSW_NW,"find mcc\n");

                 break;

             }

             i++;

@@ -1869,51 +1809,51 @@
 

         if(i == ARRAY_SIZE(lynq_operator_mcc_mnc))

         {

-            LOGD("not find mcc");

+            LOGD(GSW_NW,"not find mcc");

             strcpy(serving_info->operator_name, "unknown");

             sprintf(serving_info->reg_plmn, "%u", net.plmn);

         }

 

         else

         {

-            LOGD("find mcc\n");

+            LOGD(GSW_NW,"find mcc\n");

             strcpy(serving_info->operator_name, lynq_operator_mcc_mnc[i].lynq_operator_l);

             sprintf(serving_info->reg_plmn, "%u", net.plmn);

         }

 

-        LOGE("operator_name = %s\n", serving_info->operator_name);

-        LOGE("reg_plmn = %s\n", serving_info->reg_plmn);

+        LOGE(GSW_NW,"operator_name = %s\n", serving_info->operator_name);

+        LOGE(GSW_NW,"reg_plmn = %s\n", serving_info->reg_plmn);

     }

 

 

-    LOGD("get cell id/tac/lac/sid/nid\n");

+    LOGD(GSW_NW,"get cell id/tac/lac/sid/nid\n");

     //cell id/tac/lac/sid/nid

     mbtk_cell_type_enum cell_type;

     list_node_t* cell_list = NULL;

     

-    LOGD("mbtk_cell_get start\n");

+    LOGD(GSW_NW,"mbtk_cell_get start\n");

     ret = mbtk_cell_get(nw_info_handle, &cell_type, &cell_list);

     if(ret != 0 || cell_list == NULL)

     {

-        LOGE("mbtk_cell_get fail\n");

+        LOGE(GSW_NW,"mbtk_cell_get fail\n");

         return GSW_HAL_NORMAL_FAIL;

     }

     else

     {

-        LOGE("mbtk_cell_get end,start to get node\n");

+        LOGE(GSW_NW,"mbtk_cell_get end,start to get node\n");

         list_first(cell_list);

-        LOGE("list_first end\n");

+        LOGE(GSW_NW,"list_first end\n");

         mbtk_cell_info_t* cell = (mbtk_cell_info_t*) list_next(cell_list);

         if(cell)

         {

-            LOGE("cell is not null,value2 = %u\n",cell->value2);

+            LOGE(GSW_NW,"cell is not null,value2 = %u\n",cell->value2);

             switch(cell_type)

             {

                 case MBTK_CELL_TYPE_LTE:

                 {

-                    LOGE("is lte\n");

-                    //LOGE("LTE : tac=%x, PCI=%x, dlEuarfcn=%x, ulEuarfcn=%x, band=%x\n", cell->value1, cell->value2, cell->value3, cell->value4, cell->value5);

-                    LOGE("LTE : tac=%d, PCI=%d, dlEuarfcn=%d, ulEuarfcn=%d, band=%d\n", cell->value1, cell->value2, cell->value3, cell->value4, cell->value5);

+                    LOGE(GSW_NW,"is lte\n");

+                    //LOGE(GSW_NW,"LTE : tac=%x, PCI=%x, dlEuarfcn=%x, ulEuarfcn=%x, band=%x\n", cell->value1, cell->value2, cell->value3, cell->value4, cell->value5);

+                    LOGE(GSW_NW,"LTE : tac=%d, PCI=%d, dlEuarfcn=%d, ulEuarfcn=%d, band=%d\n", cell->value1, cell->value2, cell->value3, cell->value4, cell->value5);

                     snprintf(serving_info->tac,sizeof(serving_info->tac),"%u",cell->value1);

                     strcpy(serving_info->lac,"");

                     snprintf(serving_info->cell_id,sizeof(serving_info->cell_id),"%u",cell->value10);

@@ -1922,8 +1862,8 @@
 

                 case MBTK_CELL_TYPE_GSM:

                 {

-                    LOGE("is gsm\n");

-                    LOGE("GSM : lac=%d, ci=%d, arfcn=%d, bsic=%d\n", cell->value1, cell->value2, cell->value3, cell->value4);

+                    LOGE(GSW_NW,"is gsm\n");

+                    LOGE(GSW_NW,"GSM : lac=%d, ci=%d, arfcn=%d, bsic=%d\n", cell->value1, cell->value2, cell->value3, cell->value4);

                     sprintf(serving_info->lac,"%u",cell->value1);

                     memset(serving_info->tac,0,sizeof(serving_info->tac));

                     sprintf(serving_info->cell_id,"%u",cell->value2);

@@ -1931,8 +1871,8 @@
                 }    

                 case MBTK_CELL_TYPE_UMTS:

                 {

-                    LOGE("is wcdma\n");

-                    LOGE("UMTS : lac=%d, ci=%d, arfcn=%d\n", cell->value1, cell->value2, cell->value3);

+                    LOGE(GSW_NW,"is wcdma\n");

+                    LOGE(GSW_NW,"UMTS : lac=%d, ci=%d, arfcn=%d\n", cell->value1, cell->value2, cell->value3);

                     sprintf(serving_info->lac,"%u",cell->value1);

                     memset(serving_info->tac,0,sizeof(serving_info->tac));

                     sprintf(serving_info->cell_id,"%u",cell->value2);

@@ -1945,7 +1885,7 @@
         }

         else

         {

-            LOGE("cell is null\n");

+            LOGE(GSW_NW,"cell is null\n");

         }

     }

 

@@ -1977,7 +1917,7 @@
     ret = mbtk_net_reg_get(nw_info_handle, &reg);

     if(ret)

     {

-        LOGE("mbtk_net_reg_get fail\n");

+        LOGE(GSW_NW,"mbtk_net_reg_get fail\n");

         return GSW_HAL_NORMAL_FAIL;

     }

 

@@ -2012,7 +1952,7 @@
     ret = mbtk_get_modem_fun(nw_info_handle, &tmp_rf);

     if (ret != 0)

     {

-        LOGE("mbtk_get_modem_fun fail\n");

+        LOGE(GSW_NW,"mbtk_get_modem_fun fail\n");

         return GSW_HAL_NORMAL_FAIL;

     }

     if(tmp_rf == LYNQ_AIR_CFUN_MODE_OFF)

@@ -2069,7 +2009,7 @@
 

     if (rf_mode != LYNQ_AIR_PLANE_MODE_ON && rf_mode != LYNQ_AIR_PLANE_MODE_OFF && rf_mode != LYNQ_AIR_CFUN_MODE_OFF) 

     {

-        LOGE("Input mode is error!\n");

+        LOGE(GSW_NW,"Input mode is error!\n");

         return GSW_HAL_NORMAL_FAIL;

     }

 

@@ -2078,7 +2018,7 @@
     ret = mbtk_set_modem_fun(nw_info_handle, &info);

     if (ret != 0)

     {

-        LOGE("gsw_set_opmode fail\n");

+        LOGE(GSW_NW,"gsw_set_opmode fail\n");

         return GSW_HAL_NORMAL_FAIL;

     }

 

@@ -2108,15 +2048,15 @@
     ret = mbtk_current_band_get(nw_info_handle, &band);

     if(ret != 0)

     {

-        LOGE("mbtk_current_band_get fail\n");

+        LOGE(GSW_NW,"mbtk_current_band_get fail\n");

         return GSW_HAL_NORMAL_FAIL;

     }

 

     *mode_pref = convert_gsw_net_config(band.net_pref);

-    LOGE("band.net_pref = %d\n", *mode_pref);

+    LOGE(GSW_NW,"band.net_pref = %d\n", *mode_pref);

     if(*mode_pref <= 0)

     {

-        LOGE("no support mode\n");

+        LOGE(GSW_NW,"no support mode\n");

         return GSW_HAL_NORMAL_FAIL;

     }

     return GSW_HAL_SUCCESS;

@@ -2144,18 +2084,18 @@
     memset(&band, 0, sizeof(mbtk_band_info_t));

 

     band.net_pref = convert_mbtk_net_config(mode_pref);

-    LOGE("band.net_pref = %d\n", band.net_pref);

+    LOGE(GSW_NW,"band.net_pref = %d\n", band.net_pref);

 

     if(band.net_pref < 0)

     {

-        LOGE("no support mode\n");

+        LOGE(GSW_NW,"no support mode\n");

         return GSW_HAL_NORMAL_FAIL;

     }

 

     ret = mbtk_current_band_set(nw_info_handle, &band);

     if(ret != 0)

     {

-        LOGE("mbtk_current_band_set fail\n");

+        LOGE(GSW_NW,"mbtk_current_band_set fail\n");

         return GSW_HAL_NORMAL_FAIL;

     }

 

@@ -2179,17 +2119,17 @@
     int ret = mbtk_net_signal_get(nw_info_handle, &signal);

     if(ret != 0)

     {

-        LOGE("mbtk_net_signal_get fail\n");

+        LOGE(GSW_NW,"mbtk_net_signal_get fail\n");

         return GSW_HAL_NORMAL_FAIL;

     }

 

-    LOGD("signal.type=%d\n", signal.type);

+    LOGD(GSW_NW,"signal.type=%d\n", signal.type);

     switch(signal.type)

     {

         

         case MBTK_RADIO_TECH_E_UTRAN:

         {

-            LOGD("lte rsrp = %d dbm",signal.rsrp-141);

+            LOGD(GSW_NW,"lte rsrp = %d dbm",signal.rsrp-141);

             *csq_value = rsrpToLevel(signal.rsrp-141);

             break;

         }

@@ -2199,7 +2139,7 @@
         case MBTK_RADIO_TECH_UTRAN_HSDPA_HSUPA:

         case MBTK_RADIO_TECH_UTRAN_HSPA:

         {

-            LOGD("w rscp = %d dbm",signal.rscp-121);

+            LOGD(GSW_NW,"w rscp = %d dbm",signal.rscp-121);

             *csq_value = rscpToLevel(signal.rscp-121);

             break;

         }

@@ -2207,13 +2147,13 @@
         case MBTK_RADIO_TECH_GSM_COMPACT:

         case MBTK_RADIO_TECH_GSM_EGPRS:

         {

-            LOGD("gsm rxlev = %d (0-63)",signal.rxlev);

+            LOGD(GSW_NW,"gsm rxlev = %d (0-63)",signal.rxlev);

             *csq_value = rxlevToLevel(signal.rxlev);

             break;

         }

         default:

         {

-            LOGE("[%s] unknown reg type.[%d]", __func__, signal.type);

+            LOGE(GSW_NW,"[%s] unknown reg type.[%d]", __func__, signal.type);

             return GSW_HAL_NORMAL_FAIL;

         }

     }

@@ -2238,7 +2178,7 @@
 

     if(mode != 0 && mode != 1)

     {

-        LOGE("Input mode is error!\n");

+        LOGE(GSW_NW,"Input mode is error!\n");

         return GSW_HAL_NORMAL_FAIL;

     }

 

@@ -2246,18 +2186,17 @@
         gsw_nw_power_mode = 3;

     else

         gsw_nw_power_mode = 1;

-    LOGE("mode is %d\n",gsw_nw_power_mode);

+

+    LOGE(GSW_NW,"mode is %d\n",gsw_nw_power_mode);

     ret = mbtk_wakeup_state_set(nw_info_handle, gsw_nw_power_mode);

     if(ret != 0)

     {

-        LOGE("mbtk_wakeup_state_set fail\n");

+        LOGE(GSW_NW,"mbtk_wakeup_state_set fail\n");

         return GSW_HAL_NORMAL_FAIL;

     }

 

     return GSW_HAL_SUCCESS;

 

-

-

 }

 

 /**

@@ -2292,7 +2231,7 @@
             

         default:

         {

-            LOGE("parameter error\n");

+            LOGE(GSW_NW,"parameter error\n");

             return GSW_HAL_NORMAL_FAIL;

         }

     }

@@ -2318,7 +2257,7 @@
 

     if(!mbtk_net_sel_mode_get(nw_info_handle, &net) && net.plmn > 0)

     {

-        LOGE("Net : %d, %d, %d\n", net.net_sel_mode, net.net_type, net.plmn);

+        LOGE(GSW_NW,"Net : %d, %d, %d\n", net.net_sel_mode, net.net_type, net.plmn);

         int i = 0;

         while(i < ARRAY_SIZE(lynq_operator_mcc_mnc))

         {

@@ -2356,7 +2295,7 @@
 

     else

     {

-        LOGE("mbtk_net_sel_mode_get fail\n");

+        LOGE(GSW_NW,"mbtk_net_sel_mode_get fail\n");

         return GSW_HAL_NORMAL_FAIL;

     }

 

@@ -2383,7 +2322,7 @@
     mbtk_cell_type_enum type;

     int ret = mbtk_cell_get(nw_info_handle, &type, &cell_list);

     if(ret || cell_list == NULL) {

-        LOGE("mbtk_cell_get failed : %d\n", ret);

+        LOGE(GSW_NW,"mbtk_cell_get failed : %d\n", ret);

         list_free(cell_list);

         return GSW_HAL_NORMAL_FAIL;

     } else {

@@ -2395,7 +2334,7 @@
             {

                 case 0:

                 {

-                    LOGD("GSM : lac=%d, ci=%d, arfcn=%d, bsic=%d\n", cell->value1, cell->value2, cell->value3, cell->value4);

+                    LOGD(GSW_NW,"GSM : lac=%d, ci=%d, arfcn=%d, bsic=%d\n", cell->value1, cell->value2, cell->value3, cell->value4);

                     char gsm_temp[12];

 

                     cell_info->rat = GSW_NETWORK_RADIO_GSM;

@@ -2424,7 +2363,7 @@
                     

                 case 1:

                 {

-                    LOGD("UMTS : lac=%d, ci=%d, arfcn=%d\n", cell->value1, cell->value2, cell->value3);

+                    LOGD(GSW_NW,"UMTS : lac=%d, ci=%d, arfcn=%d\n", cell->value1, cell->value2, cell->value3);

                     char wcdma_temp[12];

 

                     cell_info->rat = GSW_NETWORK_RADIO_UMTS;

@@ -2453,7 +2392,7 @@
                     

                 case 2:

                 {

-                    LOGE("LTE : tac=%d, PCI=%d, dlEuarfcn=%d, ulEuarfcn=%d, band=%d\n", cell->value1, cell->value2, cell->value3, cell->value4, cell->value5);

+                    LOGE(GSW_NW,"LTE : tac=%d, PCI=%d, dlEuarfcn=%d, ulEuarfcn=%d, band=%d\n", cell->value1, cell->value2, cell->value3, cell->value4, cell->value5);

 

                     char lte_temp[12];

                     cell_info->rat = GSW_NETWORK_RADIO_LTE;

@@ -2520,7 +2459,7 @@
                 //WCDMA

                 case 1:

                 {

-                    LOGE("CELL : lac=%d, ci=%d, arfcn=%d\n", cell->value1, cell->value2, cell->value3);

+                    LOGE(GSW_NW,"CELL : lac=%d, ci=%d, arfcn=%d\n", cell->value1, cell->value2, cell->value3);

 

                     //cell_info->ext_info[neibor_count]->lac = cell->value1;

 

@@ -2538,7 +2477,7 @@
                 //LTE

                 case 2:

                 {

-                    LOGE("CELL : phyCellId=%d, euArfcn=%d, rsrp=%d, rsrq=%d\n", cell->value1, cell->value2, cell->value3, cell->value4);

+                    LOGE(GSW_NW,"CELL : phyCellId=%d, euArfcn=%d, rsrp=%d, rsrq=%d\n", cell->value1, cell->value2, cell->value3, cell->value4);

                     char lte_temp[12] = {0};

                     cell_info->ext_info[neibor_count].rat = GSW_NETWORK_RADIO_LTE;

 

@@ -2607,15 +2546,12 @@
 

     if(handle_ptr == NULL)

     {

-        LOGE("handle_ptr is NULL\n");

-        modem_cb=NULL;

-        return GSW_HAL_SUCCESS;

+        LOGE(GSW_NW,"reg modem state cb, handle_ptr is NULL\n");

     }

 

     modem_cb = handle_ptr;

 

     return GSW_HAL_SUCCESS;

-

 }

 

 

@@ -2634,12 +2570,12 @@
 

     int ret = -1;

     char fplmn[256] = {0};

-    LOGE("mbtk_fplmn_get enter\n");

+    LOGE(GSW_NW,"mbtk_fplmn_get enter\n");

     ret = mbtk_fplmn_get(nw_info_handle, fplmn);

-    LOGE("mbtk_fplmn_get exit\n");

+    LOGE(GSW_NW,"mbtk_fplmn_get exit\n");

     if(ret != 0)

     {

-        LOGE("mbtk_fplmn_get failed : %d\n",ret);

+        LOGE(GSW_NW,"mbtk_fplmn_get failed : %d\n",ret);

         return GSW_HAL_NORMAL_FAIL;

     }

 

@@ -2651,11 +2587,11 @@
             continue;

         }

         extract_mcc_mnc(fplmn_array[i], plmn_list->plmn_list[plmn_list->plmn_list_len].mcc, plmn_list->plmn_list[plmn_list->plmn_list_len].mnc);

-        LOGE("mcc = %s, mnc = %s\n", plmn_list->plmn_list[plmn_list->plmn_list_len].mcc, plmn_list->plmn_list[plmn_list->plmn_list_len].mnc);

+        LOGE(GSW_NW,"mcc = %s, mnc = %s\n", plmn_list->plmn_list[plmn_list->plmn_list_len].mcc, plmn_list->plmn_list[plmn_list->plmn_list_len].mnc);

         plmn_list->plmn_list_len++;

     }

 

-    LOGE("fplmn = %s\n", fplmn);

+    LOGE(GSW_NW,"fplmn = %s\n", fplmn);

     return GSW_HAL_SUCCESS;

 }

 

@@ -2675,7 +2611,7 @@
 

     if(plmn_list->plmn_list_len >= fplmn_max_length)

     {

-        LOGE("can't save all the plmn\n");

+        LOGE(GSW_NW,"can't save all the plmn\n");

         return GSW_HAL_NORMAL_FAIL;

     }

 

@@ -2688,10 +2624,10 @@
 

         if(index == -1)

         {

-            LOGE("no this PLMN, add it\n");

+            LOGE(GSW_NW,"no this PLMN, add it\n");

             if((fplmn_index + plmn_list->plmn_list_len) > fplmn_max_length)

             {

-                LOGE("can't save all the plmn\n");

+                LOGE(GSW_NW,"can't save all the plmn\n");

                 return GSW_HAL_NORMAL_FAIL;

             }

 

@@ -2700,30 +2636,30 @@
                 memcpy(fplmn_array[fplmn_index], plmn_list->plmn_list[i].mcc, 3);

                 memcpy(fplmn_array[fplmn_index] + 3, plmn_list->plmn_list[i].mnc, 2);

                 fplmn_array[fplmn_index][5] = '\0';

-                LOGE("fplmn_array[%d] = %s\n", fplmn_index, fplmn_array[fplmn_index]);

+                LOGE(GSW_NW,"fplmn_array[%d] = %s\n", fplmn_index, fplmn_array[fplmn_index]);

                 fplmn_index++;

             }

         }

 

         else

         {

-            LOGE("already have this PLMN, don't add it\n");

+            LOGE(GSW_NW,"already have this PLMN, don't add it\n");

         }

     }

 

     char fplmn_str[256] = {0};

     convert_plmn_to_fplmn_str(fplmn_str);

 

-    LOGE("fplmn_str = %s\n", fplmn_str);

+    LOGE(GSW_NW,"fplmn_str = %s\n", fplmn_str);

 

     int ret = mbtk_fplmn_set(nw_info_handle, fplmn_str);

     if(ret != 0)

     {

-        LOGE("mbtk_fplmn_set failed : %d\n",ret);

+        LOGE(GSW_NW,"mbtk_fplmn_set failed : %d\n",ret);

         return GSW_HAL_NORMAL_FAIL;

     }

 

-    LOGE("gsw_add_forbidden_networks exit\n");

+    LOGE(GSW_NW,"gsw_add_forbidden_networks exit\n");

     return GSW_HAL_SUCCESS;

 }

 

@@ -2753,27 +2689,27 @@
         }

         else

         {

-            LOGE("no this PLMN, can't remove it\n");

+            LOGE(GSW_NW,"no this PLMN, can't remove it\n");

         }

     }

 

     for(i = 0; i < fplmn_index; i++)

     {

-        LOGE("fplmn_array[%d] = %s\n", i, fplmn_array[i]);

+        LOGE(GSW_NW,"fplmn_array[%d] = %s\n", i, fplmn_array[i]);

     }

 

     char fplmn_str[256] = {0};

     convert_plmn_to_fplmn_str(fplmn_str);

-    LOGE("fplmn_str = %s\n", fplmn_str);

+    LOGE(GSW_NW,"fplmn_str = %s\n", fplmn_str);

 

     int ret = mbtk_fplmn_set(nw_info_handle, fplmn_str);

     if(ret != 0)

     {

-        LOGE("mbtk_fplmn_set failed : %d\n",ret);

+        LOGE(GSW_NW,"mbtk_fplmn_set failed : %d\n",ret);

         return GSW_HAL_NORMAL_FAIL;

     }

 

-    LOGE("gsw_remove_forbidden_networks exit\n");

+    LOGE(GSW_NW,"gsw_remove_forbidden_networks exit\n");

     return GSW_HAL_SUCCESS;

 }

 

@@ -2794,11 +2730,11 @@
     memset(fplmn_str, 'F', (6 * fplmn_max_length));

     fplmn_str[(6 * fplmn_max_length)] = '\0'; 

 

-    LOGE("%s\n", fplmn_str);

+    LOGE(GSW_NW,"%s\n", fplmn_str);

     int ret = mbtk_fplmn_set(nw_info_handle, fplmn_str);

     if(ret != 0)

     {

-        LOGE("mbtk_fplmn_set failed : %d\n",ret);

+        LOGE(GSW_NW,"mbtk_fplmn_set failed : %d\n",ret);

         return GSW_HAL_NORMAL_FAIL;

     }

 

@@ -2820,7 +2756,7 @@
 

     if(pt_info == NULL)

     {

-        LOGE("pt_info is null\n");

+        LOGE(GSW_NW,"pt_info is null\n");

         return GSW_HAL_NORMAL_FAIL;

     }

 

@@ -2832,7 +2768,7 @@
     ret = mbtk_oos_get(nw_info_handle, &oos_info);

     if(ret != 0)

     {

-        LOGE("mbtk_oos_get failed : %d\n",ret);

+        LOGE(GSW_NW,"mbtk_oos_get failed : %d\n",ret);

         return GSW_HAL_NORMAL_FAIL;

     }

 

@@ -2869,7 +2805,7 @@
 

     if(pt_info == NULL)

     {

-        LOGE("pt_info is null\n");

+        LOGE(GSW_NW,"pt_info is null\n");

         return GSW_HAL_NORMAL_FAIL;

     }

 

@@ -2879,7 +2815,7 @@
 

     if (pt_info->t_min < 0 || pt_info->t_step < 0 || pt_info->t_max < 0)

     {

-        LOGE("gsw_oos_config_set set time < 0 ");

+        LOGE(GSW_NW,"gsw_oos_config_set set time < 0 ");

         return GSW_HAL_NORMAL_FAIL;

     }

     else if ((pt_info->t_min > 0 && pt_info->t_min <= 255) && pt_info->t_step == 0 && pt_info->t_max == 0)

@@ -2906,14 +2842,14 @@
     }

     else

     {

-        LOGE("gsw_oos_config_set set Format err");

+        LOGE(GSW_NW,"gsw_oos_config_set set Format err");

         return GSW_HAL_NORMAL_FAIL;

     }

 

     ret = mbtk_oos_set(nw_info_handle, &oos_info);

     if(ret != 0)

     {

-        LOGE("mbtk_oos_set failed : %d\n",ret);

+        LOGE(GSW_NW,"mbtk_oos_set failed : %d\n",ret);

         return GSW_HAL_NORMAL_FAIL;

     }

 

@@ -2937,20 +2873,20 @@
 

     if(imei == NULL)

     {

-        LOGE("imei is NULL.");

+        LOGE(GSW_NW,"imei is NULL.");

         return GSW_HAL_ARG_INVALID;

     }

 

     if(len < GSW_IMEI_LENGTH)

     {

-        LOGE("imei len is too short,len = %d\n", len);

+        LOGE(GSW_NW,"imei len is too short,len = %d\n", len);

         return GSW_HAL_NORMAL_FAIL;

     }

 

     int ret = mbtk_imei_get(nw_info_handle, (void *)imei);

     if(ret != MBTK_ERR_OK)

     {

-        LOGE("[gsw_nw] mbtk_imei_get fail [err = %d].", ret);

+        LOGE(GSW_NW,"[gsw_nw] mbtk_imei_get fail [err = %d].", ret);

         return GSW_HAL_NORMAL_FAIL;

     }

 

@@ -2979,7 +2915,7 @@
     ret = mbtk_set_modem_fun(nw_info_handle, &info);

     if(ret)

     {

-        LOGE("[gsw_nw] mbtk_set_modem_fun 0 fail [err = %d].", ret);

+        LOGE(GSW_NW,"[gsw_nw] mbtk_set_modem_fun 0 fail [err = %d].", ret);

         return GSW_HAL_NORMAL_FAIL;

     }

 

@@ -2989,7 +2925,7 @@
     ret = mbtk_set_modem_fun(nw_info_handle, &info);

     if(ret)

     {

-        LOGE("[gsw_nw] mbtk_set_modem_fun 1 fail [err = %d].", ret);

+        LOGE(GSW_NW,"[gsw_nw] mbtk_set_modem_fun 1 fail [err = %d].", ret);

         return GSW_HAL_NORMAL_FAIL;

     }

     return GSW_HAL_SUCCESS;

@@ -3001,25 +2937,43 @@
     {

         return GSW_HAL_NORMAL_FAIL;

     }

-   

+

+     void* cb_func;

     if(handle_ptr == NULL)

     {

-        LOGE("handle_ptr is NULL\n");

-        return GSW_HAL_NORMAL_FAIL;

+        LOGE(GSW_NW,"reg airplane mode cb is NULL");

+        cb_func=NULL;

     }

- 

-    airplane_cb = handle_ptr;

- 

-    int ret = mbtk_radio_state_change_cb_reg(nw_info_handle,gsw_operating_mode_event_callback);

-    if(ret != 0)

-    {

-        LOGE("mbtk_radio_state_change_cb_reg failed : %d\n", ret);

-        airplane_cb=NULL;

-        return GSW_HAL_NORMAL_FAIL;

+    else

+    {   

+        cb_func=(void*) gsw_operating_mode_event_callback;

     }

- 

-    return GSW_HAL_SUCCESS;

 

+    int ret = mbtk_radio_state_change_cb_reg(nw_info_handle, cb_func);

+

+    if (ret != 0)

+    {

+        LOGE(GSW_NW,"mbtk_radio_state_change_cb_reg fail, ret is %d",ret);

+        return GSW_HAL_NORMAL_FAIL;

+    }

+

+    airplane_cb = handle_ptr;

+

+    if(airplane_cb !=NULL)

+    {

+         int opmode;

+         ret = gsw_get_opmode(&opmode);

+         if(ret == 0)

+         {

+             airplane_cb(opmode);

+         }

+         else

+         {

+             LOGE(GSW_NW,"gsw_get_opmode fail, ret is%d", ret);

+         }

+    }

+

+    return GSW_HAL_SUCCESS;

 }

 

 int gsw_get_apn_reserved_id(const char *apn)