Merge "[Feature][task-view-1452,bug-view-1151][T106][sdk-ready]sdk-ready add nf-conntrack detection"
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc/init.d/fscheck.sh b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc/init.d/fscheck.sh
index b5ccf20..56a4b0d 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc/init.d/fscheck.sh
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc/init.d/fscheck.sh
@@ -25,6 +25,11 @@
   reboot
 fi
 
+#xy.he@20250512 add for bug-view-1113
+if [ ! -L /etc_rw/localtime ]; then
+ln -s "/usr/share/zoneinfo/Asia/Shanghai" /etc_rw/localtime
+fi
+
 #l.yang modify for T106BUG-387 start
 if [ -e /dev/mmcblk1p1 ]; then
   mount -t ext4 /dev/mmcblk1p1 /var/log
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc/rc.local b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc/rc.local
index fc9a630..3c14b25 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc/rc.local
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc/rc.local
@@ -33,12 +33,13 @@
 
 rm -rf /etc_rw/udhcpd*.pid
 
+#xy.he@20250512 delete for bug-view-1113
 #ln -sf "/etc/zoneinfo/Asia/Shanghai" /etc/localtime
-ln -sf "/etc_rw/localtime" /etc/localtime
-if [ ! -L /etc_rw/localtime ]; then
-ln -sf "/usr/share/zoneinfo/Asia/Shanghai" /etc_rw/localtime
-fi
+#ln -sf "/etc_rw/localtime" /etc/localtime
+#if [ ! -L /etc_rw/localtime ]; then
+#ln -sf "/usr/share/zoneinfo/Asia/Shanghai" /etc_rw/localtime
+#fi
 
 echo "open nvserver at_ctl nv-rpc-daemon zxic_mainctrl rtc-service" > /proc/abnormal_exit_task
 #jb.qi@20230918 delete for autosuspend
-zxic_ramdump > /tmp/ramdump.txt 2>&1 &
\ No newline at end of file
+zxic_ramdump > /tmp/ramdump.txt 2>&1 &
diff --git a/cap/zx297520v3/src/lynq/framework/lynq-sdk-ready/main.cpp b/cap/zx297520v3/src/lynq/framework/lynq-sdk-ready/main.cpp
index 5eead08..5255025 100755
--- a/cap/zx297520v3/src/lynq/framework/lynq-sdk-ready/main.cpp
+++ b/cap/zx297520v3/src/lynq/framework/lynq-sdk-ready/main.cpp
@@ -3,12 +3,13 @@
 #include <unistd.h>
 #include <stdlib.h>
 #include <stdint.h>
+#include <liblog/lynq_deflog.h>
 #include "lynq_timer.h"
 
 #ifdef __cplusplus
 extern "C" {
 #endif
-
+#define USER_LOG_TAG "LYNQ_SDK_READY"
 
 int main(void){
     start_timer_request();
@@ -19,6 +20,7 @@
     
     return 0;
 }
+DEFINE_LYNQ_EXE_LOG(LYNQ_SDK_READY)
 #ifdef __cplusplus
 }
 #endif 
diff --git a/cap/zx297520v3/src/lynq/framework/lynq-sdk-ready/makefile b/cap/zx297520v3/src/lynq/framework/lynq-sdk-ready/makefile
index 56280dd..50b9b84 100755
--- a/cap/zx297520v3/src/lynq/framework/lynq-sdk-ready/makefile
+++ b/cap/zx297520v3/src/lynq/framework/lynq-sdk-ready/makefile
@@ -44,6 +44,7 @@
     -lbinder \
     -lpthread \
     -llynq-uci \
+    -llynq-log \
 
 LOCAL_SRC_FILES_CPP = $(wildcard *.cpp)
 EXECUTABLE = lynq-sdk-ready
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-at-factory/liblynq-at-factory.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-at-factory/liblynq-at-factory.cpp
index 5add3a1..fbd5a5c 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-at-factory/liblynq-at-factory.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-at-factory/liblynq-at-factory.cpp
@@ -5,6 +5,7 @@
 #include <sys/time.h>

 #include <unistd.h>

 #include <error.h>

+#include <fcntl.h>

 #include <string.h>

 #include <netinet/in.h>

 #include <netinet/ether.h>

@@ -101,6 +102,153 @@
     pclose(fp);

 }

 

+

+static int create_emmc_partitions()

+{

+

+    int ret = -1;

+    

+    const char *fdisk_cmd = "echo -e 'n\np\n1\n\n\nw\n' | fdisk '/dev/mmcblk1'";

+

+    ret = system(fdisk_cmd);

+    if(ret < 0)

+    {

+        ALOGE("create_emmc_partitions failed");

+        return -1;

+    }

+    

+    return 0;

+}

