[Feature][DATA][T8TSK-211]support the handle value of setup_data_call set to a valid value after timeout 2
Change-Id: I035bd34033785b3fc6e28cf6b9231b470ebf54d1
(cherry picked from commit 8dd6fc61cbf404e58fcc60966758664162f62f76)
diff --git a/src/lynq/framework/lynq-ril-service/src/data/data_gdbus.cpp b/src/lynq/framework/lynq-ril-service/src/data/data_gdbus.cpp
index 3424c22..e73020b 100755
--- a/src/lynq/framework/lynq-ril-service/src/data/data_gdbus.cpp
+++ b/src/lynq/framework/lynq-ril-service/src/data/data_gdbus.cpp
@@ -268,6 +268,41 @@
{
apnHasCreated = FALSE;
RLOGD("[cid < 0] apn_count:%d\n",apn_count);
+ if(urc_response->pdnState==PDN_DISCONNECTED)//if user disable data call,the pdn state wiil change to disconnected.
+ {
+ for(int i = 0;i < LYNQ_APN_CHANNEL_MAX;i++)
+ {
+ #if DEBUG
+ printf("line %d [PDN_DISCONNECTED]apn_table[%d],apntype:%s,apnstatus:%d,,,urc_response->apnName:%s\n",__LINE__, i,apn_table[i].apntype,apn_table[i].apnstatus,urc_response->apnType);
+ #endif
+ RLOGD("[PDN_DISCONNECTED]apn_table[%d],apntype:%s,apnstatus:%d,,,urc_response->apnName:%s\n",i,apn_table[i].apntype,apn_table[i].apnstatus,urc_response->apnType);
+ if((strcmp(apn_table[i].apntype,urc_response->apnType)==0)&&(apn_table[i].apnstatus==0))
+ {
+ bzero(apn_table[i].apn,LYNQ_APN_LEN_MAX);
+ bzero(apn_table[i].apntype,LYNQ_APNTPYE_LEN_MAX);
+ apn_table[i].used = 0;
+ apn_table[i].netId = 0;
+ apn_table[i].pdpstate = PDN_DISCONNECTED;
+ apn_count--;
+ p.writeInt32 (1);
+ p.writeInt32 (LYNQ_URC_DATA_CALL_STATUS_IND);
+ p.writeInt32 (0);//temporary plan
+ p.writeInt32(PDN_DISCONNECTED);
+ writeStringToParcel(p,urc_response->apnName);
+ writeStringToParcel(p,urc_response->apnType);
+ writeStringToParcel(p,urc_response->ifname);
+ android::LYNQ_RIL_urcBroadcast(p,LYNQ_URC_DATA_CALL_STATUS_IND);
+ RLOGD("removed apn:%s,apntype:%s",apn_table[i].apn,apn_table[i].apntype);
+ break;
+ }
+ }
+ for(int i = 0;i < LYNQ_APN_CHANNEL_MAX;i++)
+ {
+ RLOGD("for apn_table[%d].apn:%s,apntype:%s,used:%d,apnstatus:%d\n",i,apn_table[i].apn,
+ apn_table[i].apntype,apn_table[i].used,apn_table[i].apnstatus);
+ }
+ return 0;
+ }
if(apn_count>0)
{
int i = 0;
diff --git a/src/lynq/lib/liblynq-data/lynq_data.cpp b/src/lynq/lib/liblynq-data/lynq_data.cpp
index 10795bf..dfee4e0 100755
--- a/src/lynq/lib/liblynq-data/lynq_data.cpp
+++ b/src/lynq/lib/liblynq-data/lynq_data.cpp
@@ -98,6 +98,8 @@
char ifaceName[LYNQ_IFACE_NAME_MAX_LEN];
int hasUsed;
int hasTimeout;
+ int status;
+ char statusApnType[LYNQ_APN_TYPE_MAX_LEN];
}lynq_apn_t;
lynq_apn_t lynq_apn_table[LYNQ_APN_CHANNEL_MAX] = {};
lynq_data_call_response_v11_t lynq_data_call_lists[LYNQ_APN_CHANNEL_MAX] = {};
@@ -109,7 +111,7 @@
int len = 0;
for(ret;ret<LYNQ_APN_CHANNEL_MAX;ret++)
{
- len = strlen(lynq_apn_table[ret].apnType)<strlen(apnType) ? strlen(lynq_apn_table[ret].apnType):strlen(apnType);
+ len = strlen(apnType);
LYINFLOG("apn_table[%d].apnType:%s,input apntype:%s,len:%d",ret,lynq_apn_table[ret].apnType,apnType,len);
if(strncmp(lynq_apn_table[ret].apnType,apnType,len)==0)
{
@@ -119,6 +121,22 @@
return -1;
}
+int getDeactApnID(char apnType[])
+{
+ int ret = 0;
+ int len = 0;
+ for(ret;ret<LYNQ_APN_CHANNEL_MAX;ret++)
+ {
+ len = strlen(apnType);
+ LYINFLOG("apn_table[%d].apnType:%s,input apntype:%s,len:%d",ret,lynq_apn_table[ret].apnType,apnType,len);
+ if(strncmp(lynq_apn_table[ret].statusApnType,apnType,len)==0)
+ {
+ return ret;
+ }
+ }
+ return -1;
+}
+
void updateApnTable(lynq_apn_t *apn_table,char apn[],char apntype[],char ifaceName[])
{
LYDBGLOG("[updateApnTable] apn:%s,apntype:%s,ifaceName:%s",apn,apntype,ifaceName);
@@ -137,7 +155,7 @@
void cleanOnceApnTable(int apnId)
{
- LYDBGLOG("apn id:%d",apnId);
+ LYDBGLOG("%s:apn id:%d",__FUNCTION__,apnId);
if((apnId < 0) || (apnId > LYNQ_APN_CHANNEL_MAX-1))
{
LYERRLOG("apn id is invalid!!!");
@@ -145,18 +163,44 @@
}
lynq_apn_table[apnId].hasTimeout = 0;
lynq_apn_table[apnId].hasUsed = 0;
+ memcpy(lynq_apn_table[apnId].statusApnType,lynq_apn_table[apnId].apnType,strlen(lynq_apn_table[apnId].apnType));
bzero(lynq_apn_table[apnId].apn,LYNQ_APN_MAX_LEN);
- //bzero(lynq_apn_table[apnId].apnType,LYNQ_APN_TYPE_MAX_LEN);
+ bzero(lynq_apn_table[apnId].apnType,LYNQ_APN_TYPE_MAX_LEN);
bzero(lynq_apn_table[apnId].ifaceName,LYNQ_IFACE_NAME_MAX_LEN);
+ lynq_apn_table[apnId].status = 32;
return;
}
+void cleanDeactApn(int apnId)
+{
+ LYDBGLOG("%s:apn id:%d",__FUNCTION__,apnId);
+ if((apnId < 0) || (apnId > LYNQ_APN_CHANNEL_MAX-1))
+ {
+ LYERRLOG("apn id is invalid!!!");
+ return;
+ }
+ lynq_apn_table[apnId].status = 0;
+ bzero(lynq_apn_table[apnId].statusApnType,LYNQ_APN_TYPE_MAX_LEN);
+}
+
+void updateDeactApn(int apnId,int pdnState)
+{
+ LYDBGLOG("%s:apn id:%d",__FUNCTION__,apnId);
+ if((apnId < 0) || (apnId > LYNQ_APN_CHANNEL_MAX-1))
+ {
+ LYERRLOG("apn id is invalid!!!");
+ return;
+ }
+ lynq_apn_table[apnId].status = pdnState;
+}
+
+
int getUnusedElement()
{
- if (lynq_apn_table == NULL)
- {
- LYERRLOG("get UnusedElemnt apn_table is null");
- return -1;
- }
+ 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)
@@ -374,9 +418,9 @@
}
for(ret;ret<LYNQ_APN_CHANNEL_MAX;ret++)
{
- LYINFLOG("[%s][%d] apn=%s ;apntype=%s ;ifname=%s ;hasTimeout = %d ; hasUsed = %d",__FUNCTION__,ret, \
+ LYINFLOG("[%s][%d] apn=%s ;apntype=%s ;ifname=%s ;hasTimeout = %d ; hasUsed = %d,status = %d,statusDeactApn = %s",__FUNCTION__,ret, \
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);
+ lynq_apn_table[ret].hasTimeout,lynq_apn_table[ret].hasUsed,lynq_apn_table[ret].status,lynq_apn_table[ret].statusApnType);
}
return 0;
}
@@ -394,6 +438,7 @@
int urcid;
int slot_id;
int check_count = 0;
+ static int apnId=-1;
int pdnState = 0;
char apn[LYNQ_APN_MAX_LEN];
@@ -437,10 +482,10 @@
}
free(urc_msg);
//sendSignalDataCallStateChange();
- int apnId = getLynqApnID(apnType);
- LYINFLOG("URC apnType:%s,ifaceName:%s,apn:%s pdnState:%d,handle:%d",apnType,ifaceName,apn,pdnState,apnId);
+ apnId = getLynqApnID(apnType);
if(apnId >= 0)
{
+ LYINFLOG("URC apnType:%s,ifaceName:%s,apn:%s pdnState:%d,handle:%d",apnType,ifaceName,apn,pdnState,apnId);
if(lynq_apn_table[apnId].hasTimeout==1)
{
/*whether timeout?,real or not,*/
@@ -465,9 +510,16 @@
else
{
data_invaild_error = 1;
- printf_apn_table();
- LYERRLOG("invalid apnId:%d",apnId);
- break;
+ printf_apn_table_debug(__FUNCTION__,__LINE__);
+ apnId = getDeactApnID(apnType);
+ if(apnId < 0)
+ {
+ LYERRLOG("[%d]invalid apnId:%d",__LINE__,apnId);
+ break;
+ }
+ LYINFLOG("URC apnType:%s,ifaceName:%s,apn:%s pdnState:%d,handle:%d",apnType,ifaceName,apn,pdnState,apnId);
+ updateDeactApn(apnId,pdnState);
+ printf_apn_table_debug(__FUNCTION__,__LINE__);
}
pthread_mutex_lock(&s_lynq_urc_vector_mutex);
s_data_urc_wait_list.push_back(apnId);
@@ -506,16 +558,34 @@
}
free(urc_msg);
LYDBGLOG("[data thread_urc_recv] apntype:%s",apnType);
- int apnId = getLynqApnID(apnType);
- LYINFLOG("URC apnType:%s,ifaceName:%s,apn:%s pdnState:%d,handle:%d",apnType,ifaceName,apn,pdnState,apnId);
+ apnId = getLynqApnID(apnType);
if(apnId >= 0)
{
+ LYINFLOG("URC apnType:%s,ifaceName:%s,apn:%s pdnState:%d,handle:%d",apnType,ifaceName,apn,pdnState,apnId);
+ lynq_data_call_change_id = apnId;
+ //bzero(lynq_apn_table[apnId].apnType,LYNQ_APN_TYPE_MAX_LEN);//async clean
+ pthread_mutex_lock(&s_lynq_urc_vector_mutex);
+ s_data_urc_wait_list.push_back(apnId);
+ pthread_mutex_unlock(&s_lynq_urc_vector_mutex);
+ sendSignalPdnChange();
+ }
+ else
+ {
+ apnId = getDeactApnID(apnType);
+ if(apnId < 0)
+ {
+ LYERRLOG("[%d]invalid apnId:%d",__LINE__,apnId);
+ break;
+ }
+ LYINFLOG("URC apnType:%s,ifaceName:%s,apn:%s pdnState:%d,handle:%d",apnType,ifaceName,apn,pdnState,apnId);
+ cleanDeactApn(apnId);
lynq_data_call_change_id = apnId;
bzero(lynq_apn_table[apnId].apnType,LYNQ_APN_TYPE_MAX_LEN);//async clean
pthread_mutex_lock(&s_lynq_urc_vector_mutex);
s_data_urc_wait_list.push_back(apnId);
pthread_mutex_unlock(&s_lynq_urc_vector_mutex);
sendSignalPdnChange();
+ printf_apn_table_debug(__FUNCTION__,__LINE__);
}
LYDBGLOG("data call state:%d",lynq_data_call);
if(lynq_data_call==1)
@@ -1093,7 +1163,7 @@
s_data_urc_wait_list.erase(iter);
pthread_mutex_unlock(&s_lynq_urc_vector_mutex);
- LYINFLOG("lynq data call id:%d",*handle);
+ LYINFLOG("lynq_wait_data_call_state_change handle:%d",*handle);
return 0;
}
/*Warren add for T800 platform 2021/11/19 end*/