[Feature][ZXW-130]merge P50U02 version

Only Configure: No
Affected branch: master
Affected module: unknow
Is it affected on both ZXIC and MTK: only ZXIC
Self-test: Yes
Doc Update: No

Change-Id: I4f29ec5bb7c59385f23738d2b7ca84e67c100f69
diff --git a/ap/app/zte_log_agent/log_agent.h b/ap/app/zte_log_agent/log_agent.h
index b118802..661e983 100755
--- a/ap/app/zte_log_agent/log_agent.h
+++ b/ap/app/zte_log_agent/log_agent.h
@@ -70,10 +70,10 @@
 /* ͨѶģ¿éºÅ */

 #define MDL_TOOLS_BASE            (100)

 #define SUBMDL_TOOLAGENT_SET      (85)

-#define MDL_ZCAT                  (MDL_TOOLS_BASE + 15)      /* ZCAT¹¤¾ß          */

-#define SUBMDL_ZCATAGT            (SUBMDL_TOOLAGENT_SET + 0)  /* ZCAT¹¤¾ß´úÀí */

+#define MDL_ZCAT                  (MDL_TOOLS_BASE + 15)      /* ZCAT¹¤¾ß     */

+#define SUBMDL_ZCATAGT            (SUBMDL_TOOLAGENT_SET + 0) /* ZCAT¹¤¾ß´úÀí */

 

-#define MDL_PHONE                 (1)                     /* ÊÖ»ú             */

+#define MDL_PHONE                 (1)                        /* ÊÖ»ú         */

 

 /* ÈÕÖ¾Á÷ÏòÖ¾ */

 #define DIR_LOG_TCARD_VALUE 0x01

@@ -221,8 +221,10 @@
     ZCAT_MODE_CP_NET,

     ZCAT_MODE_CP_FS,

 #ifdef USE_CAP_SUPPORT

-    ZCAT_MODE_CAP_FS

+    ZCAT_MODE_CAP_FS,

+    ZCAT_MODE_CAP_NET,

 #endif

+    ZCAT_MODE_LOG_OFF,

 } E_ZCAT_MODE;

 

 typedef enum

@@ -238,6 +240,7 @@
 #ifdef USE_CAP_SUPPORT

     ZCAT_IPC_ALLOC_CAP_SMLOGBUF,

 #endif

+    ZCAT_IPC_READ_IRAM_ZCAT_MODE,

 } E_ZCAT_IPC_HANDSHAKE;

 

 

