[Bugfix][T106BUG-31] call lynq_query_registration_state to get voice state, Segmentation fault and   modify ril close response print

Change-Id: Iabc3cdd6b691f48fa56d4fe438b54f11aa221810
diff --git a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/ril.cpp b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/ril.cpp
index 6c1c84a..c23afae 100755
--- a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/ril.cpp
+++ b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/ril.cpp
@@ -200,13 +200,15 @@
     static char printBuf[PRINTBUF_SIZE];
     static char tempPrintBuf[PRINTBUF_SIZE];
     #define startRequest           sprintf(printBuf, "(")
-    #define closeRequest           sprintf(printBuf, "%s)", printBuf)
+    #define closeRequest           snprintf(tempPrintBuf, PRINTBUF_SIZE, "%s)", printBuf); \
+                                   snprintf(printBuf, PRINTBUF_SIZE, "%s", tempPrintBuf)
     #define printRequest(token, req) if(enable_syslog) {         \
         RLOGD("[%x]> %s %s", token, requestToString(req), printBuf);} else {\
         printf("[%x]> %s %s\n", token, requestToString(req), printBuf);}
 
     #define startResponse           sprintf(printBuf, "%s {", printBuf)
-    #define closeResponse           sprintf(printBuf, "%s}", printBuf)
+    #define closeResponse           snprintf(tempPrintBuf, PRINTBUF_SIZE, "%s}", printBuf); \
+                                    snprintf(printBuf, PRINTBUF_SIZE, "%s", tempPrintBuf)
     #define printResponse            if(enable_syslog) { \
                                     RLOGD("%s", printBuf); } else { \
                                     printf("%s\n", printBuf);}
@@ -366,6 +368,8 @@
 void printInputArgs(int argc, char** argv) ;
 void initRequestInfo(RequestInfo *pRI, int  request, int mode, RIL_SOCKET_ID soc_id);
 const int waitResponse(int token);
+void sendRequestToMd(int request, int id);
+
 
 #ifdef RIL_SHLIB
 #if defined(ANDROID_MULTI_SIM)
@@ -3796,6 +3800,8 @@
 
     s_registerCalled = 1;
 
+    sendRequestToMd(RIL_REQUEST_RADIO_POWER, get_default_sim_all_except_data());
+
     pthread_mutex_lock(&s_InitMutex);
     if(utils::is_support_dsds()) {
         while (s_isConnected[0] == 0 || s_isConnected[1] == 0) {
@@ -5568,6 +5574,11 @@
             getRadioCapability(1, NULL, (RIL_SOCKET_ID) ((id)), info);
             break;
         }
+        case RIL_REQUEST_RADIO_POWER:
+        {        
+            char* tmp[2] = {"RIL_REQUEST_RADIO_POWER", "1"};
+            setRadioPower(2,tmp, (RIL_SOCKET_ID) (id), info);
+        }
         default:
             RLOGE("don't support  %d in init", id);
             if(info) {
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-network/lynq_network.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-network/lynq_network.cpp
index b9d3388..d3d4d55 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-network/lynq_network.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-network/lynq_network.cpp
@@ -60,7 +60,7 @@
     int ret;

 

     init_network_timer_all();

-	

+    

     ret = lynq_start_all_urc_socket_thread();

     if(ret != 0)

     {

@@ -509,9 +509,9 @@
     int num,i;

     char *resp[LYNQ_RESP_STRING_MAX_NUM]={0};       

     if(!strcmp(str,"VOICE"))

-    {

-        p->readInt32(&num);

-        if(num == 15)

+    {        

+        p->readInt32(&num);        

+        if(num ==15)

         {

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

             {

@@ -1002,13 +1002,13 @@
     {

         LYERRLOG("%s call lynq_send_common_request failure, ret is %d",__func__,ret);

         return ret;  

-    }            

+    }                

     

     int sum = 0;

     int none = 0;

 

     p->readInt32(&solSigStren->rssi);

-    if((solSigStren->rssi<=31)&&(solSigStren->rssi>=0))

+    if((solSigStren->rssi > 0)&&(solSigStren->rssi < 99))

     {

         solSigStren->gw_sig_valid = 1;

     }else{

@@ -1031,7 +1031,7 @@
     p->readInt32(&solSigStren->rssnr);

 

     LYINFLOG("LTE_signalstrength:%d",solSigStren->lte_signalstrength);

-    if((solSigStren->lte_signalstrength<=31)&&(solSigStren->lte_signalstrength>=0))

+    if((solSigStren->lte_signalstrength > 0)&&(solSigStren->lte_signalstrength< 99))

     {

         solSigStren->lte_sig_valid = 1;

     }else{

@@ -1049,7 +1049,7 @@
     p->readInt32(&solSigStren->rscp);

     p->readInt32(&solSigStren->ecno);

     LYINFLOG("WCDMA_signalstrength:%d",solSigStren->wcdma_signalstrength);

-    if((solSigStren->wcdma_signalstrength<=31)&&(solSigStren->wcdma_signalstrength>=0))

+    if((solSigStren->wcdma_signalstrength > 0)&&(solSigStren->wcdma_signalstrength < 99))

     {

         solSigStren->wcdma_sig_valid = 1;

     }else{

@@ -1062,13 +1062,12 @@
     p->readInt32(&solSigStren->csiRsrp);

     p->readInt32(&solSigStren->csiRsrq);

     p->readInt32(&solSigStren->csiSinr);

-    sum = (solSigStren->ssRsrp) + (solSigStren->ssRsrq) + (solSigStren->ssSinr) + (solSigStren->csiRsrp)+\

-    (solSigStren->csiRsrq) + (solSigStren->csiSinr);

-    if(sum != 0)

+    if(solSigStren->ssRsrp > 0 &&  solSigStren->ssRsrp < 255)

     {

         solSigStren->nr_sig_valid = 1;

     }else{

         LYERRLOG("None of NR signal info");

+        solSigStren->nr_sig_valid = 0;

     }        

 

     LYINFLOG("%s suc",__func__);