[Feature][API-860][Data]Try to fix Data 8004 problem
Change-Id: Ifd12878a04cd994fb5a6d7eb9bbbac262b90d8e7
diff --git a/lib/liblynq-data/lynq_data.cpp b/lib/liblynq-data/lynq_data.cpp
index 6772e2d..7fac4a6 100755
--- a/lib/liblynq-data/lynq_data.cpp
+++ b/lib/liblynq-data/lynq_data.cpp
@@ -74,6 +74,8 @@
static int data_waiting_status = 0;
+static int data_invaild_error = 0;
+
/**g_lynq_data_init_flag
* @brief mark data initialization state
* 0:deinit status
@@ -102,9 +104,11 @@
int getLynqApnID(char apnType[])
{
int ret = 0;
+ int len = 0;
for(ret;ret<LYNQ_APN_CHANNEL_MAX;ret++)
{
- if(strcmp(lynq_apn_table[ret].apnType,apnType)==0)
+ len = strlen(lynq_apn_table[ret].apnType)<strlen(apnType) ? strlen(lynq_apn_table[ret].apnType):strlen(apnType);
+ if(strncmp(lynq_apn_table[ret].apnType,apnType,len)==0)
{
return ret;
}
@@ -145,6 +149,11 @@
}
int getUnusedElement()
{
+ if (lynq_apn_table == NULL)
+ {
+ LYERRLOG("get UnusedElemnt apn_table is null");
+ return -1;
+ }
for(int i=0;i < LYNQ_APN_CHANNEL_MAX; i++)
{
if(lynq_apn_table[i].hasUsed!=1)
@@ -152,6 +161,7 @@
return i;
}
}
+ LYERRLOG("None of get unused Element");
return -1;
}
int updateApn(char apnType[])
@@ -347,6 +357,24 @@
}
}
+int printf_apn_table()
+{
+ int ret = 0;
+ if (lynq_apn_table == NULL)
+ {
+ LYERRLOG("apn table is null");
+ return -1;
+ }
+ for(ret;ret<LYNQ_APN_CHANNEL_MAX;ret++)
+ {
+ LYINFLOG("[Typethree test info]apn=%s ;apntype=%s ;ifname=%s ;hasTimeout = %d ; hasUsed = %d", \
+ lynq_apn_table[ret].apn,lynq_apn_table[ret].apnType,lynq_apn_table[ret].ifaceName, \
+ lynq_apn_table[ret].hasTimeout,lynq_apn_table[ret].hasUsed);
+ }
+ return 0;
+}
+
+
void urc_msg_process(Parcel *p)
{
int len;
@@ -394,19 +422,23 @@
}
//sendSignalDataCallStateChange();
int apnId = getLynqApnID(apnType);
+ LYINFLOG("URC apnType:%s,ifaceName:%s,apn:%s pdnState:%d",apnType,ifaceName,apn,pdnState);
if(apnId >= 0)
{
if(lynq_apn_table[apnId].hasTimeout==1)
{
+ /*whether timeout?,real or not,*/
+ printf_apn_table();
LYERRLOG("apn:%s has time out,deacive this apn",lynq_apn_table[apnId].apn);
if (NULL != lynq_apn_table[apnId].apn && NULL != lynq_apn_table[apnId].apnType && strlen(lynq_apn_table[apnId].apn)>0)
{
LYERRLOG("deactive this time out APN");
lynq_deactive_data_call(&apnId);
}
- else
+ else
{
- LYERRLOG("this table is invalid");
+ /*if apn lose,update apn and deactive all apn*/
+ LYERRLOG("this table is invalid update APN table");
}
break;
}
@@ -415,7 +447,9 @@
/*To be completed*/
else
{
- LYERRLOG("invalid apnId");
+ data_invaild_error = 1;
+ printf_apn_table();
+ LYERRLOG("invalid apnId:%d",apnId);
break;
}
pthread_mutex_lock(&s_lynq_urc_vector_mutex);
@@ -587,6 +621,12 @@
client.paramLen = 0;
bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
+ lynq_data_call_id = updateApn("default");
+ if (lynq_data_call_id < 0)
+ {
+ LYERRLOG("update apn table fail error id = %d",lynq_data_call_id);
+ return -1;
+ }
pthread_mutex_lock(&g_lynq_data_sendto_mutex);
if(send_request(lynq_client_sockfd,&client)==-1)
{
@@ -598,7 +638,6 @@
pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
JumpHeader(p,&resp_type,&request,&slot_id,&error);
LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
- lynq_data_call_id = updateApn("default");
lynq_data_call = 1;
if(error==0)
{
@@ -607,6 +646,12 @@
error = LYNQ_E_TIME_OUT;
LYERRLOG("timeout:wait data Call state fail!!!");
lynq_apn_table[lynq_data_call_id].hasTimeout = 1;
+ if (data_invaild_error == 1)
+ {
+ data_invaild_error = 0;
+ LYERRLOG("urc apn info error!!!");
+ return 8085;
+ }
return error;
}
*handle = lynq_data_call_id;
@@ -725,6 +770,12 @@
bzero(client.param,LYNQ_REQUEST_PARAM_BUF);
sprintf(client.param,"%s %s %s %s %s %s %s",apn,apnType,argv[1],argv[2],argv[3],argv[4],argv[5]);
LYINFLOG("uToken=%d,request=%d,paralen=%d,param=%s",client.uToken,client.request,client.paramLen,client.param);
+ lynq_data_call_id = updateApn(apnType);
+ if (lynq_data_call_id < 0)
+ {
+ LYERRLOG("update apn table fail error id = %d",lynq_data_call_id);
+ return -1;
+ }
pthread_mutex_lock(&g_lynq_data_sendto_mutex);
if(send_request(lynq_client_sockfd,&client)==-1)
{
@@ -736,7 +787,6 @@
pthread_mutex_unlock(&g_lynq_data_sendto_mutex);
JumpHeader(p,&resp_type,&request,&slot_id,&error);
LYINFLOG("resp_type=%d,request=%d,slot_id=%d,error_code=%d",resp_type,request,slot_id,error);
- lynq_data_call_id = updateApn(apnType);
lynq_data_call = 1;
if(error==0)
{
@@ -745,6 +795,12 @@
error = LYNQ_E_TIME_OUT;
LYERRLOG("timeout:wait data Call state fail!!!");
lynq_apn_table[lynq_data_call_id].hasTimeout = 1;
+ if (data_invaild_error == 1)
+ {
+ data_invaild_error = 0;
+ LYERRLOG("urc apn info error!!!");
+ return 8085;
+ }
return error;
}
*handle = lynq_data_call_id;