data_call: 优化data_call功能

Change-Id: I5f640219abec6d5b4d884d49ae7163869f8267d6
diff --git a/mbtk/mbtk_ril/src/main.c b/mbtk/mbtk_ril/src/main.c
index 2c5922d..3f036e8 100755
--- a/mbtk/mbtk_ril/src/main.c
+++ b/mbtk/mbtk_ril/src/main.c
@@ -316,12 +316,22 @@
                 uint8 data_pdp;

                 data_pdp = 0;       //

                 urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));

-                data_pdp = cgact_wait.cid + 100;

+                data_pdp = data[1] + 100;

                 urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));

             } else if(strStartsWith(s, "+CGEV: EPS PDN ACT ")) { // +CGEV: EPS PDN ACT <cid>

                 //apn_state_set(atoi(s + 19), true);

                 data[0] = (uint8)1;

                 data[1] = (uint8)atoi(s + 19);

+            } else if(strStartsWith(s, "+CGEV: ME PDN DEACT ")) { // +CGEV: EPS PDN DEACT <cid>

+                //apn_state_set(atoi(s + 19), true);

+                data[0] = (uint8)0;

+                data[1] = (uint8)atoi(s + 20);

+

+                uint8 data_pdp;

+                data_pdp = 0;       //

+                urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));

+                data_pdp = data[1] + 100;

+                urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));

             } else if(strStartsWith(s, "+CGEV: ME PDN ACT ")) { // +CGEV: ME PDN ACT <cid>,1

                 //apn_state_set(atoi(s + 18), true);

                 data[0] = (uint8)1;

@@ -374,11 +384,9 @@
                     {

 

                     }

-                    if(cgact_wait.cid != 0)

-                    {

-                        data_pdp = cgact_wait.cid + 200;

-                        urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));

-                    }

+                    

+                    data_pdp = data[1] + 200;

+                    urc_msg_distribute(false, INFO_URC_MSG_PDP_STATE, &data_pdp, sizeof(uint8));

                 }

             } else {

                 LOGI("No process : %s", s);

diff --git a/mbtk/mbtk_ril/src/mbtk_info_server.c b/mbtk/mbtk_ril/src/mbtk_info_server.c
index 7c92094..341c9c9 100755
--- a/mbtk/mbtk_ril/src/mbtk_info_server.c
+++ b/mbtk/mbtk_ril/src/mbtk_info_server.c
@@ -5655,6 +5655,14 @@
         return;
     }
 
+    if(act)
+    {
+        cid_active[cid] = 1;
+    }
+    else
+    {
+        cid_active[cid] = 0;
+    }
     char dev[20] = {0};
     sprintf(dev, "ccinet%d", cid - 1);
     if(act) { // Config IP.
diff --git a/mbtk/ql_lib/src/ql_data_call.c b/mbtk/ql_lib/src/ql_data_call.c
index 5f88b55..c473739 100755
--- a/mbtk/ql_lib/src/ql_data_call.c
+++ b/mbtk/ql_lib/src/ql_data_call.c
@@ -20,29 +20,34 @@
 static int mbtk_interval_sec = 0;
 static nw_status_cb ql_net_status_cb = NULL;
 static ex_conn_status_cb ql_net_ex_status_cb = NULL;
+static int now_cid = 0;
 
 void ql_wan_net_state_change_cb(const void* data, int data_len)
 {
     uint8 *net_data = NULL;
     net_data = (uint8 *)data;
 
-    if(ql_net_status_cb != NULL)
+    if(*net_data > 100 && *net_data < 200)
     {
-        if(*net_data > 100 && *net_data < 200)
+        int cid;
+        cid = *net_data;
+        cid = cid - 100;
+        ql_apn_info[cid].active = FALSE;//close
+        if(ql_net_ex_status_cb != NULL)
         {
-            int cid;
-            cid = *net_data;
-            cid = cid - 100;
-            ql_apn_info[cid].active = FALSE;//close
+            ql_net_ex_status_cb(cid, ql_apn_info[cid].ip_type, CONNECT_DISCON, 0);
         }
-        else if(*net_data > 200)
-        {
-            int cid;
-            cid = *net_data;
-            cid = cid - 200;
-            ql_apn_info[cid].active = TRUE;//open
-        }
-        else
+    }
+    else if(*net_data > 200)
+    {
+        int cid;
+        cid = *net_data;
+        cid = cid - 200;
+        ql_apn_info[cid].active = TRUE;//open
+    }
+    else
+    {
+        if(ql_net_status_cb != NULL)
         {
             ql_net_status_cb(*net_data);
 
@@ -51,11 +56,16 @@
                 ql_net_status_cb(CONNECT_CONSUCCESS);
             }
         }
+
+        if(ql_net_ex_status_cb != NULL)
+        {
+            if(*net_data == 1)
+            {
+                ql_net_ex_status_cb(now_cid, ql_apn_info[now_cid].ip_type, CONNECT_CONSUCCESS, 0);
+            }
+        }
     }
-    else
-    {
-        //ql_netw_status_cb(-1);
-    }
+
 }
 
 int ql_wan_init(void)
@@ -68,6 +78,34 @@
             ql_info_handle_num++;
             inited = TRUE;
             mbtk_pdp_state_change_cb_reg(ql_info_handle, ql_wan_net_state_change_cb);
+
+            mbtk_apn_info_t apns[10] = {0};
+            int apn_num = MBTK_APN_CID_MAX;
+            int ret = mbtk_apn_get(ql_info_handle, &apn_num, apns);
+            if(ret != 0)
+            {
+                LOGD("mbtk_apn_get ret = %d",ret);
+            }
+            else
+            {
+                int i;
+                int profile_idx;
+                for(i=0;i<MBTK_APN_CID_MAX;i++)
+                {
+                    if(apns[i].cid > 0 && apns[i].cid <= MBTK_APN_CID_MAX)
+                    {
+                        profile_idx = apns[i].cid;
+                        if(apns[i].ip_type == MBTK_IP_TYPE_IPV4V6) // IPV4V6
+                            ql_apn_info[profile_idx].ip_type = 0;
+                        else if(apns[i].ip_type == MBTK_IP_TYPE_IP) // IPV4
+                            ql_apn_info[profile_idx].ip_type = 1;
+                        else if(apns[i].ip_type == MBTK_IP_TYPE_IPV6) // IPV6
+                            ql_apn_info[profile_idx].ip_type = 2;
+                        else
+                            ql_apn_info[profile_idx].ip_type = 0;
+                    }
+                }
+            }
             return 0;
         } else {
             LOGE("mbtk_info_handle_get() fail.");
@@ -138,6 +176,8 @@
     }
 
     ql_net_ex_status_cb = nw_cb;
+    ql_net_status_cb = NULL;
+    now_cid = profile_idx;
     if(profile_idx < MBTK_APN_CID_MIN || profile_idx > MBTK_APN_CID_MAX)
     {
         LOGD("ql_wan_start_ex() cid out of range.");
@@ -217,6 +257,7 @@
     }
 
     ql_net_status_cb = nw_cb;
+    ql_net_ex_status_cb = NULL;
     if(profile_idx < MBTK_APN_CID_MIN || profile_idx > MBTK_APN_CID_MAX)
     {
         ql_net_status_cb(PDP_ERROR_UNSPECIFIED);