Merge "[Feature][T106]version update to T106CN-ZS03.V2.01.01.02P54U02.AP.10.04_CAP.10.04"
diff --git a/allbins/zx297520v3/prj_vehicle/nv_dc_ref/phyLteaAmtUser_nvrwo_0x0003C800.bin b/allbins/zx297520v3/prj_vehicle/nv_dc_ref/phyLteaAmtUser_nvrwo_0x0003C800.bin
index ae19b25..197aad6 100755
--- a/allbins/zx297520v3/prj_vehicle/nv_dc_ref/phyLteaAmtUser_nvrwo_0x0003C800.bin
+++ b/allbins/zx297520v3/prj_vehicle/nv_dc_ref/phyLteaAmtUser_nvrwo_0x0003C800.bin
Binary files differ
diff --git a/allbins/zx297520v3/prj_vehicle/nv_dc_ref/phyWcdmaAmtUser_nvrwo_0x0003A000.bin b/allbins/zx297520v3/prj_vehicle/nv_dc_ref/phyWcdmaAmtUser_nvrwo_0x0003A000.bin
index 854310c..8ef3392 100755
--- a/allbins/zx297520v3/prj_vehicle/nv_dc_ref/phyWcdmaAmtUser_nvrwo_0x0003A000.bin
+++ b/allbins/zx297520v3/prj_vehicle/nv_dc_ref/phyWcdmaAmtUser_nvrwo_0x0003A000.bin
Binary files differ
diff --git a/ap/app/Script/scripts/wan_ipv4.sh b/ap/app/Script/scripts/wan_ipv4.sh
index 7c0ba39..95b5203 100755
--- a/ap/app/Script/scripts/wan_ipv4.sh
+++ b/ap/app/Script/scripts/wan_ipv4.sh
@@ -116,11 +116,11 @@
 		pswan_secdns=`nv get $wan_if"_secdns"`
 		pswan_nm=`nv get $wan_if"_nm"`
 		
-		#ifconfig $wan_if down 2>>$test_log
-		ifconfig $wan_if $pswan_ip netmask 255.255.255.0 up 2>>$test_log
-		if [ $? -ne 0 ];then
-	        echo "Error: ifconfig $wan_if $pswan_ip up failed." >> $test_log
-        fi
+#		#ifconfig $wan_if down 2>>$test_log
+#		ifconfig $wan_if $pswan_ip netmask 255.255.255.0 up 2>>$test_log
+#		if [ $? -ne 0 ];then
+#	        echo "Error: ifconfig $wan_if $pswan_ip up failed." >> $test_log
+#        fi
 		
 		pswan_pri=`nv get pswan_priority`
 		rt_num=`expr $pswan_pri \* 10 + $c_id`
@@ -296,4 +296,4 @@
 		tc_tbf.sh down $def_cid
 	fi
 	linkdown $2 $3	
