[Feature][T106ZXW-193][network]  add interface to get serve cell info

       Affected branch: unknown
       Affected module: unknown
       Is it affected on both ZXIC and MTK: ZXIC and MTK
       Self-test: Yes
       Doc Update: No

Change-Id: Id8562e4bee376986a41bf6c3b15a2e36e27da89e
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-network/lynq_qser_network.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-qser-network/lynq_qser_network.cpp
index 2628d27..d75c23b 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-network/lynq_qser_network.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-network/lynq_qser_network.cpp
@@ -488,6 +488,61 @@
     return state;  
 }
 
+int qser_romaing_state_qurey(int regState)
+{
+    if (regState == 5)
+    {
+        return  E_QSER_NW_ROAM_STATE_ON;   
+    }
+    return E_QSER_NW_ROAM_STATE_OFF;
+}
+
+int fill_registration_details_3gpp(QSER_NW_3GPP_REG_INFO_T  *registration_details_3gpp,  int regState, int netType, int serve_cell_info[MAX_CELLINFO_ITEM_NUMBER])
+{
+
+    if(serve_cell_info[1]>=0 && serve_cell_info[1] <= 999 && serve_cell_info[2]>=0 && serve_cell_info[2] <= 999 )
+    {
+        registration_details_3gpp->tech_domain = E_QSER_NW_TECH_DOMAIN_3GPP;
+        registration_details_3gpp->radio_tech = qser_radio_tech_qurey(netType);
+        registration_details_3gpp->roaming = qser_romaing_state_qurey(regState);
+        registration_details_3gpp->forbidden=0;
+
+        sprintf(registration_details_3gpp->mcc,"%d",serve_cell_info[1]);
+        sprintf(registration_details_3gpp->mnc,"%d",serve_cell_info[2]);  
+
+        if(serve_cell_info[0]<=LYNQ_CELL_INFO_TYPE_WCDMA)
+        {
+            registration_details_3gpp->lac=serve_cell_info[3];
+            registration_details_3gpp->tac=0xffff;
+        }
+        else
+        {
+            registration_details_3gpp->lac=0xffff;
+            registration_details_3gpp->tac=serve_cell_info[3];
+        }
+        
+        registration_details_3gpp->cid=serve_cell_info[4]; 
+        
+ 
+        if(serve_cell_info[0]==LYNQ_CELL_INFO_TYPE_WCDMA)
+        {
+             registration_details_3gpp->psc=serve_cell_info[5];
+        }
+        else
+        {
+             registration_details_3gpp->psc=0xffff;
+        }            
+        
+        return RESULT_OK;
+    }
+    LYERRLOG("mnc mcc error %d %d",serve_cell_info[1],serve_cell_info[2]);
+    return RESULT_ERROR;
+}
+
+int is_have_serve_cell(int regState)
+{
+    return (regState==E_QSER_NW_SERVICE_LIMITED || regState==E_QSER_NW_SERVICE_FULL);
+}
 
 int qser_nw_get_reg_status(nw_client_handle_type h_nw,QSER_NW_REG_STATUS_INFO_T *pt_info)
 {
@@ -504,6 +559,7 @@
     }    
     
     int ret = 0;
+    int ret_serve_cell=0;
     int regState = 0;
     int imsRegState = 0;
     char CID[128]={0};
@@ -511,53 +567,68 @@
     int netType = 0;
     int radioTechFam = 0;
     int netreject = 0;