+

+

+static int check_emmc_partitions()

+{

+    int fd = open("/dev/mmcblk1p1", O_RDONLY);

+    

+    if(fd < 0) //no exist,need create

+    {

+        return 0;

+    }

+    

+    close(fd);

+    return 1;

+}

+

+

+

+int lynq_handle_emmc_io(void)

+{

+    int fd;

+    int data_size = 512;

+    int ret;

+    char *write_buf;

+    char *read_buf;

+    

+    //check partitions

+    ret = check_emmc_partitions();

+    

+    if(ret == 0)//no exist

+    {

+        //create a new partitions(mmcblk1p1)

+        ret = create_emmc_partitions();

+        if(ret < 0)

+        {

+            return -1;

+        }

+        

+        //check partitions again

+        ret = check_emmc_partitions();

+        if(ret < 0)

+        {

+            ALOGE("check partitions again failed");

+        }

+        

+        //format partitions

+        system("echo -e '/n/n' | mkfs.ext4 /dev/mmcblk1p1");

+

+        //mount to /var/log

+        system("mount /dev/mmcblk1p1 /var/log");

+    }

+    

+    //already exist,so no need to create

+    

+    write_buf = malloc(data_size);

+    if(write_buf == NULL)

+    {

+       ALOGE("malloc failed");

+       return;

+    }

+    

+    memset(write_buf, 0XAA, data_size);

+    

+    fd = open("/var/log/emmc_test.txt", O_WRONLY | O_SYNC | O_CREAT | O_TRUNC,0600 );

+    if(fd == -1)

+    {

+       ALOGE("Open for write failed");

+       free(write_buf);

+       return -1;

+    }

+    

+    //write data

+    if (write(fd, write_buf, data_size) != data_size) {

+        ALOGE("Write failed");

+        handle_output("Write failed", strlen("Write failed"), Response);

+        close(fd);

+        free(write_buf);

+        return -1;

+    }

+    

+    close(fd);

+    system("sync");

+    

+    //read data

+    read_buf = malloc(data_size);

+    if(read_buf == NULL)

+    {

+       ALOGE("malloc failed");

+       free(write_buf);

+       return -1;

+    }

+    

+    //reopen(read mode)

+    fd = open("/var/log/emmc_test.txt", O_RDONLY);

+    if(fd == -1)

+    {

+       ALOGE("open for read failed");

+       free(write_buf);

+       free(read_buf);

+       return -1;

+    }

+

+    if(read(fd, read_buf, data_size) != data_size)

+    {

+       ALOGE("Read failed");

+       handle_output("Read failed", strlen("Read failed"), Response);

+       free(write_buf);

+       free(read_buf);

+       close(fd);

+       return -1;

+    }

+    

+    //check data

+    if (memcmp(write_buf, read_buf, data_size) == 0) {

+        ALOGE("Data verification success!,");

+        handle_output("emmc write/read success", strlen("emmc write/read success"), Response);

+        close(fd);

+        free(write_buf);

+        free(read_buf);

+        return 0;

+    } else {

+        ALOGE("Data verification failed!");

+        handle_output("Data verification failed!", strlen("Data verification failed!"), Response);

+        close(fd);

+        free(write_buf);

+        free(read_buf);

+        return -1;

+    }

+}

+

+

 void lynq_handle_emmc(char *input)

 {

     FILE *fp;

@@ -119,7 +267,14 @@
         return;

     }

     while(fgets(buf, sizeof(buf), fp) != NULL){

-        lynq_response_ok();

+        if(lynq_handle_emmc_io() < 0)

+        {

+            lynq_response_error(100);

+        }

+        else

+        {

+            lynq_response_ok();

+        }

         pclose(fp);

         return;

     }

@@ -128,6 +283,8 @@
 }

 

 

+