-fi
\ No newline at end of file
+fi
diff --git a/ap/app/zte_comm/at_ctl/src/atctrl/at_com.c b/ap/app/zte_comm/at_ctl/src/atctrl/at_com.c
index 116a4b5..7811261 100755
--- a/ap/app/zte_comm/at_ctl/src/atctrl/at_com.c
+++ b/ap/app/zte_comm/at_ctl/src/atctrl/at_com.c
@@ -630,8 +630,11 @@
 		written_bytes = write(fd, pstr, left_len);	

 		if(written_bytes <= 0)

 		{

-			//ºË¼äͨµÀдʧ°Ü£¬ÖØ·¢

-			if(at_chan && at_chan->attribution & (1<<CH_COMM))

+			if(written_bytes == 0){

+				at_print(AT_ERR,"====>at_sys_write written_bytes=0, fd=%d\n", fd);

+				return 0;

+			}

+			else if(at_chan && at_chan->attribution & (1<<CH_COMM))

 			{	

 				if(resendcnt > 10)

 				{

diff --git a/ap/app/zte_comm/zte_mainctrl/netdev_proc.c b/ap/app/zte_comm/zte_mainctrl/netdev_proc.c
index 36ec590..7e853a8 100755
--- a/ap/app/zte_comm/zte_mainctrl/netdev_proc.c
+++ b/ap/app/zte_comm/zte_mainctrl/netdev_proc.c
@@ -686,6 +686,7 @@
 	scriptmsg.cid = cid;
 	scriptmsg.iptype = iptype;
 	char buffer[128] = {0};
+	char nv_value[16] = {0};
 	
 	slog(NET_PRINT, SLOG_NORMAL, "$$$$$net_sendmsg_2_atctl cid=%d,iptype=%d\n", cid, iptype);
 	ret = ipc_send_message(MODULE_ID_MAIN_CTRL, MODULE_ID_AT_CTL, cmd, sizeof(TScriptMSG), &scriptmsg, 0); 
@@ -693,10 +694,18 @@
 		softap_assert("send msg to at_ctl error");		
 	}
 	snprintf(buffer, sizeof(buffer), "pdp_act_state_%d", cid);
-	if(cmd == MSG_CMD_LINKUP_END)
-		sc_cfg_set(buffer, "act");
-	else if(cmd == MSG_CMD_LINKDOWN_END)
-		sc_cfg_set(buffer, "deact");
+	sc_cfg_get(buffer, nv_value, sizeof(nv_value)-1);
+	if(cmd == MSG_CMD_LINKUP_END){
+		if(strcmp(nv_value,"acting") == 0)
+			sc_cfg_set(buffer, "act");
+		else
+			slog(NET_PRINT, SLOG_ERR, "$$$$$net_sendmsg_2_atctl_up 5s=%s\n", buffer, nv_value);
+	}else if(cmd == MSG_CMD_LINKDOWN_END){
+		if(strcmp(nv_value,"deacting") == 0)
+			sc_cfg_set(buffer, "deact");
+		else
+			slog(NET_PRINT, SLOG_ERR, "$$$$$net_sendmsg_2_atctl_down %s=%s\n", buffer, nv_value);
+	}
 }
 
 void pdp_wan_config_quick(struct pdp_active_info *actinfo, char *prefix, int prefix_len)
diff --git a/ap/os/linux/linux-3.4.x/drivers/usb/gadget/android.c b/ap/os/linux/linux-3.4.x/drivers/usb/gadget/android.c
index c6601b5..cb4a4cc 100755
--- a/ap/os/linux/linux-3.4.x/drivers/usb/gadget/android.c
+++ b/ap/os/linux/linux-3.4.x/drivers/usb/gadget/android.c
@@ -3076,7 +3076,12 @@
 {
 	usb_rpmsg_cmd *t_resp = (usb_rpmsg_cmd *)resp;
 	unsigned long flags;
-    struct android_usb_function *func_t;
+	struct android_usb_function *func_t;
+	struct android_usb_function *f;	
+	char *buff = t_resp->param;
+	int n = 0;
+	int max_len = 252;
+	int data_len = 0;	
 	
 	if(!_android_dev){
 		printk("android_set_rpmsg_resp, _android_dev is NULL\n");
@@ -3174,8 +3179,20 @@
 			}			
 			
 			break;
-		//case :
-		//	break;
+		case USB_RPMSG_GET_USB_CURR_CONFIG:
+			
+			t_resp->cmd = USB_RPMSG_GET_USB_CURR_CONFIG;
+			spin_lock_irqsave(&cdev->lock, flags);
+			list_for_each_entry(f, &_android_dev->enabled_functions, enabled_list)
+			{	
+				n = snprintf(buff, (max_len - n), "%s,", f->name);
+				buff += n;
+				data_len += n;
+			}
+			t_resp->param[data_len] = '\0';
+			spin_unlock_irqrestore(&cdev->lock, flags);
+			
+			break;
 		//case :
 		//	break;
 		//case :
diff --git a/ap/os/linux/linux-3.4.x/include/linux/android_notify.h b/ap/os/linux/linux-3.4.x/include/linux/android_notify.h
index 8ac4fe9..c18981d 100755
--- a/ap/os/linux/linux-3.4.x/include/linux/android_notify.h
+++ b/ap/os/linux/linux-3.4.x/include/linux/android_notify.h
@@ -78,6 +78,7 @@
 	USB_RPMSG_GET_USB_STATE,

 	USB_RPMSG_GET_USB_LINK_STATE,

 	USB_RPMSG_GET_USB_ENUM_MODE,

+	USB_RPMSG_GET_USB_CURR_CONFIG,

 	//USB_RPMSG_GET_,

 	//USB_RPMSG_GET_,

 	

diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-fota-backup/files/lynq-fota-backup.cpp b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-fota-backup/files/lynq-fota-backup.cpp
index 84a727b..d91390c 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-fota-backup/files/lynq-fota-backup.cpp
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-fota-backup/files/lynq-fota-backup.cpp
@@ -27,6 +27,7 @@
 extern "C" {

 #endif

 

+#define FOTA_REBOOT_FLAG "/mnt/userdata/.fota_reboot_flag"

 #define FOTA_FLAG_FILE "/mnt/userdata/.back_up_flag"

 #define FOTA_SYNC_FLAG    1

 

@@ -34,6 +35,24 @@
 extern int lynq_fota_get_addr_value(char *tmp_value);

 extern int lynq_fota_set_addr_value(char        *value,int size);

 extern int lynq_fota_nrestart(void);

+#define REBOOT_DONE  1

+

+void set_upgrade_reboot_flag(void)

+{

+    FILE *fp = NULL;

+    int reboot_flag = REBOOT_DONE;

+    fp = fopen(FOTA_REBOOT_FLAG,"w+");

+    if(fp == NULL)

+    {

+        printf("Open reboot flag file failed\n");

+        return;

+    }

+    

+    fwrite(&reboot_flag,sizeof(int),1,fp);

+    fclose(fp);

+    system("sync");

+    return ;

+}

 int main()

 {

     int ret = 0 ;

@@ -48,8 +67,11 @@
         return -1;

 

     }

-    

+   

     fread(&sync_flag,sizeof(int),1,fp);

+    fclose(fp);

+    

+    set_upgrade_reboot_flag();

     

     if(sync_flag == FOTA_SYNC_FLAG)

     {

@@ -57,7 +79,6 @@
         if(ret != 0)

         {

             printf("sync faild\n");

-            fclose(fp);

         }

        system("rm -rf /mnt/userdata/.back_up_flag");

         

@@ -76,7 +97,6 @@
         {

             printf("Set addr failed\n");

             return -1;

-

         }

         ret = lynq_fota_nrestart();

         if(ret != 0)

diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-fota-demo/files/lynq-qser-fota-demo.cpp b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-fota-demo/files/lynq-qser-fota-demo.cpp
index 63c9504..de637ec 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-fota-demo/files/lynq-qser-fota-demo.cpp
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-fota-demo/files/lynq-qser-fota-demo.cpp
@@ -5,14 +5,30 @@
 #include <unistd.h>

 #include <dlfcn.h>

 #include <stdint.h>

+#include <pthread.h>

 

 int (*lynq_get_upgrade_status)(void);

 int (*lynq_fota_set_addr_value)(char *value,int size);

 int (*lynq_fota_nrestart)(void);

 int (*lynq_rock_main)(int first_run);

-

+int (*lynq_read_process)(void);

 void *dlHandle_fota = NULL;

 

+void *thread_function_noreboot(void *arg) 

+{

+

+        lynq_fota_nrestart();

+        return NULL;

+}

+

+void *thread_function_reboot(void *arg) 

+{

+

+        lynq_rock_main(1);

+        return NULL;

+}

+

+

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

 {

     int ret = 0;

@@ -53,6 +69,13 @@
         printf("lynq_rock_main is null\n");

         return -1;

     }

+

+    lynq_read_process = (int (*)(void))dlsym(dlHandle_fota,"lynq_read_process");

+    if(lynq_read_process == NULL)

+    {

+        printf("lynq_read_process is null\n");

+        return -1;

+    }

     

     ret = lynq_fota_set_addr_value(value,(int )strlen(value));

     if(ret != 0)

@@ -60,34 +83,53 @@
         printf("set upgrade package addr failed\n");

         return -1;

     }

-

-    printf("Please chose  reboot or not when upgrade done  1: reboot 0: not reboot\n");

-    scanf("%d",&reboot_flag);

-

-    switch(reboot_flag)

+    while(1)

     {

-        case 0:

-            printf("Not reboot when upgrade done!!!\n ");

-            ret = lynq_fota_nrestart();

-            printf("upgrade result is %d\n",ret);

-            ret = lynq_get_upgrade_status();

-            printf("get upgrade status result is %d\n",ret);

-            break;

+        printf("Please chose action  0:  upgrade done ,not reboot 1: upgrade done ,reboot 2:get upgrade status 3:read fota process \n");

+        scanf("%d",&reboot_flag);

 

-        case 1:

-            printf("Will reboot when upgrade done!!!\n ");

-            ret = lynq_rock_main(1);

-            printf("upgrade result is %d\n",ret);

-            ret = lynq_get_upgrade_status();

-            printf("get upgrade status result is %d\n",ret);

-            break;

+        switch(reboot_flag)

+        {

+            case 0:

+                {

+                    pthread_t thread_id_noreboot;

+                    int result = pthread_create(&thread_id_noreboot, NULL, thread_function_noreboot, NULL);

+                    if (result != 0) 

+                    {

+                        printf("pthread_create failed \n");

+                        return -1;;

+                    }

+                }

+                break;

 

-        default:

-            printf("please input right flag 1 or 0\n");

-            break;

+            case 1:

+                {

+                    pthread_t thread_id_reboot;

+                    int result = pthread_create(&thread_id_reboot, NULL, thread_function_reboot, NULL);

+                    if (result != 0) 

+                    {

+                        printf("pthread_create failed \n");

+                        return -1;;

+                    }

+                }

+                break;

+            case 2:

+                printf("Get fota upgrade status \n");

+                ret = lynq_get_upgrade_status();

+                printf("lynq_get_upgrade_status ret is %d\n",ret);

+                break;

+            case 3:

+                printf("get fota upgrade process\n");

+                ret = lynq_read_process();

+                printf("Now upgrade process is %d\n",ret);

+                break;

+            default:

+                printf("please input right flag 0 or 1 or 2 or 3\n");

+                break;

 

+        }

+         

     }

-    

     return 0;

 

 }

diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-fota-demo/lynq-qser-fota-demo.bb b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-fota-demo/lynq-qser-fota-demo.bb
index d24b8bb..1ce3f8c 100644
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-fota-demo/lynq-qser-fota-demo.bb
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-fota-demo/lynq-qser-fota-demo.bb
@@ -16,7 +16,7 @@
 
 LOCAL_C_INCLUDES = "-I."
 
-LOCAL_LIBS = "-L. -ldl -lstdc++"
+LOCAL_LIBS = "-L. -ldl -lstdc++ -lpthread"
 
 #INHIBIT_PACKAGE_STRIP = "1"
 S = "${WORKDIR}"
diff --git a/cap/zx297520v3/sources/meta-zxic-selinux/recipes-security/refpolicy/files/policy-mls/policy/modules/system/logging.te b/cap/zx297520v3/sources/meta-zxic-selinux/recipes-security/refpolicy/files/policy-mls/policy/modules/system/logging.te
old mode 100755
new mode 100644
index 2672b4a..fe01295
--- a/cap/zx297520v3/sources/meta-zxic-selinux/recipes-security/refpolicy/files/policy-mls/policy/modules/system/logging.te
+++ b/cap/zx297520v3/sources/meta-zxic-selinux/recipes-security/refpolicy/files/policy-mls/policy/modules/system/logging.te
@@ -526,7 +526,7 @@
 	# for systemd-journal
 	allow syslogd_t self:netlink_audit_socket connected_socket_perms;
 	allow syslogd_t self:capability2 audit_read;
-	allow syslogd_t self:capability { chown setgid setuid sys_ptrace dac_read_search };
+	allow syslogd_t self:capability { chown setgid setuid sys_ptrace dac_read_search sys_rawio };
 	allow syslogd_t self:netlink_audit_socket { getattr getopt read setopt write nlmsg_write };
 
 	# remove /run/log/journal when switching to permanent storage
@@ -671,6 +671,7 @@
 allow syslogd_t mnt_t:dir { search };
 allow syslogd_t tmpfs_t:dir { write add_name remove_name search };
 
+allow syslogd_t self:capability { sys_rawio };
 
 
 
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-fota/include/lynq-qser-fota.h b/cap/zx297520v3/src/lynq/lib/liblynq-qser-fota/include/lynq-qser-fota.h
index 34be9aa..2a8cfd6 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-fota/include/lynq-qser-fota.h
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-fota/include/lynq-qser-fota.h
@@ -18,6 +18,7 @@
 int lynq_fota_set_addr_value(char        *value,int size);

 int lynq_fota_nrestart(void);

 int lynq_rock_main(int first_run);

+int lynq_read_process(void);

 

 #ifdef __cplusplus

 }

diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-fota/lynq-qser-fota.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-qser-fota/lynq-qser-fota.cpp
index 53ee3c8..5dab391 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-fota/lynq-qser-fota.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-fota/lynq-qser-fota.cpp
@@ -28,12 +28,13 @@
 #include "include/lynq-qser-fota.h"

 #include "liblog/lynq_deflog.h"

 

-#define FOTA_FLAG_FILE "/mnt/userdata/.back_up_flag"

 

+#define FOTA_REBOOT_FLAG "/mnt/userdata/.fota_reboot_flag"

+#define FOTA_FLAG_FILE "/mnt/userdata/.back_up_flag"

 #define USER_LOG_TAG    "LYNQ_FOTA"

 #define FOTA_ADDR_FILE  "/mnt/userdata/.addr_value"

 #define FOTA_FILE_NAME  "upgrade.package"

-

+#define FOTA_UPGRADE_PROCESS  "/mnt/userdata/.fota_upgrade_process"

 #define  SYSTEM_A  "34650"

 #define  SYSTEM_B  "39019"

 

@@ -49,6 +50,18 @@
 #define    LYNQ_UPGRADE_STATUS_UPDATE_SUCCESS      (4)

 #define    LYNQ_UPGRADE_STATUS_UPDATE_FAIL         (5)

 

+#define    LYNQ_SYNNCHRONIZING  8

+#define    LYNQ_SYNC_SUCCESS    9

+#define    LYNQ_SYNC_FAILED    -1

+

+#define    ZXIC_SYNCHRONIZING    1

+#define    ZXIC_SYNC_SUCCESS      0

+

+#define    NO_REBOOT    0

+

+

+int total_size = 0;

+int upgrade_size = 0;

 

 typedef struct

 {

@@ -122,6 +135,7 @@
     int ret = 0;

     int current_slot = 0;

     int fota_sync_flag = 0;

+    int reboot_flg = NO_REBOOT;

     FILE *fp = NULL;

     fp = fopen(FOTA_FLAG_FILE,"w+");

     if(fp == NULL)

@@ -134,6 +148,17 @@
 

     /* T106BUG-189 fix */

     system("sync");

+

+    fp =fopen(FOTA_REBOOT_FLAG,"w+");

+    if(fp == NULL)

+    {

+        LYERRLOG("Creaf get upgrade status flag failed");

+        return -1;

+    }

+

+    fwrite(&reboot_flg,sizeof(int),1,fp);

+    fclose(fp);

+    system("sync");

     

     ret = lynq_fota_verify();

     if(ret != 0)

@@ -233,7 +258,20 @@
     LYINFLOG("Total size:%d ", p_status->total_size);

 

     LYINFLOG("Updated size:%d ", p_status->upgraded_size);

-    return ;

+

+    total_size = p_status->total_size;

+    upgrade_size = p_status->upgraded_size;

+

+    FILE *fp = NULL;

+    fp = fopen(FOTA_UPGRADE_PROCESS,"w");

+    if (fp == NULL) 

+    {

+        LYERRLOG("Error opening file");

+        return;

+    }

+    

+    fprintf(fp, "%d,%d\n", total_size, upgrade_size);

+    fclose(fp);

 }

 

 /*****************************************

@@ -528,21 +566,59 @@
 {

     z_upgrade_status_info_t status;

     int ret = 0;

-

-    

-    ret = zxic_dual_get_upgrade_status(&status);

-    if(ret  < 0)

+    int reboot_flag = -1;

+    FILE *fp = NULL;

+    fp = fopen(FOTA_REBOOT_FLAG,"r");

+    if(fp == NULL)

     {

-        LYINFLOG("Get upgrade status fail! ");

+        LYERRLOG("Open reboot flag file failed");

         return -1;

     }

+    

+    fread(&reboot_flag,sizeof(int),1,fp);

+    fclose(fp);

+    

+    //get upgrade status before no reboot

+    if(reboot_flag == NO_REBOOT)

+    {

+    

+        ret = zxic_dual_get_upgrade_status(&status);

+        if(ret  < 0)

+        {

+            LYERRLOG("Get upgrade status fail! ");

+            return -1;

+        }

      

-    LYINFLOG("Current upgrade info: ");

-    LYINFLOG("Current upgrade status:%d ", status.upgrade_status);

-    LYINFLOG("Current upgrade total size:%d ", status.total_size);

-    LYINFLOG("Current upgrade updated size:%d ", status.upgraded_size);

-

-    return status.upgrade_status;

+        LYINFLOG("Current upgrade info: ");

+        LYINFLOG("Current upgrade status:%d ", status.upgrade_status);

+        LYINFLOG("Current upgrade total size:%d ", status.total_size);

+        LYINFLOG("Current upgrade updated size:%d ", status.upgraded_size);

+                           

+        return status.upgrade_status;

+    }

+    else

+    {

+        //get sync status 

+        int fota_sync_tatus = 0;

+        fota_sync_tatus = lynq_get_sync_status();

+        if(fota_sync_tatus == ZXIC_SYNCHRONIZING)

+        {

+            LYINFLOG("Now fota upgrade sync status is synchronizing");

+            return LYNQ_SYNNCHRONIZING;

+        }

+        else if(fota_sync_tatus == ZXIC_SYNC_SUCCESS)

+        {

+            LYINFLOG("Now fota upgrade sync status sync success ");

+            return LYNQ_SYNC_SUCCESS;

+        }        

+        else if(fota_sync_tatus == LYNQ_SYNC_FAILED)

+        {

+            LYERRLOG("Now fota upgrade sync status sync failed ");

+            return LYNQ_SYNC_FAILED;

+        }

+        

+        

+    }

 

 }

 

@@ -753,7 +829,7 @@
     int sync_status = -2;

     zxic_dual_get_sync_status(&sync_status);

     LYINFLOG("Current sync status is %d", sync_status);

-    return 0;

+    return sync_status;

 }

 

 /*****************************************

@@ -785,6 +861,67 @@
     return 0;

 }

 

+/*****************************************

+* @brief:lynq_read_process

+* @param count [IN]:NS

+* @param sum [OUT]:NA

+* @return :fota upgrade process 0-10

+* @todo:NA

+* @see:NA

+* @warning:NA

+*****************************************/

+int lynq_read_process(void)

+{

+    LYINFLOG("Enter lynq_read_process");

+    

+    float fota_process = 0;

+    int ration = 0;

+    int read_count = 0;

+    FILE *fp = NULL;

+    

+    while(1)

+    {

+        

+        fp = fopen(FOTA_UPGRADE_PROCESS, "r");

+        if(fp == NULL)

+        {

+            LYERRLOG("lynq_read_process open file failed");

+            usleep(10000);

+            read_count++;

+            if(read_count > 5)

+            {

+                break;

+            }

+        }

+        else

+        {

+            break;

+        }

+    }

+    

+    if(fp != NULL) 

+    {

+        

+        char line[256] = {0};

+        if (fgets(line, sizeof(line), fp) != NULL) 

+        {

+            sscanf(line, "%d,%d", &total_size, &upgrade_size);

+        }

+        fclose(fp);

+    }

+    

+    

+    if(total_size != 0 && upgrade_size <= total_size)

+    {

+        LYINFLOG("Caculate fota process ration ");

+        fota_process =  (float) upgrade_size / total_size;

+     }

+     

+     ration = (int)(fota_process * 10);

+     LYINFLOG("Fota process ration is %d",ration);

+     return ration;

+}

+

 DEFINE_LYNQ_LIB_LOG(LYNQ_FOTA)

 

 #ifdef __cplusplus

diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/net/ethernet/zte/zx29_gmac.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/net/ethernet/zte/zx29_gmac.c
old mode 100755
new mode 100644
index b344482..a4d3372
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/net/ethernet/zte/zx29_gmac.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/net/ethernet/zte/zx29_gmac.c
@@ -1391,11 +1391,174 @@
 }

 /*jb.qi add for gamc power down on 20231116 end */

 

