Merge "[Bugfix][bug-view-1134] Modify the qser_get/set_initial_apnname interface timeout to 5 seconds"
diff --git a/cap/zx297520v3/src/lynq/framework/lynq-sdk-ready/lynq_timer.cpp b/cap/zx297520v3/src/lynq/framework/lynq-sdk-ready/lynq_timer.cpp
index d22a736..31a02a7 100755
--- a/cap/zx297520v3/src/lynq/framework/lynq-sdk-ready/lynq_timer.cpp
+++ b/cap/zx297520v3/src/lynq/framework/lynq-sdk-ready/lynq_timer.cpp
@@ -24,6 +24,7 @@
 

 

 #define LOG_UCI_FILE "lynq_uci"

+#define LOG_UCI_RO_FILE "lynq_uci_ro"

 #define LOG_UCI_MODULE "debug_mode"

 

 using ::android::Parcel;

@@ -38,6 +39,8 @@
 }lynq_client_t;

 

 int num = 0;

+int nf_conntrack_max = 0;

+int conntrack_flag = 0;

 

 int max_num;

 static int get_md_sta(void)

@@ -124,6 +127,37 @@
     return 0;

 }

 

+

+static int t106_get_current_conntrack()

+{

+    FILE *fp = fopen("/proc/sys/net/netfilter/nf_conntrack_count", "r");

+    int count = -1;

+    

+    if(fp)

+    {

+        fscanf(fp, "%d", &count);

+        ALOGD("nf_conntrack_count is %d",count);

+        fclose(fp);

+    }

+    

+    return count;

+}

+

+int get_conntrack_count(void)

+{

+    int current_num = 0;

+

+    current_num = t106_get_current_conntrack();

+    if(current_num == nf_conntrack_max)

+    {

+        return 1;

+    }

+    else

+    {

+        return 0;

+    }

+}

+

 /**

  * @brief 30s request imei

  * 

@@ -286,8 +320,30 @@
         /*judge the res_error*/

         if(!res_error)

         {

-            lynq_set_section("sdk_ready", "0");

-            RLOGE("sdk_ready = 0\n");

+            if(conntrack_flag)

+            {

+                ret = get_conntrack_count();

+                if(ret == 1)

+                {

+                    ALOGD("print nf_conntrack in var/log");

+                    system("date > /var/log/conntrack.txt");

+                    system("cat /proc/net/nf_conntrack >> /var/log/conntrack.txt");

+                    lynq_set_section("sdk_ready", "5");

+                }

+                

+                else if(ret == 0)

+                {

+                    lynq_set_section("sdk_ready", "0");

+                    RLOGE("sdk_ready = 0\n");

+                }

+                

+            }

+            

+            else

+            {

+                lynq_set_section("sdk_ready", "0");

+                RLOGE("sdk_ready = 0\n");

+            }

         }

         else

         {

@@ -623,15 +679,40 @@
 

 

 

+int t106_get_conntrack_max(void)

+{

+    //only when progress startup to get nf_conntrack_max

+    FILE *fp = fopen("/proc/sys/net/netfilter/nf_conntrack_max", "r");

+    

+    if(fp)

+    {

+        fscanf(fp, "%d", &nf_conntrack_max);

+        ALOGD("nf_conntrack_max = %d",nf_conntrack_max);

+        fclose(fp);

+        return 0;

+    } 

+    

+    else 

+    {

+        return -1;

+    }

+

+}

+

+

+

+

+

 void start_timer_request(void)

 {

-    pthread_t thid,thid_1,thid_2;

+    pthread_t thid,thid_1,thid_2,thid_3;

     pthread_attr_t a;

     pthread_attr_init(&a);

     pthread_attr_setdetachstate(&a, PTHREAD_CREATE_DETACHED);

 

     char tmp[20];

     int debug_mode;

+    int conntrack_mode = 0;

     int ret;

 

     ALOGD("start lynq-sdk-ready\n");

@@ -649,6 +730,25 @@
     }

     pthread_detach(thid_2);

 */

+

+    //read uci

+    ret = lynq_get_value(LOG_UCI_RO_FILE, LOG_UCI_MODULE, "conntrack_mode", tmp);

+    ALOGD("ret = %d, tmp is %s\n",ret,tmp);

+    conntrack_mode = atoi(tmp);

+    

+    if(conntrack_mode == 1)

+    {

+        if(t106_get_conntrack_max() < 0)

+        {

+            ALOGD("can not get conntrack_max");

+        }

+        else

+        {

+            conntrack_flag = 1;

+        }

+    }

+

+

     ret = pthread_create(&thid, &a, timer_request_imei, NULL);

     if(ret != 0){

         ALOGD("pthread_create error!!!");

diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-uci/lynq_uci_ro.config b/cap/zx297520v3/src/lynq/lib/liblynq-uci/lynq_uci_ro.config
index 305e4e4..32f563e 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-uci/lynq_uci_ro.config
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-uci/lynq_uci_ro.config
@@ -1,3 +1,5 @@
 config lynq_version_ro 'lynq_version'

         option LYNQ_SW_VERSION 'T106CN-ZS03.V2.01.01.02P52U02.AP.09.05_CAP.09.05'

         option LYNQ_SW_INSIDE_VERSION 'T106CN-ZS03.V2.01.01.02P52U02.AP.09.05_CAP.09.05'

+config debug_mode 'debug_mode'

+       option conntrack_mode '1'
\ No newline at end of file