[Feature][ZXW-179]merge P52U02 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: I4fa8f86757e71388ae88400914dae8b50cd00338
diff --git a/ap/app/zte_amt/amt.c b/ap/app/zte_amt/amt.c
index 5280171..0557c0f 100755
--- a/ap/app/zte_amt/amt.c
+++ b/ap/app/zte_amt/amt.c
@@ -235,7 +235,7 @@
     char s1[100] = "";

     char s2[50] = "";	

     memset(s1, 0, sizeof(s1));

-    strncpy(s1, str,sizeof(s1) - 1);

+    memcpy(s1, str,sizeof(s1) - 1);

     strcat(s1, ",");

     Begb = s1;						//ÆðʼµØÖ·

     Endb = strchr(s1,',');			//µÚÒ»¸ö¶ººÅλÖÃ

@@ -247,10 +247,10 @@
         Len = 0;

         Len = Endb - Begb;			//³¤¶È

         memset(s2, 0, sizeof(s2));	//½ØÈ¡Á½¸ö¶ººÅ¼äµÄ×Ö·û´®

-        strncpy(s2, Begb, sizeof(s2) - 1);		//½ØÈ¡Á½¸ö¶ººÅ¼äµÄ×Ö·û´®

+        memcpy(s2, Begb, sizeof(s2) - 1);		//½ØÈ¡Á½¸ö¶ººÅ¼äµÄ×Ö·û´®

         data[Lc] = atof(s2);			//string to int

         ptr = Endb + 1;				//Ö¸ÏòϸöÊýµÄÆðʼµØÖ·

-        strncpy(s1, ptr, sizeof(s1) - 1);			//È¥µôÒÑת»¯µÄ×Ö·û´®

+        memcpy(s1, ptr, 99);			//È¥µôÒÑת»¯µÄ×Ö·û´®

         Begb = s1;					//ÆðʼµØÖ·¸üÐÂ

         Endb = strchr(s1,',');		//ϸö¶ººÅλÖÃ

         Lc++;

@@ -734,6 +734,36 @@
 

 

 /**

+ * @brief ¼ÓÔØ°®¿ÆÎ¢WIFI¹Ì¼þ

+ * @param[in] args Ï̺߳¯Êý²ÎÊý

+ * @return N/A

+ * @note

+ * @see 

+ */

+static void* LoadWifiFirmwareThread(void* args)

+{

+    int ret = -1;

+    UNUSED(args);

+	

+	prctl(PR_SET_NAME, "LoadWifiFirmwareThread");

+

+	#if (defined(__AIC_8800DW_CHIP__))

+	ret = wifi_ioctl_handle(3); //¼ÓÔØ²âÊԹ̼þ

+	if(ret < 0)

+	{

+		AmtPrintf(AMT_ERROR "%s: load AIC_8800DW firmware fail! ret=%d.\n", __FUNCTION__, ret);

+	}

+    else

+	{

+		AmtPrintf(AMT_INFO "%s: load AIC_8800DW firmware success! ret=%d.\n", __FUNCTION__, ret);

+	}

+	#endif

+	

+    return NULL;

+}

+

+

+/**

  * @brief AMTÏûÏ¢´ò°ü·¢¸øCP

  * @param[in] fd ÎļþÃèÊö·û

  * @param[in] msg_id FID

@@ -1791,7 +1821,7 @@
             set_fd(g_amt_fd_usb_hotplug);

         }

     }

-

+	

     /*********************** Create socket ***********************/

     if (socket_port > 0)

     {

@@ -1870,6 +1900,15 @@
 	}

 

 	//¼ÓÔØaic8800¹Ì¼þ

+    // Create load wifi firmware thread

+    pthread_t load_wifi_firmware_thread;

+    if (pthread_create(&load_wifi_firmware_thread, NULL, LoadWifiFirmwareThread, NULL) != 0)

+    {

+        AmtPrintf(AMT_ERROR "Failed to create load wifi firmware thread!\n");

+        return -1;

+    }

+

+	#if 0

 	#if (defined(__AIC_8800DW_CHIP__))

 	ret = wifi_ioctl_handle(3); //¼ÓÔØ²âÊԹ̼þ

 	if(ret < 0)

@@ -1881,7 +1920,8 @@
 		AmtPrintf(AMT_INFO "%s: load AIC_8800DW firmware success! ret=%d.\n", __FUNCTION__, ret);

 	}

 	#endif

-	

+	#endif

+

 	g_amt_at_mode = is_amt_atmode();

 	AmtPrintf(AMT_INFO"%s: g_amt_at_mode=%d\n", __FUNCTION__,g_amt_at_mode);

 

@@ -1929,16 +1969,19 @@
 

                 if (g_amt_fd_usb >= 0)

                 {

-                    close(g_amt_fd_usb);

-                    clr_fd(g_amt_fd_usb);

-                    g_amt_fd_usb = -1;

+                    AmtPrintf(AMT_INFO "amt already open usb,do nothing\n");

+                    //close(g_amt_fd_usb);

+                    //clr_fd(g_amt_fd_usb);

+                    //g_amt_fd_usb = -1;

                 }

-

-                g_amt_fd_usb = init_usb_device();

-                if (g_amt_fd_usb >= 0)

+                else

                 {

-                    AmtPrintf(AMT_INFO "g_amt_fd_usb = %d.\n", g_amt_fd_usb);

-                    set_fd(g_amt_fd_usb);

+	                g_amt_fd_usb = init_usb_device();

+	                if (g_amt_fd_usb >= 0)

+	                {

+	                    AmtPrintf(AMT_INFO "g_amt_fd_usb = %d.\n", g_amt_fd_usb);

+	                    set_fd(g_amt_fd_usb);

+	                }

                 }

             }

         }