+/*zw.wang add for switching the primary/secondary mode of gmac on 20240118 start*/

+int mode_type = -1;

+

+ssize_t gmac_master_or_slave_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count)

+{

+	struct platform_device *pdev	= to_platform_device(dev);

+	struct net_device 	*ndev		= platform_get_drvdata(pdev);

+	struct zx29_gmac_dev *priv = (struct zx29_gmac_dev *)netdev_priv(ndev);

+	int mmd = 0;

+	int reg = 0;

+	int val = 0;

+	int ret;

+

+	///read mode_type

+	ret = sscanf(buf, "%d", &mode_type);

+	if (ret < 1) {

+		printk(KERN_ERR "Please enter the number 0-3 to enable the corresponding mode \n"

+				"Enter values in the non-0-3 range to get pattern description \n");

+		return count;

+	}

+

+	///Judgment model

+	if (mode_type < 0 || mode_type > 3) {

+		printk(KERN_DEBUG "Please enter the number range 0-3\n"

+				"0: Set the slave mode \n"

+				"1: Set the main mode \n"

+				"2: indicates setting SQI value view mode \n"

+				"3: Set the VCT value view mode \n"

+				"After the mode is set, the corresponding value can be obtained\n");

+		return ret ? ret : count;

+	}

+

+	///Set the Ethernet slave mode

+	if (mode_type == 0) {

+		mmd = 0x1;

+		reg = 0x834;

+		mdiobus_write(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0d, mmd);

+		mdiobus_write(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0e, reg);

+		mdiobus_write(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0d, 0x4000 | mmd);

+		val = mdiobus_read(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0e);

+

+		mdiobus_write(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0d, mmd);

+		mdiobus_write(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0e, reg);

+		mdiobus_write(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0d, 0x4000 | mmd);

+		mdiobus_write(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0e, val & (~BIT(14)));

+	}

+	///Set the Ethernet master mode

+	else if (mode_type == 1) {

+		mmd = 0x1;

+		reg = 0x834;

+		mdiobus_write(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0d, mmd);

+		mdiobus_write(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0e, reg);

+		mdiobus_write(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0d, 0x4000 | mmd);

+		val = mdiobus_read(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0e);

+

+		mdiobus_write(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0d, mmd);

+		mdiobus_write(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0e, reg);

+		mdiobus_write(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0d, 0x4000 | mmd);

+		mdiobus_write(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0e, val | BIT(14));

+	}

+	return count;

+}

