fix cell reg bug

Change-Id: I9a1de3d8eb9723bc68598614473c8e740b49309a
diff --git a/mbtk/mbtk_rild/src/mbtk_info_server.c b/mbtk/mbtk_rild/src/mbtk_info_server.c
index 6c1ac75..5c1469a 100755
--- a/mbtk/mbtk_rild/src/mbtk_info_server.c
+++ b/mbtk/mbtk_rild/src/mbtk_info_server.c
@@ -3113,6 +3113,7 @@
         err = at_tok_nextstr(&line, &tmp_str); // lac
         if (err < 0)
         {
+            LOGE("[%s] at_tok_nextstr get lac fail.[%d]", __func__, err);
             goto exit;
         }
         reg->lac = strtol(tmp_str, NULL, 16);
@@ -3120,6 +3121,7 @@
         err = at_tok_nextstr(&line, &tmp_str); // ci
         if (err < 0)
         {
+            LOGE("[%s] at_tok_nextstr get ci fail.[%d]", __func__, err);
             goto exit;
         }
         reg->ci = strtol(tmp_str, NULL, 16);
@@ -3127,59 +3129,116 @@
         err = at_tok_nextint(&line, &tmp_int);// AcT
         if (err < 0)
         {
-            goto exit;
+            LOGE("[%s] at_tok_nextstr get act fail.[%d]", __func__, err);
+            //goto exit;
         }
-        reg->type = (uint8)tmp_int;
+        else
+        {
+            reg->type = (uint8)tmp_int;
+        }
     }
     at_response_free(response);
 
-    err = at_send_command_multiline("AT+CEREG?", "+CEREG:", &response);
-    if (err < 0 || response->success == 0 || !response->p_intermediates){
-        *cme_err = at_get_cme_error(response);
-        goto exit;
-    }
+    if(reg->type == MBTK_RADIO_TECH_E_UTRAN)
+    {
+        err = at_send_command_multiline("AT+CEREG?", "+CEREG:", &response);
+        if (err < 0 || response->success == 0 || !response->p_intermediates){
+            *cme_err = at_get_cme_error(response);
+            goto exit;
+        }
 
-    line = response->p_intermediates->line;
-    err = at_tok_start(&line);
-    if (err < 0)
-    {
-        goto exit;
-    }
-    err = at_tok_nextint(&line, &tmp_int); // n
-    if (err < 0)
-    {
-        goto exit;
-    }
-    err = at_tok_nextint(&line, &tmp_int);// stat
-    if (err < 0)
-    {
-        goto exit;
-    }
-    reg->data_state = (uint8)tmp_int;
-
-    if(reg->lac == 0 && at_tok_hasmore(&line)) {
-        err = at_tok_nextstr(&line, &tmp_str); // lac
+        line = response->p_intermediates->line;
+        err = at_tok_start(&line);
         if (err < 0)
         {
             goto exit;
         }
-        reg->lac = strtol(tmp_str, NULL, 16);
-
-        err = at_tok_nextstr(&line, &tmp_str); // ci
+        err = at_tok_nextint(&line, &tmp_int); // n
         if (err < 0)
         {
             goto exit;
         }
-        reg->ci = strtol(tmp_str, NULL, 16);
-
-        err = at_tok_nextint(&line, &tmp_int);// AcT
+        err = at_tok_nextint(&line, &tmp_int);// stat
         if (err < 0)
         {
             goto exit;
         }
-        reg->type = (uint8)tmp_int;
+        reg->data_state = (uint8)tmp_int;
+
+        if(reg->lac == 0 && at_tok_hasmore(&line)) {
+            err = at_tok_nextstr(&line, &tmp_str); // lac
+            if (err < 0)
+            {
+                goto exit;
+            }
+            reg->lac = strtol(tmp_str, NULL, 16);
+
+            err = at_tok_nextstr(&line, &tmp_str); // ci
+            if (err < 0)
+            {
+                goto exit;
+            }
+            reg->ci = strtol(tmp_str, NULL, 16);
+
+            err = at_tok_nextint(&line, &tmp_int);// AcT
+            if (err < 0)
+            {
+                goto exit;
+            }
+            reg->type = (uint8)tmp_int;
+        }
+        at_response_free(response);
     }
-    at_response_free(response);
+    else
+    {
+        err = at_send_command_multiline("AT+CGREG?", "+CGREG:", &response);
+        if (err < 0 || response->success == 0 || !response->p_intermediates){
+            *cme_err = at_get_cme_error(response);
+            goto exit;
+        }
+
+        line = response->p_intermediates->line;
+        err = at_tok_start(&line);
+        if (err < 0)
+        {
+            goto exit;
+        }
+        err = at_tok_nextint(&line, &tmp_int); // n
+        if (err < 0)
+        {
+            goto exit;
+        }
+        err = at_tok_nextint(&line, &tmp_int);// stat
+        if (err < 0)
+        {
+            goto exit;
+        }
+        reg->data_state = (uint8)tmp_int;
+
+        if(reg->lac == 0 && at_tok_hasmore(&line)) {
+            err = at_tok_nextstr(&line, &tmp_str); // lac
+            if (err < 0)
+            {
+                goto exit;
+            }
+            reg->lac = strtol(tmp_str, NULL, 16);
+
+            err = at_tok_nextstr(&line, &tmp_str); // ci
+            if (err < 0)
+            {
+                goto exit;
+            }
+            reg->ci = strtol(tmp_str, NULL, 16);
+
+            err = at_tok_nextint(&line, &tmp_int);// AcT
+            if (err < 0)
+            {
+                goto exit;
+            }
+            reg->type = (uint8)tmp_int;
+        }
+        at_response_free(response);
+    }
 
     err = at_send_command_multiline("AT+CIREG?", "+CIREG:", &response);
     if (err < 0 || response->success == 0 || !response->p_intermediates){
@@ -5122,7 +5181,9 @@
                                 pack_rsp_send(cli_info->fd, MBTK_INFO_ID_NET_CELL_RSP, data, sizeof(uint8) + sizeof(mbtk_cell_info_t) * cell_info.cell_num);
                                 free(data);
                             }
-                        } else {
+                        }else if(cell_info.cell_num == 0) {
+                            pack_rsp_send(cli_info->fd, MBTK_INFO_ID_NET_CELL_RSP, &cell_info.type, sizeof(uint8));
+                        }else {
                             err = MBTK_INFO_ERR_UNKNOWN;
                             LOG("Get net cell fail.");
                         }