[Feature][ZXW-41] merged 0601 version

Change-Id: I667af6bb09d65581d455b73f8984c160b2c67ad8
diff --git a/ap/lib/libatext/ext_audio_func.c b/ap/lib/libatext/ext_audio_func.c
index f1b45a7..143a6d2 100755
--- a/ap/lib/libatext/ext_audio_func.c
+++ b/ap/lib/libatext/ext_audio_func.c
@@ -15,6 +15,7 @@
 #ifdef _USE_VOICE_ALSA

 #include "tinyalsa/audio_mixer_ctrl.h"

 #include "voice_lib.h"

+#include "voice_ipc.h"

 #endif

 //#include "ext_regist.h"

 //#include "softap_api.h"

@@ -479,6 +480,46 @@
 	return AT_END;

 }

 

+int extAt_CAP_VALSA_act_func (int at_fd, char * at_paras, void * *res_msg, int * res_msglen)

+{

+	char *at_str = NULL;

+	UINT32 ret = DRV_SUCCESS;

+

+	int mode = 0;

+    int enable = 0;

+	

+	UINT16 onOff = 0;

+	at_str = at_paras;

+	printf("extAt_CAP_VALSA_act_func, at_paras:%s \n", at_paras);

+

+	ret = sscanf (at_str, "%d,%d", &mode,&enable);

+	onOff = enable;

+	printf("extAt_CAP_VALSA_act_func mode=%d,enable=%d,ret=%d\n",mode,enable,ret);

+

+	if (ret == 2) {

+		if(onOff == 1)

+		{

+			ret = cap_alsa_voice_open(mode);

+			printf("extAt_CAP_VALSA_act_func alsa_voice_open,ret=%d\n",ret);

+		}

+		else

+		{

+			ret = cap_alsa_voice_close(mode);

+			printf("extAt_CAP_VALSA_act_func alsa_voice_close,ret=%d\n",ret);

+			

+		}		

+		if (ret == DRV_SUCCESS) {

+			*res_msg = at_ok_build();

+			*res_msglen = strlen (*res_msg);

+			return AT_END;

+		}

+	}

+	*res_msg = at_err_build(ATERR_PROC_FAILED);

+	*res_msglen = strlen (*res_msg);

+	

+	return AT_END;

+}

+

 #endif

 

 void ext_audio_regist_init(void)

@@ -501,6 +542,7 @@
 

 	register_serv_func2("VALSA=", 0, 0, 0, extAt_VALSA_act_func, NULL);

 	register_serv_func2("VPATH=", 0, 0, 0, extAt_VPATH_act_func, NULL);

+    register_serv_func2("CAP_VALSA=", 0, 0, 0, extAt_CAP_VALSA_act_func, NULL);

 	

 #endif

 }

diff --git a/ap/lib/libatext/ext_normal_func.c b/ap/lib/libatext/ext_normal_func.c
index 90116eb..3c170fa 100644
--- a/ap/lib/libatext/ext_normal_func.c
+++ b/ap/lib/libatext/ext_normal_func.c
@@ -1534,16 +1534,20 @@
 	{

 		*res_msg = at_err_build(retCode); 

 	}

-	if (cardSlotFlag == 1)

-	{

-		snprintf(tmp,sizeof(tmp),"%d,%d,%d,%d,%d",simCard0PreFlag, simCard0Flag, simCard1PreFlag, simCard1Flag, cardSlotFlag);

-	}

 	else

 	{

-		snprintf(tmp,sizeof(tmp),"%d,%d",simCard0PreFlag, simCard0Flag);

+		if (cardSlotFlag == 1)

+		{

+			snprintf(tmp,sizeof(tmp),"%d,%d,%d,%d,%d",simCard0PreFlag, simCard0Flag, simCard1PreFlag, simCard1Flag, cardSlotFlag);

+		}

+		else

+		{

+			snprintf(tmp,sizeof(tmp),"%d,%d",simCard0PreFlag, simCard0Flag);

+		}

+		

+		*res_msg = at_query_result_build("ZCARDSWITCH", tmp);

 	}

 	

-	*res_msg = at_query_result_build("ZCARDSWITCH", tmp);

 	*res_msglen = strlen(*res_msg);

 	return AT_END;

 }

diff --git a/ap/lib/libatext/ext_wdt_func.c b/ap/lib/libatext/ext_wdt_func.c
index db6806d..d0df9f6 100644
--- a/ap/lib/libatext/ext_wdt_func.c
+++ b/ap/lib/libatext/ext_wdt_func.c
@@ -244,11 +244,13 @@
 	ret=ioctl(fd, RPMSG_SET_INT_FLAG, NULL);

 	if(ret<0){

 	 	at_print(AT_DEBUG,"cap add  ioctl FAIL\n");

+		close(fd);

 		return AT_END;	

 	}		

 	ret=write(fd, &ctx, 4);

 	if(ret<0){

 	 	at_print(AT_DEBUG,"cap add  write FAIL\n");

+		close(fd);

 		return AT_END;	

 	}

 	

@@ -278,11 +280,13 @@
 	ret=ioctl(fd, RPMSG_SET_INT_FLAG, NULL);

 	if(ret<0){

 	 	at_print(AT_DEBUG,"cap add  ioctl FAIL\n");

+		close(fd);

 		return AT_END;	

 	}		

 	ret=write(fd, &ctx, 4);

 	if(ret<0){

 	 	at_print(AT_DEBUG,"cap add  write FAIL\n");

+		close(fd);

 		return AT_END;	

 	}