Merge "[Feature][T8TSK-183][VERSION]Update software version LYNQ_SW_INSIDE_VERSION:T800_GSW_v02.MP1_MR3.02b19.00.05 to T800_GSW_v02.MP1_MR3.02b19.00.05.05" into CS1E-K08-J1U5CRB
diff --git a/meta/meta-mediatek-mt2735/recipes-core/initial/files/lynq_data_recover b/meta/meta-mediatek-mt2735/recipes-core/initial/files/lynq_data_recover
old mode 100644
new mode 100755
index 97e16c4..cf95d6a
--- a/meta/meta-mediatek-mt2735/recipes-core/initial/files/lynq_data_recover
+++ b/meta/meta-mediatek-mt2735/recipes-core/initial/files/lynq_data_recover
@@ -118,6 +118,7 @@
 #recover some files start
 echo "$TAG: Before recover radio_property" > /dev/kmsg
 rm -rf /etc/config/.*.uci*
+rm -rf /home/root/.config/pulse/*
 
 mkdir -p /data/atsvc
 cp /data_backup/lynq_atsvc_plugin.xml /data/atsvc/lynq_atsvc_plugin.xml
@@ -168,3 +169,39 @@
     fi
 fi
 echo "$TAG === Initial: LYNQ MOUNT Abnomal End ===" > /dev/kmsg
+
+
+a_int=$(df | grep '/data$' | awk '{print $4}')
+b_int=1024
+
+   if [ $a_int -eq $b_int ];then
+       echo "$a_int = $b_int"
+   elif [ $a_int -lt $b_int ];then
+       find /data -name '*.pcap' | xargs rm -rf
+       sleep 0.02
+       find /data -name '*.cap' | xargs rm -rf
+       sleep 0.02
+       find /data -name '*.log' | xargs rm -rf
+       sleep 0.02
+       c_int=$(df | grep '/data$' | awk '{print $4}')
+
+       if [ $c_int -eq $b_int ];then
+	      echo "$c_int = $b_int"
+       elif [ $c_int -lt $b_int ];then
+          echo '#/bin/sh' > /tmp/delete_partition.sh
+          echo 'cd /data' >> /tmp/delete_partition.sh
+          echo 'GLOBIGNORE=agps_sup1:.update_status:atsvc:ccci_cfg:core:gpio:gps_mnl:lynq-low-power.sh:mdlog:misc:mpe_mnl:nvram:ril:vendor:lynq-test.sh:wifi:delete_partition.sh' >> /tmp/delete_partition.sh
+
+          echo 'rm -rf *' >>  /tmp/delete_partition.sh
+          cd /tmp
+          chmod 777 delete_partition.sh
+          /tmp/delete_partition.sh
+          rm -rf delete_partition.sh
+       else
+          echo "$c_int > $b_int"
+       fi
+     
+    else
+    echo "userdata avalil size is $a_int"
+    fi
+
diff --git a/src/lynq/framework/lynq-sdk-ready/src/timer/lynq_timer.cpp b/src/lynq/framework/lynq-sdk-ready/src/timer/lynq_timer.cpp
index 4d5c7ee..252a13f 100755
--- a/src/lynq/framework/lynq-sdk-ready/src/timer/lynq_timer.cpp
+++ b/src/lynq/framework/lynq-sdk-ready/src/timer/lynq_timer.cpp
@@ -14,15 +14,16 @@
 #include <errno.h>

 #include "lynq_timer.h"

 #include <include/lynq_uci.h>

-

-

+
+#include <stdlib.h>
+#include <fcntl.h>
+#include <assert.h>
+
 #define DEST_PORT 8088

 #define DSET_IP_ADDRESS  "127.0.0.1"

 #define RIL_REQUEST_DEVICE_IDENTITY 98

 #define MAX_LEN 1024

 #define TIMER 30

-

-

 #define LOG_UCI_FILE "lynq_uci"

 #define LOG_UCI_MODULE "debug_mode"

 

@@ -97,6 +98,25 @@
     return 0;

 }

 

+/**
+ * @brief find partition zhengshu for exzample 5.7M,get value 5
+ * 
+ * @param arg 
+ * @return  
+ */
+static void removeSpaces(char* str) 
+{
+    char* dest = str;  
+    while (*str) {
+        if (*str != ' ') {
+            *dest++ = *str;  
+        }
+        str++;  
+    }
+    *dest = '\0';
+	return ;
+}
+
 /**

  * @brief 30s request imei

  * 

@@ -105,6 +125,10 @@
  */

 void * timer_request_imei(void * arg)

 {

+    FILE *fp1 = NULL;
+    char buf[8] = {0};
+    int ucivalue = 0;
+    int nread = 0;
     int sock_fd = socket(AF_INET, SOCK_DGRAM, 0);

     if (-1 == sock_fd)

     {

@@ -245,7 +269,21 @@
         /*judge the res_error*/

         if(!res_error)

         {

-            system("uci set lynq_uci.sdk_ready='0'");

+            fp1 = popen("uci get lynq_uci.sdk_ready","r");
+            if(fp1 == NULL)
+            {
+                RLOGD("Failed to run uci get lynq_uci.sdk_ready\n");
+                continue;
+            }
+            memset(buf, 0, sizeof(buf));
+            nread = fread(buf,1,8,fp1);
+            pclose(fp1);
+            ucivalue = atoi(buf);
+
+            if((0 != ucivalue)&&(5 != ucivalue)&&(6 != ucivalue))
+            {
+                system("uci set lynq_uci.sdk_ready='0'");

+            }
         }

         else

         {

@@ -491,12 +529,140 @@
     }

     return NULL;

 }

-

-

+
+static void *delete_partition(void  *arg)
+{
+    char buf[64] = {0};
+    char tmp[64] = {0};
+    char ucibuf[8] = {0};
+    FILE *fp = NULL;
+    FILE *fp1 = NULL;
+    char *result1 = NULL;
+    int nread = 0;

+    int nnread = 0;
+    int count1 = 0;
+    int q = 22;
+    int qWarnValue = 10;
+    int ubisize = 0;
+    int uciValue = 0;
+
+    while(1)
+    {
+
+    sleep(300);
+
+    fp = popen("df -lh| grep '/data$' | awk '{print $3}'","r");
+
+    if(fp == NULL)
+    {
+       RLOGD("Failed to run command\n");
+       continue;
+    }
+
+    memset(buf, 0, sizeof(buf));
+    nread = fread(buf,1,64,fp);
+
+    if(nread != 64)
+    {
+        pclose(fp);
+        RLOGD("Read file failed!\n");	
+        continue;
+    }
+    if (pclose(fp) == -1) 
+    {
+        RLOGD("close fp file failed!\n");
+        continue;
+     }
+
+    removeSpaces(buf);
+
+    result1 = strchr(buf, 'M');
+
+   if(result1 != NULL)
+   {
+      count1 = result1 - buf;
+
+      memset(tmp,0,sizeof(tmp));
+
+      if(strncpy(tmp,buf,count1) == NULL)
+      {
+          RLOGD("copy buf failed!\n");
+          continue;
+      }
+      else
+      {
+          RLOGD("copy buf success!\n");
+          ubisize = atoi(tmp);
+      }
+
+     if((ubisize > qWarnValue)&&(ubisize < q))
+       {	
+         fp1 = popen("uci get lynq_uci.sdk_ready","r");
+         if(fp1 == NULL)
+         {
+             RLOGD("Failed to run uci get lynq_uci.sdk_ready\n");
+             continue;
+         }
+
+        memset(ucibuf, 0, sizeof(ucibuf));
+        nnread = fread(ucibuf,1,8,fp1);
+        pclose(fp1);
+        uciValue = atoi(ucibuf);
+        
+        if(0x0 == uciValue)
+        {
+           system("uci set lynq_uci.sdk_ready='5'");
+           RLOGD(">set ready 5,userdata size is %d M\n",ubisize);
+        }
+        else
+        {
+           RLOGD("userdata size is %d M,uciValue is %d\n",ubisize,uciValue);
+        }
+     }
+     else if(ubisize >= q)
+     {
+        fp1 = popen("uci get lynq_uci.sdk_ready","r");
+        if(fp1 == NULL)
+        {
+          RLOGD("Failed to run uci get lynq_uci.sdk_ready\n");
+          continue;
+        }
+
+        memset(ucibuf, 0, sizeof(ucibuf));
+        nnread = fread(ucibuf,1,8,fp1);
+        pclose(fp1);
+        uciValue = atoi(ucibuf);
+
+        if(0x0 == uciValue)
+        {
+           RLOGD(">set ready 6,userdata size is %d M\n",ubisize);
+           system("uci set lynq_uci.sdk_ready='6'"); 
+        }
+     else
+     {
+        RLOGD("userdata size is %d M,uciValue is %d\n",ubisize,uciValue);
+     }
+    } 
+    else
+    {
+        RLOGD("userdata size is %d M\n",ubisize);
+    }
+
+  }
+  else
+  {
+     RLOGD("userdata partition size is kb!\n");
+  }
+
+
+  }
+
+return (void *)0;
+}
 

 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);