+

 /******gpio API******/

 /*sc_gpio_init(gpio, direction, value, pullsel);

   sc_gpio_direction_set(test_gpio_handle[gpio], direction, 0);

diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-log/include/liblog/liblog.h b/cap/zx297520v3/src/lynq/lib/liblynq-log/include/liblog/liblog.h
index d1ca261..afa272e 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-log/include/liblog/liblog.h
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-log/include/liblog/liblog.h
@@ -28,7 +28,7 @@
 int lynq_set_special_log_level(const char * exe_name, const char * module_name, log_level_enum level);
 int lynq_get_special_log_level(const char * exe_name, const char * module_name, log_level_enum *level);
 int lynq_notify_recalc_log_level(pid_t pid);
-
+int lynq_notify_recalc_log_level_bottom(char *log_level);
 #ifdef __cplusplus
 }
 #endif
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-log/log-riltel/log.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-log/log-riltel/log.cpp
index 6256d4f..51c209f 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-log/log-riltel/log.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-log/log-riltel/log.cpp
@@ -13,6 +13,7 @@
 #ifdef MOBILETEK_TARGET_PLATFORM_T106
 extern "C" {
 #include <cfg_api.h>
+extern int log_level(char *level_name);
 }
 #endif
 
@@ -546,14 +547,74 @@
     return system(cmd_buf);
 }
 
+#define MAX_PIDS 128
+int kill_pid(char *command,int signal)
+{
+    int pids[MAX_PIDS];
+    int pid_count = 0;
+    FILE *fp = popen(command, "r");
+    if (fp == NULL)
+    {
+        perror("popen failed");
+        return -1;
+    }
+    char line[1024];
+    while(fgets(line, sizeof(line), fp) != NULL)
+    {
+        if (pid_count < MAX_PIDS)
+        {
+            pids[pid_count] = atoi(line);
+            kill(pids[pid_count], signal);
+            pid_count++;
+        }  
+    }
+    pclose(fp);
+    return 0;
+}
+
+int lynq_notify_recalc_log_level_bottom(char *log_level)
+{
+    sc_cfg_set("print_level", log_level);
+	sc_cfg_set("syslog_level", log_level);
+
+    const char* process_names[] = {
+        "at_ctl",
+        "mnet_whitelist_proxy",
+        "rtc-service",
+        "msm_svr",
+        "zxic_mainctrl",
+        "zxic_mmi",
+        "lynq-ril-service"
+    };
+    const int process_count = sizeof(process_names) / sizeof(process_names[0]);
+    
+    
+    char command[1024] = "";
+    for (int i = 0; i < process_count; i++)
+    {
+        strcat(command, "pidof ");
+        strcat(command, process_names[i]);
+        if (i < process_count - 1)
+            strcat(command, " && ");
+    }
+/*close zxic-process kill SIGUSR2*/
+    kill_pid(command, SIGUSR2);
+/*close lynq-process kill SIGUSR1*/
+    kill_pid("ls /tmp/log_level/", SIGUSR1);
+    return 0;
+}
+
+
 static void log_signal_handler(int signum) {
     if (SIGUSR1 != signum)
         return;
     // 处理信号
+    log_level("syslog_level");
+    log_level("print_level");
     for(int i=0; i < s_curr_reg_count; i++)
     {
         get_module_log_level(s_log_module_entries[i]);
-    }
+    } 
 }
 
 void __attribute__((constructor)) lynq_log_init()
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-log/log-riltel/makefile b/cap/zx297520v3/src/lynq/lib/liblynq-log/log-riltel/makefile
index 017fc6a..d08765c 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-log/log-riltel/makefile
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-log/log-riltel/makefile
@@ -18,15 +18,16 @@
 LOCAL_C_INCLUDES = \
   -I. \
   -I$(LOCAL_PATH)/../include/liblog \
- -I$(ROOT)$(includedir)/logger \
+  -I$(ROOT)$(includedir)/logger \
 
 
 LOCAL_LIBS := \
     -L. \
     -ldl \
-	-lstdc++ \
+    -lstdc++ \
     -llynq-uci \
     -llog \
+    -lbinder
 
 ifeq ($(strip $(TARGET_PLATFORM)), T106)
 LOCAL_CFLAGS += -DMOBILETEK_TARGET_PLATFORM_T106
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mmc/core/block.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mmc/core/block.c
old mode 100644
new mode 100755
index 6622e32..af57016
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mmc/core/block.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mmc/core/block.c
@@ -132,6 +132,9 @@
 	/* debugfs files (only in main mmc_blk_data) */
 	struct dentry *status_dentry;
 	struct dentry *ext_csd_dentry;
+//cz.li@20250420 for emmc health begin
+	struct dentry *health_dentry;
+//cz.li@20250420 for emmc health begin
 };
 
 /* Device type for RPMB character devices */
@@ -1042,6 +1045,12 @@
 		ext_csd = mq_rq->drv_op_data;
 		ret = mmc_get_ext_csd(card, ext_csd);
 		break;
+//cz.li@20250420 for emmc health begin
+	case MMC_DRV_OP_GET_HEALTH:
+		ext_csd = mq_rq->drv_op_data;
+		ret = mmc_get_ext_csd(card, ext_csd);
+		break;
+//cz.li@20250420 for emmc health end 
 	default:
 		pr_err("%s: unknown driver specific operation\n",
 		       md->disk->disk_name);
@@ -2837,6 +2846,92 @@
 	.llseek		= default_llseek,
 };
 