+

+ssize_t gmac_master_or_slave_show(struct device *dev, struct device_attribute *attr, char *buf)

+{

+	struct platform_device *pdev	= to_platform_device(dev);

+	struct net_device 	*ndev		= platform_get_drvdata(pdev);

+	struct zx29_gmac_dev *priv = (struct zx29_gmac_dev *)netdev_priv(ndev);

+	int mmd = 0;

+	int reg = 0;

+	int val = 0;

+	int len = 0;

+	int ret;

+

+	///Read the network master/slave

+	if (mode_type == 0 || mode_type == 1) {

+		mmd = 0x1;

+		reg = 0x834;

+		mdiobus_write(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0d, mmd);

+		mdiobus_write(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0e, reg);

+		mdiobus_write(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0d, 0x4000 | mmd);

+		val = mdiobus_read(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0e) & BIT(14);

+		if(val)

+			memcpy(buf, "Master\n",7);

+		else

+			memcpy(buf, "Slave\n", 6);

+

+		printk(KERN_DEBUG "mode_type %d - gmac_master_or_slave is %s\n", mode_type, buf);

+

+	}

+	///Obtain the cable quality SQI value

+	else if(mode_type == 2){

+		mmd = 0x1;

+		reg = 0x8B10;

+		mdiobus_write(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0d, mmd);

+		mdiobus_write(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0e, reg);

+		mdiobus_write(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0d, 0x4000 | mmd);

+		val = mdiobus_read(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0e);

+		sprintf(buf, "0x%x\n", val);

+		sprintf(buf, "SQI : 0x%x\n", val);

+		printk(KERN_DEBUG "mode_type %d - SQI is 0x%x", mode_type, val);

+

+	}

+	///Obtain short circuit, open circuit and normal connection of VCT

+	else if(mode_type == 3){

+		///--TDR Enable

+		mmd = 0x1;

+		reg = 0x8B00;

+		mdiobus_write(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0d, mmd);

+		mdiobus_write(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0e, reg);

+		mdiobus_write(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0d, 0x4000 | mmd);

+		mdiobus_write(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0e, BIT(14) | BIT(12));

+

+		///--Read VCT

+		mmd = 0x1;

+		reg = 0x8B02;

+		mdiobus_write(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0d, mmd);

+		mdiobus_write(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0e, reg);

+		mdiobus_write(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0d, 0x4000 | mmd);

+		val = mdiobus_read(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0e);

+		printk(KERN_DEBUG "Open status: %s - Short status: %s\n",

+		 (val & BIT(0)) ? "Open" : "Normal",  (val & BIT(1)) ? "Short" : "Normal");

+		sprintf(buf, "Open status: %s\nShort status: %s\n",

+		 (val & BIT(0)) ? "Open" : "Normal",  (val & BIT(1)) ? "Short" : "Normal");

+		reg = 0x8B01;

+		mdiobus_write(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0d, mmd);

+		mdiobus_write(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0e, reg);

+		mdiobus_write(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0d, 0x4000 | mmd);

+		val = mdiobus_read(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0e);

+		sprintf(buf, "%sDistance status: 0x%x\n", buf, val);

+		printk(KERN_DEBUG "mode_type %d - Distance status is 0x%x\n", mode_type, val);

+

+		///--TDR Disable

+		mmd = 0x1;

+		reg = 0x8B00;

+		mdiobus_write(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0d, mmd);

+		mdiobus_write(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0e, reg);

+		mdiobus_write(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0d, 0x4000 | mmd);

+		mdiobus_write(priv->phydev->mdio.bus, priv->phydev->mdio.addr, 0x0e, 0);

+

+	}

+	///Get model help information

+	else{

+		sprintf(buf, "Please enter the number range 0-3\n"

+				"0: Set the slave mode \n"

+				"1: Set the main mode \n"

+				"2: indicates setting SQI value view mode \n"

+				"3: Set the VCT value view mode \n"

+				"After the mode is set, the corresponding value can be obtained\n");

+		printk(KERN_DEBUG "Please enter the number range 0-3\n"

+				"0: Set the slave mode \n"

+				"1: Set the main mode \n"

+				"2: indicates setting SQI value view mode \n"

+				"3: Set the VCT value view mode \n"

+				"After the mode is set, the corresponding value can be obtained\n");

+	}

+	return strlen(buf);

+

+}