-    pt_info->voice_registration_valid = 1;
-    ret = lynq_query_registration_state("VOICE",&regState,&imsRegState,LAC,CID,&netType,&radioTechFam,&netreject);
-    if(ret == 0)
-    {
-        pt_info->voice_registration_valid = 1;
-        pt_info->voice_registration.tech_domain = E_QSER_NW_TECH_DOMAIN_NONE;
-        pt_info->voice_registration.radio_tech = qser_radio_tech_qurey(netType);
-        if (regState == 5)
-        {
-            pt_info->voice_registration.roaming = E_QSER_NW_ROAM_STATE_ON;
-        }
-        else
-        {
-            pt_info->voice_registration.roaming = E_QSER_NW_ROAM_STATE_OFF;
-        }
-        pt_info->voice_registration.registration_state = switch_nw_regstate(regState);
-    }
-    else
-    {
-        pt_info->voice_registration_valid = 0;
-        LYERRLOG("get voice regstate fail");
-    }
-    ret = lynq_query_registration_state("DATA",&regState,&imsRegState,LAC,CID,&netType,&radioTechFam,&netreject);
-    if(ret == 0)
-    {
-        pt_info->data_registration_valid = 1;
-        pt_info->data_registration.tech_domain = E_QSER_NW_TECH_DOMAIN_NONE;
-        pt_info->data_registration.radio_tech = qser_radio_tech_qurey(netType);
-        if (regState == 5)
-        {
-            pt_info->data_registration.roaming = E_QSER_NW_ROAM_STATE_ON;
-        }
-        else
-        {
-            pt_info->data_registration.roaming = E_QSER_NW_ROAM_STATE_OFF;
-        }
-        pt_info->data_registration.registration_state = switch_nw_regstate(regState);
-    }
-    else
-    {
-        pt_info->data_registration_valid = 0;
-        LYERRLOG("get data regstate fail");
-    }
+    int serve_cell_info[MAX_CELLINFO_ITEM_NUMBER];
+    int valid_number;
+    int query_servce_cell=false;
+
+    pt_info->voice_registration_valid = 0;
+    pt_info->data_registration_valid = 0;
     pt_info->voice_registration_details_3gpp_valid = 0;
     pt_info->data_registration_details_3gpp_valid = 0;
     pt_info->voice_registration_details_3gpp2_valid = 0;
     pt_info->data_registration_details_3gpp2_valid = 0;
+        
+
+    ret = lynq_query_registration_state("VOICE",&regState,&imsRegState,LAC,CID,&netType,&radioTechFam,&netreject);
+    if(ret!=0)
+    {
+         LYERRLOG("get voice regstate fail");
+    }
+    else {    
+        pt_info->voice_registration_valid = 1;
+        pt_info->voice_registration.tech_domain = E_QSER_NW_TECH_DOMAIN_NONE;
+        pt_info->voice_registration.radio_tech = qser_radio_tech_qurey(netType);       
+        pt_info->voice_registration.roaming = qser_romaing_state_qurey(regState);       
+        pt_info->voice_registration.registration_state = switch_nw_regstate(regState);
+        
+        if(is_have_serve_cell(pt_info->voice_registration.registration_state))
+        {  
+            ret_serve_cell=lynq_query_serve_cell_info(serve_cell_info, &valid_number);                   
+            query_servce_cell=true;
+            if(ret_serve_cell== RESULT_OK && fill_registration_details_3gpp(&pt_info->voice_registration_details_3gpp,regState,netType,serve_cell_info) == RESULT_OK)
+            {
+                pt_info->voice_registration_details_3gpp_valid=1;                   
+            }    
+        }             
+    }
+    
+    ret = lynq_query_registration_state("DATA",&regState,&imsRegState,LAC,CID,&netType,&radioTechFam,&netreject);
+    if(ret!=0)
+    {
+         LYERRLOG("get data regstate fail");
+    }
+    else
+    {      
+        pt_info->data_registration_valid = 1;
+        pt_info->data_registration.tech_domain = E_QSER_NW_TECH_DOMAIN_NONE;
+        pt_info->data_registration.radio_tech = qser_radio_tech_qurey(netType);      
+        pt_info->data_registration.roaming = qser_romaing_state_qurey(regState);         
+        pt_info->data_registration.registration_state = switch_nw_regstate(regState);
+
+        if(is_have_serve_cell(pt_info->data_registration.registration_state))
+        {  
+            if(!query_servce_cell)
+            {
+                ret_serve_cell=lynq_query_serve_cell_info(serve_cell_info, &valid_number);                   
+            }
+                         
+            if(ret_serve_cell== RESULT_OK && fill_registration_details_3gpp(&pt_info->data_registration_details_3gpp,regState,netType,serve_cell_info) == RESULT_OK)
+            {
+                pt_info->data_registration_details_3gpp_valid=1;   
+            }    
+        }         
+    }    
+    
     return RESULT_OK;
 }