+//cz.li@20250420 for emmc health begin
+#define HEALTH_STR_LEN 2
+static int mmc_health_open(struct inode *inode, struct file *filp)
+{
+	struct mmc_card *card = inode->i_private;
+	struct mmc_blk_data *md = dev_get_drvdata(&card->dev);
+	struct mmc_queue *mq = &md->queue;
+	struct request *req;
+	char *buf;
+	u8 *ext_csd = NULL;
+	int err;
+	ssize_t n;
+	unsigned int health;
+	char health_buf[64];
+	//printk("cy-health open\n");
+	buf = kmalloc(EXT_CSD_STR_LEN + 1, GFP_KERNEL);
+	if (!buf)
+		return -ENOMEM;
+	
+	/* Ask the block layer for the EXT CSD */
+	req = blk_get_request(mq->queue, REQ_OP_DRV_IN, 0);
+	if (IS_ERR(req)) {
+		err = PTR_ERR(req);
+		goto out_free;
+	}
+	req_to_mmc_queue_req(req)->drv_op = MMC_DRV_OP_GET_HEALTH;
+	req_to_mmc_queue_req(req)->drv_op_data = &ext_csd;
+	//printk("cy- blk_execute_rq begin\n");
+	blk_execute_rq(mq->queue, NULL, req, 0);
+	//printk("cy- blk_execute_rq end\n");
+	err = req_to_mmc_queue_req(req)->drv_op_result;
+	//printk("cy-blk_put_request begin\n");
+	blk_put_request(req);
+	//printk("cy-blk_put_request end\n");
+	if (ext_csd == NULL) {
+		printk("EXT_CSD IF NULL\n");
+		goto out_free;
+	}
+	if (err) {
+		pr_err("FAILED %d\n", err);
+		if (ext_csd != NULL)
+			kfree(ext_csd);
+		goto out_free;
+	}
+	
+	health = ext_csd[269];
+	//printk("cy-bad health %d\n",ext_csd[269]);
+	n = sprintf(buf, "%02x", health);
+	if (n != HEALTH_STR_LEN) {
+		//printk("cy-bad count %d , %d\n", (int)n , HEALTH_STR_LEN);
+		err = -EINVAL;
+		kfree(ext_csd);
+		goto out_free;
+	}
+
+	filp->private_data = buf;
+	kfree(ext_csd);
+	return 0;
+out_free:
+	kfree(buf);
+	return err;
+}
+
+static ssize_t mmc_health_read(struct file *filp, char __user *ubuf,
+                                size_t cnt, loff_t *ppos)
+{
+	char *buf = filp->private_data;
+	printk("cy-mmc_ext_csd_read\n");
+	return simple_read_from_buffer(ubuf, cnt, ppos,
+                                       buf, HEALTH_STR_LEN);
+}
+
+static int mmc_health_release(struct inode *inode, struct file *file)
+{
+	kfree(file->private_data);
+	return 0;
+}
+
+static const struct file_operations mmc_dbg_health_fops = {
+	.open		= mmc_health_open,
+	.read		= mmc_health_read,
+	.release	= mmc_health_release,
+	.llseek		= default_llseek,
+};
+//cz.li@20250420 for emmc health end
+
 static int mmc_blk_add_debugfs(struct mmc_card *card, struct mmc_blk_data *md)
 {
 	struct dentry *root;
@@ -2862,7 +2957,13 @@
 		if (!md->ext_csd_dentry)
 			return -EIO;
 	}
-
+//cz.li@20250420 for emmc health begin
+	if (mmc_card_mmc(card)) {
+		md->health_dentry=
+			debugfs_create_file("health", S_IRUSR, root, card,
+					    &mmc_dbg_health_fops);
+	}
+//cz.li@20250420 for emmc health end
 	return 0;
 }
 
@@ -2881,6 +2982,13 @@
 		debugfs_remove(md->ext_csd_dentry);
 		md->ext_csd_dentry = NULL;
 	}
+
+//cz.li@20250420 for emmc health begin
+	if (!IS_ERR_OR_NULL(md->health_dentry)) {
+		debugfs_remove(md->health_dentry);
+		md->health_dentry= NULL;
+	}
+//cz.li@20250420 for emmc health end
 }
 
 #else
diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mmc/core/queue.h b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mmc/core/queue.h
old mode 100644
new mode 100755
index fd11491..6713585
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mmc/core/queue.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/mmc/core/queue.h
@@ -59,6 +59,9 @@
 	MMC_DRV_OP_BOOT_WP,
 	MMC_DRV_OP_GET_CARD_STATUS,
 	MMC_DRV_OP_GET_EXT_CSD,
+//cz.li@20250420 for emmc health begin
+	MMC_DRV_OP_GET_HEALTH,
+//cz.li@20250420 for emmc health end
 };
 
 struct mmc_queue_req {