diff --git a/ap/app/zte_log_agent/log_agent_main.c b/ap/app/zte_log_agent/log_agent_main.c
index 6869bd1..369767e 100755
--- a/ap/app/zte_log_agent/log_agent_main.c
+++ b/ap/app/zte_log_agent/log_agent_main.c
@@ -94,11 +94,38 @@
  */

 int init_log_type(int argc, char *argv[])

 {

-    char zcat_mode[16] = { 0 };

+    UINT32 iram_val      = 0;    

+    char   zcat_mode[16] = { 0 };

 

     // 1.»ñÈ¡nvÖµ

-    sc_cfg_get("zcat_mode", zcat_mode, sizeof(zcat_mode) - 1);

-    if (strcmp(zcat_mode, "APTF") == 0)

+     sc_cfg_get("zcat_mode", zcat_mode, sizeof(zcat_mode) - 1);    

+

+    cplog_fd = open(cplog_dev, O_RDWR);

+    if (cplog_fd < 0) {

+       return -1;

+    }

+    

+    if (strcmp(zcat_mode, "LOGOFF") == 0)

+    {

+        for(;;)

+        {

+            if(ioctl(cplog_fd, ZCAT_IPC_READ_IRAM_ZCAT_MODE, &iram_val)!= 0)

+            {

+                printf("[zcat]ioctl:ZCAT_IPC_READ_IRAM_ZCAT_MODE fail!\n");

+                return -1;

+            }

+            if((iram_val == 0) || (iram_val == ZCAT_MODE_LOG_OFF))

+            {

+                sleep(5);

+            }

+            else

+            {

+                g_log_dir = iram_val;

+                break;

+            }

+        }

+    }

+    else if (strcmp(zcat_mode, "APTF") == 0)

     {

         g_log_dir = ZCAT_MODE_AP_TF;

     }

@@ -134,6 +161,10 @@
     {

         g_log_dir = ZCAT_MODE_CAP_FS;

     }

+    else if (strcmp(zcat_mode, "CAPNET") == 0)

+    {

+        g_log_dir = ZCAT_MODE_CAP_NET;

+    }

 #endif

     else

     {

@@ -205,14 +236,9 @@
 

     // 2.³õʼ»¯È«¾Ö±äÁ¿

     init_log_agent_tools();

-    

+

     // 3.¸ù¾Ýģʽ´ò¿ªlogÊý¾ÝÔ´É豸²¢´´½¨µÄ¹¤×÷Ïß³Ì

     //   V3E²»ÐèÒª¶ÁÈ¡applogºÍkernellogÉ豸

-    cplog_fd = open(cplog_dev, O_RDWR);

-    if (cplog_fd < 0) {

-        goto __exit;

-    }

-   

     if((g_log_dir == ZCAT_MODE_AP_USB) || (g_log_dir == ZCAT_MODE_AP_TF)

         || (g_log_dir == ZCAT_MODE_AP_NET) || (g_log_dir == ZCAT_MODE_AP_FS))

     {

diff --git a/ap/app/zte_log_agent/log_agent_sdcard.c b/ap/app/zte_log_agent/log_agent_sdcard.c
index e4a5117..2eea475 100755
--- a/ap/app/zte_log_agent/log_agent_sdcard.c
+++ b/ap/app/zte_log_agent/log_agent_sdcard.c
@@ -186,7 +186,7 @@
             g_log_sdcard_para.max_total_size = (UINT64)(nvint_size) * ZCAT_ONE_MB_SIZE;    

         }

     }

-    

+

     max_logNum = g_log_sdcard_para.max_file_num;

     total_size = g_log_sdcard_para.max_total_size;

     printf("[zcat] max_logNum %d\n", max_logNum);

@@ -463,7 +463,7 @@
     ruledir_size = sizeof(g_log_sdcard_para.rule_path);

 

     init_cfg_param(ZCAT_MODE_AP_FS);

-    

+

     memset(log_path,  0, logdir_size);

     memset(rule_file, 0, ruledir_size);

     

@@ -490,8 +490,16 @@
     else

         sc_cfg_get("rule_file", rule_file, ruledir_size - 1);

         

-    printf("[zcat] log_path: %s, rule_file %s\n", log_path, rule_file);

-    

+    if(strlen(log_path) && strlen(rule_file))

+    {

+        printf("[zlog-agent]zlog_path: %s, rule_file %s\n", log_path, rule_file);

+    }

+    else

+    {

+        printf("[zlog-agent]zlog_path or rule_file nv item is NULL, please check and nv set them Now!\n");

+        return -1;

+    }

+

     if(test_dir_exist(log_path) < 0)//´´½¨ÈÕÖ¾Îļþ¼Ð

     {

         printf("[zcat] test %s dir exist failed. \n", g_log_sdcard_para.log_dir);

diff --git a/ap/app/zte_log_agent/log_agent_tool.c b/ap/app/zte_log_agent/log_agent_tool.c
old mode 100644
new mode 100755
index a5ec0f2..cfa33f4
--- a/ap/app/zte_log_agent/log_agent_tool.c
+++ b/ap/app/zte_log_agent/log_agent_tool.c
@@ -110,8 +110,8 @@
     memset(buf, 0, 22);

     time(&timep);

     p =localtime(&timep);

-	if(p != NULL)

-		snprintf(buf,21,"%4d/%02d/%02d %02d:%02d:%02d ",1900 + p->tm_year,1 + p->tm_mon,p->tm_mday,p->tm_hour,p->tm_min,p->tm_sec);

+    if(p != NULL)

+        snprintf(buf,21,"%4d/%02d/%02d %02d:%02d:%02d ",1900 + p->tm_year,1 + p->tm_mon,p->tm_mday,p->tm_hour,p->tm_min,p->tm_sec);

     return buf;

 }

 

@@ -197,9 +197,9 @@
             pthread_mutex_unlock(&mutex_SD); 

         }

     }

-	else if(g_log_dir == ZCAT_MODE_AP_FS)

-	{

-		if(bSDSet == FALSE )

+    else if(g_log_dir == ZCAT_MODE_AP_FS)

+    {

+        if(bSDSet == FALSE )

         {

             bSDSet = TRUE;

             if(init_fs_log_dir() < 0) //³õʼ»¯cpÊä³öÎļþ¼Ð¼°²ÎÊý

@@ -216,7 +216,7 @@
             send_message_to_sdcard(buf, len);

             pthread_mutex_unlock(&mutex_SD); 

         }

-	}

+    }

     else

     {

         deal_with_encoded_data(buf, len);

diff --git a/ap/app/zte_log_agent/log_agent_usblog.c b/ap/app/zte_log_agent/log_agent_usblog.c
old mode 100644
new mode 100755
index e07c50e..128cf37
--- a/ap/app/zte_log_agent/log_agent_usblog.c
+++ b/ap/app/zte_log_agent/log_agent_usblog.c
@@ -116,7 +116,7 @@
     int read_len = 0;

     

     pbuf = g_UsbLogBuf;

-	/*

+    /*

     if(pbuf == NULL)

     {

         printf("[zcat] read_usblog fail.\n");