@@ -504,6 +670,7 @@
     char tmp[20];

     int debug_mode;

     int ret;

+    int ret3;
     

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

     if(ret != 0){

@@ -526,15 +693,23 @@
         }

 

     }

-

-    

-

+
     ret = pthread_create(&thid_2,NULL,check_uci,NULL);

     if(ret != 0){

         RLOGD("pthread_create error!!!");

         return;

     }

     pthread_detach(thid_2);

+
+    sleep(1);
+
+    ret3 = pthread_create(&thid_3,NULL,delete_partition,NULL);
+    if(ret3 != 0)
+     { 
+        RLOGD("pthread_create error!!!");
+        return;
+     }
+
     return;

 }

 

diff --git a/src/lynq/lib/liblynq-data/lynq_data.cpp b/src/lynq/lib/liblynq-data/lynq_data.cpp
index b8865ef..06913d4 100755
--- a/src/lynq/lib/liblynq-data/lynq_data.cpp
+++ b/src/lynq/lib/liblynq-data/lynq_data.cpp
@@ -1071,6 +1071,15 @@
     return error;
 }
 
+void deactiveAfterTimeout(int apnId)
+{
+    LYDBGLOG("%s:apn id:%d",__FUNCTION__,apnId);
+    cleanDeactApn(apnId);
+    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();
+}
 int lynq_deactive_data_call(int *handle)
 {
     Parcel *p = NULL;
@@ -1141,6 +1150,7 @@
         {
             error = LYNQ_E_TIME_OUT;
             LYERRLOG("[lynq_deactive_data_call] timeout:wait data Call state fail!!!");
+            deactiveAfterTimeout(lynq_data_call_id);
             printf_apn_table_debug(__FUNCTION__,__LINE__);
         }
     }