+

+/*zw.wang add for switching the primary/secondary mode of gmac on 20240118 end */

+

 static DEVICE_ATTR(gmac_test, 0664, show_fun, store_fun);
 static DEVICE_ATTR(mdio_test, 0664, mdio_show, mdio_store);

 static DEVICE_ATTR(free_mdio, 0664, free_mdio_show, free_mdio_store);

 static DEVICE_ATTR(debug_on, 0664, debug_on_show, debug_on_store);

 static DEVICE_ATTR(gmac_power, 0664, gmac_power_show, gmac_power_store);//jb.qi add for gamc power down on 20231116

+static DEVICE_ATTR(gmac_master_or_slave, 0664, gmac_master_or_slave_show, gmac_master_or_slave_store);//zw.wang add for switching the primary/secondary mode of gmac on 20240118

 

 static int zx29_gmac_probe(struct platform_device *pdev)

 {

@@ -1423,6 +1586,7 @@
 	device_create_file(&pdev->dev, &dev_attr_free_mdio);

 	device_create_file(&pdev->dev, &dev_attr_debug_on);

     device_create_file(&pdev->dev, &dev_attr_gmac_power);//jb.qi add for gamc power down on 20231116

+	device_create_file(&pdev->dev, &dev_attr_gmac_master_or_slave);//zw.wang add for switching the primary/secondary mode of gmac on 20240118

 

 	prv = netdev_priv(ndev);

 	memset(prv, 0, sizeof(*prv));

@@ -1668,6 +1832,7 @@
 	    device_remove_file(&pdev->dev, &dev_attr_free_mdio);

 	    device_remove_file(&pdev->dev, &dev_attr_debug_on);

         device_remove_file(&pdev->dev, &dev_attr_gmac_power);//jb.qi add for gamc power down on 20231116

+		device_remove_file(&pdev->dev, &dev_attr_gmac_master_or_slave);//zw.wang add for switching the primary/secondary mode of gmac on 20240118

 	}

 	return 0;

 }

diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/usb/gadget/usb_netlink.c b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/usb/gadget/usb_netlink.c
index ad17fd7..4be86bd 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/usb/gadget/usb_netlink.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/drivers/usb/gadget/usb_netlink.c
@@ -56,6 +56,7 @@
 #define USB_SPEED_TYPE   "usb_speed"

 

 #define USB_SWITCH_MODE   "switch_mode"

+#define USB_CURR_CONFIG   "currcfg"

 #define USB_DL_OPEN   "dl_open"

 

 #define NET_NAME           "netname"

@@ -163,6 +164,11 @@
 		.name = "dl_open",

 		.mode = S_IRUGO|S_IWUSR,

 };

+static struct attribute usb_currcfg_attr =

+{

+		.name = "currcfg",

+		.mode = S_IRUGO|S_IWUSR,

+};

 

 static struct attribute *usb_status_attrs[] =

 {

@@ -177,6 +183,7 @@
 	&usb_adb_switch_attr,

 	&usb_switch_mode_attr,

 	&usb_dl_open_attr,

+	&usb_currcfg_attr,

        NULL,

 };

 

@@ -259,7 +266,8 @@
 	int dc=0;

 	int ret = 0;

 	if(usbnetlink_ws){

-		__pm_wakeup_event(usbnetlink_ws, 3000);

+		//__pm_wakeup_event(usbnetlink_ws, 3000);

+		__pm_stay_awake(usbnetlink_ws);

 	}	

 	  if(!strcmp(attr->name, USB_STATE)){	  	

             //printk("\n[usb_netlink:%s-%d]:plug_state\n",__func__,__LINE__);

@@ -325,6 +333,20 @@
 				goto done;

 			}				

 	  		sprintf(buf, "%s\n",usb_get_resp_data());	  

+	  }else if(!strcmp(attr->name, USB_CURR_CONFIG)){

+			usb_rpmsg_config_cmd(USB_RPMSG_GET_USB_CURR_CONFIG, NULL, 0);

+			usb_schedule_work();

+			ret = wait_event_interruptible(usb_netlink_wq, atomic_read(&resp_done));

+			if (ret < 0 ) {            

+				sprintf(buf, "%s\n", "got fail \n");

+				goto done;

+			}

+			if(usb_get_resp_type() != USB_RPMSG_GET_USB_CURR_CONFIG){

+				printk("GET_USB_CURR_CONFIG invalid resp type\n");           

+				sprintf(buf, "%s\n",  "got fail \n");

+				goto done;

+			}				

+	  		sprintf(buf, "%s\n",usb_get_resp_data());	  

 	  }else if(!strcmp(attr->name, RAMDUMP_FLAG)){

 	  		sprintf(buf, "%d\n",ramdump_flag);

 	  }else if(!strcmp(attr->name, HOT_PLUG)){

@@ -345,6 +367,11 @@
  done:    

  	atomic_set(&resp_done,0);

 	usb_clean_mem();

+

+	if(usbnetlink_ws){

+		//__pm_wakeup_event(usbnetlink_ws, 3000);

+		__pm_relax(usbnetlink_ws);

+	}		

 	return strlen(buf);

 }

 

diff --git a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/include/linux/android_notify.h b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/include/linux/android_notify.h
index a95eb06..4e2a0ed 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/include/linux/android_notify.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/linux-5.10/include/linux/android_notify.h
@@ -67,6 +67,7 @@
 	USB_RPMSG_GET_USB_STATE,
 	USB_RPMSG_GET_USB_LINK_STATE,

 	USB_RPMSG_GET_USB_ENUM_MODE,

+	USB_RPMSG_GET_USB_CURR_CONFIG,

 	USB_RPMSG_CMD_MAX,
 	USB_RPMSG_NOTIFY_ADB_TO_AP,

 	USB_RPMSG_NOTIFY_ADB_TO_CAP,

diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/dhcp6/dhcp6s.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/dhcp6/dhcp6s.c
index c4d4b16..db6a967 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/dhcp6/dhcp6s.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/platform/dhcp6/dhcp6s.c
@@ -355,11 +355,11 @@
 		exit(1);
 	}
 	if (num_device != 0) {
-		{
+		/*{
 			char tmp_buf[128] = {0};
 			snprintf(tmp_buf, sizeof(tmp_buf),"nv set %s_dhcp6s_pid=%d", device[0], getpid());
 			system(tmp_buf);
-		}
+		}*/
 		for (i = 0; i < num_device; i++) {
 			ifidx[i] = if_nametoindex(device[i]);
 			if (ifidx[i] == 0) {
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_usb.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_usb.c
index 6a1bd73..8970498 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_usb.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_usb.c
@@ -19,6 +19,7 @@
 #include "sc_usb.h"
 //#include "nv_api.h"
 
+#define BUFF_LEN   256
 
 /*¶ÁдÎļþÏà¹Ø²Ù×÷begin*/
 static int filelength(FILE *fp)
@@ -178,5 +179,43 @@
 	sc_usb_set_netcardtype(USB_NET_ECM);
 }
 
+int sc_usb_usermode_net_state(void)
+{
+	char curr_cfg[BUFF_LEN] = {0};
+	int ret = 0;
+	memset(curr_cfg, 0, BUFF_LEN);
+	ret = readfile(USB_ATTR_CURRCFG, curr_cfg, BUFF_LEN);
+	if(ret < 0){
+		printf("sc_usb_usermode_adb_state fail\n");
+		goto END;
+	}
+	ret = 0;
+	
+	if(strstr(curr_cfg, "rndis")  || strstr(curr_cfg, "ecm"))
+		return 1;
+	
+END:
+	return ret;
+}
 
 
+int  sc_usb_usermode_adb_state(void)
+{
+	
+	char curr_cfg[BUFF_LEN] = {0};
+	int ret = 0;
+	memset(curr_cfg, 0, BUFF_LEN);
+	ret = readfile(USB_ATTR_CURRCFG, curr_cfg, BUFF_LEN);
+	if(ret < 0){
+		printf("sc_usb_usermode_adb_state fail\n");
+		goto END;
+	}
+	ret = 0;
+	
+	if(strstr(curr_cfg, "adb"))
+		return 1;
+	
+END:
+	return ret;
+}
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_usb.c.orig b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_usb.c.orig
new file mode 100644
index 0000000..6a1bd73
--- /dev/null
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_usb.c.orig
@@ -0,0 +1,182 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include <errno.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <string.h>
+#include <unistd.h>
+
+//add for cmux
+#include <sys/socket.h>
+#include <linux/if.h>
+#include <linux/gsmmux.h>
+#include <linux/netlink.h>
+#include <poll.h>
+#include <linux/serial.h>
+#include <termios.h>
+#include "sc_usb.h"
+//#include "nv_api.h"
+
+
+/*¶ÁдÎļþÏà¹Ø²Ù×÷begin*/
+static int filelength(FILE *fp)
+{
+    int num;
+    fseek(fp,0,SEEK_END);
+    num=ftell(fp);
+    fseek(fp,0,SEEK_SET);
+    return num;
+}
+
+int readfile(char *path, char* buf, unsigned len)
+{
+    FILE *fp;
+    unsigned int length;
+    if((fp=fopen(path,"r"))==NULL)
+    {
+        //slog(USBCFGMNG_PRINT,SLOG_ERR, "[usbCfgMng] open file %s error.\n",path);
+        return -1;
+    }
+    length=filelength(fp);
+    length = length > len? len: length;
+    //ch=(char *)malloc(length+1);
+    int read_len = fread(buf,length,1,fp);
+    if(read_len < 1)  // cov M CHECKED_RETURN
+    {
+        //slog(SDCARD_PRINT, SLOG_ERR, "fread %s error.\n",path); 
+    }
+	
+    fclose(fp);
+    *(buf+length) = '\0';
+    return (int)length;
+}
+
+
+
+int writefile(char*path, char*buf, unsigned len)
+{
+    FILE *fp;
+    int rtv = 0;
+    if((fp=fopen(path,"w"))==NULL)
+    {
+        return -1;
+    }
+    rtv = fwrite(buf,len,1, fp);
+    fclose(fp);
+    return rtv;
+}
+
+
+void sc_usb_dl_open(void)
+{
+	writefile(USB_ATTR_DL_OPEN, "1", 1);
+}
+
+void sc_usb_dl_close(void)
+{
+	writefile(USB_ATTR_DL_OPEN, "0", 1);
+}
+
+int sc_usb_get_mode(char* buf, int len)
+{
+	int ret = 0;
+	ret = readfile(USB_ATTR_SWITCH_MODE, buf, len);
+	return ret;
+}
+
+int sc_usb_switch_mode(char *type)
+{
+	int ret = 0;
+	
+	ret = writefile(USB_ATTR_SWITCH_MODE, type, strlen(type));
+	return ret;
+}
+
+void sc_usb_set_usermode(void)
+{
+	sc_usb_switch_mode("1");
+}
+
+void sc_usb_user_closedl(void)
+{
+	sc_usb_dl_close();
+	sc_usb_switch_mode("1");
+}
+
+void sc_usb_set_debugmode(void)
+{
+	sc_usb_switch_mode("0");
+
+}
+
+void sc_usb_debug_opendl(void)
+{
+	sc_usb_dl_open();
+	sc_usb_switch_mode("0");
+
+}
+void sc_usb_set_amtmode(void)
+{
+	sc_usb_switch_mode("3");
+}
+
+void sc_usb_set_factorymode(void)
+{
+	sc_usb_switch_mode("2");
+}
+
+void sc_usb_set_eyemode(void)
+{
+	sc_usb_switch_mode("4");
+}
+
+
+int sc_usb_get_usbstate(char* buf, int len)
+{
+	int ret = 0;
+	ret = readfile(USB_ATTR_USB_STATE, buf, len);
+	return ret;
+}
+
+int sc_usb_get_usb_speed(char* buf, int len)
+{
+	int ret = 0;
+	ret = readfile(USB_ATTR_SPEED, buf, len);
+	return ret;
+}
+
+
+int sc_usb_get_netname(char* buf, int len)
+{
+	int ret = 0;
+	ret = readfile(USB_ATTR_NETNAME, buf, len);
+	return ret;
+}
+
+
+int sc_usb_set_netcardtype(e_usb_net_type type)
+{
+	int ret = 0;
+	if(type == USB_NET_RNDIS)
+		ret = writefile(USB_ATTR_FORCENET, "0", 1);
+	else
+		ret = writefile(USB_ATTR_FORCENET, "1", 1);
+	return ret;
+}
+
+void sc_usb_set_net_rndis(void)
+{
+	//nv_set_item(NV_RO, STR_FORCE_NETCARD_TYPE, "force_rndis", 1);
+	sc_usb_set_netcardtype(USB_NET_RNDIS);
+}
+
+void sc_usb_set_net_ecm(void)
+{
+	//nv_set_item(NV_RO, STR_FORCE_NETCARD_TYPE, "force_ecm", 1);
+	sc_usb_set_netcardtype(USB_NET_ECM);
+}
+
+
+
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_usb.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_usb.h
index 32820a3..d24f750 100644
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_usb.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/libbsp/sc_usb.h
@@ -28,7 +28,8 @@
 #define USB_ATTR_NETNAME           "/sys/gen_usb/usb_state/netname"

 #define USB_ATTR_FORCENET          "/sys/gen_usb/usb_state/forcenet"

 #define USB_ATTR_SIMULATE_PLUG     "/sys/gen_usb/usb_state/usb_simulate_plug"

-#define USB_ATTR_BOOT_MODE         "/sys/gen_usb/usb_state/boot_mode"    

+#define USB_ATTR_BOOT_MODE         "/sys/gen_usb/usb_state/boot_mode"  

+#define USB_ATTR_CURRCFG           "/sys/gen_usb/usb_state/currcfg"  

 #define STR_FORCE_NETCARD_TYPE           "forcenetcard_type" 

 

 #define USB_ATTR_FAST_POWEROFF     "/sys/gen_usb/usb_state/fast_poweroff"

@@ -128,6 +129,8 @@
 

 
 void sc_usb_set_net_ecm(void);

+int  sc_usb_usermode_net_state(void);

+int  sc_usb_usermode_adb_state(void);

 

 

 

diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_mm.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_mm.c
index 8400938..04ce391 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_mm.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_mm.c
@@ -62,9 +62,6 @@
 static int sCSQ[2] = { 99, 99 };

 static int sys_mode = 0;/*LTE*/

 

-static int airPlaneMode = 0;

-

-

 static uint64_t ref_ril_nano_time(void)

 {

 	struct timespec now;

@@ -257,6 +254,10 @@
 	setRadioState(RADIO_STATE_OFF);

 }

 

+void resetRadioStateOff(void)

+{

+    setRadioStateOff();

+}

 

 static void reportRadioTech(RIL_Token t)

 {

@@ -1016,7 +1017,6 @@
 	if ((err < 0 || response->success == 0) && (isRadioOn() != 1)) {

 		goto error;

 	}

-	airPlaneMode = 0;

 	updateRadioState();

 	ril_request_open_zsqr_notify();

 

@@ -1856,33 +1856,27 @@
 	RIL_RadioState  currentState = getRadioState();

 

 	RLOGD("ril_request_radio_power(): onOff=%d, currentState=%d", onOff, currentState);

-	if ((onOff == 4) && (currentState != RADIO_STATE_OFF)) {

+	if ( onOff == 4 ) {

 		RLOGD("onOff=%d, currentState=%d   --> AT+CFUN=4", onOff, currentState);

 		err = at_send_command_timeout("AT+CFUN=4", &response, TIMEOUT_CFUN);

 		DO_MM_RESPONSE_ERROR_JDUGE;

 		setRadioStateOff();

-		airPlaneMode = 1;

-	} else if ((onOff == 0) && (currentState != RADIO_STATE_OFF)) {

+	} else if ( onOff == 0 ) {

 		RLOGD("onOff=%d, currentState=%d   --> AT+CFUN=4", onOff, currentState);

 		err = at_send_command_timeout("AT+CFUN=4", &response, TIMEOUT_CFUN);

 		DO_MM_RESPONSE_ERROR_JDUGE;

 		//err = at_send_command("AT^ZPOWEROFF", NULL); //poweroff

-		airPlaneMode = 1;

 		setRadioStateOff();

-	} else if (((onOff == 1) && (currentState == RADIO_STATE_OFF)) || (currentState == RADIO_STATE_UNAVAILABLE) || (currentState == RADIO_STATE_SIM_READY)) {

+	} else if (onOff == 1) {

 		RLOGD("onOff=%d, currentState=%d   --> AT+CFUN=1", onOff, currentState);

 		err = at_send_command_timeout("AT+CFUN=1", &response, TIMEOUT_CFUN);

 		if ((err < 0 || response->success == 0) && (isRadioOn() != 1)) {

 			goto error;

 		}

-		airPlaneMode = 0;

 		updateRadioState();

 		ril_request_open_zsqr_notify();

-	} else if ((onOff == 4) && (airPlaneMode == 1)) {

-		RLOGD("onOff=%d, airPlaneMode=%d   --> AT^ZPOWEROFF", onOff, airPlaneMode);

-		at_send_command("AT^ZPOWEROFF", NULL);

-		setRadioStateOff();

-	}

+	} 

+

 	RIL_onRequestComplete(token, RIL_E_SUCCESS, NULL, 0);

 	goto exit;

 error:

diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_ref.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_ref.c
index 64eecd2..43b4347 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_ref.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_ref.c
@@ -248,7 +248,17 @@
 
 RIL_RadioState getRadioState(void)
 {
-	return sState;
+    int radioState = -1;
+    
+    radioState = isRadioOn();
+    
+    if(1 == radioState) {    
+        updateRadioState();    
+    } 
+    else if((0 == radioState) || (4 == radioState)) {
+        resetRadioStateOff();    
+    }
+    return sState;
 }
 
 /** returns 1 if on, 0 if off, and -1 on error */
diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_ref.h b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_ref.h
index 0b985a2..8b12387 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_ref.h
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/sdk/ril/reference-ril/ril_ref.h
@@ -177,6 +177,7 @@
 void requestSendUSSD(void *data, size_t datalen, RIL_Token t);

 void requestCancelUSSD(void *data, size_t datalen, RIL_Token t);

 void requestDeviceIdentity(void *data, size_t datalen, RIL_Token t);

+void resetRadioStateOff(void);

 

 /*ril_sim.c*/

 void ril_handle_sim_pin_puk(int request, void *data, size_t datalen, RIL_Token token);

diff --git a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/usbtest/usbtest.c b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/usbtest/usbtest.c
index 998ee5d..6955ce8 100755
--- a/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/usbtest/usbtest.c
+++ b/cap/zx297520v3/zxic_code/zxic_source/zxic_app_open/test/usbtest/usbtest.c
@@ -408,6 +408,39 @@
 	printf("do_set_netcardtype test fail\n");

 	

 }

+

+

+void do_get_adb_state(int nargs, char **argv)

+{

+	

+	int ret = 0;

+	

+	ret = sc_usb_usermode_adb_state();

+	if(ret < 0){

+		printf("get adb state fail,ret:%d \n", ret);

+		return;

+	}

+	

+	printf("adb state:%d, %s\n", ret, ((ret == 0) ? "off" : "on"));

+	

+}

+

+void do_get_net_state(int nargs, char **argv)

+{

+	

+	int ret = 0;

+	

+	ret = sc_usb_usermode_net_state();

+	if(ret < 0){

+		printf("get net state fail,ret:%d \n", ret);

+		return;

+	}

+	

+	printf("net state:%d, %s\n", ret, ((ret == 0) ? "off" : "on"));

+	

+}

+

+

 void do_monitor_usb_plug(int nargs, char **argv)

 {

 	int ret;
@@ -477,6 +510,16 @@
 		"monitor usb plug in/plug out",

 	  NULL, NULL, 0

 	},

+	{ do_get_adb_state, -0, 

+		"get_adb_state","\n"

+		"get adb state.",

+	  NULL, NULL, 0

+	},

+	{ do_get_net_state, -0, 

+		"get_net_state","\n"

+		"get net state.",

+	  NULL, NULL, 0

+	},

 	{ 0, 0, 0, 0, NULL, NULL, 0 }

 };

 

diff --git a/mk_T106.sh b/mk_T106.sh
index 6a218cc..2a53128 100644
--- a/mk_T106.sh
+++ b/mk_T106.sh
@@ -1,7 +1,11 @@
 #!/bin/bash
 TOP=$(pwd)
 source update_version.sh
-
+mkdir esdk_patch/Uboot
+cp -R boot/ build/ cp/ pub/ rpm/ tools/ esdk_patch/Uboot/
+cd esdk_patch
+tar -czvf Uboot.tar.gz Uboot
+cd ${TOP}
 cd ap/project/zx297520v3/prj_vehicle_dc_ref/build/
 make allclean all
 cd ../../../../..
@@ -29,6 +33,7 @@
 tar -czvf upstream.tar.gz upstream
 mkdir do_package_tool
 cd ${TOP}
+cp esdk_patch/Uboot.tar.gz allbins cap/zx297520v3/build-vehicle_dc_ref/tmp/deploy/sdk/
 cp -R allbins cap/zx297520v3/build-vehicle_dc_ref/tmp/deploy/sdk/do_package_tool/
 cd cap/zx297520v3/build-vehicle_dc_ref/tmp/deploy/sdk/
 tar -czvf do_package_tool.tar.gz do_package_tool