Squashed 'LYNQ_PUBLIC/' content from commit 79d8f932f

git-subtree-dir: LYNQ_PUBLIC
git-subtree-split: 79d8f932fb4ebc4b5aec6c5ace97634912394272
Change-Id: If2527ba937f56fe989487bf71e996f7cfd9fbe61
diff --git a/common_src/packages/apps/clientTest/LICENSE b/common_src/packages/apps/clientTest/LICENSE
new file mode 100644
index 0000000..77f59ed
--- /dev/null
+++ b/common_src/packages/apps/clientTest/LICENSE
@@ -0,0 +1,31 @@
+Copyright Statement:
+
+This software/firmware and related documentation ("MediaTek Software") are
+protected under relevant copyright laws. The information contained herein is
+confidential and proprietary to MediaTek Inc. and/or its licensors. Without
+the prior written permission of MediaTek inc. and/or its licensors, any
+reproduction, modification, use or disclosure of MediaTek Software, and
+information contained herein, in whole or in part, shall be strictly
+prohibited.
+
+MediaTek Inc. (C) 2015. All rights reserved.
+
+BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
+ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
+WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
+NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH
+RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
+INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES
+TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
+RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
+OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK
+SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE
+RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S
+ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE
+RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE
+MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
+CHARGE PAID BY RECEIVER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
diff --git a/common_src/packages/apps/clientTest/main.cpp b/common_src/packages/apps/clientTest/main.cpp
new file mode 100644
index 0000000..e3b8c4a
--- /dev/null
+++ b/common_src/packages/apps/clientTest/main.cpp
@@ -0,0 +1,159 @@
+#include<stdio.h>
+#include<stdlib.h>
+#include<errno.h>
+#include<string.h>
+#include<sys/types.h>
+#include<netinet/in.h>
+#include<sys/socket.h>
+#include <arpa/inet.h>
+#include<sys/wait.h>
+#include <pthread.h>
+#include <unistd.h>
+#include <log/log.h>
+#include <string.h>
+#include <binder/Parcel.h>
+#define SERVER_PORT 8088
+#define BUFFER_SIZE 8192
+#define LOG_TAG "PLUGIN_MAIN"
+using::android::Parcel;
+int server_socket_fd;
+struct sockaddr_in client_addr;
+
+static int s_started =0;
+static pthread_mutex_t s_startupMutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t s_startupCond = PTHREAD_COND_INITIALIZER;
+static pthread_t s_tid_dispatch;
+
+int plugin_StartSerSocket()
+{
+    struct sockaddr_in server_addr;
+    bool count = true;
+    int ret = 0;
+    int dataSize = 0; 
+    bzero(&server_addr, sizeof(server_addr));
+    Parcel parcel;
+    int32_t type= 0;
+    int32_t request = 0;
+    int32_t error = 0;
+    server_addr.sin_family = AF_INET;
+    server_addr.sin_addr.s_addr = htonl(INADDR_ANY);
+    server_addr.sin_port = htons(SERVER_PORT);
+    /* create socket */
+    //int server_socket_fd = socket(AF_INET, SOCK_DGRAM, 0);
+    server_socket_fd = socket(AF_INET, SOCK_DGRAM, 0);
+    if(server_socket_fd == -1)
+    {
+         RLOGE("Create Socket Failed:");
+         exit(1);
+    }
+
+    /* bind socket port*/
+    if(-1 == (bind(server_socket_fd,(struct sockaddr*)&server_addr,sizeof(server_addr))))
+    {
+         RLOGE("Server Bind Failed:");
+         exit(1);
+    }
+
+    /* tranlate data */
+    while(true)
+    {
+         /* define address to catch the client addreess*/
+        //struct sockaddr_in client_addr;
+        socklen_t client_addr_length = sizeof(client_addr);
+        printf("read socket 8088!!\n");
+        /* receive the data */
+        char buffer[BUFFER_SIZE];
+        bzero(buffer, BUFFER_SIZE);
+        ret = recvfrom(server_socket_fd, buffer, BUFFER_SIZE,0,(struct sockaddr*)&client_addr, &client_addr_length);
+        if(ret == -1)
+        {
+            RLOGE("Receive Data Failed:");
+            continue;
+        }
+        if(count)
+        {
+            //uint8_t datalength[]=
+            uint8_t *datalength = (uint8_t *)buffer;
+            printf("PLUGIN:%s, receve: datalength[0] %x,datalength length = %d\n", inet_ntoa(client_addr.sin_addr),(datalength[0]<<8),ret);
+            if(ret==4)
+            {
+                if(((datalength[0]<<8)==0x5500)&&(datalength[1]==0xAA))
+                {
+                    RLOGD("PLUGIN:%s, receve: dataSize1= %x,dataSize2= %x", inet_ntoa(client_addr.sin_addr), (datalength[2]<<8),datalength[3]);
+                    printf("PLUGIN:%s, receve: dataSize1= %d,dataSize2= %d,dataSize = %d\n", inet_ntoa(client_addr.sin_addr), (datalength[2]<<8),datalength[3],((datalength[2]<<8)+datalength[3]));
+                    dataSize = datalength[2]+datalength[3];
+                    count=false;
+                }
+            }
+        }
+        else
+        {
+            count=true;
+            int32_t type= 0;
+            int32_t request = 0;
+            int32_t error = 0;
+            //parcel = (Parcel)buffer;
+            parcel.setData((unsigned char *)buffer, sizeof(buffer));
+            parcel.setDataPosition(0);
+            parcel.readInt32(&type);
+            parcel.readInt32(&request);
+            parcel.readInt32(&error);
+            RLOGD("PLUGIN:%s, receve: type= %d,request= %d,error = %d", inet_ntoa(client_addr.sin_addr), type,request,error);
+            printf("PLUGIN:%s, receve: type= %d,request= %d,error = %d\n", inet_ntoa(client_addr.sin_addr), type,request,error);
+        }
+     }
+
+     RLOGD("close socket fd");
+     close(server_socket_fd);
+     return 1;
+}
+void *eventLoop(void *param) {
+    pthread_mutex_lock(&s_startupMutex);
+    s_started = 1;
+    pthread_cond_broadcast(&s_startupCond);
+    pthread_mutex_unlock(&s_startupMutex);
+    //#ifdef ECALL_SUPPORT
+    //init_ecall_timer_all();
+    //#endif /**/ECALL_SUPPORT
+    plugin_StartSerSocket();
+    RLOGD("error in event_loop_base errno:%d", errno);
+    // kill self to restart on error
+    kill(0, SIGKILL);
+    return NULL;
+}
+void plugin_startEventLoop()
+{
+    RLOGD("RIL_startEventLoop()");
+    /* spin up eventLoop thread and wait for it to get started */
+    s_started = 0;
+    pthread_mutex_lock(&s_startupMutex);
+
+    pthread_attr_t attr;
+    pthread_attr_init(&attr);
+    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+
+    int result = pthread_create(&s_tid_dispatch, &attr, eventLoop, NULL);
+    if (result != 0) {
+        RLOGW("Failed to create dispatch thread: %s", strerror(result));
+        goto done;
+    }
+    while (s_started == 0) {
+        pthread_cond_wait(&s_startupCond, &s_startupMutex);
+    }
+    done:
+    pthread_mutex_unlock(&s_startupMutex);
+}
+int onRequest()
+{
+    printf("this is callback function\n");
+    return 0;
+}
+int main(int argc, char **argv)
+{
+    plugin_startEventLoop();
+    while(1)
+    {
+        sleep(1);
+    }
+    return 0;
+}
\ No newline at end of file
diff --git a/common_src/packages/apps/clientTest/makefile b/common_src/packages/apps/clientTest/makefile
new file mode 100644
index 0000000..31682d9
--- /dev/null
+++ b/common_src/packages/apps/clientTest/makefile
@@ -0,0 +1,82 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+                -std=gnu++14 \
+                -g -Os \
+                -flto \
+                -DRIL_SHLIB \
+                -DATCI_PARSE \
+                -DKEEP_ALIVE \
+                -DECALL_SUPPORT
+
+$(warning ################# C2K support: $(RAT_CONFIG_C2K_SUPPORT))
+ifeq ($(strip $(RAT_CONFIG_C2K_SUPPORT)), yes)
+    LOCAL_CFLAGS += -DC2K_SUPPORT
+endif
+
+ifeq ($(strip $(MTK_MULTI_SIM_SUPPORT)), dsds)
+    LOCAL_CFLAGS += -DANDROID_SIM_COUNT_2 \
+                     -DANDROID_MULTI_SIM \
+                     -DMODE_DSDS
+endif
+
+ifeq ($(strip $(MTK_MULTI_SIM_SUPPORT)), dsss)
+    LOCAL_CFLAGS += -DMODE_DSSS
+endif
+
+$(warning ################# TARGET_PLATFORM: $(TARGET_PLATFORM))
+ifeq ($(strip $(TARGET_PLATFORM)), mt2731)
+$(warning ################# TARGET_PLATFORM_MT2731)
+    LOCAL_CFLAGS += -DTARGET_PLATFORM_MT2731 \
+                    -DMD_93_SUPPORT
+else ifeq ($(strip $(TARGET_PLATFORM)), mt2635)
+$(warning ################# TARGET_PLATFORM_MT2635)
+    LOCAL_CFLAGS += -DTARGET_PLATFORM_MT2635 \
+                    -DMD_90_SUPPORT
+endif
+
+ifeq ($(strip $(TARGET_PLATFORM)), mt2735)
+LOCAL_CFLAGS += -DTARGET_PLATFORM_MT2735
+LOCAL_CFLAGS += -DBASELIB_DIR_LIB64 -DTELEMATIC_5G_SUPPORT
+endif
+
+LOCAL_PATH   = .
+
+LOCAL_C_INCLUDES = \
+  -I. \
+  -I$(ROOT)$(includedir)/logger \
+
+
+LOCAL_LIBS := \
+    -L. \
+    -ldl \
+    -lrt \
+    -lstdc++ \
+    -llog \
+    -lbinder \
+    -lpthread \
+
+#ifeq ($(strip $(TARGET_PLATFORM)), mt2735)
+#LOCAL_LIBS += -luciwrapper
+#else
+#LOCAL_LIBS += -lsncfg
+#endif
+
+
+SOURCES = main.cpp
+
+EXECUTABLE = clientTest
+
+OBJECTS=$(SOURCES:.cpp=.o)
+all: $(EXECUTABLE)
+
+$(EXECUTABLE): $(OBJECTS)
+	$(CXX) $(OBJECTS) $(LOCAL_LIBS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES) -o $@
+
+%.o : %.cpp
+	$(CXX) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+
+.PHONY: clean
+clean:
+	$(RM) $(OBJECTS) $(EXECUTABLE)
diff --git a/common_src/packages/apps/lynq-at-extension/src/main.cpp b/common_src/packages/apps/lynq-at-extension/src/main.cpp
new file mode 100755
index 0000000..b1226de
--- /dev/null
+++ b/common_src/packages/apps/lynq-at-extension/src/main.cpp
@@ -0,0 +1,49 @@
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <lib_at/lynq_at.h>
+
+/**
+ * @brief callback
+ * 
+ * @param input type:in
+ * @param output type:out
+ * @param out_max_size type:in
+ */
+void lynq_test_example(char input[], char output[], int out_max_size)
+{
+    if(!strcmp(input, "AT+TEST1"))
+    {
+        memcpy(output, input, strlen(input));
+    }
+    else if(!strcmp(input, "AT+TEST2"))
+    {
+        memcpy(output, input, strlen(input));
+    }
+    else if(!strcmp(input, "AT+TEST3"))
+    {
+        memcpy(output, input, strlen(input));
+    }
+    else if(!strcmp(input, "AT+TEST4"))
+    {
+        memcpy(output, input, strlen(input));
+    }
+    else if(!strcmp(input, "AT+TEST5"))
+    {
+        memcpy(output, input, strlen(input));
+    }
+    return;
+}
+
+int main(void)
+{
+    /*regis third at cmd*/
+    char cmd[64] = "AT+TEST1;AT+TEST2;AT+TEST3;AT+TEST4;AT+TEST5";
+    int ret = lynq_reg_third_at(cmd, lynq_test_example);//syn
+    while (1)
+    {
+       getchar();
+    }
+    return 0;
+}
diff --git a/common_src/packages/apps/lynq-at-extension/src/makefile b/common_src/packages/apps/lynq-at-extension/src/makefile
new file mode 100755
index 0000000..1eef0fa
--- /dev/null
+++ b/common_src/packages/apps/lynq-at-extension/src/makefile
@@ -0,0 +1,79 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+                -g -Os \
+                -flto \
+                -DRIL_SHLIB \
+                -DATCI_PARSE \
+                -DKEEP_ALIVE \
+                -D__LINUX_OS__ \
+                -DECALL_SUPPORT
+
+$(warning ################# C2K support: $(RAT_CONFIG_C2K_SUPPORT))
+ifeq ($(strip $(RAT_CONFIG_C2K_SUPPORT)), yes)
+    LOCAL_CFLAGS += -DC2K_SUPPORT
+
+endif
+
+ifeq ($(strip $(MTK_MULTI_SIM_SUPPORT)), dsds)
+    LOCAL_CFLAGS += -DANDROID_SIM_COUNT_2 \
+                     -DANDROID_MULTI_SIM \
+                     -DMODE_DSDS
+endif
+
+ifeq ($(strip $(MTK_MULTI_SIM_SUPPORT)), dsss)
+    LOCAL_CFLAGS += -DMODE_DSSS
+endif
+
+$(warning ################# TARGET_PLATFORM: $(TARGET_PLATFORM))
+ifeq ($(strip $(TARGET_PLATFORM)), mt2731)
+#$(warning #################add for debug $(ROOT), $(includedir))
+$(warning ################# TARGET_PLATFORM_MT2731)
+    LOCAL_CFLAGS += -DTARGET_PLATFORM_MT2731 \
+                    -DMD_93_SUPPORT
+else ifeq ($(strip $(TARGET_PLATFORM)), mt2635)
+$(warning ################# TARGET_PLATFORM_MT2635)
+    LOCAL_CFLAGS += -DTARGET_PLATFORM_MT2635 \
+                    -DMD_90_SUPPORT
+endif
+
+
+LOCAL_PATH   = .
+#CFLAGS = $(LOCAL_CFLAGS) -std=c99 
+#CXXFLAGS = $(LOCAL_CFLAGS) -std=gnu++14
+$(warning ################# ZHOUQUNCHAO ROOT: $(ROOT),includedir:$(includedir),LOCAL_PATH:$(LOCAL_PATH))
+LOCAL_C_INCLUDES = \
+  -I. \
+  -I$(LOCAL_PATH) \
+  -I$(ROOT)$(includedir)/ \
+  -I$(ROOT)$(includedir)/include  \
+  -DLIB_GNSS_HAL_DIR='"$(libdir)"'
+
+LOCAL_C_INCLUDES+=$(DNS_FLAGS)
+
+LOCAL_LIBS := \
+    -L. \
+    -ldl \
+    -lstdc++ \
+    -llynq-at-extension \
+
+LOCAL_SRC_FILES_CPP = $(wildcard *.cpp)
+LOCAL_SRC_FILES_C = $(wildcard *.c)
+EXECUTABLE = lynq-at-extension
+
+OBJECTS=$(LOCAL_SRC_FILES_CPP:.cpp=.o) $(LOCAL_SRC_FILES_C:.c=.o)
+all: $(EXECUTABLE)
+
+$(EXECUTABLE): $(OBJECTS)
+	$(CXX) $(OBJECTS) $(LOCAL_LIBS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES) -o $@
+
+%.o: %.c
+	$(warning ----->build $<)
+	$(CC) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+%.o : %.cpp
+	$(CXX) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+
+.PHONY: clean
+clean:
+	$(RM) $(OBJECTS) $(EXECUTABLE)
diff --git a/common_src/packages/apps/lynq-broadcast-receive/LICENSE b/common_src/packages/apps/lynq-broadcast-receive/LICENSE
new file mode 100644
index 0000000..77f59ed
--- /dev/null
+++ b/common_src/packages/apps/lynq-broadcast-receive/LICENSE
@@ -0,0 +1,31 @@
+Copyright Statement:
+
+This software/firmware and related documentation ("MediaTek Software") are
+protected under relevant copyright laws. The information contained herein is
+confidential and proprietary to MediaTek Inc. and/or its licensors. Without
+the prior written permission of MediaTek inc. and/or its licensors, any
+reproduction, modification, use or disclosure of MediaTek Software, and
+information contained herein, in whole or in part, shall be strictly
+prohibited.
+
+MediaTek Inc. (C) 2015. All rights reserved.
+
+BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
+ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
+WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
+NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH
+RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
+INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES
+TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
+RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
+OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK
+SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE
+RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S
+ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE
+RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE
+MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
+CHARGE PAID BY RECEIVER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
diff --git a/common_src/packages/apps/lynq-broadcast-receive/src/LICENSE b/common_src/packages/apps/lynq-broadcast-receive/src/LICENSE
new file mode 100644
index 0000000..77f59ed
--- /dev/null
+++ b/common_src/packages/apps/lynq-broadcast-receive/src/LICENSE
@@ -0,0 +1,31 @@
+Copyright Statement:
+
+This software/firmware and related documentation ("MediaTek Software") are
+protected under relevant copyright laws. The information contained herein is
+confidential and proprietary to MediaTek Inc. and/or its licensors. Without
+the prior written permission of MediaTek inc. and/or its licensors, any
+reproduction, modification, use or disclosure of MediaTek Software, and
+information contained herein, in whole or in part, shall be strictly
+prohibited.
+
+MediaTek Inc. (C) 2015. All rights reserved.
+
+BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
+ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
+WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
+NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH
+RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
+INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES
+TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
+RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
+OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK
+SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE
+RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S
+ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE
+RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE
+MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
+CHARGE PAID BY RECEIVER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
diff --git a/common_src/packages/apps/lynq-broadcast-receive/src/lynq_dbus_receive.c b/common_src/packages/apps/lynq-broadcast-receive/src/lynq_dbus_receive.c
new file mode 100644
index 0000000..da8b6b3
--- /dev/null
+++ b/common_src/packages/apps/lynq-broadcast-receive/src/lynq_dbus_receive.c
@@ -0,0 +1,86 @@
+#include <string.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <log/log.h>
+#include <gio/gio.h>
+#include <glib.h>
+
+#include "liblynq-broadcast/broadcast_receiver.h"
+
+
+static void CallbackByName( char*broadcast_name, int data_length,const char*data)
+{
+    printf("CallbackByName,str_arg:%s,data_length:%d,int_arg:%s\n", broadcast_name,data_length,data);
+
+    return;
+}
+static void CallbackByName1( char*broadcast_name, int data_length,const char*data)
+{
+    printf("CallbackByName1,str_arg:%s,data_length:%d,int_arg:%s\n", broadcast_name,data_length,data);
+
+    return;
+}
+static void CallbackById(int id, int data_length,const char*data)
+{
+    printf("CallbackById,id:%d,data_length:%d,data:%s\n", id,data_length,data);
+
+    return;
+}
+static void CallbackById1(int id, int data_length,const char*data)
+{
+    printf("CallbackById1,id:%d,data_length:%d,data:%s\n", id,data_length,data);
+
+    return;
+}
+static void callbackPrameUnfixed(char*broadcast_name,GVariant *parameters)
+{
+	gchar *out_a;
+    gchar *out_b;
+    gchar *out_c;
+    guchar out_d;
+    gboolean out_e;
+    gint16 out_f;
+    guint16 out_g;
+    gint out_h;
+    guint out_i;
+    gint64 out_j;
+    guint64 out_k;
+    gdouble out_l;
+    
+	g_variant_get (parameters,
+                 "(sogybnqiuxtd)",
+                 &out_a,
+                 &out_b,
+                 &out_c,
+                 &out_d,
+                 &out_e,
+                 &out_f,
+                 &out_g,
+                 &out_h,
+                 &out_i,
+                 &out_j,
+                 &out_k,
+                 &out_l);
+	printf("SignalCallback11111,,broadcast_name:%s\n", broadcast_name);
+	printf("%s,%s,%s,%u,%d,%.2fF\n", out_a,out_b,out_c,out_d,out_e,out_l);
+	
+    return;
+}
+int main(int argc, char** argv)
+{   
+   char data[] = "BrcastA";
+   char data1[] = "BrcastB";
+   GVariant *ret_struct;
+    register_broadcast_loop();
+//BOOL ServiceIsReady(void);
+   receive_callback_by_name(data, CallbackByName);
+   receive_callback_by_name(data1, CallbackByName1);
+   receive_callback_by_id(120, CallbackById);
+    receive_callback_by_id(128, CallbackById1);
+    while (1) {
+       sleep(10);
+    }
+
+	
+}
diff --git "a/common_src/packages/apps/lynq-broadcast-receive/src/lynq_testprocess\050gpio\051.tmp" "b/common_src/packages/apps/lynq-broadcast-receive/src/lynq_testprocess\050gpio\051.tmp"
new file mode 100644
index 0000000..c07e271
--- /dev/null
+++ "b/common_src/packages/apps/lynq-broadcast-receive/src/lynq_testprocess\050gpio\051.tmp"
@@ -0,0 +1,144 @@
+#include <stdio.h>
+#include <string.h>
+#include <pthread.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <gio/gio.h>
+#include <log/log.h>
+#include <glib.h>
+#define GPIO_SERVICE "lynq.gpio" /*well-known bus name */
+#define GPIO_DATA_INTERFACE "lynq.gpio.Data" /*interface name*/
+#define GPIO_DATA_PATH "/lynq/gpio/data" /*object name*/
+GMainLoop *loop = NULL;
+GDBusProxy *proxy = NULL;
+#define LOG_TAG "GPIO_CONTROL"
+int set_gpio (gchar * mode,guint *gpio_numb,guint param)
+{
+	GDBusConnection *c1;
+	GVariant *result;
+	GError *error;
+	guint  set_result = -1;
+	 g_type_init();
+	loop = g_main_loop_new(NULL, FALSE);   /** create main loop, but do not start it.*/
+	c1 = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
+	g_assert (c1 != NULL);
+	g_assert (!g_dbus_connection_is_closed (c1));
+	result = g_dbus_connection_call_sync (c1,
+                                        GPIO_SERVICE,  /* bus name */
+                                        GPIO_DATA_PATH, /* object path */
+                                        GPIO_DATA_INTERFACE,  /* interface name */
+                                        "setGpio",                 /* method name */
+                                        g_variant_new ("(sii)", mode,gpio_numb,param),  /* parameters */
+                                         G_VARIANT_TYPE ("(i)"),                    /* return type */
+                                        G_DBUS_CALL_FLAGS_NONE,
+                                        -1,
+                                        NULL,
+                                        &error);
+	g_assert_no_error (error);
+	g_assert (result != NULL);
+	g_variant_get(result, "((i))", &(set_result));
+	g_variant_unref (result);
+	g_main_loop_run (loop);
+	g_main_loop_unref (loop);
+    return set_result;
+}
+int get_gpio (guint *gpio_numb)
+{
+   	GDBusConnection *c1;
+	GVariant *result;
+	GError *error;
+	guint  parm=0;
+	 const gchar *set_result;
+	 const gchar *mode ="gpio";
+	if(set_gpio(mode,gpio_numb,parm)== -1)
+	{
+		RLOGD("get_gpio number error");
+		return -1;
+	}
+	c1 = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
+	g_assert (c1 != NULL);
+	g_assert (!g_dbus_connection_is_closed (c1));
+	result = g_dbus_connection_call_sync (c1,
+                                        GPIO_SERVICE,  /* bus name */
+                                        GPIO_DATA_PATH, /* object path */
+                                        GPIO_DATA_INTERFACE,  /* interface name */
+                                        "getGpio",                 /* method name */
+                                        NULL,  /* parameters */
+                                         G_VARIANT_TYPE ("(s)"),                     /* return type */
+                                        G_DBUS_CALL_FLAGS_NONE,
+                                        -1,
+                                        NULL,
+                                        &error);
+	g_assert_no_error (error);
+	g_assert (result != NULL);
+	g_variant_get(result, "((s))", &(set_result));
+	RLOGD("get_gpio,%s",set_result);
+	g_variant_unref (result);
+    return 1;
+}
+void proxy_ready(GObject *source, GAsyncResult *result, gpointer user_data) {
+    GError *error;
+
+    error = NULL;
+    proxy = g_dbus_proxy_new_for_bus_finish(result, &error);
+    if (proxy == NULL) {
+        RLOGE("create proxy fail");
+        return ;
+    }
+    RLOGD("proxy is ready");
+    gulong signal_handler_id;
+
+  //  signal_handler_id = g_signal_connect(proxy, "g-signal",
+  //          G_CALLBACK (proxy_signals_on_signal), NULL);
+   // if (signal_handler_id == 0) {
+   //     RLOGE("listen singal fail!");
+   // }
+}
+
+void* init_data_gdbus_cb(void *param)
+{
+    /* all the tests rely on a shared main loop */
+    loop = g_main_loop_new(NULL, FALSE);
+
+    g_dbus_proxy_new_for_bus(G_BUS_TYPE_SYSTEM,
+            G_DBUS_PROXY_FLAGS_NONE,
+            NULL, /* GDBusInterfaceInfo */
+            GPIO_SERVICE, /* name */
+            GPIO_DATA_PATH, /* object path */
+            GPIO_DATA_INTERFACE, /* interface */
+            NULL, /* GCancellable */
+            proxy_ready,
+            NULL);
+
+    g_main_loop_run(loop);
+
+    RLOGD("data gdbus main loop run()");
+    if(proxy != NULL) {
+        g_object_unref (proxy);
+    }
+    if(loop != NULL) {
+        g_main_loop_unref(loop);
+    }
+}
+
+
+void startGdbusLoop(void)
+{
+    pthread_t gpioThread;
+
+    RLOGD("startGdbusLoop()");
+   // pthread_mutex_lock(&s_startupMutex);
+    pthread_attr_t attr;
+    pthread_attr_init(&attr);
+    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+
+    int result = pthread_create(&gpioThread, &attr, init_data_gdbus_cb, NULL);
+    if (result != 0) {
+        RLOGW("Failed to create gdbus thread: %s", strerror(result));
+        //goto done;
+    }
+//done:
+ //   pthread_mutex_unlock(&s_startupMutex);
+}
diff --git a/common_src/packages/apps/lynq-broadcast-receive/src/makefile b/common_src/packages/apps/lynq-broadcast-receive/src/makefile
new file mode 100644
index 0000000..9245b6f
--- /dev/null
+++ b/common_src/packages/apps/lynq-broadcast-receive/src/makefile
@@ -0,0 +1,67 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+                -g -Os \
+                -flto \
+                -DRIL_SHLIB \
+                -DATCI_PARSE \
+                -DKEEP_ALIVE \
+                -D__LINUX_OS__ \
+                -DECALL_SUPPORT
+                
+CXXFLAGS = -fpermissive
+LOCAL_PATH   = .
+#CFLAGS = $(LOCAL_CFLAGS) -std=c99 
+#CXXFLAGS = $(LOCAL_CFLAGS) -std=gnu++14
+$(warning ################# ZHOUQUNCHAO ROOT: $(ROOT),includedir:$(includedir),LOCAL_PATH:$(LOCAL_PATH))
+LOCAL_C_INCLUDES = \
+  -I. \
+  -I$(LOCAL_PATH) \
+  -I$(ROOT)$(includedir)/logger \
+  -I$(ROOT)$(includedir)/vendor-ril \
+  -I$(ROOT)$(includedir)/gstreamer-1.0 \
+  -I$(ROOT)$(includedir)/glib-2.0 \
+  -I$(ROOT)$(includedir)/liblynq-broadcast \
+  -I$(ROOT)$(libdir)/glib-2.0/include \
+  -I$(ROOT)$(libdir)/gstreamer-1.0/include\
+  -I$(ROOT)$(includedir)/dbus-1.0 \
+  -I$(ROOT)$(libdir)/dbus-1.0/include \
+
+LOCAL_C_INCLUDES+=$(DNS_FLAGS)
+
+LOCAL_LIBS := \
+    -L. \
+    -ldl \
+    -lstdc++ \
+    -llog \
+    -lcutils \
+    -lutils \
+    -lpthread \
+    -lpal \
+    -llynq-broadcast \
+    -lglib-2.0 \
+    -lgobject-2.0 \
+    -lgio-2.0 \
+    -lapn \
+    -ldbus-1 \
+
+LOCAL_SRC_FILES_CPP = $(wildcard *.cpp)
+LOCAL_SRC_FILES_C = $(wildcard *.c)
+EXECUTABLE = lynq-broadcast-receive
+
+OBJECTS=$(LOCAL_SRC_FILES_CPP:.cpp=.o) $(LOCAL_SRC_FILES_C:.c=.o)
+all: $(EXECUTABLE)
+
+$(EXECUTABLE): $(OBJECTS)
+	$(CXX) $(OBJECTS) $(LOCAL_LIBS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES) -o $@ 
+
+%.o: %.c
+	$(warning ----->build $<)
+	$(CC) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+%.o : %.cpp
+	$(CXX) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+
+.PHONY: clean
+clean:
+	$(RM) $(OBJECTS) $(EXECUTABLE)
diff --git a/common_src/packages/apps/lynq-broadcast-send/LICENSE b/common_src/packages/apps/lynq-broadcast-send/LICENSE
new file mode 100644
index 0000000..77f59ed
--- /dev/null
+++ b/common_src/packages/apps/lynq-broadcast-send/LICENSE
@@ -0,0 +1,31 @@
+Copyright Statement:
+
+This software/firmware and related documentation ("MediaTek Software") are
+protected under relevant copyright laws. The information contained herein is
+confidential and proprietary to MediaTek Inc. and/or its licensors. Without
+the prior written permission of MediaTek inc. and/or its licensors, any
+reproduction, modification, use or disclosure of MediaTek Software, and
+information contained herein, in whole or in part, shall be strictly
+prohibited.
+
+MediaTek Inc. (C) 2015. All rights reserved.
+
+BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
+ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
+WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
+NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH
+RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
+INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES
+TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
+RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
+OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK
+SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE
+RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S
+ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE
+RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE
+MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
+CHARGE PAID BY RECEIVER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
diff --git a/common_src/packages/apps/lynq-broadcast-send/src/LICENSE b/common_src/packages/apps/lynq-broadcast-send/src/LICENSE
new file mode 100644
index 0000000..77f59ed
--- /dev/null
+++ b/common_src/packages/apps/lynq-broadcast-send/src/LICENSE
@@ -0,0 +1,31 @@
+Copyright Statement:
+
+This software/firmware and related documentation ("MediaTek Software") are
+protected under relevant copyright laws. The information contained herein is
+confidential and proprietary to MediaTek Inc. and/or its licensors. Without
+the prior written permission of MediaTek inc. and/or its licensors, any
+reproduction, modification, use or disclosure of MediaTek Software, and
+information contained herein, in whole or in part, shall be strictly
+prohibited.
+
+MediaTek Inc. (C) 2015. All rights reserved.
+
+BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
+ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
+WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
+NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH
+RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
+INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES
+TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
+RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
+OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK
+SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE
+RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S
+ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE
+RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE
+MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
+CHARGE PAID BY RECEIVER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
diff --git a/common_src/packages/apps/lynq-broadcast-send/src/lynq_broadcast_send.c b/common_src/packages/apps/lynq-broadcast-send/src/lynq_broadcast_send.c
new file mode 100644
index 0000000..9b6396f
--- /dev/null
+++ b/common_src/packages/apps/lynq-broadcast-send/src/lynq_broadcast_send.c
@@ -0,0 +1,105 @@
+#include <string.h>
+#include <stdio.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <log/log.h>
+#include <gio/gio.h>
+#include <glib.h>
+
+#include "liblynq-broadcast/broadcast_send.h"
+#include <gio/gio.h>
+#include <glib.h>
+#define LOG_TAG "BROADCAST_SEND_APP"
+
+int main(int argc, char** argv)
+{   
+    char data[] = "BrcastA comming";
+	char dataB[] = "BrcastB,comming";
+	char data1[] = "120,comming";
+	char data2[] = "128,comming";
+	int select_argvi = -1;
+	GVariant *ret_struct;
+	ret_struct = g_variant_new ("(sogybnqiuxtd)",
+                                      "this is a string",
+                                      "/this/is/a/path",
+                                      "sad",
+                                      42,
+                                      TRUE,
+                                      -42,
+                                      60000,
+                                      -44,
+                                      100000,
+                                      -(G_GUINT64_CONSTANT(2)<<34),
+                                      G_GUINT64_CONSTANT(0xffffffffffffffff),
+                                      42.5);
+    
+	/****************test  prame data **************/
+	/*
+	register_broadcast_send_loop();
+    RLOGD("register_broadcast_send_loop,start");
+	while(1){
+	 char str[8192]={ 0 };
+        fgets(str, 8192, stdin);
+        str[strlen(str)-1]='\0';
+		send_broadcast_by_name("BrcastA",sizeof(str),str);
+	}
+	while (1) {
+       sleep(10);
+	*/
+  /********************test  prame data *************/
+  
+  
+   /*******************test Multiple broadcasts  ******************/
+	 /*  
+	register_broadcast_send_loop();
+    RLOGD("register_broadcast_send_loop,start");
+    if(argv[1] != NULL)
+    {
+        select_argvi = atoi(argv[1]);
+    }
+	if (1 == select_argvi ){
+    for (int i=0;i<1000;i++)
+    {
+        send_broadcast_by_name("BrcastA",sizeof(data),data);
+		//send_broadcast_by_name("BrcastB",sizeof(dataB),dataB);
+		send_broadcast_by_id(120,sizeof(data1),data1);
+		//send_broadcast_by_id(128,sizeof(data2),data2);
+		//send_broadcast_param_unfixed("Brcastc",ret_struct);
+	
+    }
+	}
+	else {
+	    for (int i=0;i<1000;i++)
+        {
+			//send_broadcast_by_name("BrcastA",sizeof(data),data);
+			send_broadcast_by_name("BrcastB",sizeof(dataB),dataB);
+			//send_broadcast_by_id(120,sizeof(data1),data1);
+			send_broadcast_by_id(128,sizeof(data2),data2);
+			//send_broadcast_param_unfixed("Brcastc",ret_struct);
+		
+       }
+	}
+    
+    while (1) {
+       sleep(10);
+    }*/
+  /**********************test Multiple broadcasts  ********************/
+  
+
+  
+   register_broadcast_send();
+
+   RLOGD("register_broadcast_send,ok");
+   for (int i=0;i<1000;i++)
+   {
+    send_broadcast_by_name("BrcastA",sizeof(data),data);
+    send_broadcast_by_id("BrcastB",sizeof(dataB),dataB);
+	//send_broadcast_param_unfixed("Brcastc",ret_struct);
+   }
+   //send_broadcast_by_id(120,sizeof(data1),data1);
+   while(1){
+       sleep(10);
+   }
+  /**********************test Remove thread  ********************/
+	
+}
diff --git a/common_src/packages/apps/lynq-broadcast-send/src/makefile b/common_src/packages/apps/lynq-broadcast-send/src/makefile
new file mode 100644
index 0000000..d51ba19
--- /dev/null
+++ b/common_src/packages/apps/lynq-broadcast-send/src/makefile
@@ -0,0 +1,67 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+                -g -Os \
+                -flto \
+                -DRIL_SHLIB \
+                -DATCI_PARSE \
+                -DKEEP_ALIVE \
+                -D__LINUX_OS__ \
+                -DECALL_SUPPORT
+                
+CXXFLAGS = -fpermissive
+LOCAL_PATH   = .
+#CFLAGS = $(LOCAL_CFLAGS) -std=c99 
+#CXXFLAGS = $(LOCAL_CFLAGS) -std=gnu++14
+$(warning ################# ZHOUQUNCHAO ROOT: $(ROOT),includedir:$(includedir),LOCAL_PATH:$(LOCAL_PATH))
+LOCAL_C_INCLUDES = \
+  -I. \
+  -I$(LOCAL_PATH) \
+  -I$(ROOT)$(includedir)/logger \
+  -I$(ROOT)$(includedir)/vendor-ril \
+  -I$(ROOT)$(includedir)/gstreamer-1.0 \
+  -I$(ROOT)$(includedir)/glib-2.0 \
+  -I$(ROOT)$(libdir)/glib-2.0/include \
+  -I$(ROOT)$(includedir)/liblynq-broadcast \
+  -I$(ROOT)$(libdir)/gstreamer-1.0/include\
+  -I$(ROOT)$(includedir)/dbus-1.0 \
+  -I$(ROOT)$(libdir)/dbus-1.0/include \
+
+LOCAL_C_INCLUDES+=$(DNS_FLAGS)
+
+LOCAL_LIBS := \
+    -L. \
+    -ldl \
+    -lstdc++ \
+    -llog \
+    -lcutils \
+    -lutils \
+    -lpthread \
+    -lpal \
+    -llynq-broadcast \
+    -lglib-2.0 \
+    -lgobject-2.0 \
+    -lgio-2.0 \
+    -lapn \
+    -ldbus-1 \
+
+LOCAL_SRC_FILES_CPP = $(wildcard *.cpp)
+LOCAL_SRC_FILES_C = $(wildcard *.c)
+EXECUTABLE = lynq-broadcast-send
+
+OBJECTS=$(LOCAL_SRC_FILES_CPP:.cpp=.o) $(LOCAL_SRC_FILES_C:.c=.o)
+all: $(EXECUTABLE)
+
+$(EXECUTABLE): $(OBJECTS)
+	$(CXX) $(OBJECTS) $(LOCAL_LIBS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES) -o $@ 
+
+%.o: %.c
+	$(warning ----->build $<)
+	$(CC) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+%.o : %.cpp
+	$(CXX) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+
+.PHONY: clean
+clean:
+	$(RM) $(OBJECTS) $(EXECUTABLE)
diff --git a/common_src/packages/apps/lynq-dev-test/src/LICENSE b/common_src/packages/apps/lynq-dev-test/src/LICENSE
new file mode 100644
index 0000000..77f59ed
--- /dev/null
+++ b/common_src/packages/apps/lynq-dev-test/src/LICENSE
@@ -0,0 +1,31 @@
+Copyright Statement:
+
+This software/firmware and related documentation ("MediaTek Software") are
+protected under relevant copyright laws. The information contained herein is
+confidential and proprietary to MediaTek Inc. and/or its licensors. Without
+the prior written permission of MediaTek inc. and/or its licensors, any
+reproduction, modification, use or disclosure of MediaTek Software, and
+information contained herein, in whole or in part, shall be strictly
+prohibited.
+
+MediaTek Inc. (C) 2015. All rights reserved.
+
+BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
+ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
+WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
+NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH
+RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
+INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES
+TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
+RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
+OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK
+SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE
+RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S
+ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE
+RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE
+MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
+CHARGE PAID BY RECEIVER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
diff --git a/common_src/packages/apps/lynq-dev-test/src/lynq_dev_test.c b/common_src/packages/apps/lynq-dev-test/src/lynq_dev_test.c
new file mode 100644
index 0000000..9d65d85
--- /dev/null
+++ b/common_src/packages/apps/lynq-dev-test/src/lynq_dev_test.c
@@ -0,0 +1,58 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <log/log.h>
+#ifdef __cplusplus
+extern "C" {
+#endif
+//#include "libdev/lynq_dev_control.h"
+//#include "liblynq-media/lynq_medial.h"
+#ifdef __cplusplus
+}
+#endif
+static const char *devicename = "/data/ring.wav";
+#define LOG_TAG "DEV_TEST"
+int main(int argc, char **argv) 
+{
+    char devicename[100] = {0};
+    char swversion[100] = {0};
+    char oemversion[100] = {0};
+    char manufacturer[100] = {0};
+    char hwversion[100] = {0};
+    int get_rtc ,set_rtc ,cancel_rtc,get_adc,get_usb_status;
+    struct tm timer_time;
+    gsdk_device_get_devicename(devicename);
+    printf("gsdk_device_get_devicename:%s \n",devicename);
+    gsdk_device_get_swversion(swversion);
+    printf("gsdk_device_get_swversion:%s \n",swversion);
+    gsdk_device_get_oemversion(oemversion);
+    printf("gsdk_device_get_oemversion:%s \n",oemversion);	
+    gsdk_device_get_manufacturer(manufacturer);
+    printf("gsdk_device_get_manufacturer:%s \n",manufacturer);	
+    gsdk_device_get_hwversion(hwversion);
+    printf("gsdk_device_get_hwversion:%s \n",hwversion);
+
+    //set_rtc = gsdk_device_set_rtc_timer();
+    //printf("gsdk_device_set_rtc_timer:%d \n",set_rtc);
+    //get_adc = gsdk_device_get_adc();
+    //printf("gsdk_device_get_adc:%d \n",get_adc);
+    //sleep(30);
+    
+    //get_rtc = gsdk_device_get_rtc_timer(set_rtc,&timer_time);
+    //printf("gsdk_device_get_rtc_timer:%d,timer_time,year:%d\n",get_rtc,timer_time.tm_year);
+    //printf("timer_time,tm_mon:%d\n",timer_time.tm_mon);
+    //printf("timer_time,tm_mday:%d\n",timer_time.tm_mday);
+    //printf("timer_time,tm_hour:%d\n",timer_time.tm_hour);
+    //printf("timer_time,tm_min:%d\n",timer_time.tm_min);
+    //printf("timer_time,tm_sec:%d\n",timer_time.tm_sec);
+    //sleep(30);
+    //cancel_rtc = gsdk_device_cancel_rtc_timer(set_rtc);
+    //printf("gsdk_device_cancel_rtc_timer:%d \n",cancel_rtc);
+    //sleep(30);
+    get_usb_status = gsdk_device_get_usb_state();
+    printf("gsdk_device_get_usb_state,get_usb_status:%d\n",get_usb_status);
+    //gsdk_device_reboot_system();
+    //printf(" reboot_system");
+    while(1){sleep(10);}
+    return 0;
+}
\ No newline at end of file
diff --git "a/common_src/packages/apps/lynq-dev-test/src/lynq_testprocess\050gpio\051.tmp" "b/common_src/packages/apps/lynq-dev-test/src/lynq_testprocess\050gpio\051.tmp"
new file mode 100644
index 0000000..c07e271
--- /dev/null
+++ "b/common_src/packages/apps/lynq-dev-test/src/lynq_testprocess\050gpio\051.tmp"
@@ -0,0 +1,144 @@
+#include <stdio.h>
+#include <string.h>
+#include <pthread.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <gio/gio.h>
+#include <log/log.h>
+#include <glib.h>
+#define GPIO_SERVICE "lynq.gpio" /*well-known bus name */
+#define GPIO_DATA_INTERFACE "lynq.gpio.Data" /*interface name*/
+#define GPIO_DATA_PATH "/lynq/gpio/data" /*object name*/
+GMainLoop *loop = NULL;
+GDBusProxy *proxy = NULL;
+#define LOG_TAG "GPIO_CONTROL"
+int set_gpio (gchar * mode,guint *gpio_numb,guint param)
+{
+	GDBusConnection *c1;
+	GVariant *result;
+	GError *error;
+	guint  set_result = -1;
+	 g_type_init();
+	loop = g_main_loop_new(NULL, FALSE);   /** create main loop, but do not start it.*/
+	c1 = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
+	g_assert (c1 != NULL);
+	g_assert (!g_dbus_connection_is_closed (c1));
+	result = g_dbus_connection_call_sync (c1,
+                                        GPIO_SERVICE,  /* bus name */
+                                        GPIO_DATA_PATH, /* object path */
+                                        GPIO_DATA_INTERFACE,  /* interface name */
+                                        "setGpio",                 /* method name */
+                                        g_variant_new ("(sii)", mode,gpio_numb,param),  /* parameters */
+                                         G_VARIANT_TYPE ("(i)"),                    /* return type */
+                                        G_DBUS_CALL_FLAGS_NONE,
+                                        -1,
+                                        NULL,
+                                        &error);
+	g_assert_no_error (error);
+	g_assert (result != NULL);
+	g_variant_get(result, "((i))", &(set_result));
+	g_variant_unref (result);
+	g_main_loop_run (loop);
+	g_main_loop_unref (loop);
+    return set_result;
+}
+int get_gpio (guint *gpio_numb)
+{
+   	GDBusConnection *c1;
+	GVariant *result;
+	GError *error;
+	guint  parm=0;
+	 const gchar *set_result;
+	 const gchar *mode ="gpio";
+	if(set_gpio(mode,gpio_numb,parm)== -1)
+	{
+		RLOGD("get_gpio number error");
+		return -1;
+	}
+	c1 = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
+	g_assert (c1 != NULL);
+	g_assert (!g_dbus_connection_is_closed (c1));
+	result = g_dbus_connection_call_sync (c1,
+                                        GPIO_SERVICE,  /* bus name */
+                                        GPIO_DATA_PATH, /* object path */
+                                        GPIO_DATA_INTERFACE,  /* interface name */
+                                        "getGpio",                 /* method name */
+                                        NULL,  /* parameters */
+                                         G_VARIANT_TYPE ("(s)"),                     /* return type */
+                                        G_DBUS_CALL_FLAGS_NONE,
+                                        -1,
+                                        NULL,
+                                        &error);
+	g_assert_no_error (error);
+	g_assert (result != NULL);
+	g_variant_get(result, "((s))", &(set_result));
+	RLOGD("get_gpio,%s",set_result);
+	g_variant_unref (result);
+    return 1;
+}
+void proxy_ready(GObject *source, GAsyncResult *result, gpointer user_data) {
+    GError *error;
+
+    error = NULL;
+    proxy = g_dbus_proxy_new_for_bus_finish(result, &error);
+    if (proxy == NULL) {
+        RLOGE("create proxy fail");
+        return ;
+    }
+    RLOGD("proxy is ready");
+    gulong signal_handler_id;
+
+  //  signal_handler_id = g_signal_connect(proxy, "g-signal",
+  //          G_CALLBACK (proxy_signals_on_signal), NULL);
+   // if (signal_handler_id == 0) {
+   //     RLOGE("listen singal fail!");
+   // }
+}
+
+void* init_data_gdbus_cb(void *param)
+{
+    /* all the tests rely on a shared main loop */
+    loop = g_main_loop_new(NULL, FALSE);
+
+    g_dbus_proxy_new_for_bus(G_BUS_TYPE_SYSTEM,
+            G_DBUS_PROXY_FLAGS_NONE,
+            NULL, /* GDBusInterfaceInfo */
+            GPIO_SERVICE, /* name */
+            GPIO_DATA_PATH, /* object path */
+            GPIO_DATA_INTERFACE, /* interface */
+            NULL, /* GCancellable */
+            proxy_ready,
+            NULL);
+
+    g_main_loop_run(loop);
+
+    RLOGD("data gdbus main loop run()");
+    if(proxy != NULL) {
+        g_object_unref (proxy);
+    }
+    if(loop != NULL) {
+        g_main_loop_unref(loop);
+    }
+}
+
+
+void startGdbusLoop(void)
+{
+    pthread_t gpioThread;
+
+    RLOGD("startGdbusLoop()");
+   // pthread_mutex_lock(&s_startupMutex);
+    pthread_attr_t attr;
+    pthread_attr_init(&attr);
+    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+
+    int result = pthread_create(&gpioThread, &attr, init_data_gdbus_cb, NULL);
+    if (result != 0) {
+        RLOGW("Failed to create gdbus thread: %s", strerror(result));
+        //goto done;
+    }
+//done:
+ //   pthread_mutex_unlock(&s_startupMutex);
+}
diff --git a/common_src/packages/apps/lynq-dev-test/src/makefile b/common_src/packages/apps/lynq-dev-test/src/makefile
new file mode 100644
index 0000000..478152b
--- /dev/null
+++ b/common_src/packages/apps/lynq-dev-test/src/makefile
@@ -0,0 +1,67 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+                -g -Os \
+                -flto \
+                -DRIL_SHLIB \
+                -DATCI_PARSE \
+                -DKEEP_ALIVE \
+                -D__LINUX_OS__ \
+                -DECALL_SUPPORT
+                
+CXXFLAGS = -fpermissive
+LOCAL_PATH   = .
+#CFLAGS = $(LOCAL_CFLAGS) -std=c99 
+#CXXFLAGS = $(LOCAL_CFLAGS) -std=gnu++14
+$(warning ################# ZHOUQUNCHAO ROOT: $(ROOT),includedir:$(includedir),LOCAL_PATH:$(LOCAL_PATH))
+LOCAL_C_INCLUDES = \
+  -I. \
+  -I$(LOCAL_PATH) \
+  -I$(ROOT)$(includedir)/logger \
+  -I$(ROOT)$(includedir)/vendor-ril \
+  -I$(ROOT)$(includedir)/liblynq-dev \
+  -I$(ROOT)$(includedir)/liblynq-media \
+  -I$(ROOT)$(includedir)/glib-2.0 \
+  -I$(ROOT)$(libdir)/glib-2.0/include \
+  -I$(ROOT)$(includedir)/dbus-1.0 \
+  -I$(ROOT)$(libdir)/dbus-1.0/include \
+
+LOCAL_C_INCLUDES+=$(DNS_FLAGS)
+
+LOCAL_LIBS := \
+    -L. \
+    -ldl \
+    -lstdc++ \
+    -llog \
+    -lcutils \
+    -lutils \
+    -lpthread \
+    -llynq-dev \
+    -llynq-media \
+    -lpal \
+    -lglib-2.0 \
+    -lgobject-2.0 \
+    -lgio-2.0 \
+    -lapn \
+    -ldbus-1 \
+
+LOCAL_SRC_FILES_CPP = $(wildcard *.cpp)
+LOCAL_SRC_FILES_C = $(wildcard *.c)
+EXECUTABLE = lynq-dev-test
+
+OBJECTS=$(LOCAL_SRC_FILES_CPP:.cpp=.o) $(LOCAL_SRC_FILES_C:.c=.o)
+all: $(EXECUTABLE)
+
+$(EXECUTABLE): $(OBJECTS)
+	$(CXX) $(OBJECTS) $(LOCAL_LIBS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES) -o $@ 
+
+%.o: %.c
+	$(warning ----->build $<)
+	$(CC) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+%.o : %.cpp
+	$(CXX) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+
+.PHONY: clean
+clean:
+	$(RM) $(OBJECTS) $(EXECUTABLE)
diff --git a/common_src/packages/apps/lynq-factory-test/src/T800_GPIO_TEST.sh b/common_src/packages/apps/lynq-factory-test/src/T800_GPIO_TEST.sh
new file mode 100755
index 0000000..c0a28fa
--- /dev/null
+++ b/common_src/packages/apps/lynq-factory-test/src/T800_GPIO_TEST.sh
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+result="pass"
+for var in 230 231 232 233 234 102 104 103 101 186 188 187 185 194 196 195 193 205 204 203 202 201 190 192 191 189 173 174 175 176 170 169 184 183 182 181 24 25 157 158 155 156 143 144 140 141 153 154 180 179 29 30 178 177 7 5 4 113 112 116 115 114 107 108 105 106 100 99 98 97 94 93 92 91 1 130 41 67 69 68 63 22 23 199 200
+do
+echo mode $var 0 > /sys/devices/platform/10005000.pinctrl/mt_gpio
+echo out $var 0 > /sys/devices/platform/10005000.pinctrl/mt_gpio
+done
+
+for var in 230 231 232 233 234 102 104 103 101 186 188 187 185 194 196 195 193 205 204 203 202 201 190 192 191 189 173 174 175 176 170 169 184 183 182 181 24 25 157 158 155 156 143 144 140 141 153 154 180 179 29 30 178 177 7 5 4 113 112 116 115 114 107 108 105 106 100 99 98 97 94 93 92 91 1 130 41 67 69 68 63 22 23 199 200
+do
+echo "test gpio $var"
+echo mode $var 0 > /sys/devices/platform/10005000.pinctrl/mt_gpio
+echo out $var 1 > /sys/devices/platform/10005000.pinctrl/mt_gpio
+
+cat /sys/devices/platform/10005000.pinctrl/mt_gpio |grep 006
+temp=$(cat /sys/devices/platform/10005000.pinctrl/mt_gpio |grep 006)
+temp1=${temp:7:1}
+echo out $var 0 > /sys/devices/platform/10005000.pinctrl/mt_gpio
+cat /sys/devices/platform/10005000.pinctrl/mt_gpio |grep 006
+temp=$(cat /sys/devices/platform/10005000.pinctrl/mt_gpio |grep 006)
+temp2=${temp:7:1}
+if [ "$temp1" -eq "1" ] && [ "$temp2" -eq "0" ]
+then
+     echo GPIO $var test pass
+else
+     echo -e "\e[31m GPIO $var test fail \e[0m"
+          result="fail"
+fi
+
+done
+echo "========================================================="
+echo "               GPIO  test result is $result" 
+
+
diff --git a/common_src/packages/apps/lynq-factory-test/src/main.cpp b/common_src/packages/apps/lynq-factory-test/src/main.cpp
new file mode 100755
index 0000000..7ffb9f1
--- /dev/null
+++ b/common_src/packages/apps/lynq-factory-test/src/main.cpp
@@ -0,0 +1,398 @@
+#include <stdio.h>
+#include <sys/types.h>    
+#include <sys/stat.h>    
+#include <fcntl.h>
+#include <unistd.h>
+#include <string.h>
+#include<stdlib.h>
+#include "include/lynq_sim.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+#define MAX_ARGS 20
+static const char *usb3_speed = "super-speed";
+static const char *usb2_speed = "high-speed";
+static const char *switch_info = "switching card,please waiting 10s";
+static const char *switch_compelete_info = "switching card complete";
+static const char *gpio_start = "starting GPIO";
+static const char *end = "TO BE END";
+static const char *sink = "staring sink";
+static const char *adc = "staring adc";
+static const char *sim = "staring sim";
+
+static int parse_buf(char *buf,float pre,float bey,char *flag){
+    float num = atoi(buf)/1000.0;
+    if(num < pre || num > bey){
+        printf("\033[47;31m%s FAILED\033[0m\n",flag);
+    }
+    return 0;
+}
+
+int lynq_dispose_factory_adc(int lynq_adc_num)
+{   
+    float pre = 0.89;
+    float bey = 0.91;
+    char *flag = "ADC";
+    FILE *fp;
+    char lynq_adc_dev[512] = {0};
+    char lynq_adc_buf[512];
+    char lynq_adc_log_buf[512];
+    bzero(lynq_adc_buf, 512);
+    bzero(lynq_adc_dev,512);
+    bzero(lynq_adc_log_buf,512);
+    if(lynq_adc_num == 0)
+    {
+        sprintf(lynq_adc_dev,"cat /sys/bus/iio/devices/iio:device1/in_voltage0_input  2>&1");
+    }
+    else if(lynq_adc_num == 1)
+    {
+        sprintf(lynq_adc_dev,"cat /sys/bus/iio/devices/iio:device1/in_voltage1_input  2>&1");
+    }
+    else if(lynq_adc_num == 2)
+    {
+        sprintf(lynq_adc_dev,"cat /sys/bus/iio/devices/iio:device1/in_voltage2_input  2>&1");
+    }
+    else if(lynq_adc_num == 3)
+    {
+        sprintf(lynq_adc_dev,"cat /sys/bus/iio/devices/iio:device1/in_voltage3_input  2>&1");
+    }
+    else
+    {
+        printf("[adc][errror]:no adc device \n");
+        return 0;
+    }
+    fp=popen(lynq_adc_dev, "r");
+    fgets(lynq_adc_buf,sizeof(lynq_adc_buf),fp);    
+    if(strlen(lynq_adc_buf) > 0)
+    {
+        sprintf(lynq_adc_log_buf,"[adc%d][result]:%s\n",lynq_adc_num,lynq_adc_buf);
+        parse_buf(lynq_adc_buf,pre,bey,flag);
+    }
+    else
+    {
+        sprintf(lynq_adc_log_buf,"[adc%d][result]:error\n",lynq_adc_num);
+    }
+    printf("%s\n",lynq_adc_log_buf);
+    pclose(fp);
+    return 1;
+}
+
+int test_RGMII(void){
+    printf("Testing RGMII\n");
+    FILE *fp;
+    fp=popen("ping -c 4 baidu.com 2>&1", "r");
+    if(NULL == fp){
+        printf("popen error");
+        return 0;
+    }
+    char lynq_factory_buf[1024] = {0};
+    if(NULL == fgets(lynq_factory_buf,sizeof(lynq_factory_buf),fp)){
+        printf("UNKONE ERROR\n");
+        pclose(fp);
+        return 0;
+    }
+    else{
+        printf("%s\n",lynq_factory_buf);
+        if(strstr(lynq_factory_buf, "bad"))
+            return 0;
+    }
+    while (NULL != fgets(lynq_factory_buf,sizeof(lynq_factory_buf),fp))
+    {
+        printf("%s\n",lynq_factory_buf);
+    }
+    pclose(fp);
+    printf("%s\n",end);
+    return 0;
+}
+
+int lynq_check_emmc()
+{
+    FILE *fp;
+    char emmc_buf[100] = {0};
+    char buf[100] = {0};
+    sprintf(emmc_buf, "ls /dev | grep mmcblk0  2>&1");
+    fp=popen(emmc_buf, "r");
+    if(!fp){
+        printf("\n+CME: POPEN ERROR\n");
+        return -1;
+    }
+    while(fgets(buf, sizeof(buf), fp) != NULL){
+        printf("[EMMC] EMMC OK \n"); 
+        pclose(fp);
+        return 0;   
+    }
+    printf("\033[47;31m[EMMC] NO EMMC\033[0m\n");
+    pclose(fp);
+    return 0;
+}
+
+int lynq_check_gpio()
+{
+    #if 0
+    FILE *fp;
+    int lynq_gpio_arr[88] = {6,230,231,232,233,234,102,104,103,101,186,188,187,185,194,196,195,193,205,204,203,202,199,200,201,190,192,191,189,173,174,175,176,170,169,184,183,182,181,24,25,23,25,157,158,155,156,143,144,140,141,153,154,180,179,29,30,178,177,7,5,4,113,112,116,115,114,107,108,105,106,100,99,98,97,94,93,92,91,1,130,41,67,69,68,63};
+    char lynq_show_gpio_state[64] = {0};
+    char lynq_set_gpio_arr[256] = {0};
+    char lynq_get_gpio_state[512] = {0};
+    int lynq_gpio_low = 0;
+    int lynq_gpio_hig = 0;
+    int i = 0;
+    for(i = 0; i < 58; i++)
+    {
+        lynq_gpio_low = 0;
+        lynq_gpio_hig = 0;
+        bzero(lynq_set_gpio_arr, 256);
+        sprintf(lynq_set_gpio_arr,"echo mode %d 0 >/sys/devices/platform/10005000.pinctrl/mt_gpio & echo dir %d 1 >/sys/devices/platform/10005000.pinctrl/mt_gpio & echo out %d 0 >/sys/devices/platform/10005000.pinctrl/mt_gpio",lynq_gpio_arr[i],lynq_gpio_arr[i],lynq_gpio_arr[i]);
+        system(lynq_set_gpio_arr);
+        bzero(lynq_set_gpio_arr, 256);
+        sprintf(lynq_set_gpio_arr,"cat /sys/devices/platform/10005000.pinctrl/mt_gpio |grep %03d",lynq_gpio_arr[i]);
+        fp=popen(lynq_set_gpio_arr, "r");
+        bzero(lynq_get_gpio_state, 512);
+        fgets(lynq_get_gpio_state,sizeof(lynq_get_gpio_state),fp);
+        pclose(fp);
+        if(lynq_get_gpio_state[6] == '0')
+        {
+            lynq_gpio_low = 1;
+        }
+        bzero(lynq_set_gpio_arr, 256);
+        sprintf(lynq_set_gpio_arr,"echo mode %d 0 >/sys/devices/platform/10005000.pinctrl/mt_gpio & echo dir %d 1 >/sys/devices/platform/10005000.pinctrl/mt_gpio & echo out %d 1 >/sys/devices/platform/10005000.pinctrl/mt_gpio",lynq_gpio_arr[i],lynq_gpio_arr[i],lynq_gpio_arr[i]);
+        system(lynq_set_gpio_arr);
+        bzero(lynq_set_gpio_arr, 256);
+        sprintf(lynq_set_gpio_arr,"cat /sys/devices/platform/10005000.pinctrl/mt_gpio |grep %03d:",lynq_gpio_arr[i]);
+        fp=popen(lynq_set_gpio_arr, "r");
+        bzero(lynq_get_gpio_state, 512);
+        fgets(lynq_get_gpio_state,sizeof(lynq_get_gpio_state),fp);
+        pclose(fp);
+        if(lynq_get_gpio_state[6] == '1')
+        {
+            lynq_gpio_hig = 1;
+        }
+        bzero(lynq_show_gpio_state, 64);
+        if((lynq_gpio_low == 1) && (lynq_gpio_hig == 1))
+        {
+            sprintf(lynq_show_gpio_state,"[gpio%d][result]:PASS \n",lynq_gpio_arr[i]);
+        }
+        else
+        {
+            sprintf(lynq_show_gpio_state,"[gpio%d][result]:FAIL \n",lynq_gpio_arr[i]);
+        }
+        printf("%s\n",lynq_show_gpio_state);
+    }
+    #endif
+    FILE *fp;
+    char lynq_usb_dev[52] = {0};
+    sprintf(lynq_usb_dev,"source /data/test/T800_GPIO_TEST.sh  2>&1");
+    fp=popen(lynq_usb_dev, "r");
+    char lynq_usb_buf[512];
+    if(NULL == fp){
+        printf("popen errorn");
+        return 0;
+    }
+    while(NULL != fgets(lynq_usb_buf,sizeof(lynq_usb_buf),fp)){
+       printf("%s\n",lynq_usb_buf);
+    }
+    pclose(fp);
+   return 0;
+}
+
+int lynq_dispose_factory_usb()
+{
+    FILE *fp;
+    char lynq_usb_dev[512] = {0};
+    char lynq_usb_buf[512];
+    bzero(lynq_usb_buf, 512);
+    bzero(lynq_usb_dev,512);
+    sprintf(lynq_usb_dev,"cat /sys/devices/platform/11201000.usb/udc/11201000.usb/current_speed  2>&1");
+
+    fp=popen(lynq_usb_dev, "r");
+    fgets(lynq_usb_buf,sizeof(lynq_usb_buf),fp);
+    if(!strncmp(lynq_usb_buf,usb3_speed,strlen(usb3_speed)))
+    {   
+        printf("[usb][result],3.0 \n");
+    }
+    else if(!strncmp(lynq_usb_buf,usb2_speed,strlen(usb2_speed)))
+    {
+        printf("[usb][result],2.0 \n");
+    }
+    else
+    {
+        printf("[usb][rat][UNKNOWN] \n");
+    }
+    pclose(fp);
+    return 1;
+}
+
+
+
+int lynq_test_sink(){
+    float pre;
+    float bey;
+    char *flag = "SINK";
+    FILE *fp;
+    char lynq_usb_dev[512] = {0};
+    char lynq_usb_buf[512] = {0};
+    char buf[512] = {0};
+    int sink[3][3] = {{255,0,0},{0,255,0},{0,0,255}};
+    char dev_buf[][40]={{"green:cellular-radio/brightness"},{"green:cellular-quality/brightness"},{"red:system/brightness"}};
+    int i;
+    int j;
+    int k = 15;
+    int cnt = 1;
+    for(i = 0;i < 3;i++){
+        if(i == 0){
+            pre = 0.9;
+            bey = 1.3;
+        }
+        if(i == 1){
+            pre = 0.8;
+            bey = 1.3;
+        }
+        if(i == 2){
+            pre = 0.9;
+            bey = 1.2;
+        }
+        bzero(lynq_usb_buf, 512);
+        bzero(buf, 512);
+        k = 15;
+        for(j = 0;j < 3;j++){
+            bzero(lynq_usb_dev, 512);
+            sprintf(lynq_usb_dev,"echo %d >  /sys/class/leds/led95%d:%s  2>&1", sink[i][j], k++, dev_buf[j]);
+            fp=popen(lynq_usb_dev, "r");
+        }
+        sprintf(lynq_usb_buf,"cat /sys/bus/iio/devices/iio:device1/in_voltage4_input  2>&1");
+        fp=popen(lynq_usb_buf, "r");
+        fgets(buf,sizeof(buf),fp);
+        parse_buf(buf,pre,bey,flag);
+        printf("[sink%d] %s\n",cnt++,buf);
+    }
+    pclose(fp);
+    return 1;
+}
+
+int lynq_judge_sim_state(int *state){
+    int res = lynq_get_sim_status(state);
+    if(!res){
+        if(*state == 1){
+            printf("[SIM]:SUCCESS\n");
+            printf("[SIM]:CARD STATE:%d\n",*state);
+        }
+        else{
+            printf("\033[47;31m[SIM]:FAILED\033[0m\n");
+            printf("[SIM]:CARD STATE:%d\n",*state);
+        }
+        return res;
+    }
+    else{
+        printf("\033[47;31m[SIM]:FAILED\033[0m\n");
+        return res;
+    }
+}
+
+int lynq_gps_start(void){
+    system("echo \"EPO_enabled=1\">/etc/gnss/mnl.pro");
+    system("echo \"debug.dbg2file=1\">/etc/gnss/mnl.prop");
+    system("mnld_test start &");
+    return 0;
+}
+
+int lynq_gps_close(void){
+    system("killall mnld_test");
+    sleep(1);
+    system("cat /etc/gnss/*.nma");
+    return 0;
+}
+
+int print_info(int second){
+    int i = 0;
+    char bar[200] = {0};
+    char *lab = "-\\|/";
+    int cnt = 0;
+    while (i <= 100)
+    {
+        printf("[%-101s][%d%%][%c]\r",bar,cnt,lab[i%4]);
+        cnt+=second;
+        fflush(stdout);
+        sleep(1);
+        for(int j = 0;j < second;j++){
+            bar[i++]='#';
+            bar[i] = '\0';
+        }
+    }
+    printf("\n");
+    return 0;
+}
+
+int lynq_check_pcie(void){
+    FILE *fp;
+    char lynq_usb_dev[128] = {0};
+    char lynq_get_gpio_state[512] = {0};
+    sprintf(lynq_usb_dev,"cat sys/devices/platform/10005000.pinctrl/mt_gpio |grep 097  2>&1");
+    fp=popen(lynq_usb_dev, "r");
+    fgets(lynq_get_gpio_state,sizeof(lynq_get_gpio_state),fp);
+    pclose(fp);
+    if(lynq_get_gpio_state[6] == '1')
+    {
+        printf("PCIE SUCCESS\n");
+    }
+    else{
+        printf("\033[47;31mPCIE FAILED\033[0m\n");
+    }
+    return 0;
+}
+
+int main(void){
+    printf("GPS is open\n");
+    lynq_gps_start();
+    int utoken = 123;
+    int x = -1;
+    int y = -1;
+    int res = -1;
+    int *state = &x;
+    char imsi[21] = {0};
+    lynq_sim_init(utoken);
+    sleep(1);
+    char imei[32] = {0};
+    lynq_get_imei(imei);
+    printf("IMEI: %s\n", imei);
+    lynq_judge_sim_state(state);
+    print_info(50);
+    int slot = 1;
+    res = lynq_switch_card(slot);
+    printf("%s\n",switch_info);
+    print_info(10);
+    printf("%s\n",switch_compelete_info);
+    int *card_sim = &y;
+    bzero(imsi,21);
+    lynq_judge_sim_state(card_sim);
+    printf("PCIE Testing\n");
+    print_info(50);
+    lynq_check_pcie();
+    printf("GPIO Testing\n");
+    print_info(50);
+    lynq_check_gpio();
+    printf("ADC Testing\n");
+    print_info(50);
+    for(int i = 0;i < 4;i++){
+        lynq_dispose_factory_adc(i);
+    }
+    printf("RGMII/SGMII Testing\n");
+    print_info(50);
+    test_RGMII();
+    printf("SINK Testing\n");
+    print_info(50);
+    lynq_test_sink();
+    printf("USB Testing\n");
+    print_info(50);
+    lynq_dispose_factory_usb();
+    printf("EMMC Testing\n");
+    print_info(50);
+    lynq_check_emmc();
+    sleep(1);
+    printf("Factory test is done,starting output nema,please waiting 100s\n");
+    print_info(1);
+    lynq_gps_close();
+    return 0;
+}
+#ifdef __cplusplus
+}
+#endif 
\ No newline at end of file
diff --git a/common_src/packages/apps/lynq-factory-test/src/makefile b/common_src/packages/apps/lynq-factory-test/src/makefile
new file mode 100755
index 0000000..e26c502
--- /dev/null
+++ b/common_src/packages/apps/lynq-factory-test/src/makefile
@@ -0,0 +1,85 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+                -g -Os \
+                -flto \
+                -DRIL_SHLIB \
+                -DATCI_PARSE \
+                -DKEEP_ALIVE \
+                -D__LINUX_OS__ \
+                -DECALL_SUPPORT
+
+$(warning ################# C2K support: $(RAT_CONFIG_C2K_SUPPORT))
+ifeq ($(strip $(RAT_CONFIG_C2K_SUPPORT)), yes)
+    LOCAL_CFLAGS += -DC2K_SUPPORT
+
+endif
+
+ifeq ($(strip $(MTK_MULTI_SIM_SUPPORT)), dsds)
+    LOCAL_CFLAGS += -DANDROID_SIM_COUNT_2 \
+                     -DANDROID_MULTI_SIM \
+                     -DMODE_DSDS
+endif
+
+ifeq ($(strip $(MTK_MULTI_SIM_SUPPORT)), dsss)
+    LOCAL_CFLAGS += -DMODE_DSSS
+endif
+
+$(warning ################# TARGET_PLATFORM: $(TARGET_PLATFORM))
+ifeq ($(strip $(TARGET_PLATFORM)), mt2731)
+#$(warning #################add for debug $(ROOT), $(includedir))
+$(warning ################# TARGET_PLATFORM_MT2731)
+    LOCAL_CFLAGS += -DTARGET_PLATFORM_MT2731 \
+                    -DMD_93_SUPPORT
+else ifeq ($(strip $(TARGET_PLATFORM)), mt2635)
+$(warning ################# TARGET_PLATFORM_MT2635)
+    LOCAL_CFLAGS += -DTARGET_PLATFORM_MT2635 \
+                    -DMD_90_SUPPORT
+endif
+
+
+LOCAL_PATH   = .
+#CFLAGS = $(LOCAL_CFLAGS) -std=c99 
+#CXXFLAGS = $(LOCAL_CFLAGS) -std=gnu++14
+$(warning ################# ZHOUQUNCHAO ROOT: $(ROOT),includedir:$(includedir),LOCAL_PATH:$(LOCAL_PATH))
+LOCAL_C_INCLUDES = \
+  -I. \
+  -I$(LOCAL_PATH) \
+  -I$(ROOT)$(includedir)/ \
+  -I$(ROOT)$(includedir)/include  \
+  -DLIB_GNSS_HAL_DIR='"$(libdir)"'
+
+LOCAL_C_INCLUDES+=$(DNS_FLAGS)
+
+LOCAL_LIBS := \
+    -L. \
+    -ldl \
+    -lstdc++ \
+    -llog \
+    -lcutils \
+    -lutils \
+    -lbinder \
+    -llynq-log \
+    -lpthread \
+    -llynq-sim \
+
+LOCAL_SRC_FILES_CPP = $(wildcard *.cpp gpio/*.cpp ril/*.cpp)
+LOCAL_SRC_FILES_C = $(wildcard *.c gps/*.c)
+EXECUTABLE = lynq-factory-test
+
+OBJECTS=$(LOCAL_SRC_FILES_CPP:.cpp=.o) $(LOCAL_SRC_FILES_C:.c=.o)
+all: $(EXECUTABLE)
+
+$(EXECUTABLE): $(OBJECTS)
+	$(CXX) $(OBJECTS) $(LOCAL_LIBS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES) -o $@
+
+%.o: %.c
+	$(warning ----->build $<)
+	$(CC) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+%.o : %.cpp
+	$(CXX) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+
+.PHONY: clean
+clean:
+	$(RM) $(OBJECTS) $(EXECUTABLE)
diff --git a/common_src/packages/apps/lynq-media-test/src/LICENSE b/common_src/packages/apps/lynq-media-test/src/LICENSE
new file mode 100644
index 0000000..77f59ed
--- /dev/null
+++ b/common_src/packages/apps/lynq-media-test/src/LICENSE
@@ -0,0 +1,31 @@
+Copyright Statement:
+
+This software/firmware and related documentation ("MediaTek Software") are
+protected under relevant copyright laws. The information contained herein is
+confidential and proprietary to MediaTek Inc. and/or its licensors. Without
+the prior written permission of MediaTek inc. and/or its licensors, any
+reproduction, modification, use or disclosure of MediaTek Software, and
+information contained herein, in whole or in part, shall be strictly
+prohibited.
+
+MediaTek Inc. (C) 2015. All rights reserved.
+
+BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
+ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
+WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
+NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH
+RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
+INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES
+TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
+RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
+OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK
+SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE
+RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S
+ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE
+RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE
+MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
+CHARGE PAID BY RECEIVER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
diff --git a/common_src/packages/apps/lynq-media-test/src/lynq_media_test.c b/common_src/packages/apps/lynq-media-test/src/lynq_media_test.c
new file mode 100755
index 0000000..18b02f1
--- /dev/null
+++ b/common_src/packages/apps/lynq-media-test/src/lynq_media_test.c
@@ -0,0 +1,47 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <log/log.h>
+#ifdef __cplusplus
+extern "C" {
+#endif 
+#include "liblynq-media/lynq_medial.h"
+#include "liblynq-media/lynq_modem_voice.h"
+#ifdef __cplusplus
+}
+#endif 
+#include <pthread.h>
+
+#define LOG_TAG "DEV_TEST"
+
+int main(int argc, char **argv) 
+{
+    const char *devicename = argv[1];
+    const char *devicesavename = argv[2];
+
+    int ret;
+    ret=lynq_media_play_audio(devicename);
+    if(ret!=0)
+    {
+        printf("lynq_media_play_audio failure\n");
+        return 1;
+    }
+    lynq_incall_record(devicesavename);
+    sleep(20);
+    lynq_stop_record();
+    printf("going to stop play\n");
+
+    lynq_media_stop_audio();
+
+
+    ret=lynq_media_play_audio(devicesavename);
+    if(ret!=0)
+    {
+        printf("lynq_media_play_audio failure 2\n");
+        return 1;
+    }
+    sleep(15);
+    lynq_media_stop_audio();  
+
+    return 0;
+}
\ No newline at end of file
diff --git a/common_src/packages/apps/lynq-media-test/src/lynq_media_test1.c.tmp b/common_src/packages/apps/lynq-media-test/src/lynq_media_test1.c.tmp
new file mode 100644
index 0000000..5d167f5
--- /dev/null
+++ b/common_src/packages/apps/lynq-media-test/src/lynq_media_test1.c.tmp
@@ -0,0 +1,106 @@
+#include <gst/gst.h>
+
+#define GST_CAT_DEFAULT myelement_debug
+
+typedef struct _CustomData {
+  GstElement *pipeline;
+  GstElement *playbin;
+} CustomData;
+  
+ static gboolean
+  bus_call (GstBus * bus, GstMessage * msg, gpointer data)
+  {
+    GMainLoop *loop = (GMainLoop *) data;
+  
+    switch (GST_MESSAGE_TYPE (msg)) {
+      case GST_MESSAGE_EOS:{
+        g_print ("End-of-stream\n");
+        g_main_loop_quit (loop);
+        break;
+      }
+      case GST_MESSAGE_ERROR:{
+        gchar *debug;
+        GError *err;
+  
+        gst_message_parse_error (msg, &err, &debug);
+        g_printerr ("Debugging info: %s\n", (debug) ? debug : "none");
+        g_free (debug);
+  
+        g_print ("Error: %s\n", err->message);
+        g_error_free (err);
+  
+        g_main_loop_quit (loop);
+  
+        break;
+      }
+      default:
+        break;
+    }
+    return TRUE;
+  }
+/* Handler for the pad-added signal */
+GST_DEBUG_CATEGORY_STATIC (myelement_debug);
+static void pad_added_handler (GstElement *src, GstPad *pad, CustomData *data);
+  
+int main(int argc, char *argv[]) {
+  CustomData data;
+  GstBus *bus;
+  GstMessage *msg;
+  GstStateChangeReturn ret;
+  gboolean terminate = FALSE;
+  GMainLoop *loop;
+  guint bus_watch_id;
+  /* Initialize GStreamer */
+  gst_init (&argc, &argv);
+  GST_DEBUG_CATEGORY_INIT (myelement_debug, "myelement", 0, "My own element");
+  /* Create the elements */
+  data.playbin = gst_element_factory_make ("playbin", "playbin");
+
+  g_print ("main start.\n");
+  /* Create the empty pipeline */
+  data.pipeline = gst_pipeline_new ("test-pipeline");
+  
+  if (!data.pipeline || !data.playbin) {
+    g_printerr ("Not all elements could be created.\n");
+    return -1;
+  }
+  
+
+  /* Set the URI to play */
+  g_object_set (data.playbin, "uri", "file:///data/ring.wav", NULL);
+
+  
+
+  g_object_set (data.playbin, "flags", 0x42  , NULL);
+  g_object_set (data.playbin, "volume", 1.0  , NULL);
+  g_object_set (data.playbin, "mute", 0  , NULL);
+  /* Start playing */
+  ret = gst_element_set_state (data.pipeline, GST_STATE_PLAYING);
+  if (ret == GST_STATE_CHANGE_FAILURE) {
+    g_printerr ("Unable to set the pipeline to the playing state.\n");
+    gst_object_unref (data.pipeline);
+    return -1;
+  }
+  
+   // loop = g_main_loop_new (NULL, FALSE);
+  
+   // bus = gst_element_get_bus (data.playbin);
+  //  bus_watch_id = gst_bus_add_watch (bus, bus_call, loop);
+   // g_object_unref (bus);
+    g_print ("gst_bus_add_watch.\n");
+    /* start play back and listed to events */
+    gst_element_set_state (data.playbin, GST_STATE_PLAYING);
+	sleep(10);
+    g_object_set (data.playbin, "mute", 1  , NULL);
+    g_print ("g_main_loop_run start.\n");
+   // g_main_loop_run (loop);
+    g_print ("g_main_loop_run stop.\n");
+  /* cleanup */
+   // gst_element_set_state (data.playbin, GST_STATE_NULL);
+  //  g_object_unref (data.playbin);
+  //  g_source_remove (bus_watch_id);
+  // g_main_loop_unref (loop);
+  return 0;
+}
+  
+
diff --git a/common_src/packages/apps/lynq-media-test/src/lynq_media_test_old.c.tmp b/common_src/packages/apps/lynq-media-test/src/lynq_media_test_old.c.tmp
new file mode 100644
index 0000000..3443f4a
--- /dev/null
+++ b/common_src/packages/apps/lynq-media-test/src/lynq_media_test_old.c.tmp
@@ -0,0 +1,152 @@
+#include <gst/gst.h>
+  
+/* Structure to contain all our information, so we can pass it to callbacks */
+typedef struct _CustomData {
+  GstElement *pipeline;
+  GstElement *source;
+  GstElement *convert;
+  GstElement *sink;
+} CustomData;
+  
+/* Handler for the pad-added signal */
+static void pad_added_handler (GstElement *src, GstPad *pad, CustomData *data);
+  
+int main(int argc, char *argv[]) {
+  CustomData data;
+  GstBus *bus;
+  GstMessage *msg;
+  GstStateChangeReturn ret;
+  gboolean terminate = FALSE;
+
+  
+  /* Initialize GStreamer */
+  gst_init (&argc, &argv);
+   
+  /* Create the elements */
+  data.source = gst_element_factory_make ("uridecodebin", "source");
+  data.convert = gst_element_factory_make ("audioconvert", "convert");
+  data.sink = gst_element_factory_make ("autoaudiosink", "sink");
+  g_print ("main start.\n");
+  printf ("main start.\n");
+  /* Create the empty pipeline */
+  data.pipeline = gst_pipeline_new ("test-pipeline");
+  
+  if (!data.pipeline || !data.source || !data.convert || !data.sink) {
+    g_printerr ("Not all elements could be created.\n");
+    return -1;
+  }
+  
+  /* Build the pipeline. Note that we are NOT linking the source at this
+   * point. We will do it later. */
+  gst_bin_add_many (GST_BIN (data.pipeline), data.source, data.convert , data.sink, NULL);
+  if (!gst_element_link (data.convert, data.sink)) {
+    g_printerr ("Elements could not be linked.\n");
+    gst_object_unref (data.pipeline);
+    return -1;
+  }
+  
+  /* Set the URI to play */
+  g_object_set (data.source, "uri", "file:///data/ring.wav", NULL);
+  
+  /* Connect to the pad-added signal */
+  g_signal_connect (data.source, "pad-added", G_CALLBACK (pad_added_handler), &data);
+  
+  /* Start playing */
+  ret = gst_element_set_state (data.pipeline, GST_STATE_PLAYING);
+  if (ret == GST_STATE_CHANGE_FAILURE) {
+    g_printerr ("Unable to set the pipeline to the playing state.\n");
+    gst_object_unref (data.pipeline);
+    return -1;
+  }
+  
+  /* Listen to the bus */
+  bus = gst_element_get_bus (data.pipeline);
+  do {
+    msg = gst_bus_timed_pop_filtered (bus, GST_CLOCK_TIME_NONE,
+        GST_MESSAGE_STATE_CHANGED | GST_MESSAGE_ERROR | GST_MESSAGE_EOS);
+  
+    /* Parse message */
+    if (msg != NULL) {
+      GError *err;
+      gchar *debug_info;
+      
+      switch (GST_MESSAGE_TYPE (msg)) {
+        case GST_MESSAGE_ERROR:
+          gst_message_parse_error (msg, &err, &debug_info);
+          g_printerr ("Error received from element %s: %s\n", GST_OBJECT_NAME (msg->src), err->message);
+          g_printerr ("Debugging information: %s\n", debug_info ? debug_info : "none");
+          g_clear_error (&err);
+          g_free (debug_info);
+          terminate = TRUE;
+          break;
+        case GST_MESSAGE_EOS:
+          g_print ("End-Of-Stream reached.\n");
+          terminate = TRUE;
+          break;
+        case GST_MESSAGE_STATE_CHANGED:
+          /* We are only interested in state-changed messages from the pipeline */
+          if (GST_MESSAGE_SRC (msg) == GST_OBJECT (data.pipeline)) {
+            GstState old_state, new_state, pending_state;
+            gst_message_parse_state_changed (msg, &old_state, &new_state, &pending_state);
+            g_print ("Pipeline state changed from %s to %s:\n",
+                gst_element_state_get_name (old_state), gst_element_state_get_name (new_state));
+          }
+          break;
+        default:
+          /* We should not reach here */
+          g_printerr ("Unexpected message received.\n");
+          break;
+      }
+      gst_message_unref (msg);
+    }
+  } while (!terminate);
+  
+  /* Free resources */
+  gst_object_unref (bus);
+  gst_element_set_state (data.pipeline, GST_STATE_NULL);
+  gst_object_unref (data.pipeline);
+  return 0;
+}
+  
+/* This function will be called by the pad-added signal */
+static void pad_added_handler (GstElement *src, GstPad *new_pad, CustomData *data) {
+  GstPad *sink_pad = gst_element_get_static_pad (data->convert, "sink");
+  GstPadLinkReturn ret;
+  GstCaps *new_pad_caps = NULL;
+  GstStructure *new_pad_struct = NULL;
+  const gchar *new_pad_type = NULL;
+  
+  g_print ("Received new pad '%s' from '%s':\n", GST_PAD_NAME (new_pad), GST_ELEMENT_NAME (src));
+  
+  /* If our converter is already linked, we have nothing to do here */
+  if (gst_pad_is_linked (sink_pad)) {
+    g_print ("  We are already linked. Ignoring.\n");
+    goto exit;
+  }
+  
+  /* Check the new pad's type */
+  new_pad_caps = gst_pad_get_current_caps (new_pad);
+  new_pad_struct = gst_caps_get_structure (new_pad_caps, 0);
+  new_pad_type = gst_structure_get_name (new_pad_struct);
+  if (!g_str_has_prefix (new_pad_type, "audio/x-raw")) {
+    g_print ("  It has type '%s' which is not raw audio. Ignoring.\n", new_pad_type);
+    goto exit;
+  }
+  
+  /* Attempt the link */
+  ret = gst_pad_link (new_pad, sink_pad);
+  if (GST_PAD_LINK_FAILED (ret)) {
+    g_print ("  Type is '%s' but link failed.\n", new_pad_type);
+  } else {
+    g_print ("  Link succeeded (type '%s').\n", new_pad_type);
+  }
+  
+exit:
+  /* Unreference the new pad's caps, if we got them */
+  if (new_pad_caps != NULL)
+    gst_caps_unref (new_pad_caps);
+  
+  /* Unreference the sink pad */
+  gst_object_unref (sink_pad);
+}
+
diff --git "a/common_src/packages/apps/lynq-media-test/src/lynq_testprocess\050gpio\051.tmp" "b/common_src/packages/apps/lynq-media-test/src/lynq_testprocess\050gpio\051.tmp"
new file mode 100644
index 0000000..c07e271
--- /dev/null
+++ "b/common_src/packages/apps/lynq-media-test/src/lynq_testprocess\050gpio\051.tmp"
@@ -0,0 +1,144 @@
+#include <stdio.h>
+#include <string.h>
+#include <pthread.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <gio/gio.h>
+#include <log/log.h>
+#include <glib.h>
+#define GPIO_SERVICE "lynq.gpio" /*well-known bus name */
+#define GPIO_DATA_INTERFACE "lynq.gpio.Data" /*interface name*/
+#define GPIO_DATA_PATH "/lynq/gpio/data" /*object name*/
+GMainLoop *loop = NULL;
+GDBusProxy *proxy = NULL;
+#define LOG_TAG "GPIO_CONTROL"
+int set_gpio (gchar * mode,guint *gpio_numb,guint param)
+{
+	GDBusConnection *c1;
+	GVariant *result;
+	GError *error;
+	guint  set_result = -1;
+	 g_type_init();
+	loop = g_main_loop_new(NULL, FALSE);   /** create main loop, but do not start it.*/
+	c1 = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
+	g_assert (c1 != NULL);
+	g_assert (!g_dbus_connection_is_closed (c1));
+	result = g_dbus_connection_call_sync (c1,
+                                        GPIO_SERVICE,  /* bus name */
+                                        GPIO_DATA_PATH, /* object path */
+                                        GPIO_DATA_INTERFACE,  /* interface name */
+                                        "setGpio",                 /* method name */
+                                        g_variant_new ("(sii)", mode,gpio_numb,param),  /* parameters */
+                                         G_VARIANT_TYPE ("(i)"),                    /* return type */
+                                        G_DBUS_CALL_FLAGS_NONE,
+                                        -1,
+                                        NULL,
+                                        &error);
+	g_assert_no_error (error);
+	g_assert (result != NULL);
+	g_variant_get(result, "((i))", &(set_result));
+	g_variant_unref (result);
+	g_main_loop_run (loop);
+	g_main_loop_unref (loop);
+    return set_result;
+}
+int get_gpio (guint *gpio_numb)
+{
+   	GDBusConnection *c1;
+	GVariant *result;
+	GError *error;
+	guint  parm=0;
+	 const gchar *set_result;
+	 const gchar *mode ="gpio";
+	if(set_gpio(mode,gpio_numb,parm)== -1)
+	{
+		RLOGD("get_gpio number error");
+		return -1;
+	}
+	c1 = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
+	g_assert (c1 != NULL);
+	g_assert (!g_dbus_connection_is_closed (c1));
+	result = g_dbus_connection_call_sync (c1,
+                                        GPIO_SERVICE,  /* bus name */
+                                        GPIO_DATA_PATH, /* object path */
+                                        GPIO_DATA_INTERFACE,  /* interface name */
+                                        "getGpio",                 /* method name */
+                                        NULL,  /* parameters */
+                                         G_VARIANT_TYPE ("(s)"),                     /* return type */
+                                        G_DBUS_CALL_FLAGS_NONE,
+                                        -1,
+                                        NULL,
+                                        &error);
+	g_assert_no_error (error);
+	g_assert (result != NULL);
+	g_variant_get(result, "((s))", &(set_result));
+	RLOGD("get_gpio,%s",set_result);
+	g_variant_unref (result);
+    return 1;
+}
+void proxy_ready(GObject *source, GAsyncResult *result, gpointer user_data) {
+    GError *error;
+
+    error = NULL;
+    proxy = g_dbus_proxy_new_for_bus_finish(result, &error);
+    if (proxy == NULL) {
+        RLOGE("create proxy fail");
+        return ;
+    }
+    RLOGD("proxy is ready");
+    gulong signal_handler_id;
+
+  //  signal_handler_id = g_signal_connect(proxy, "g-signal",
+  //          G_CALLBACK (proxy_signals_on_signal), NULL);
+   // if (signal_handler_id == 0) {
+   //     RLOGE("listen singal fail!");
+   // }
+}
+
+void* init_data_gdbus_cb(void *param)
+{
+    /* all the tests rely on a shared main loop */
+    loop = g_main_loop_new(NULL, FALSE);
+
+    g_dbus_proxy_new_for_bus(G_BUS_TYPE_SYSTEM,
+            G_DBUS_PROXY_FLAGS_NONE,
+            NULL, /* GDBusInterfaceInfo */
+            GPIO_SERVICE, /* name */
+            GPIO_DATA_PATH, /* object path */
+            GPIO_DATA_INTERFACE, /* interface */
+            NULL, /* GCancellable */
+            proxy_ready,
+            NULL);
+
+    g_main_loop_run(loop);
+
+    RLOGD("data gdbus main loop run()");
+    if(proxy != NULL) {
+        g_object_unref (proxy);
+    }
+    if(loop != NULL) {
+        g_main_loop_unref(loop);
+    }
+}
+
+
+void startGdbusLoop(void)
+{
+    pthread_t gpioThread;
+
+    RLOGD("startGdbusLoop()");
+   // pthread_mutex_lock(&s_startupMutex);
+    pthread_attr_t attr;
+    pthread_attr_init(&attr);
+    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+
+    int result = pthread_create(&gpioThread, &attr, init_data_gdbus_cb, NULL);
+    if (result != 0) {
+        RLOGW("Failed to create gdbus thread: %s", strerror(result));
+        //goto done;
+    }
+//done:
+ //   pthread_mutex_unlock(&s_startupMutex);
+}
diff --git a/common_src/packages/apps/lynq-media-test/src/makefile b/common_src/packages/apps/lynq-media-test/src/makefile
new file mode 100644
index 0000000..21f876f
--- /dev/null
+++ b/common_src/packages/apps/lynq-media-test/src/makefile
@@ -0,0 +1,67 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+                -g -Os \
+                -flto \
+                -DRIL_SHLIB \
+                -DATCI_PARSE \
+                -DKEEP_ALIVE \
+                -D__LINUX_OS__ \
+                -DECALL_SUPPORT
+                
+CXXFLAGS = -fpermissive
+LOCAL_PATH   = .
+#CFLAGS = $(LOCAL_CFLAGS) -std=c99 
+#CXXFLAGS = $(LOCAL_CFLAGS) -std=gnu++14
+$(warning ################# ZHOUQUNCHAO ROOT: $(ROOT),includedir:$(includedir),LOCAL_PATH:$(LOCAL_PATH))
+LOCAL_C_INCLUDES = \
+  -I. \
+  -I$(LOCAL_PATH) \
+  -I$(ROOT)$(includedir)/logger \
+  -I$(ROOT)$(includedir)/vendor-ril \
+  -I$(ROOT)$(includedir)/liblynq-dev \
+  -I$(ROOT)$(includedir)/liblynq-media \
+  -I$(ROOT)$(includedir)/glib-2.0 \
+  -I$(ROOT)$(libdir)/glib-2.0/include \
+  -I$(ROOT)$(includedir)/dbus-1.0 \
+  -I$(ROOT)$(libdir)/dbus-1.0/include \
+
+LOCAL_C_INCLUDES+=$(DNS_FLAGS)
+
+LOCAL_LIBS := \
+    -L. \
+    -ldl \
+    -lstdc++ \
+    -llog \
+    -lcutils \
+    -lutils \
+    -lpthread \
+    -llynq-dev \
+    -llynq-media \
+    -lpal \
+    -lglib-2.0 \
+    -lgobject-2.0 \
+    -lgio-2.0 \
+    -lapn \
+    -ldbus-1 \
+
+LOCAL_SRC_FILES_CPP = $(wildcard *.cpp)
+LOCAL_SRC_FILES_C = $(wildcard *.c)
+EXECUTABLE = lynq-media-test
+
+OBJECTS=$(LOCAL_SRC_FILES_CPP:.cpp=.o) $(LOCAL_SRC_FILES_C:.c=.o)
+all: $(EXECUTABLE)
+
+$(EXECUTABLE): $(OBJECTS)
+	$(CXX) $(OBJECTS) $(LOCAL_LIBS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES) -o $@ 
+
+%.o: %.c
+	$(warning ----->build $<)
+	$(CC) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+%.o : %.cpp
+	$(CXX) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+
+.PHONY: clean
+clean:
+	$(RM) $(OBJECTS) $(EXECUTABLE)
diff --git a/common_src/packages/apps/lynq-tcpcli/LICENSE b/common_src/packages/apps/lynq-tcpcli/LICENSE
new file mode 100644
index 0000000..77f59ed
--- /dev/null
+++ b/common_src/packages/apps/lynq-tcpcli/LICENSE
@@ -0,0 +1,31 @@
+Copyright Statement:
+
+This software/firmware and related documentation ("MediaTek Software") are
+protected under relevant copyright laws. The information contained herein is
+confidential and proprietary to MediaTek Inc. and/or its licensors. Without
+the prior written permission of MediaTek inc. and/or its licensors, any
+reproduction, modification, use or disclosure of MediaTek Software, and
+information contained herein, in whole or in part, shall be strictly
+prohibited.
+
+MediaTek Inc. (C) 2015. All rights reserved.
+
+BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
+ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
+WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
+NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH
+RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
+INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES
+TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
+RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
+OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK
+SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE
+RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S
+ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE
+RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE
+MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
+CHARGE PAID BY RECEIVER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
diff --git a/common_src/packages/apps/lynq-tcpcli/lynq_tcpcli.c b/common_src/packages/apps/lynq-tcpcli/lynq_tcpcli.c
new file mode 100644
index 0000000..b131b76
--- /dev/null
+++ b/common_src/packages/apps/lynq-tcpcli/lynq_tcpcli.c
@@ -0,0 +1,66 @@
+#include <stdio.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <strings.h>
+#include<stdlib.h>
+#include "liblog/liblog.h"
+#include "liblog/lynq_deflog.h"
+
+#define USER_LOG_TAG "TCPCLI"
+#define SA struct sockaddr
+#define BUF_LEN 128
+#define ERR_CMDVALID  2	
+#define ERR_SOCK  3
+
+int main(int argc, const char *argv[])
+{
+	int sockfd;
+	char buf[BUF_LEN];
+	int ret_con;
+	
+	LYLOGEINIT(USER_LOG_TAG);    
+	if(argc<3)
+	{
+		LYDBGLOG("arg is wrong, please input ip and port\n");
+		LYVERBLOG("+[tcpcli]: error num = %d\n", ERR_CMDVALID);
+		return ERR_CMDVALID;
+	}
+
+	sockfd=socket(AF_INET,SOCK_STREAM,0);
+
+	if(sockfd<0)
+	{
+		LYDBGLOG("fail to socket\n");
+		return ERR_SOCK;
+	}
+	struct sockaddr_in seraddr;
+	seraddr.sin_family=AF_INET;
+	seraddr.sin_port=htons(atoi(argv[2]));
+	seraddr.sin_addr.s_addr=inet_addr(argv[1]);
+
+
+	while(1)
+	{
+		ret_con=connect(sockfd,(SA *)&seraddr,sizeof(seraddr));
+		if(ret_con<0)
+		{
+			LYDBGLOG("fail to connect\n");
+			return ERR_SOCK;
+		}
+		while(1)
+		{
+			bzero(buf,sizeof(buf));
+			fgets(buf,sizeof(buf),stdin);
+
+			send(sockfd,buf,sizeof(buf),0);
+
+			bzero(buf,sizeof(buf));
+			recv(sockfd,buf,sizeof(buf),0);
+
+			LYVERBLOG("+[tcpcli]: cli_rcv = %s\n",buf);
+		}
+	}
+	
+	return 0;
+}
diff --git a/common_src/packages/apps/lynq-tcpcli/makefile b/common_src/packages/apps/lynq-tcpcli/makefile
new file mode 100644
index 0000000..5719a8a
--- /dev/null
+++ b/common_src/packages/apps/lynq-tcpcli/makefile
@@ -0,0 +1,51 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+                -g -Os \
+                -flto \
+                -fpermissive \
+                -fPIC \
+
+
+
+
+LOCAL_PATH   = .
+
+LOCAL_C_INCLUDES = \
+  -I. \
+  -I$(ROOT)$(includedir)/logger \
+  -I$(ROOT)$(includedir)/liblog \
+  -I$(ROOT)$(includedir)/glib-2.0 \
+  -I$(ROOT)$(libdir)/glib-2.0/include \
+  -I$(ROOT)$(includedir)/dbus-1.0 \
+  -I$(ROOT)$(libdir)/dbus-1.0/include \
+
+
+LOCAL_LIBS := \
+    -L. \
+    -ldl \
+    -lpthread \
+    -llog-ril \
+    -lssl \
+    -lglib-2.0 \
+    -lgobject-2.0 \
+    -lgio-2.0 \
+    -ldbus-1 \
+
+SOURCES = $(wildcard *.c)
+
+EXECUTABLE = lynq-tcpcli
+
+OBJECTS=$(SOURCES:.c=.o)
+all: $(EXECUTABLE)
+
+$(EXECUTABLE): $(OBJECTS)
+	$(CXX) -shared -Wl,--no-undefined $(OBJECTS) $(LOCAL_LIBS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES) -o $@
+
+%.o : %.c
+	$(CC) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+
+.PHONY: clean
+clean:
+	$(RM) $(OBJECTS) $(EXECUTABLE)
diff --git a/common_src/packages/apps/lynq-tcpser/LICENSE b/common_src/packages/apps/lynq-tcpser/LICENSE
new file mode 100644
index 0000000..77f59ed
--- /dev/null
+++ b/common_src/packages/apps/lynq-tcpser/LICENSE
@@ -0,0 +1,31 @@
+Copyright Statement:
+
+This software/firmware and related documentation ("MediaTek Software") are
+protected under relevant copyright laws. The information contained herein is
+confidential and proprietary to MediaTek Inc. and/or its licensors. Without
+the prior written permission of MediaTek inc. and/or its licensors, any
+reproduction, modification, use or disclosure of MediaTek Software, and
+information contained herein, in whole or in part, shall be strictly
+prohibited.
+
+MediaTek Inc. (C) 2015. All rights reserved.
+
+BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
+ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
+WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
+NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH
+RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
+INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES
+TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
+RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
+OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK
+SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE
+RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S
+ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE
+RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE
+MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
+CHARGE PAID BY RECEIVER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
diff --git a/common_src/packages/apps/lynq-tcpser/lynq_tcpser.c b/common_src/packages/apps/lynq-tcpser/lynq_tcpser.c
new file mode 100644
index 0000000..fb97a16
--- /dev/null
+++ b/common_src/packages/apps/lynq-tcpser/lynq_tcpser.c
@@ -0,0 +1,80 @@
+#include <stdio.h>
+#include <sys/socket.h>
+#include <netinet/in.h>
+#include <arpa/inet.h>
+#include <strings.h>
+#include <unistd.h>
+#include "liblog/liblog.h"
+#include "liblog/lynq_deflog.h"
+
+#define USER_LOG_TAG "TCPSER"
+#define SA struct sockaddr
+#define BUF_LEN 128
+#define ERR_SOCK  3
+
+int main(int argc, const char *argv[])
+{
+	int sockfd,confd;
+	char buf[BUF_LEN];
+	int ret_recv;
+	int ret_bind;
+
+	LYLOGEINIT(USER_LOG_TAG);    
+	sockfd=socket(AF_INET,SOCK_STREAM,0);
+
+	if(sockfd<0)
+	{
+		LYDBGLOG("fail to socket\n");
+		return ERR_SOCK;
+	}
+	struct sockaddr_in seraddr;
+	seraddr.sin_family=AF_INET;
+	seraddr.sin_port=htons(50000);
+	seraddr.sin_addr.s_addr=inet_addr("0.0.0.0");
+
+	ret_bind=bind(sockfd,(SA *)&seraddr,sizeof(seraddr));
+	if(ret_bind<0)
+	{
+		LYDBGLOG("fail to bind\n");
+		return ERR_SOCK;
+	}
+
+	listen(sockfd,5);
+
+	while(1)
+	{
+		confd=accept(sockfd,NULL,NULL);
+		//printf("confd =%d\n",confd);
+		if(confd<0)
+		{
+			LYDBGLOG("fail to accept\n");
+			return ERR_SOCK;
+		}
+
+		while(1)
+		{
+			bzero(buf,sizeof(buf));
+
+			ret_recv=recv(confd,buf,sizeof(buf),0);
+			
+			if(ret_recv<0)
+			{
+				LYDBGLOG("fail to recv\n");
+				return ERR_SOCK;
+			}
+			if(ret_recv==0)
+			{
+				close(confd);
+				LYDBGLOG("closed,confd =%d\n",confd);
+				break;
+			}
+			
+			LYVERBLOG("+[tcpser]: ser_rcv = %s\n",buf);
+			send(confd,buf,sizeof(buf),0);
+		}
+	
+	}
+
+	
+	return 0;
+}
diff --git a/common_src/packages/apps/lynq-tcpser/makefile b/common_src/packages/apps/lynq-tcpser/makefile
new file mode 100644
index 0000000..4fdc5ce
--- /dev/null
+++ b/common_src/packages/apps/lynq-tcpser/makefile
@@ -0,0 +1,50 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+                -g -Os \
+                -flto \
+                -fpermissive \
+                -fPIC \
+
+
+
+LOCAL_PATH   = .
+
+LOCAL_C_INCLUDES = \
+  -I. \
+  -I$(ROOT)$(includedir)/logger \
+  -I$(ROOT)$(includedir)/liblog \
+  -I$(ROOT)$(includedir)/glib-2.0 \
+  -I$(ROOT)$(libdir)/glib-2.0/include \
+  -I$(ROOT)$(includedir)/dbus-1.0 \
+  -I$(ROOT)$(libdir)/dbus-1.0/include \
+
+
+LOCAL_LIBS := \
+    -L. \
+    -ldl \
+    -lpthread \
+    -llog-ril \
+    -lssl \
+    -lglib-2.0 \
+    -lgobject-2.0 \
+    -lgio-2.0 \
+    -ldbus-1 \
+
+SOURCES = $(wildcard *.c)
+
+EXECUTABLE = lynq-tcpser
+
+OBJECTS=$(SOURCES:.c=.o)
+all: $(EXECUTABLE)
+
+$(EXECUTABLE): $(OBJECTS)
+	$(CXX) -shared -Wl,--no-undefined $(OBJECTS) $(LOCAL_LIBS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES) -o $@
+
+%.o : %.c
+	$(CC) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+
+.PHONY: clean
+clean:
+	$(RM) $(OBJECTS) $(EXECUTABLE)
diff --git a/common_src/packages/apps/lynq-threadhandle/LICENSE b/common_src/packages/apps/lynq-threadhandle/LICENSE
new file mode 100644
index 0000000..77f59ed
--- /dev/null
+++ b/common_src/packages/apps/lynq-threadhandle/LICENSE
@@ -0,0 +1,31 @@
+Copyright Statement:
+
+This software/firmware and related documentation ("MediaTek Software") are
+protected under relevant copyright laws. The information contained herein is
+confidential and proprietary to MediaTek Inc. and/or its licensors. Without
+the prior written permission of MediaTek inc. and/or its licensors, any
+reproduction, modification, use or disclosure of MediaTek Software, and
+information contained herein, in whole or in part, shall be strictly
+prohibited.
+
+MediaTek Inc. (C) 2015. All rights reserved.
+
+BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
+ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
+WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
+NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH
+RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
+INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES
+TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
+RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
+OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK
+SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE
+RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S
+ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE
+RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE
+MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
+CHARGE PAID BY RECEIVER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
diff --git a/common_src/packages/apps/lynq-threadhandle/include/common.h b/common_src/packages/apps/lynq-threadhandle/include/common.h
new file mode 100644
index 0000000..02fcdeb
--- /dev/null
+++ b/common_src/packages/apps/lynq-threadhandle/include/common.h
@@ -0,0 +1,19 @@
+#ifndef _COMMON_H_

+#define _COMMON_H_

+

+

+#define NO_ERROR 			0

+#define ERR_VALID 			70			//valid error

+#define ERR_CMDVALID 		71			//cmd error

+#define ERR_SESSIONVALID 	72			//session error

+#define ERR_MALLOCVALID 	73 			//malloc error

+#define ERR_INVOKE 			74			//invoke error

+#define ERR_SYSTEM 			75			//system error

+#define ERR_TIMEOUT 		76			//time out error

+

+#define BUF_SIZE 		8192

+//int th_error;

+

+int str_arr(char *str, char *substr, char parts[][BUF_SIZE]);

+#endif

+

diff --git a/common_src/packages/apps/lynq-threadhandle/include/double_list.h b/common_src/packages/apps/lynq-threadhandle/include/double_list.h
new file mode 100644
index 0000000..b8682c0
--- /dev/null
+++ b/common_src/packages/apps/lynq-threadhandle/include/double_list.h
@@ -0,0 +1,49 @@
+#ifndef __DOUBLE_LIST__H__

+#define __DOUBLE_LIST__H__

+

+

+#include "syn_primitive.h"

+

+

+typedef struct tag_d_list 

+{

+	void *data;

+	unsigned int data_len;

+	struct tag_d_list *pre;

+	struct tag_d_list *next;

+}d_list_node_t;

+

+

+typedef struct  

+{

+	unsigned int node_count;

+	d_list_node_t *head;

+	d_list_node_t *tail;

+

+	d_list_node_t *cur_idx;

+}d_list_t;

+

+

+typedef int (*compare_func)(void *usr_data, unsigned int udata_len, void *list_data, unsigned int ldata_len);

+

+BOOL is_empty_d_list(d_list_t *list);

+unsigned int get_d_list_node_count(d_list_t *list);

+d_list_t *create_d_list(void);

+void destroy_d_list(d_list_t *list);

+BOOL insert_d_list_head(d_list_t *list, void *data, unsigned int data_len);

+BOOL insert_d_list_tail(d_list_t *list, void *data, unsigned int data_len);

+BOOL insert_d_list_head_node(d_list_t *list, d_list_node_t *node);

+BOOL insert_d_list_tail_node(d_list_t *list, d_list_node_t *node);

+BOOL delete_d_list_head(d_list_t *list);

+BOOL delete_d_list_tail(d_list_t *list);

+BOOL delete_d_list_node_all(d_list_t *list);

+BOOL remove_d_list_node(d_list_t *list, d_list_node_t *node);

+d_list_node_t *remove_d_list_head_node(d_list_t *list);

+d_list_node_t *remove_d_list_tail_node(d_list_t *list);

+d_list_node_t *find_d_list_node(d_list_t *list, void *user_data, unsigned int data_len, compare_func func);

+d_list_node_t *get_d_list_node(d_list_t *list, int idx);

+d_list_node_t *get_next_node(d_list_t *list);

+

+#endif //__DOUBLE_LIST__H__

+

+

diff --git a/common_src/packages/apps/lynq-threadhandle/include/ftp_manager.h b/common_src/packages/apps/lynq-threadhandle/include/ftp_manager.h
new file mode 100644
index 0000000..bb833ab
--- /dev/null
+++ b/common_src/packages/apps/lynq-threadhandle/include/ftp_manager.h
@@ -0,0 +1,29 @@
+#ifndef _FTP_MANAGER_H

+#define _FTP_MANAGER_H

+

+#include "thread_pool.h"

+#include "list.h"

+#include "ftp/lynq_ftp.h"

+#include "common.h"

+

+typedef struct  

+{

+	int id;

+	char *action;

+	int (*ftp_action)(lynq_ftp_socker_info* FTP);

+}FTP_MAG_S; 

+

+

+typedef struct FTP_LIST_LINK

+{

+	struct list_head list;

+	lynq_ftp_socker_info data;

+}FTP_LIST_LINK_S;

+

+

+void ftp_list_init(void);

+int ftp_list_locate(void);

+int ftp_param_verification(char result[][BUF_SIZE] , int line);

+int ftp_act_handler(thread_pool_t *pool);

+

+#endif
\ No newline at end of file
diff --git a/common_src/packages/apps/lynq-threadhandle/include/http_manager.h b/common_src/packages/apps/lynq-threadhandle/include/http_manager.h
new file mode 100644
index 0000000..21f5e70
--- /dev/null
+++ b/common_src/packages/apps/lynq-threadhandle/include/http_manager.h
@@ -0,0 +1,26 @@
+#ifndef _HTTP_MANAGER_H

+#define _HTTP_MANAGER_H

+

+

+#include "http/lynq_http.h"

+#include "thread_pool.h"

+#include "list.h"

+#include "common.h"

+

+

+

+typedef struct

+{

+	struct list_head list;

+	lynq_http_client_t data;

+}HTTP_LIST_LINK_S;

+

+void http_list_init(void);

+int http_list_locate(void);

+int http_param_verification(char result[][BUF_SIZE], int line);

+int http_act_handler(thread_pool_t *pool);

+

+

+

+#endif

+

diff --git a/common_src/packages/apps/lynq-threadhandle/include/list.h b/common_src/packages/apps/lynq-threadhandle/include/list.h
new file mode 100644
index 0000000..697ff6f
--- /dev/null
+++ b/common_src/packages/apps/lynq-threadhandle/include/list.h
@@ -0,0 +1,122 @@
+#ifndef _LINUX_LIST_H

+#define _LINUX_LIST_H

+

+#ifndef NULL

+#define NULL 0

+#endif

+

+

+#ifndef offsetof

+#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)

+#endif

+

+#ifndef container_of

+#define container_of(ptr, type, member) ((type *)((char *)ptr - offsetof(type,member)))

+#endif

+

+#define prefetch(x)  ((void)x)

+#define LIST_POISON1  (NULL)

+#define LIST_POISON2  (NULL)

+

+struct list_head{

+    struct list_head *next, *prev;

+};

+

+struct hlist_node{

+    struct hlist_node *next, **pprev;

+};

+

+struct hlist_head{

+    struct hlist_node *first;

+};

+

+#define LIST_HEAD_INIT(name) { &(name), &(name) }

+

+#define LIST_HEAD(name) \

+    struct list_head name = LIST_HEAD_INIT(name)

+

+static void INIT_LIST_HEAD(struct list_head *list)

+{

+    list->next = list;

+    list->prev = list;

+}

+

+

+static void __list_add(struct list_head *node,

+                  struct list_head *prev,

+                  struct list_head *next)

+{

+    next->prev = node;

+    node->next = next;

+    node->prev = prev;

+    prev->next = node;

+}

+

+static void list_add(struct list_head *node, struct list_head *head)

+{

+    __list_add(node, head, head->next);

+}

+

+

+static void list_add_tail(struct list_head *node, struct list_head *head)

+{

+    __list_add(node, head->prev, head);

+}

+

+/*

+ * Delete a list entry by making the prev/next entries

+ * point to each other.

+ *

+ * This is only for internal list manipulation where we know

+ * the prev/next entries already!

+ */

+static void __list_del(struct list_head * prev, struct list_head * next)

+{

+    next->prev = prev;

+    prev->next = next;

+}

+

+/**

+ * list_del - deletes entry from list.

+ * @entry: the element to delete from the list.

+ * Note: list_empty() on entry does not return true after this, the entry is

+ * in an undefined state.

+ */

+static void __list_del_entry(struct list_head *entry)

+{

+    __list_del(entry->prev, entry->next);

+}

+

+static void list_del(struct list_head *entry)

+{

+    __list_del(entry->prev, entry->next);

+    entry->next = LIST_POISON1;

+    entry->prev = LIST_POISON2;

+}

+

+/**

+ * list_entry - get the struct for this entry

+ * @ptr:    the &struct list_head pointer.

+ * @type:    the type of the struct this is embedded in.

+ * @member:    the name of the list_struct within the struct.

+ */

+#define list_entry(ptr, type, member) \

+    container_of(ptr, type, member)

+

+

+/**

+ * list_for_each    -    iterate over a list

+ * @pos:    the &struct list_head to use as a loop cursor.

+ * @head:    the head for your list.

+ */

+#define list_for_each(pos, head) \

+    for (pos = (head)->next; prefetch(pos->next), pos != (head); \

+            pos = pos->next)

+

+#define list_safe_reset_next(pos, n, member)                \

+    n = list_entry(pos->member.next, typeof(*pos), member)

+

+#define hlist_entry(ptr, type, member) container_of(ptr,type,member)

+

+#endif

+

diff --git a/common_src/packages/apps/lynq-threadhandle/include/model_manager.h b/common_src/packages/apps/lynq-threadhandle/include/model_manager.h
new file mode 100644
index 0000000..78fb3c7
--- /dev/null
+++ b/common_src/packages/apps/lynq-threadhandle/include/model_manager.h
@@ -0,0 +1,31 @@
+#ifndef _MODEL_MANAGER_H

+#define _MODEL_MANAGER_H

+

+#include "http_manager.h"

+#include "ftp_manager.h"

+#include "list.h"

+#include "thread_pool.h"

+#include <log/log.h>

+#include "ril_manager.h"

+#include "mqtt_manager.h"

+#include "common.h"

+

+typedef struct  

+{

+	char *name;

+	void (*func_list_init)(void);

+	int (*func_param_verification)(char result[][BUF_SIZE], int line);

+	int (*func_list_locate)(void);

+	int (*func_act_handler)(thread_pool_t *pool);

+	int (*func_del)(void);

+	int (*func_get)(void);

+	int (*func_set)(void);

+	int (*func_next)(void);

+}MAG_LIST_S; 

+

+

+MAG_LIST_S *list_manager_proc(const char *name);

+

+

+#endif

+

diff --git a/common_src/packages/apps/lynq-threadhandle/include/mqtt_manager.h b/common_src/packages/apps/lynq-threadhandle/include/mqtt_manager.h
new file mode 100644
index 0000000..5f8cbee
--- /dev/null
+++ b/common_src/packages/apps/lynq-threadhandle/include/mqtt_manager.h
@@ -0,0 +1,25 @@
+#ifndef _MQTT_MANAGER_H

+#define _MQTT_MANAGER_H

+

+#include "lynq_mqtt/lynq_mqtt.h"

+#include "thread_pool.h"

+#include "list.h"

+#include "common.h"

+

+

+

+typedef struct

+{

+	struct list_head list;

+	struct mqtt_set_parament data;

+}MQTT_LIST_LINK_S;

+

+

+void mqtt_list_init();

+int mqtt_param_verification(char result[][BUF_SIZE] , int line);

+int mqtt_list_locate();

+int mqtt_act_handler(thread_pool_t *pool);

+

+

+#endif

+

diff --git a/common_src/packages/apps/lynq-threadhandle/include/ril_manager.h b/common_src/packages/apps/lynq-threadhandle/include/ril_manager.h
new file mode 100644
index 0000000..c491cda
--- /dev/null
+++ b/common_src/packages/apps/lynq-threadhandle/include/ril_manager.h
@@ -0,0 +1,7 @@
+#include "model_manager.h"

+#include "common.h"

+

+void ril_list_init();

+int ril_param_verification(char result[][BUF_SIZE] , int line);

+int ril_list_locate();

+int ril_act_handler(thread_pool_t *pool);

diff --git a/common_src/packages/apps/lynq-threadhandle/include/seq_queue.h b/common_src/packages/apps/lynq-threadhandle/include/seq_queue.h
new file mode 100644
index 0000000..2aed03e
--- /dev/null
+++ b/common_src/packages/apps/lynq-threadhandle/include/seq_queue.h
@@ -0,0 +1,43 @@
+#ifndef __SEQ_QUEUE__H_

+#define __SEQ_QUEUE__H_

+

+#include "syn_primitive.h"

+

+

+#ifndef in

+#define in

+#define out

+#endif

+

+#define EXPAND_BLOCK_NUM 100

+

+typedef struct  

+{

+	BOOL expandabilit;

+	unsigned int expand_blocks;

+

+	unsigned int block_size;

+	unsigned int total_block;

+

+	unsigned int current_block;

+	unsigned int tail_block;

+	unsigned int used_block;

+

+	void *block_buffer;

+

+	//mutex_handle task_queue_lock;

+	sem_handle task_queue_lock;

+

+}seq_queue_t;

+

+

+seq_queue_t *create_seq_queue(in unsigned int block_size, in unsigned int total_block, in BOOL expand);

+void destroy_seq_queue(in seq_queue_t *queue);

+BOOL en_seq_queue(in seq_queue_t *queue, in void *data);

+BOOL de_seq_queue(in seq_queue_t *queue, out void *data);

+unsigned int get_count_seq_queue(in seq_queue_t *queue);

+unsigned int get_total_seq_queue(in seq_queue_t *queue);

+

+

+#endif //__SEQ_QUEUE__H_

+

diff --git a/common_src/packages/apps/lynq-threadhandle/include/syn_primitive.h b/common_src/packages/apps/lynq-threadhandle/include/syn_primitive.h
new file mode 100644
index 0000000..77dc2d5
--- /dev/null
+++ b/common_src/packages/apps/lynq-threadhandle/include/syn_primitive.h
@@ -0,0 +1,43 @@
+#ifndef __SYN_PRIMITIVE__H_

+#define __SYN_PRIMITIVE__H_

+

+#include <pthread.h>

+#include <semaphore.h>

+#include "typedefs.h"

+#include <string.h>

+#include <stdio.h>

+#include <stdlib.h>

+#include "liblog/liblog.h"

+#include "liblog/lynq_deflog.h"

+

+typedef pthread_t       thread_id;

+typedef pthread_t       thread_handle;

+typedef pthread_cond_t  condition_handle;

+typedef pthread_mutex_t mutex_handle;

+typedef sem_t			sem_handle;

+

+

+

+#define TIME_WAIT_INFINITE 0x7fffffff

+

+

+

+int init_condition_handle(condition_handle *cond);

+int destroy_condition_handle(condition_handle *cond);

+//int wait_condition(condition_handle *cond, mutex_handle *mutex);

+int wait_condition(condition_handle *cond, mutex_handle *mutex, unsigned int wait);

+int post_condition_signal(condition_handle *cond);

+int init_mutex_handle(mutex_handle *mutex);

+int mutex_lock(mutex_handle *mutex);

+int mutex_unlock(mutex_handle *mutex);

+int mutex_destroy(mutex_handle *mutex);

+int create_sem(sem_handle *sem, int init_count);

+int wait_sem(sem_handle *sem);

+int post_sem(sem_handle *sem);

+int destroy_sem(sem_handle *sem);

+

+

+

+#endif //__SYN_PRIMITIVE__H_

+

+

diff --git a/common_src/packages/apps/lynq-threadhandle/include/thread_pool.h b/common_src/packages/apps/lynq-threadhandle/include/thread_pool.h
new file mode 100644
index 0000000..cc2cd29
--- /dev/null
+++ b/common_src/packages/apps/lynq-threadhandle/include/thread_pool.h
@@ -0,0 +1,83 @@
+#ifndef __THREAD_POOL__H_

+#define __THREAD_POOL__H_

+

+#include "syn_primitive.h"

+#include "double_list.h"

+#include "seq_queue.h"

+

+typedef enum {EThread_pool_unknown, EThread_pool_alloc, EThread_pool_init

+, EThread_pool_run, EThread_pool_exit, EThread_pool_MAX}EThread_pool_status;

+

+

+#define RELEASE_THREAD_INTERVAL 5*60 

+

+

+typedef void (*THREAD_FUNC)(void *);

+typedef void (*USER_FUNC)(void *thread_para);

+

+

+typedef struct {

+	USER_FUNC timeout_callback;

+	unsigned long time_out;

+}time_out_t;

+

+typedef struct  

+{

+	USER_FUNC process_func;

+	USER_FUNC  release_func;

+	void *args;

+	time_out_t time_out_info;

+}thread_func_t;

+

+typedef struct  

+{

+	thread_func_t thread_para;

+	unsigned int pri;

+

+	BOOL busy;

+	BOOL release;

+

+	unsigned long launch_time;

+	unsigned long time_out;

+

+	EThread_pool_status *pool_status;

+

+	thread_handle h_thread;

+	condition_handle thread_cond;

+	mutex_handle thread_lock;

+

+}thread_info_t;

+

+typedef struct 

+{

+	unsigned int pri;

+	unsigned int min_thread_num;

+	unsigned int max_thread_num;

+

+	unsigned int pool_thread_num;

+

+	condition_handle manage_cond;

+	mutex_handle mange_lock;

+

+	unsigned long release_threads_interval;

+

+	d_list_t *idle_threads;

+	d_list_t *busy_threads;

+	seq_queue_t *task_queue;

+

+	sem_handle sem_inc;

+	thread_handle h_id;

+	

+	EThread_pool_status status;

+}thread_pool_t;

+

+

+thread_pool_t *threadpool_create(unsigned int min_thread_num, unsigned int max_thread_num);

+void threadpool_destroy(thread_pool_t *pool);

+BOOL threadpool_add(thread_pool_t *pool, USER_FUNC process_func, void *args);

+BOOL threadpool_add_timeout(thread_pool_t *pool, USER_FUNC process_func

+		, USER_FUNC release_func, void *args, time_out_t *time_out);

+void tp_sleep(unsigned int ms);

+

+#endif //__THREAD_POOL__H_

+

diff --git a/common_src/packages/apps/lynq-threadhandle/include/typedefs.h b/common_src/packages/apps/lynq-threadhandle/include/typedefs.h
new file mode 100644
index 0000000..d205b1c
--- /dev/null
+++ b/common_src/packages/apps/lynq-threadhandle/include/typedefs.h
@@ -0,0 +1,21 @@
+#ifndef __TYPE_DEFS__H_

+#define __TYPE_DEFS__H_

+

+#ifndef NULL

+#define NULL 0

+#endif

+

+#ifndef BOOL

+#define BOOL unsigned char

+#endif

+

+#ifndef TRUE

+#define TRUE 1

+#endif

+

+#ifndef FALSE

+#define FALSE 0

+#endif

+

+

+#endif //__TYPE_DEFS__H_

diff --git a/common_src/packages/apps/lynq-threadhandle/makefile b/common_src/packages/apps/lynq-threadhandle/makefile
new file mode 100644
index 0000000..281cea7
--- /dev/null
+++ b/common_src/packages/apps/lynq-threadhandle/makefile
@@ -0,0 +1,61 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+                -std=gnu++14 \
+                -g -Os \
+                -flto \
+                -fpermissive \
+                -fPIC \
+
+
+
+
+LOCAL_PATH   = .
+
+LOCAL_C_INCLUDES = \
+  -I. \
+  -I$(ROOT)$(includedir)/logger \
+  -I$(ROOT)$(includedir)/vendor-ril \
+  -I$(LOCAL_PATH)/include \
+  -I$(ROOT)$(includedir)/liblog \
+  -I$(ROOT)$(includedir)/glib-2.0 \
+  -I$(ROOT)$(libdir)/glib-2.0/include \
+  -I$(ROOT)$(includedir)/dbus-1.0 \
+  -I$(ROOT)$(libdir)/dbus-1.0/include \
+  -I$(ROOT)$(includedir)/ftp \
+  -I$(ROOT)$(includedir)/http \
+  -I$(ROOT)$(includedir)/lynq_mqtt \
+  -I$(ROOT)$(includedir)/liblynq-broadcast \
+
+
+LOCAL_LIBS := \
+    -L. \
+    -ldl \
+    -lpthread \
+    -llynq-log \
+    -lssl \
+    -lglib-2.0 \
+    -lgobject-2.0 \
+    -lgio-2.0 \
+    -ldbus-1 \
+    -llynq-protcl \
+    -llog \
+    -llynq-broadcast \
+
+SOURCES = $(wildcard *.c src/*.c)
+
+EXECUTABLE = lynq-threadhandle
+
+OBJECTS=$(SOURCES:.c=.o)
+all: $(EXECUTABLE)
+
+$(EXECUTABLE): $(OBJECTS)
+	$(CXX) $(OBJECTS) $(LOCAL_LIBS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES) -o $@
+
+%.o : %.c
+	$(CC) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+
+.PHONY: clean
+clean:
+	$(RM) $(OBJECTS) $(EXECUTABLE)
diff --git a/common_src/packages/apps/lynq-threadhandle/src/common.c b/common_src/packages/apps/lynq-threadhandle/src/common.c
new file mode 100644
index 0000000..e8a5968
--- /dev/null
+++ b/common_src/packages/apps/lynq-threadhandle/src/common.c
@@ -0,0 +1,65 @@
+#include <stdio.h>

+#include <malloc.h>

+#include <string.h>

+#include "common.h"

+#include "liblog/lynq_deflog.h"

+

+int str_arr(char *str, char *substr, char parts[][BUF_SIZE])

+{         

+	char *p = NULL;  

+	char *q = NULL;		

+	char tmp[BUF_SIZE] = "";	

+	char end[BUF_SIZE] = "";			

+	char *start = strdup(str);	

+	int i = 0, j = 0, k = 0, par_num=0;

+

+

+	while(*str != '\0')    

+	{        

+		p = str;        

+		q = substr;		

+		tmp[i] = *str;		

+		i++;

+		

+		while((*p == *q) && (*p != '\0') && (*q != '\0'))        

+		{            

+			p++;            

+			q++;        

+		}         

+		if(*q == '\0')

+		{			

+			memset(end, 0, sizeof(end));			

+			strcpy(end, p);

+

+			memset(parts[j], 0, sizeof(parts[j]));

+			

+			j == 0 ? memcpy(parts[j], tmp, strlen(tmp)-1) : memcpy(parts[j], tmp+1, strlen(tmp)-2) ;			

+

+			j++;			

+			memset(tmp, 0, sizeof(tmp));			

+			i = 0;			            

+			par_num++;         

+		}		

+

+		str++;

+	}	

+	

+	

+	if (!par_num) {

+		LYDBGLOG("[%s-%d] cmd is error!!!\n", __FUNCTION__, __LINE__);

+		LYVERBLOG("+[thhandle]: error num = %d\n", ERR_CMDVALID);

+		return ERR_CMDVALID;

+	}

+		

+	

+	if (strcmp(end, "") != 0) {		

+		memset(parts[j], 0, sizeof(parts[j]));

+		memcpy(parts[j], tmp+1, strlen(tmp)-2);

+	}

+

+	for (i = 0 ; i < par_num + 1 ; i++)

+		memcpy(parts[i], strchr(parts[i],'"')+1,strlen(parts[i]));	

+	

+	return par_num; 			

+}

+

diff --git a/common_src/packages/apps/lynq-threadhandle/src/double_list.c b/common_src/packages/apps/lynq-threadhandle/src/double_list.c
new file mode 100644
index 0000000..030e677
--- /dev/null
+++ b/common_src/packages/apps/lynq-threadhandle/src/double_list.c
@@ -0,0 +1,378 @@
+#include "double_list.h"

+

+

+BOOL is_empty_d_list(d_list_t *list) {

+	BOOL ret = FALSE;

+	if (list == NULL)

+		return FALSE;

+

+	if (list->node_count == 0 && list->head == NULL && list->tail == NULL) 

+		ret = TRUE;

+	

+	return ret;

+}

+

+

+unsigned int get_d_list_node_count(d_list_t *list) {

+	return list->node_count;

+}

+

+

+d_list_t *create_d_list(void) {

+	d_list_t *temp_list = (d_list_t *)malloc(sizeof(d_list_t));

+	if (temp_list) {

+		memset(temp_list, 0, sizeof(d_list_t));

+	}

+

+	return temp_list;

+}

+

+

+d_list_node_t *create_d_list_node(void *data, unsigned int data_len) {

+

+	d_list_node_t *temp_node = (d_list_node_t *)malloc(sizeof(d_list_node_t));

+	if (temp_node) {

+

+		memset(temp_node, 0, sizeof(d_list_node_t));

+		temp_node->data = data;

+		temp_node->data_len = data_len;

+	}

+

+	return temp_node;

+}

+

+

+d_list_node_t *insert_d_list_node_head_n(d_list_node_t *head, d_list_node_t *node) {

+		

+	if (head && node) {

+		node->pre = head->pre;

+		node->next = head;

+		

+		head->pre = node;

+	}

+	

+	return node;

+}

+

+

+d_list_node_t *insert_d_list_node_tail_n(d_list_node_t *tail, d_list_node_t *node) {

+	

+	if (tail && node) {

+		

+		tail->next = node;

+		node->pre = tail;

+		node->next = NULL;

+	}

+	

+	return node;

+}

+

+

+d_list_node_t *insert_d_list_node_head(d_list_node_t *head, void *data, unsigned int data_len) {

+

+	d_list_node_t *temp_node = create_d_list_node(data, data_len);

+

+	return insert_d_list_node_head_n(head, temp_node);

+}

+

+d_list_node_t *insert_d_list_node_tail(d_list_node_t *tail, void *data, unsigned int data_len) {

+	

+	d_list_node_t *temp_node = create_d_list_node(data, data_len);

+	

+	return insert_d_list_node_tail_n(tail, temp_node);

+}

+

+

+BOOL insert_d_list_head(d_list_t *list, void *data, unsigned int data_len) {

+	

+	if (list) {

+

+		if (list->node_count == 0) {

+			list->head = insert_d_list_node_head(list->head, data, data_len);

+			list->tail = list->head;

+		} else {

+			list->head = insert_d_list_node_head(list->head, data, data_len);

+		}

+

+		list->node_count++;

+

+		return TRUE;

+	}

+	

+	return FALSE;

+}

+

+

+BOOL insert_d_list_head_node(d_list_t *list, d_list_node_t *node) {

+	

+	if (list) {

+		

+		node->next = NULL;

+		node->pre = NULL;

+		if (list->node_count == 0) {

+			list->head = insert_d_list_node_head_n(list->head, node);

+			list->tail = list->head;

+		} else {

+			list->head = insert_d_list_node_head_n(list->head, node);

+		}

+		

+		list->node_count++;

+		

+		return TRUE;

+	}

+	

+	return FALSE;

+}

+

+

+BOOL insert_d_list_tail(d_list_t *list, void *data, unsigned int data_len) {

+

+	if (list && data) {

+

+		if (list->node_count == 0) {

+			list->tail = insert_d_list_node_tail(list->tail, data, data_len);

+			list->head = list->tail;

+		} else {

+			list->tail = insert_d_list_node_tail(list->tail, data, data_len);

+		}

+

+		list->node_count++;

+

+		return TRUE;

+	}

+

+	return FALSE;

+}

+

+

+BOOL insert_d_list_tail_node(d_list_t *list, d_list_node_t *node) {

+

+	BOOL ret = FALSE;

+	if (list) {

+

+		node->next = NULL;

+		node->pre = NULL;

+		if (list->node_count == 0) {

+			list->tail = insert_d_list_node_tail_n(list->tail, node);

+			list->head = list->tail;

+		} else {

+			list->tail = insert_d_list_node_tail_n(list->tail, node);

+		}

+		list->node_count++;

+		ret = TRUE;

+	}

+

+	return ret;

+}

+

+

+BOOL delete_d_list_head(d_list_t *list) {

+

+	BOOL ret = FALSE;

+	if (list == NULL)

+		return FALSE;

+

+	if (list->node_count > 0) {

+		d_list_node_t *temp_node = list->head;

+		

+		list->head = list->head->next;

+		list->node_count--;

+		if (list->node_count == 0 && list->head == NULL) {

+			list->tail = NULL;

+		} else {

+			list->head->pre = NULL;

+		}

+

+		free(temp_node);

+		ret = TRUE;

+	}

+

+	

+	return ret;

+}

+

+

+BOOL delete_d_list_tail(d_list_t *list) {

+	

+	BOOL ret = FALSE;

+	if (list == NULL)

+		return FALSE;

+

+	if (list->node_count > 0) {

+		d_list_node_t *temp_node = list->tail;

+		

+		list->tail = list->tail->pre;

+		list->node_count--;

+		if (list->node_count == 0 && list->tail == NULL) {

+			list->head = NULL;

+		} else {

+			list->tail->next = NULL;

+		}

+		

+		free(temp_node);

+		ret = TRUE;

+	}

+	

+	return ret;

+}

+

+

+BOOL remove_d_list_node(d_list_t *list, d_list_node_t *node) {

+	

+	if (node == NULL || list == NULL || list->node_count == 0)

+		return FALSE;

+

+	if (list->head == node) {

+		list->head = node->next;

+		if (list->head != NULL) {

+			node->next->pre = NULL;

+		} else {

+			list->tail = NULL;

+		}

+	} else {

+		node->pre->next = node->next;

+		if (node->next == NULL) {

+			list->tail = node->pre;

+		} else {

+			node->next->pre = node->pre;

+		}

+	}

+

+	node->next = NULL;

+	node->pre = NULL;

+	list->node_count--;

+

+	return TRUE;

+}

+

+

+d_list_node_t *remove_d_list_head_node(d_list_t *list) {

+

+	d_list_node_t *temp_node = NULL;

+	if (list == NULL)

+		return NULL;

+

+	if (list->head != NULL) {

+

+		temp_node = list->head;

+		list->head = list->head->next;

+		if (list->head == NULL)

+			list->tail = NULL;

+		else

+			list->head->pre = NULL;

+

+		list->node_count--;

+	}

+

+	return temp_node;

+}

+

+

+d_list_node_t *remove_d_list_tail_node(d_list_t *list) {

+

+	d_list_node_t *temp_node = NULL;

+	if (list == NULL)

+		return NULL;

+

+	if (list->tail != NULL) {

+

+		temp_node = list->tail;

+		list->tail = list->tail->pre;

+		if (list->tail == NULL)

+			list->head = NULL;

+		else

+			list->tail->next = NULL;

+

+		list->node_count--;

+	}

+

+	return temp_node;

+}

+

+

+BOOL delete_d_list_node_all(d_list_t *list) {

+

+	if (list) {

+		while (delete_d_list_head(list)) {

+

+		}

+

+		if (list->node_count == 0) {

+			return TRUE;

+		}

+	}

+

+	return FALSE;

+}

+

+void destroy_d_list(d_list_t *list) {

+	if (list == NULL)

+		return;

+

+	delete_d_list_node_all(list);

+	free(list);

+}

+

+

+d_list_node_t *find_d_list_node(d_list_t *list, void *user_data, unsigned int data_len, compare_func func) {

+	

+	d_list_node_t *temp_node = NULL;

+	if (list == NULL)

+		return NULL;

+

+	if (list->node_count > 0) {

+		temp_node = list->head;

+		while (temp_node)

+		{

+			if (func(user_data, data_len, temp_node->data, temp_node->data_len) == 0) {

+				break;

+			}

+

+			temp_node = temp_node->next;

+		}

+	}

+

+	return temp_node;

+}

+

+

+d_list_node_t *get_d_list_node(d_list_t *list, int idx) {

+	d_list_node_t *temp_node = NULL;

+	if (list == NULL)

+		return NULL;

+

+	if (list->node_count >= (unsigned int)abs(idx) && idx != 0) {

+

+		if (idx > 0) {

+			temp_node = list->head;

+			while (--idx)

+			{

+				temp_node = temp_node->next;

+			}

+		} else {

+			temp_node = list->tail;

+			while (++idx)

+			{

+				temp_node = temp_node->pre;

+			}

+		}

+	}

+

+	return temp_node;

+}

+

+

+d_list_node_t *get_next_node(d_list_t *list) {

+

+	d_list_node_t *temp_node;

+	if (list == NULL)

+		return NULL;

+

+	temp_node = list->cur_idx;

+	if (temp_node == NULL)

+		list->cur_idx = list->head;

+	else

+		list->cur_idx = list->cur_idx->next;

+	

+	return temp_node;

+}

diff --git a/common_src/packages/apps/lynq-threadhandle/src/ftp_manager.c b/common_src/packages/apps/lynq-threadhandle/src/ftp_manager.c
new file mode 100644
index 0000000..8f453cc
--- /dev/null
+++ b/common_src/packages/apps/lynq-threadhandle/src/ftp_manager.c
@@ -0,0 +1,327 @@
+#include "ftp_manager.h"

+#include "common.h"

+#include <unistd.h>

+#include <stdio.h>

+#include <string.h>

+

+

+enum FTP_ID { 

+	FTP_LOGIN_ID = 0, 

+	FTP_GET_ID, 

+	FTP_UP_ID, 

+	FTP_QUIT_ID, 

+	FTP_LS_ID,

+	FTP_CD_ID = 5,

+	FTP_MKDIR_ID, 

+	FTP_RMD_ID,

+	FTP_DELETE_ID

+};

+

+

+

+FTP_MAG_S ftp_manager[] = {

+	{FTP_LOGIN_ID, "login", lynq_ftp_login},

+	{FTP_GET_ID, "get", lynq_ftp_download},

+	{FTP_UP_ID, "up", lynq_ftp_up},

+	{FTP_QUIT_ID, "quit", lynq_ftp_quit},

+	{FTP_LS_ID, "ls", lynq_ftp_ls},

+	{FTP_CD_ID, "cd", lynq_ftp_cd},

+	{FTP_MKDIR_ID, "mkdir", lynq_ftp_creat_mkd},

+	{FTP_RMD_ID, "rmd", lynq_ftp_delete_mkd},

+	{FTP_DELETE_ID, "delete", lynq_ftp_deletefile_mkd},

+};

+

+

+static int ftp_init = 0;

+static struct list_head lynq_ftp_list;

+static FTP_LIST_LINK_S* ftp_slider;

+static lynq_ftp_socker_info ftp_cmd = {0};

+

+FTP_MAG_S *ftp_mag_ret = NULL;

+

+

+void *ftp_handler(void * list)

+{

+	FTP_LIST_LINK_S* pos_list  = (FTP_LIST_LINK_S *)list;

+	int ftp_login = 0; 

+	char cmpybuf[64] = "";

+	

+	while(1)

+	{

+		if (pos_list->data.modify_thread != 1 && pos_list->data.add_thread != 1)

+			continue;

+		

+		//LYDBGLOG("[%s-%d] rita thread_id %lu start.\n",__FUNCTION__, __LINE__, pthread_self());

+

+		pos_list->data.add_thread = 0;

+		pos_list->data.modify_thread = 0;

+#if 0

+		LYDBGLOG("**************************ftp_handler debug************************************\n");

+		LYDBGLOG("[%s %d] ---------- > pos_list->data.session = %d\n", __FUNCTION__, __LINE__, pos_list->data.session);

+		LYDBGLOG("[%s %d] ---------- > pos_list->data.sevname = %s\n", __FUNCTION__, __LINE__, pos_list->data.sevname);

+		LYDBGLOG("[%s %d] ---------- > pos_list->data.username = %s\n", __FUNCTION__, __LINE__, pos_list->data.username);

+		LYDBGLOG("[%s %d] ---------- > pos_list->data.pw = %s\n", __FUNCTION__, __LINE__, pos_list->data.pw);

+		LYDBGLOG("[%s %d] ---------- > pos_list->data.is_pasv_mode = %s\n", __FUNCTION__, __LINE__, pos_list->data.is_pasv_mode);

+		LYDBGLOG("[%s %d] ---------- > pos_list->data.action = %s\n", __FUNCTION__, __LINE__, pos_list->data.action);

+		LYDBGLOG("[%s %d] ---------- > pos_list->data.id = %d\n", __FUNCTION__, __LINE__, pos_list->data.id);

+		LYDBGLOG("**************************debug end************************************\n");

+#endif

+		if (ftp_login == 0 && FTP_QUIT_ID != pos_list->data.id) {

+			ftp_login = lynq_ftp_login(&pos_list->data);

+			LYDBGLOG("[%s-%d] rita test for debuging ftp,ftp_login = %d\n", __FUNCTION__, __LINE__, ftp_login);

+			if(!ftp_login)//rita add @2021.7.19 for error connect,reconnect failure

+			{

+				LYDBGLOG("[%s-%d] rita test for debuging ftp,error!!!\n", __FUNCTION__, __LINE__);

+				list_del((struct list_head* )pos_list);

+			}

+		} 

+		else {

+			LYDBGLOG("[%s-%d] +ftplogin: Device logged in before !!!\n", __FUNCTION__, __LINE__);

+		}

+

+		ftp_mag_ret->ftp_action(&pos_list->data);

+	}

+}

+

+

+int ftp_act_handler(thread_pool_t *pool)

+{

+	FTP_LIST_LINK_S* tmp_list = (FTP_LIST_LINK_S *)ftp_slider;

+	struct list_head* slider = NULL;

+	FTP_LIST_LINK_S* tmp = NULL;

+	if(tmp == NULL)

+	{

+		tmp = (FTP_LIST_LINK_S*)malloc(sizeof(FTP_LIST_LINK_S));

+		if(tmp == NULL)

+		{

+			LYVERBLOG("+[thhandle]: error num = %d\n", ERR_MALLOCVALID);

+			return ERR_MALLOCVALID;

+		}

+	}

+	memset(tmp, 0, sizeof(FTP_LIST_LINK_S));

+	LYDBGLOG("[%s-%d] ftp_cmd.id = %d\n", __FUNCTION__, __LINE__, ftp_cmd.id);

+

+	switch(ftp_cmd.id)

+	{

+		case FTP_LOGIN_ID:

+		case FTP_GET_ID:

+		case FTP_UP_ID:

+		case FTP_QUIT_ID:

+		case FTP_LS_ID:

+		case FTP_CD_ID:

+		case FTP_MKDIR_ID:

+		case FTP_RMD_ID:

+		case FTP_DELETE_ID:

+			if (tmp_list == NULL ) {

+				LYDBGLOG("[%s-%d] first time\n", __FUNCTION__, __LINE__);

+				tmp->data = ftp_cmd;

+				tmp->data.add_thread = 1;

+				list_add_tail(&tmp->list, &lynq_ftp_list);

+					

+				ftp_list_locate();

+				if (!threadpool_add(pool, ftp_handler, (void *)ftp_slider)) {

+					LYDBGLOG("add error!!!\n");

+					LYVERBLOG("+[thhandle]: error num = %d\n", ERR_INVOKE);

+					return ERR_INVOKE;

+				}

+			}

+			else {

+				LYDBGLOG("[%s-%d] change ftp_cmd.file_type = %s \n",__func__, __LINE__, ftp_cmd.file_type);

+				LYDBGLOG("[%s-%d] change ftp_cmd.is_pasv_mode = %s \n",__func__, __LINE__, ftp_cmd.is_pasv_mode);

+				LYDBGLOG("[%s-%d] tmp_list->data.control_sockfd = %d \n", __FUNCTION__, __LINE__, tmp_list->data.control_sockfd);

+

+				//	Save sockfd. If you don't save it, it will be overridden to 0, resulting in unable to connect

+				ftp_cmd.control_sockfd = tmp_list->data.control_sockfd;

+				tmp_list->data = ftp_cmd;

+				tmp_list->data.modify_thread = 1;

+			}

+

+			break;

+		default:

+			LYDBGLOG("[%s-%d] cmd error \n", __FUNCTION__, __LINE__);

+			LYVERBLOG("+[thhandle]: error num = %d\n", ERR_CMDVALID);

+

+			if (tmp != NULL)

+				free(tmp);

+			return ERR_CMDVALID;

+	}

+

+	tmp = NULL;

+	return NO_ERROR;

+}

+

+

+FTP_MAG_S *ftp_manager_proc(const char *action)

+{

+    int type_num = sizeof(ftp_manager) / sizeof(FTP_MAG_S);

+    int i = 0;

+    for (i = 0; i < type_num; i++)

+    {

+        if (0 == strcmp(ftp_manager[i].action, action))

+        {

+			//LYDBGLOG("[%s-%d] action is ftp %s\n",  __FUNCTION__, __LINE__, ftp_manager[i].action);//rita add @2021.07.19 for debug description

+            return &ftp_manager[i];

+        }

+    }

+	//LYDBGLOG("[%s-%d] error action %s\n", __FUNCTION__, __LINE__, action);

+	return NULL;

+}

+

+

+int ftp_param_verification(char result[][BUF_SIZE] , int line)

+{

+

+	for (int i = 0; i < line; i++) {

+	        LYDBGLOG("[%s-%d]=======>rita,str[%d] = %s \n", __FUNCTION__, __LINE__, i, result[i]);

+	}

+

+	if (line < 3) {

+		LYDBGLOG("[%s-%d] command error\n", __FUNCTION__, __LINE__);

+		LYVERBLOG("+[thhandle]: error num = %d\n", ERR_CMDVALID);

+		return ERR_CMDVALID;

+	}

+

+

+	memcpy(ftp_cmd.protocol, result[0], sizeof(ftp_cmd.protocol));//rita add @2021.07.19 for protocol type mismatch

+

+	if(!atoi(result[2])) {

+		LYDBGLOG("[%s %d] session error\n", __FUNCTION__, __LINE__);

+		LYVERBLOG("+[thhandle]: error num = %d\n", ERR_SESSIONVALID);

+		return ERR_SESSIONVALID;

+	}

+	ftp_cmd.session = atoi(result[2]);

+	memcpy(ftp_cmd.action, result[1], sizeof(ftp_cmd.action));//rita add @2021.07.19 for action type mismatch

+	strcpy(ftp_cmd.sevname, result[3]);

+

+	ftp_cmd.portnum = atoi(result[4]);

+	strcpy(ftp_cmd.username, result[5]);

+	strcpy(ftp_cmd.pw, result[6]);

+	

+	//LYDBGLOG("[%s-%d] sevname=%s, portnum=%d, username=%s,pw=%s \n", __FUNCTION__, __LINE__, ftp_cmd.sevname, ftp_cmd.portnum, ftp_cmd.username, ftp_cmd.pw);

+

+	ftp_mag_ret = ftp_manager_proc(ftp_cmd.action);	

+

+	

+	ftp_cmd.id = ftp_mag_ret->id;

+

+	LYDBGLOG("[%s-%d] ftp_cmd.id = %d\n", __FUNCTION__, __LINE__, ftp_cmd.id);

+

+	switch (ftp_mag_ret->id)

+	{

+		case FTP_LOGIN_ID:

+			if(line != 7)

+			{

+				LYDBGLOG("[%s-%d] command error\n", __FUNCTION__, __LINE__);

+				LYVERBLOG("+[thhandle]: error num = %d\n", ERR_CMDVALID);

+				return ERR_CMDVALID;

+			}

+			break;

+			

+		case FTP_GET_ID:

+			if(line != 12)

+			{

+				LYDBGLOG("[%s-%d] command error\n", __FUNCTION__, __LINE__);

+				LYVERBLOG("+[thhandle]: error num = %d\n", ERR_CMDVALID);

+				return ERR_CMDVALID;

+			}			

+			strcpy(ftp_cmd.getfilename_path, result[9]);

+			strcpy(ftp_cmd.getfilename, result[10]);

+		case FTP_UP_ID:

+			if (line != 12) {

+				LYDBGLOG("[%s-%d] command error id = %d\n", __FUNCTION__, __LINE__, ftp_mag_ret->id);

+				LYVERBLOG("+[thhandle]: error num = %d\n", ERR_CMDVALID);

+				return ERR_CMDVALID;

+			}

+			strcpy(ftp_cmd.file_type, result[7]);

+			strcpy(ftp_cmd.is_pasv_mode, result[8]);

+			strcpy(ftp_cmd.put_opt , result[11]);

+

+			if (ftp_mag_ret->id == FTP_UP_ID) {

+				strcpy(ftp_cmd.putfilename_path, result[9]);

+				strcpy(ftp_cmd.putfilename, result[10]);

+			}

+			break;

+

+		case FTP_QUIT_ID:

+			if (line < 8) {

+				LYVERBLOG("+[thhandle]: error num = %d\n", ERR_CMDVALID);				

+				return ERR_CMDVALID;

+			}

+			break;

+

+		case FTP_LS_ID:

+			if (line !=9) {

+				LYDBGLOG("[%s-%d] command error id = %d\n", __FUNCTION__, __LINE__, ftp_mag_ret->id);

+				LYVERBLOG("+[thhandle]: error num = %d\n", ERR_CMDVALID);

+				return ERR_CMDVALID;

+			}

+

+			strcpy(ftp_cmd.dir, result[8]);//rita add @2021.7.19 for ls bug

+			strcpy(ftp_cmd.is_pasv_mode, result[7]);

+			break;

+		case FTP_CD_ID:

+		case FTP_MKDIR_ID:

+		case FTP_RMD_ID:

+		case FTP_DELETE_ID:

+			if (line != 8) {

+				LYVERBLOG("+[thhandle]: error num = %d\n", ERR_CMDVALID);

+				return ERR_CMDVALID;

+			}

+			strcpy(ftp_cmd.del_mkr_filename, result[7]);

+			//strcpy(ftp_cmd.is_pasv_mode, result[7]);

+			break;

+

+		default:

+			LYVERBLOG("+[thhandle]: error num = %d\n", ERR_CMDVALID);

+			break;

+			

+	}

+

+	return NO_ERROR;

+

+}

+

+

+int ftp_list_locate()

+{

+	struct list_head* slider = NULL;

+	ftp_slider = NULL;

+	list_for_each(slider, &lynq_ftp_list) {

+		ftp_slider = (FTP_LIST_LINK_S*)slider;

+		LYDBGLOG("[%s-%d]  =============START====================== \n", __func__, __LINE__);

+		LYDBGLOG("[%s-%d]  protocol : %s \n", __FUNCTION__, __LINE__, ftp_slider->data.protocol);

+		LYDBGLOG("[%s-%d]  session : %d \n", __FUNCTION__, __LINE__, ftp_slider->data.session);

+		LYDBGLOG("[%s-%d]  action : %s \n", __FUNCTION__, __LINE__, ftp_slider->data.action);

+		LYDBGLOG("[%s-%d]  port : %d \n", __FUNCTION__, __LINE__, ftp_slider->data.portnum);

+		LYDBGLOG("[%s-%d]  sevname : %s \n", __FUNCTION__, __LINE__, ftp_slider->data.sevname);

+		LYDBGLOG("[%s-%d]  username : %s \n", __FUNCTION__, __LINE__, ftp_slider->data.username);

+		LYDBGLOG("[%s-%d]  pw : %s \n", __FUNCTION__, __LINE__, ftp_slider->data.pw);

+		LYDBGLOG("[%s-%d]  index : %d \n", __FUNCTION__, __LINE__, ftp_slider->data.index);

+		LYDBGLOG("[%s-%d]  ==============END===================== \n", __func__, __LINE__);

+

+		if (!strcmp(ftp_slider->data.protocol, ftp_cmd.protocol) && ftp_slider->data.session == ftp_cmd.session) {

+			//LYDBGLOG("[%s-%d] Node found\n", __FUNCTION__, __LINE__);

+			if (strcmp(ftp_slider->data.sevname, ftp_cmd.sevname) != 0 || strcmp(ftp_slider->data.username, ftp_cmd.username) != 0 || strcmp(ftp_slider->data.pw, ftp_cmd.pw) != 0 || ftp_slider->data.portnum != ftp_cmd.portnum) {

+				LYDBGLOG("[%s-%d] sevname  error\n", __FUNCTION__, __LINE__);

+				LYVERBLOG("+[thhandle]: error num = %d\n", ERR_CMDVALID);

+				return ERR_CMDVALID;

+			}	

+			LYDBGLOG("[%s-%d]=======> Node found\n", __FUNCTION__, __LINE__);

+			return NO_ERROR;

+		}		

+	}

+	ftp_slider = NULL;

+

+	LYDBGLOG("[%s-%d] Not found\n", __FUNCTION__, __LINE__);

+	return NO_ERROR;

+}

+

+

+void ftp_list_init()

+{

+	if (ftp_init == 0) {

+		INIT_LIST_HEAD(&lynq_ftp_list);

+		ftp_init = 1;

+	}

+

+}

diff --git a/common_src/packages/apps/lynq-threadhandle/src/http_manager.c b/common_src/packages/apps/lynq-threadhandle/src/http_manager.c
new file mode 100644
index 0000000..259b10c
--- /dev/null
+++ b/common_src/packages/apps/lynq-threadhandle/src/http_manager.c
@@ -0,0 +1,359 @@
+#include "http_manager.h"

+#include <unistd.h>

+#include <stdio.h>

+#include <string.h>

+

+static struct list_head http_list;

+static HTTP_LIST_LINK_S* http_slider;

+static lynq_http_client_t http_cmd = {0};

+

+

+void *http_handler(void * list)

+{

+	int error_code = 0;

+	HTTP_LIST_LINK_S* pos_list  = (HTTP_LIST_LINK_S *)list;

+	

+	while(1)

+	{

+		if (pos_list->data.modify_thread != 1 && pos_list->data.add_thread != 1)

+			continue;

+		

+		pos_list->data.add_thread = 0;

+		pos_list->data.modify_thread = 0;

+

+		if (!strcmp(pos_list->data.action, "init")) {}

+		else if (!strcmp(pos_list->data.action, "send")) {}

+		else if (!strcmp(pos_list->data.action, "get")) {

+			lynq_http_init();

+			lynq_http_client_t * http_data = lynq_http_new();

+			

+			http_data->session = pos_list->data.session;

+			memcpy(http_data->action, pos_list->data.action, sizeof(http_data->action));//rita add @2021.7.19 for action type mismatch

+			lynq_http_sync_request(http_data , pos_list->data.url, M_GET, M_CLOSE);	

+			

+			error_code = lynq_http_get_error_code(http_data);

+			if(error_code!=0){

+				LYDBGLOG("[%s-%d] get error!!!\n", __FUNCTION__, __LINE__);//rita add @2021.7.19 for debuging error

+				LYVERBLOG("+[http][%s][session%d]: error num = %d\n", http_data->action, http_data->session, error_code);

+			}

+			

+			if (pos_list->data.url)

+				free(pos_list->data.url);

+

+			if (pos_list->data.post_data)

+				free(pos_list->data.post_data);

+

+			list_del((struct list_head* )pos_list);

+			return NULL;

+		}

+

+		else if (!strcmp(pos_list->data.action, "getfile")) {//rita add @2021.7.19 for http get

+			lynq_http_init();

+			lynq_http_client_t * http_data = lynq_http_new();

+			

+			http_data->session = pos_list->data.session;

+			memcpy(http_data->action, pos_list->data.action, sizeof(http_data->action));

+			lynq_http_sync_download_file(http_data, pos_list->data.url, "",M_GET, M_CLOSE);

+

+			error_code = lynq_http_get_error_code(http_data);

+			if(error_code!=0){

+				LYDBGLOG("[%s-%d] get file error!!!\n", __FUNCTION__, __LINE__);//rita add @2021.7.19 for debuging error

+				LYVERBLOG("[http][%s][session%d]: error num = %d\n", http_data->action, http_data->session, error_code);

+			}

+			

+			if (pos_list->data.url) {

+				free(pos_list->data.url);

+			}

+

+			if (pos_list->data.post_data) {

+				free(pos_list->data.post_data);

+			}

+

+			list_del((struct list_head* )pos_list);

+			return NULL;

+		}

+		else if (!strcmp(pos_list->data.action, "post")) {

+			lynq_http_init();

+			lynq_http_client_t * http_data = lynq_http_new();

+

+			http_data->session = pos_list->data.session;

+			memcpy(http_data->action, pos_list->data.action, sizeof(http_data->action));

+			lynq_http_sync_post_request(http_data , pos_list->data.url, pos_list->data.post_data, M_POST, M_CLOSE);

+

+			error_code = lynq_http_get_error_code(http_data);

+			if(error_code!=0){

+				LYDBGLOG("[%s-%d] post error!!!\n", __FUNCTION__, __LINE__);//rita add @2021.7.19 for debuging error

+				LYVERBLOG("+[http][%s][session%d]: error num = %d\n", http_data->action, http_data->session, error_code);

+			}

+			if (pos_list->data.url) {

+				free(pos_list->data.url);

+			}

+			

+			if (pos_list->data.post_data) {

+				free(pos_list->data.post_data);

+			}

+			

+			list_del((struct list_head* )pos_list);

+			return NULL;

+		}

+

+		else if (!strcmp(pos_list->data.action, "lpost")) {

+			lynq_http_init();

+			lynq_http_client_t *http_data = lynq_http_new();

+			

+			memcpy(http_data->action, pos_list->data.action, sizeof(http_data->action));

+			memcpy(http_data->protocol, pos_list->data.protocol, sizeof(http_data->protocol));

+			http_data->session = pos_list->data.session;

+

+			if (pos_list->data.index != 1) {

+				http_data->index = 1;

+				lynq_http_sync_post_request(http_data , pos_list->data.url, pos_list->data.post_data, M_POST, M_KEEP);

+			}

+			else {

+				http_data->fd = pos_list->data.fd;

+				http_data->url = pos_list->data.url;

+				http_data->post_data = pos_list->data.post_data;

+				http_data->post_data_len = pos_list->data.post_data_len;

+				http_data->method = M_POST;

+				http_data->conn_method= M_KEEP;

+

+				if( http_parser_parse_url(http_data->url, strlen(http_data->url), 0, &http_data->u) != 0 )

+				{

+					//printf("[%s-%d] \n", __FUNCTION__, __LINE__);

+					LYVERBLOG("+[thhandle]: error num = %d\n", ERR_INVOKE);

+					return NULL;

+				}

+				

+				lynq_http_write_head_data(http_data);

+			}

+

+			error_code = lynq_http_get_error_code(http_data);

+			if(error_code != 0) {

+				LYVERBLOG("+[http][%s][session%d]: error num = %d\n", http_data->action, http_data->session, error_code);

+				if (pos_list->data.url)

+					free(pos_list->data.url);

+				

+				if (pos_list->data.post_data)

+					free(pos_list->data.post_data);

+				

+				list_del((struct list_head* )pos_list);

+				return NULL;

+			}

+

+			memcpy(&pos_list->data, http_data, sizeof(lynq_http_client_t));

+			pos_list->data.index = 1;

+		}

+

+		else if (!strcmp(pos_list->data.action, "close")) {

+			lynq_http_client_t *http_data = lynq_http_new();

+

+			http_data->session = pos_list->data.session;

+			memcpy(http_data->action, pos_list->data.action, sizeof(http_data->action));

+			http_data->fd = pos_list->data.fd;

+			http_data->url = pos_list->data.url;

+			http_data->conn_method = M_CLOSE;

+			http_data->post_data = pos_list->data.post_data;

+

+

+			pos_list->data.index = 0;

+			if( http_parser_parse_url(http_data->url, strlen(http_data->url), 0, &http_data->u) != 0 )

+			{

+				//printf("[%s-%d]\n", __FUNCTION__, __LINE__);

+				LYVERBLOG("+[thhandle]: error num = %d\n", ERR_INVOKE);

+				return NULL;

+			}

+				

+			lynq_http_write_head_data(http_data);

+			error_code = lynq_http_get_error_code(http_data);

+			if(error_code!=0)

+				LYVERBLOG("+[http][%s][session%d]: error num = %d\n", http_data->action, http_data->session, error_code);

+			

+			lynq_http_data_send("close");

+

+			if (pos_list->data.url)

+				free(pos_list->data.url);

+			

+			if (pos_list->data.post_data)

+				free(pos_list->data.post_data);

+			

+			list_del((struct list_head* )pos_list);

+			return NULL;

+		}

+	}

+}

+

+

+

+int http_act_handler(thread_pool_t *pool)

+{

+	HTTP_LIST_LINK_S* tmp_list = (HTTP_LIST_LINK_S *)http_slider;

+	struct list_head* slider = NULL;

+	HTTP_LIST_LINK_S* tmp = NULL;

+	if(tmp == NULL)

+	{

+		tmp = (HTTP_LIST_LINK_S*)malloc(sizeof(HTTP_LIST_LINK_S));

+		if(tmp == NULL)

+		{

+			return ERR_MALLOCVALID;

+		}

+	}

+	memset(tmp, 0, sizeof(HTTP_LIST_LINK_S));

+

+	if (tmp_list == NULL ) {

+		if(!strcmp(http_cmd.action, "init") || !strcmp(http_cmd.action, "conn") || !strcmp(http_cmd.action, "send") || !strcmp(http_cmd.action, "get") || !strcmp(http_cmd.action, "post") || !strcmp(http_cmd.action, "lpost")  || !strcmp(http_cmd.action, "getfile")) {

+			tmp->data = http_cmd;

+			if (http_cmd.url != NULL) 

+			{

+			

+				tmp->data.url = (char *)malloc(strlen(http_cmd.url)+1);

+				if (tmp->data.url == NULL)

+					return ERR_MALLOCVALID;

+

+				memset(tmp->data.url, 0x00, strlen(http_cmd.url)+1);

+				memcpy(tmp->data.url, http_cmd.url, strlen(http_cmd.url));

+			}

+

+			if (http_cmd.post_data != NULL) 

+			{

+				tmp->data.post_data = (char *)malloc(strlen(http_cmd.post_data)+1);

+				if (tmp->data.post_data == NULL)

+					return ERR_MALLOCVALID;

+

+				memset(tmp->data.post_data, 0x00, strlen(http_cmd.post_data)+1);

+				memcpy(tmp->data.post_data, http_cmd.post_data, strlen(http_cmd.post_data));

+			}

+

+			tmp->data.add_thread = 1;

+			list_add_tail(&tmp->list, &http_list);				

+			http_list_locate();

+

+			if (!threadpool_add(pool, http_handler, (void *)http_slider)) {

+				LYVERBLOG("+[thhandle]: error num = %d\n", ERR_INVOKE);	

+				return ERR_INVOKE;

+			}

+		}

+		else	{

+			LYDBGLOG("[%s-%d] cmd error \n", __FUNCTION__, __LINE__);

+			LYVERBLOG("+[thhandle]: error num = %d\n", ERR_CMDVALID);

+			if (tmp != NULL)

+				free(tmp);

+			return ERR_CMDVALID;

+		}

+	}

+	else {

+		if(!strcmp(http_cmd.action, "send") || !strcmp(http_cmd.action, "lpost") || !strcmp(http_cmd.action, "close")) {

+			memcpy(tmp_list->data.action, http_cmd.action, sizeof(tmp_list->data.action));

+			memcpy(tmp_list->data.post_data, http_cmd.post_data, strlen(http_cmd.post_data));

+			tmp_list->data.modify_thread = 1;

+		}		

+		else	{

+			LYDBGLOG("[%s-%d] cmd error \n", __FUNCTION__, __LINE__);

+			LYVERBLOG("+[thhandle]: error num = %d\n", ERR_CMDVALID);

+			return ERR_CMDVALID;

+		}

+	}

+

+	tmp = NULL;

+	return NO_ERROR;

+}

+

+

+

+int http_param_verification(char result[][BUF_SIZE] , int line)

+{

+	if (line < 3) {

+		LYDBGLOG("[%s-%d] command error\n", __FUNCTION__, __LINE__);

+		LYVERBLOG("+[thhandle]: error num = %d\n", ERR_CMDVALID);

+		return ERR_CMDVALID;

+	}

+

+	http_cmd.url = NULL;

+	http_cmd.post_data = NULL;

+	memcpy(http_cmd.protocol, result[0], sizeof(http_cmd.protocol));

+

+	if(!atoi(result[2])) { //session

+		LYDBGLOG("[%s-%d] session error\n", __FUNCTION__, __LINE__);

+		LYVERBLOG("+[thhandle]: error num = %d\n", ERR_SESSIONVALID);

+		return ERR_SESSIONVALID;

+	}

+	

+	http_cmd.session = atoi(result[2]); 

+	memcpy(http_cmd.action, result[1], sizeof(http_cmd.action));

+

+	if (!(strcmp(result[1], "post"))) {

+		http_cmd.url = result[3];

+		http_cmd.post_data = result[4];

+	}

+

+	else if (!(strcmp(result[1], "lpost"))) {

+		http_cmd.url = result[3];

+		http_cmd.post_data = result[4];

+	}

+

+	else if (!(strcmp(result[1], "get"))) {

+		strcat(result[3], result[4]);

+		http_cmd.url = result[3];

+	}

+

+	else if (!(strcmp(result[1], "getfile"))) {

+		http_cmd.url = result[3];

+		strcat(http_cmd.url, result[4]);//path

+

+	}

+

+	else if (!(strcmp(result[1], "close"))) {

+		http_cmd.conn_method = M_CLOSE;

+		http_cmd.post_data = "s=close";

+	}

+	else {

+		LYVERBLOG("+[thhandle]: error num = %d\n", ERR_CMDVALID);

+		return ERR_CMDVALID;

+	}

+	

+	return NO_ERROR;

+}

+

+

+int http_list_locate()

+{

+	struct list_head* slider = NULL;

+	http_slider = NULL;

+	list_for_each(slider, &http_list) 

+	{

+		http_slider = (HTTP_LIST_LINK_S*)slider;

+#if 0

+		LYDBGLOG("[%s-%d] =================================== \n", __func__, __LINE__);

+		LYDBGLOG("[%s-%d] protocol : %s \n", __FUNCTION__, __LINE__, http_slider->data.protocol);

+		LYDBGLOG("[%s-%d] session : %d \n", __FUNCTION__, __LINE__, http_slider->data.session);

+		LYDBGLOG("[%s-%d] action : %s \n", __FUNCTION__, __LINE__, http_slider->data.action);

+		LYDBGLOG("[%s-%d] index : %d \n", __FUNCTION__, __LINE__, http_slider->data.index);

+		LYDBGLOG("[%s-%d] =================================== \n", __func__, __LINE__);

+#endif

+

+		if (!strcmp(http_slider->data.protocol, http_cmd.protocol) && http_slider->data.session == http_cmd.session) {

+			if (strcmp(http_cmd.action, "close") != 0) {

+				if (strcmp(http_slider->data.url, http_cmd.url) != 0) {

+					//LYDBGLOG("[%s-%d] URL error\n", __FUNCTION__, __LINE__);

+					LYVERBLOG("+[thhandle]: error num = %d\n", ERR_CMDVALID);

+					return ERR_CMDVALID;

+				}

+			}

+			return NO_ERROR;

+		}

+	}

+	http_slider = NULL;

+

+	return NO_ERROR;

+}

+

+

+static int http_init = 0;

+void http_list_init()

+{

+	if (http_init == 0) {

+		INIT_LIST_HEAD(&http_list);

+		http_init = 1;

+	}

+

+}

+

diff --git a/common_src/packages/apps/lynq-threadhandle/src/model_manager.c b/common_src/packages/apps/lynq-threadhandle/src/model_manager.c
new file mode 100644
index 0000000..a63a291
--- /dev/null
+++ b/common_src/packages/apps/lynq-threadhandle/src/model_manager.c
@@ -0,0 +1,34 @@
+#include "model_manager.h"

+#include <unistd.h>

+#include <stdio.h>

+#include <string.h>

+

+

+

+

+MAG_LIST_S list_manager[] = {

+	{"http", http_list_init, http_param_verification, http_list_locate, http_act_handler, NULL, NULL, NULL, NULL },

+	{"ftp", ftp_list_init, ftp_param_verification, ftp_list_locate, ftp_act_handler, NULL, NULL, NULL},

+	{"mqtt", mqtt_list_init, mqtt_param_verification, mqtt_list_locate, mqtt_act_handler, NULL, NULL, NULL,NULL},

+	//{"ril", ril_list_init,ril_param_verification, ril_list_locate, ril_act_handler, NULL, NULL, NULL,NULL},

+};

+

+

+MAG_LIST_S *list_manager_proc(const char *name)

+{

+	int type_num = sizeof(list_manager) / sizeof(MAG_LIST_S);

+	int i = 0;

+	for (i = 0; i < type_num; i++)

+	{

+		if (0 == strcmp(list_manager[i].name, name))

+		{

+		    LYDBGLOG("[%s-%d] recognized message type is %s\n", __FUNCTION__, __LINE__, list_manager[i].name);

+		    return &list_manager[i];

+		}

+	}

+	LYDBGLOG("[%s-%d] Unrecognized message type %s\n", __FUNCTION__, __LINE__, name);

+	

+	return NULL;

+}

+

+

diff --git a/common_src/packages/apps/lynq-threadhandle/src/mqtt_manager.c b/common_src/packages/apps/lynq-threadhandle/src/mqtt_manager.c
new file mode 100644
index 0000000..922a7e7
--- /dev/null
+++ b/common_src/packages/apps/lynq-threadhandle/src/mqtt_manager.c
Binary files differ
diff --git a/common_src/packages/apps/lynq-threadhandle/src/seq_queue.c b/common_src/packages/apps/lynq-threadhandle/src/seq_queue.c
new file mode 100644
index 0000000..787a601
--- /dev/null
+++ b/common_src/packages/apps/lynq-threadhandle/src/seq_queue.c
@@ -0,0 +1,132 @@
+#include "seq_queue.h"

+

+

+seq_queue_t *create_seq_queue(in unsigned int block_size, in unsigned int total_block, in BOOL expand) {

+

+	seq_queue_t *queue = (seq_queue_t *)malloc(sizeof(seq_queue_t));

+	if (queue) {

+

+		memset(queue, 0, sizeof(seq_queue_t));

+		queue->block_buffer = malloc(total_block * block_size);

+		if (queue->block_buffer == NULL) {

+			free(queue);

+			queue = NULL;

+		} else {

+			queue->block_size = block_size;

+			queue->total_block = total_block;

+			queue->expandabilit = expand;

+			queue->expand_blocks = EXPAND_BLOCK_NUM;

+

+			create_sem(&queue->task_queue_lock, 1);

+//			init_mutex_handle(&queue->task_queue_lock);

+		}

+	}

+

+	return queue;

+}

+

+void destroy_seq_queue(in seq_queue_t *queue) {

+

+	if (queue == NULL)

+		return ;

+

+	destroy_sem(&queue->task_queue_lock);

+//	mutex_destroy(&queue->task_queue_lock);

+	free(queue->block_buffer);

+	free(queue);

+}

+

+

+BOOL expand_seq_queue(in seq_queue_t *queue) {

+

+	void *new_buffer;

+	BOOL ret = FALSE;

+	if (queue == NULL || !queue->expandabilit)

+		return FALSE;

+

+	new_buffer = malloc((queue->total_block+queue->expand_blocks) * queue->block_size);

+	if (new_buffer) {

+		if (queue->current_block > queue->tail_block) {

+			memcpy(new_buffer, (char *)queue->block_buffer, queue->total_block * queue->block_size);

+		} else if (queue->current_block < queue->tail_block || (queue->current_block == queue->tail_block && queue->used_block != 0)) {

+			int head_block = queue->total_block - queue->tail_block;

+			int head_data_len = head_block * queue->block_size;

+			memcpy(new_buffer, (char *)queue->block_buffer + queue->tail_block * queue->block_size, head_data_len);

+			memcpy((char *)new_buffer + head_data_len, (char *)queue->block_buffer, queue->current_block * queue->block_size);

+			queue->tail_block = 0;

+			queue->current_block = head_block + queue->current_block;

+		} else if (queue->current_block == queue->tail_block){

+			queue->current_block = 0;

+			queue->tail_block = 0;

+		}

+

+		queue->total_block += queue->expand_blocks;

+

+		free(queue->block_buffer);

+		queue->block_buffer = new_buffer;

+		ret = TRUE;

+	}

+

+	return ret;

+}

+

+

+BOOL en_seq_queue(in seq_queue_t *queue, in void *data) {

+

+	if (queue == NULL || data == NULL)

+		return FALSE;

+

+	wait_sem(&queue->task_queue_lock);

+	//mutex_lock(&queue->task_queue_lock);

+	if (queue->used_block >= queue->total_block) {

+		static int times= 0;

+		times++;

+		if (!expand_seq_queue(queue)) {

+

+			return FALSE;

+		}

+	}

+

+	memcpy((char *)queue->block_buffer + queue->current_block * queue->block_size

+		, data, queue->block_size);

+	queue->current_block++;

+	queue->current_block = queue->current_block % queue->total_block;

+	queue->used_block++;

+	

+	post_sem(&queue->task_queue_lock);

+	//mutex_unlock(&queue->task_queue_lock);

+

+	return TRUE;

+}

+

+BOOL de_seq_queue(in seq_queue_t *queue, out void *data) {

+

+	BOOL ret = FALSE;

+	if (queue == NULL)

+		return FALSE;

+

+	wait_sem(&queue->task_queue_lock);

+	//mutex_lock(&queue->task_queue_lock);

+	if (queue->used_block != 0) {

+		memcpy(data, (char *)queue->block_buffer + queue->tail_block * queue->block_size

+			, queue->block_size);

+		queue->tail_block++;

+		queue->tail_block = queue->tail_block % queue->total_block;

+		queue->used_block--;

+		ret = TRUE;

+	}

+	post_sem(&queue->task_queue_lock);

+	//mutex_unlock(&queue->task_queue_lock);

+

+	return ret;

+}

+

+unsigned int get_count_seq_queue(in seq_queue_t *queue) {

+	return queue->used_block;

+}

+

+unsigned int get_size_seq_queue(in seq_queue_t *queue) {

+	return queue->total_block;

+}

+

+

diff --git a/common_src/packages/apps/lynq-threadhandle/src/syn_primitive.c b/common_src/packages/apps/lynq-threadhandle/src/syn_primitive.c
new file mode 100644
index 0000000..9494df7
--- /dev/null
+++ b/common_src/packages/apps/lynq-threadhandle/src/syn_primitive.c
@@ -0,0 +1,65 @@
+

+#include "syn_primitive.h"

+#define SEM_VALUE_MAX 32767 

+

+int init_condition_handle(condition_handle *cond) {

+	return pthread_cond_init(cond, NULL);

+}

+

+

+int destroy_condition_handle(condition_handle *cond) {

+	return pthread_cond_destroy(cond);

+}

+

+

+int wait_condition(condition_handle *cond, mutex_handle *mutex, unsigned int wait) {

+	struct timespec wait_time;

+	if (wait == TIME_WAIT_INFINITE)

+		wait_time.tv_sec = TIME_WAIT_INFINITE;

+	else

+		wait_time.tv_sec = wait + time(0);

+	wait_time.tv_nsec = 0;

+	

+	return pthread_cond_timedwait(cond, mutex, &wait_time);

+}

+

+

+int post_condition_signal(condition_handle *cond) {

+	return pthread_cond_signal(cond);

+}

+

+

+int init_mutex_handle(mutex_handle *mutex) {

+	return pthread_mutex_init(mutex, NULL);

+}

+

+int mutex_lock(mutex_handle *mutex) {

+	return pthread_mutex_lock(mutex);

+}

+

+int mutex_unlock(mutex_handle *mutex) {

+	return pthread_mutex_unlock(mutex);

+}

+

+int mutex_destroy(mutex_handle *mutex) {

+	return pthread_mutex_destroy(mutex);

+}

+

+

+int create_sem(sem_handle *sem, int init_count) {	

+	return sem_init(sem, 0, init_count>SEM_VALUE_MAX ? SEM_VALUE_MAX:init_count );

+}

+

+

+int wait_sem(sem_handle *sem) {

+	return sem_wait(sem);

+}

+

+int post_sem(sem_handle *sem) {

+	return sem_post(sem);

+}

+

+int destroy_sem(sem_handle *sem) {

+	return sem_destroy(sem);

+}

+

diff --git a/common_src/packages/apps/lynq-threadhandle/src/thread_main.c b/common_src/packages/apps/lynq-threadhandle/src/thread_main.c
new file mode 100644
index 0000000..6a4e453
--- /dev/null
+++ b/common_src/packages/apps/lynq-threadhandle/src/thread_main.c
@@ -0,0 +1,86 @@
+#include "model_manager.h"

+#include "list.h"

+#include "thread_pool.h"

+#include "common.h"

+#include <signal.h>

+#include <stdio.h>

+#include <malloc.h>

+#include <gio/gio.h>

+#include <stdlib.h>

+#include <unistd.h> 

+//#include <libtel/lib_tele.h>

+#include "liblynq-broadcast/broadcast_receiver.h"

+

+

+#define USER_LOG_TAG "THHANDLE" 

+#define MIN_THR_NUM 	10

+#define MAX_THR_NUM 	100

+

+

+

+thread_pool_t *pool = NULL;

+char cmd_buf[BUF_SIZE] = "";

+

+static void CallbackByName( char*broadcast_name, int data_length,const char*data)

+{

+    LYDBGLOG("[%s-%d] str_arg = %s, data_length = %d, int_arg = %s\n", broadcast_name, data_length, data);

+    memcpy(cmd_buf, data, strlen(data));

+

+    return;

+}

+

+void *cmd_thread_func(void* argv_list)

+{

+	int runing = 1 ;

+	int ret = NO_ERROR;

+	

+	while(runing)

+	{		

+		char result[20][BUF_SIZE] = {0};

+		while (strcmp(cmd_buf, "") == 0) {

+			usleep(100);

+		}

+		LYDBGLOG("[%s-%d]========cmd_buf = %s\n", __FUNCTION__, __LINE__, cmd_buf );

+		int line = str_arr(cmd_buf, "\"&", result)+1;

+		memset(cmd_buf, 0, sizeof(cmd_buf));

+		LYDBGLOG("[%s-%d]========result[0] = %s\n", __FUNCTION__, __LINE__, result[0] );

+		MAG_LIST_S *list_manager = list_manager_proc(result[0]);

+		if (list_manager == NULL) {

+			memset(cmd_buf, 0, sizeof(cmd_buf));

+			continue;

+		}

+

+		ret = list_manager->func_param_verification(result, line);	

+		if (ret != NO_ERROR){

+			memset(cmd_buf, 0, sizeof(cmd_buf));

+			continue;

+		}

+

+		list_manager->func_list_init();

+		ret = list_manager->func_list_locate();

+		if (ret != NO_ERROR)

+			continue;

+		list_manager->func_act_handler(pool);

+	}

+}

+

+

+int main(void)

+{

+	LYLOGEINIT(USER_LOG_TAG);    

+	LYDBGLOG("======lynq-threadhandle start=======\n");

+	pool = threadpool_create(MIN_THR_NUM, MAX_THR_NUM);

+

+	register_broadcast_loop();

+	receive_callback_by_name("function", CallbackByName);//rita add @2021.6.21 for receive dbus info

+	

+	if (!threadpool_add(pool, cmd_thread_func, NULL)) {

+		LYVERBLOG("+[thhandle]: error num = %d\n", ERR_INVOKE);

+		return 0;

+	}

+	

+	while (1) {

+		usleep(100);

+	}

+	return 0;

+}

diff --git a/common_src/packages/apps/lynq-threadhandle/src/thread_pool.c b/common_src/packages/apps/lynq-threadhandle/src/thread_pool.c
new file mode 100644
index 0000000..50da0a9
--- /dev/null
+++ b/common_src/packages/apps/lynq-threadhandle/src/thread_pool.c
@@ -0,0 +1,504 @@
+#include "thread_pool.h"

+#include <time.h>

+#include "common.h"

+

+EThread_pool_status get_threadpool_status(thread_pool_t *pool);

+void set_threadpool_status(thread_pool_t *pool, EThread_pool_status state);

+thread_info_t *create_thread_info(EThread_pool_status *pool_status);

+thread_handle pool_thread_create(THREAD_FUNC threadFun, int pri, void *para);

+BOOL init_threadpool(thread_pool_t *pool);

+thread_handle get_self_thread_id(void);

+

+#define THREAD_PRI_NOMAL_LEVEL 60

+#define THREAD_PRI_ABOVE_LEVEL 70

+#define THREAD_PRI_HIGH_LEVEL 80

+

+

+#define TASK_QUEUE_COUNT_MAX 100

+#define CONDITION_WAIT_TIME 1000

+#define INCRE_THREADS_UNIT  5

+

+

+

+thread_handle get_self_thread_id() {

+	return pthread_self();

+}

+

+void tp_sleep(unsigned int ms) {

+	struct timeval  delay;

+	

+	delay.tv_sec = ms/1000;

+	delay.tv_usec = (ms%1000) * 1000;

+	select(0, NULL, NULL, NULL, &delay);

+}

+

+

+unsigned long get_current_time(void) {

+	return time(NULL);

+}

+

+void force_exit_thread(thread_info_t *thread_info) {

+

+	int ret;

+	pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, NULL);

+	pthread_cancel(thread_info->h_thread);

+	pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, NULL);

+

+	ret = destroy_condition_handle(&thread_info->thread_cond);

+	if (ret) {

+		post_condition_signal(&thread_info->thread_cond);

+		destroy_condition_handle(&thread_info->thread_cond);

+	}

+	

+	ret = mutex_destroy(&thread_info->thread_lock);

+	if (ret) {

+		mutex_unlock(&thread_info->thread_lock);

+		mutex_destroy(&thread_info->thread_lock);

+	}

+}

+

+

+int compare_thread_id(void *usr_data, unsigned int sdata_len, void *list_data, unsigned int ldata_len) {

+	if (((thread_info_t *)usr_data)->h_thread == ((thread_info_t *)list_data)->h_thread) {

+		return 0;

+	} else {

+		return -1;

+	}

+}

+

+

+static void pool_thread_work(void *para)

+{

+	int ret = 0;

+

+	thread_info_t *thread_info = (thread_info_t *)para;

+	thread_func_t *thread_func;

+

+	if (thread_info == NULL) {

+		LYVERBLOG("+[thhandle]: error num = %d\n", ERR_INVOKE);

+		return;

+	}

+

+	while (*thread_info->pool_status != EThread_pool_exit) {

+		mutex_lock(&thread_info->thread_lock);

+		while (!thread_info->busy) {

+			ret = wait_condition(&thread_info->thread_cond, &thread_info->thread_lock, TIME_WAIT_INFINITE);

+		}

+

+		mutex_unlock(&thread_info->thread_lock);

+

+		if (*thread_info->pool_status == EThread_pool_exit || thread_info->release)

+			break;

+

+		thread_func = &thread_info->thread_para;

+		thread_info->time_out = thread_func->time_out_info.time_out;

+		thread_info->launch_time = get_current_time();

+		thread_info->thread_para.process_func(thread_info->thread_para.args);

+		if (thread_info->thread_para.release_func) {

+			thread_info->thread_para.release_func(thread_info->thread_para.args);

+		}

+		thread_info->launch_time = TIME_WAIT_INFINITE;

+

+		mutex_lock(&thread_info->thread_lock);

+		thread_info->busy = FALSE;

+		mutex_unlock(&thread_info->thread_lock);

+	}

+

+	LYDBGLOG(" thread %lu exit.\n", get_self_thread_id());

+	

+	pthread_exit(0);

+}

+

+

+BOOL scan_idle_thread_from_busy(thread_pool_t *pool) {

+

+	BOOL ret = FALSE;

+	

+	d_list_t *idle_list = pool->idle_threads;

+	d_list_t *busy_list = pool->busy_threads;

+	

+	d_list_node_t *temp_node;

+	thread_info_t *info;

+	if (busy_list == NULL || idle_list == NULL) 

+		return FALSE;

+

+	while ((temp_node = get_next_node(busy_list)) != NULL)

+	{

+		if (temp_node == NULL || temp_node->data == NULL)

+			break;

+		

+		info = (thread_info_t *)temp_node->data;

+		if (!info->busy) {

+

+			if (remove_d_list_node(busy_list, temp_node)) {

+				insert_d_list_tail_node(idle_list, temp_node);

+				ret = TRUE;

+				//break;

+			}

+		} else {

+			if (info->time_out == 0 || info->launch_time == TIME_WAIT_INFINITE) {

+				continue;

+			}

+

+			if (get_current_time() - info->time_out > info->launch_time) {

+			//if (get_current_time() - info->launch_time > info->time_out) {

+				LYDBGLOG("[%s-%d] ####### time out , force exit thread.  %lu #########\n", __FUNCTION__, __LINE__, info->h_thread);

+				LYVERBLOG("+[thhandle]: error num = %d\n", ERR_TIMEOUT);

+				if (remove_d_list_node(busy_list, temp_node)) {

+					force_exit_thread(info);

+

+					if (info->thread_para.time_out_info.timeout_callback) {

+						info->thread_para.time_out_info.timeout_callback(&info->thread_para);

+					}

+

+					init_condition_handle(&info->thread_cond);

+					init_mutex_handle(&info->thread_lock);

+					

+					info->busy = FALSE;

+					info->release = FALSE;

+					info->launch_time = TIME_WAIT_INFINITE;

+					info->h_thread = pool_thread_create(pool_thread_work, info->pri, info);

+					if (info->h_thread < 0) {

+						

+						free(info);

+						free(temp_node);

+						pool->pool_thread_num--;

+					} else {

+						

+						insert_d_list_tail_node(idle_list, temp_node);

+						ret = TRUE;

+					}

+				}				

+			}

+		

+		}

+	}

+	

+	return ret;

+}

+

+

+static void pool_thread_manage(void *para)

+{

+	thread_func_t thread_para;	

+	d_list_node_t *list_node;

+	thread_info_t *thread_info;

+	thread_pool_t *pool = (thread_pool_t *)para;

+	

+	if (pool == NULL) {

+		return;

+	}

+	

+	while (get_threadpool_status(pool) != EThread_pool_exit) {

+

+		if (get_count_seq_queue(pool->task_queue) > 0) {

+	

+			pool->release_threads_interval = 0;

+

+			list_node = remove_d_list_head_node(pool->idle_threads);

+			if (list_node && list_node->data) {

+

+				memset(&thread_para, 0, sizeof(thread_func_t));

+				if (de_seq_queue(pool->task_queue, &thread_para)) {

+

+					thread_info = (thread_info_t *)list_node->data;

+					post_sem(&pool->sem_inc);

+

+					mutex_lock(&thread_info->thread_lock);

+					memcpy(&thread_info->thread_para, &thread_para, sizeof(thread_func_t));

+					thread_info->busy = TRUE;

+					post_condition_signal(&thread_info->thread_cond);

+					mutex_unlock(&thread_info->thread_lock);

+					

+					insert_d_list_tail_node(pool->busy_threads, list_node);

+

+				} else {

+

+					insert_d_list_head_node(pool->idle_threads, list_node);

+				}

+				

+

+			} else {

+				if (scan_idle_thread_from_busy(pool))

+					continue;

+

+				if (pool->pool_thread_num < pool->max_thread_num) {

+					

+					int i;

+					for (i=0; i<INCRE_THREADS_UNIT; i++) {

+						thread_info_t *thread_inf = create_thread_info(&pool->status);

+						insert_d_list_tail(pool->idle_threads, thread_inf, sizeof(thread_info_t));

+						pool->pool_thread_num++;

+					}

+					

+				} else {

+					//continue;

+				}

+			}

+

+		} else {

+			if (get_d_list_node_count(pool->busy_threads) > 0) {

+				pool->release_threads_interval = 0;

+				scan_idle_thread_from_busy(pool);

+			} else {

+				BOOL is_release_threads = FALSE;

+				if (pool->release_threads_interval == 0) {

+					pool->release_threads_interval = get_current_time();

+				} else {

+					is_release_threads = (get_current_time() - pool->release_threads_interval) > RELEASE_THREAD_INTERVAL;

+				}

+

+				if (is_release_threads && get_d_list_node_count(pool->idle_threads) > pool->min_thread_num) {

+					//

+					list_node = remove_d_list_head_node(pool->idle_threads);

+					if (list_node && list_node->data) {							

+						thread_info = (thread_info_t *)list_node->data;

+						if (!thread_info->busy) {

+							mutex_lock(&thread_info->thread_lock);

+							thread_info->release = TRUE;

+							mutex_unlock(&thread_info->thread_lock);

+							post_condition_signal(&thread_info->thread_cond);

+							pool->pool_thread_num--;

+							free(thread_info);

+							free(list_node);

+						} else {

+							insert_d_list_tail(pool->busy_threads, thread_info, sizeof(thread_info_t));

+						}

+					}

+					

+				} else {

+					mutex_lock(&pool->mange_lock);

+					wait_condition(&pool->manage_cond, &pool->mange_lock, CONDITION_WAIT_TIME);

+					mutex_unlock(&pool->mange_lock);

+				}

+			}

+

+		}

+	}

+}

+

+

+thread_handle pool_thread_create(THREAD_FUNC threadFun, int pri, void *para) {

+	

+		thread_handle h_thread;

+		pthread_attr_t attr;

+		struct sched_param p;

+

+		pthread_attr_init(&attr);

+		p.sched_priority = pri;

+		

+		pthread_attr_setschedpolicy(&attr,SCHED_OTHER);

+		pthread_attr_setschedparam(&attr,&p);

+

+		pthread_create(&h_thread, &attr, (void *)threadFun, para);

+		return h_thread;

+}

+

+void pool_thread_release(thread_handle h_thread)

+{

+	pthread_join(h_thread, NULL);

+}

+

+EThread_pool_status get_threadpool_status(thread_pool_t *pool) {

+

+	if (pool) {

+		return pool->status;

+	} else {

+		return EThread_pool_unknown;

+	}

+}

+

+void set_threadpool_status(thread_pool_t *pool, EThread_pool_status state) {

+	

+	if (pool) {

+		pool->status = state;

+	}

+}

+

+thread_pool_t *threadpool_create(unsigned int min_thread_num, unsigned int max_thread_num)

+{

+	thread_pool_t *pool = (thread_pool_t *)malloc(sizeof(thread_pool_t));

+

+	if (pool) {

+		memset(pool, 0, sizeof(thread_pool_t));

+		pool->min_thread_num = min_thread_num;

+		pool->max_thread_num = max_thread_num;

+		pool->pri = THREAD_PRI_HIGH_LEVEL;

+		pool->status = EThread_pool_alloc;

+

+		if (!init_threadpool(pool)) {

+			free(pool);

+			pool = NULL;

+		}

+	}

+

+	return pool;

+}

+

+thread_info_t *create_thread_info(EThread_pool_status *pool_status) {

+	thread_info_t *thread_inf = (thread_info_t *)malloc(sizeof(thread_info_t));

+	if (thread_inf == NULL)

+		return NULL;

+	

+	memset(thread_inf, 0, sizeof(thread_info_t));

+	

+	thread_inf->busy = FALSE;

+	thread_inf->release = FALSE;

+	thread_inf->pri = THREAD_PRI_ABOVE_LEVEL;

+	thread_inf->launch_time = TIME_WAIT_INFINITE;

+	thread_inf->pool_status = pool_status;

+

+	init_condition_handle(&thread_inf->thread_cond);

+	init_mutex_handle(&thread_inf->thread_lock);

+	

+	thread_inf->h_thread = pool_thread_create(pool_thread_work, thread_inf->pri, thread_inf);

+	if (thread_inf->h_thread < 0) {

+		destroy_condition_handle(&thread_inf->thread_cond);

+		mutex_destroy(&thread_inf->thread_lock);

+

+		free(thread_inf);

+		thread_inf = NULL;

+	}

+	

+	return thread_inf;

+}

+

+

+void destroy_thread_info(thread_info_t *thread_info) {

+	if (thread_info == NULL)

+		return;

+

+	thread_info->release = TRUE;

+	pool_thread_release(thread_info->h_thread);

+

+	destroy_condition_handle(&thread_info->thread_cond);

+	mutex_destroy(&thread_info->thread_lock);

+}

+

+BOOL init_threadpool(thread_pool_t *pool) {

+

+	unsigned int thread_num = 0;

+	if (pool == NULL)

+		return FALSE;

+

+	pool->busy_threads = create_d_list();

+	pool->idle_threads = create_d_list();

+	pool->task_queue = create_seq_queue(sizeof(thread_func_t), TASK_QUEUE_COUNT_MAX, TRUE);

+	if (pool->busy_threads == NULL || pool->idle_threads == NULL || pool->task_queue == NULL)

+		goto err_flag;

+

+	for (thread_num=0; thread_num<pool->min_thread_num; thread_num++) {

+		thread_info_t *thread_inf = create_thread_info(&pool->status);

+

+		if (!insert_d_list_tail(pool->idle_threads, thread_inf, sizeof(thread_info_t)))

+			goto err_flag;

+		

+	}

+

+	create_sem(&pool->sem_inc, TASK_QUEUE_COUNT_MAX);

+	init_condition_handle(&pool->manage_cond);

+	init_mutex_handle(&pool->mange_lock);

+	pool->h_id = pool_thread_create(pool_thread_manage, pool->pri, pool);

+

+	pool->status = EThread_pool_init;

+	pool->pool_thread_num = pool->min_thread_num;

+

+	return TRUE;

+

+

+err_flag:

+	LYDBGLOG("[%s-%d]##################### err ################\n", __FUNCTION__, __LINE__);

+	LYVERBLOG("+[thhandle]: error num = %d\n", ERR_INVOKE);

+	threadpool_destroy(pool);

+

+	return FALSE;

+}

+

+void threadpool_destroy(thread_pool_t *pool)

+{

+	d_list_node_t *temp_node;

+	if (pool == NULL)

+		return;

+

+	set_threadpool_status(pool, EThread_pool_exit);

+

+	destroy_sem(&pool->sem_inc);

+	mutex_lock(&pool->mange_lock);

+	post_condition_signal(&pool->manage_cond);

+	mutex_unlock(&pool->mange_lock);

+	pool_thread_release(pool->h_id);

+

+	mutex_destroy(&pool->mange_lock);

+	destroy_condition_handle(&pool->manage_cond);

+

+	while ((temp_node = remove_d_list_head_node(pool->idle_threads))) {

+		thread_info_t *info = (thread_info_t *)temp_node->data;

+		post_condition_signal(&info->thread_cond);

+		destroy_thread_info(info);

+		free(info);

+		free(temp_node);

+	}

+

+	while ((temp_node = remove_d_list_head_node(pool->busy_threads))) {

+		thread_info_t *info = (thread_info_t *)temp_node->data;

+		post_condition_signal(&info->thread_cond);

+		destroy_thread_info(info);

+		free(info);

+		free(temp_node);

+	}

+	

+	destroy_d_list(pool->busy_threads);

+	destroy_d_list(pool->idle_threads);

+	destroy_seq_queue(pool->task_queue);

+

+	free(pool);

+}

+

+BOOL threadpool_add(thread_pool_t *pool, USER_FUNC process_func, void *args)

+{

+	BOOL ret = FALSE;

+	thread_func_t function;

+	

+	if (pool == NULL)

+		return FALSE;

+	

+	memset(&function, 0, sizeof(thread_func_t));

+	function.process_func = process_func;

+	function.args = args;

+

+	wait_sem(&pool->sem_inc);

+	ret = en_seq_queue(pool->task_queue, &function);

+

+	mutex_lock(&pool->mange_lock);

+	post_condition_signal(&pool->manage_cond);

+	mutex_unlock(&pool->mange_lock);

+	

+	return ret;

+}

+

+BOOL threadpool_add_timeout(thread_pool_t *pool, USER_FUNC process_func

+		, USER_FUNC release_func, void *args, time_out_t *time_out)

+{

+	BOOL ret = FALSE;

+	thread_func_t function;

+	

+	if (pool == NULL)

+		return FALSE;

+	

+	memset(&function, 0, sizeof(thread_func_t));

+	function.process_func = process_func;

+	function.release_func = release_func;

+	function.args = args;

+	memcpy(&function.time_out_info, time_out, sizeof(time_out_t));

+	

+	wait_sem(&pool->sem_inc);

+	ret = en_seq_queue(pool->task_queue, &function);

+

+	mutex_lock(&pool->mange_lock);

+	post_condition_signal(&pool->manage_cond);

+	mutex_unlock(&pool->mange_lock);

+	

+	return ret;

+}

+

+

diff --git a/common_src/packages/apps/lynq-udpcli/LICENSE b/common_src/packages/apps/lynq-udpcli/LICENSE
new file mode 100644
index 0000000..77f59ed
--- /dev/null
+++ b/common_src/packages/apps/lynq-udpcli/LICENSE
@@ -0,0 +1,31 @@
+Copyright Statement:
+
+This software/firmware and related documentation ("MediaTek Software") are
+protected under relevant copyright laws. The information contained herein is
+confidential and proprietary to MediaTek Inc. and/or its licensors. Without
+the prior written permission of MediaTek inc. and/or its licensors, any
+reproduction, modification, use or disclosure of MediaTek Software, and
+information contained herein, in whole or in part, shall be strictly
+prohibited.
+
+MediaTek Inc. (C) 2015. All rights reserved.
+
+BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
+ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
+WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
+NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH
+RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
+INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES
+TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
+RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
+OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK
+SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE
+RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S
+ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE
+RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE
+MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
+CHARGE PAID BY RECEIVER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
diff --git a/common_src/packages/apps/lynq-udpcli/lynq_udpcli.c b/common_src/packages/apps/lynq-udpcli/lynq_udpcli.c
new file mode 100644
index 0000000..de42922
--- /dev/null
+++ b/common_src/packages/apps/lynq-udpcli/lynq_udpcli.c
@@ -0,0 +1,60 @@
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include<stdlib.h>
+#include <netinet/in.h>
+#include <strings.h>
+#include "liblog/liblog.h"
+#include "liblog/lynq_deflog.h"
+
+
+#define USER_LOG_TAG "UDPCLI"
+#define BUF_LEN 128
+#define ERR_CMDVALID  2	
+#define ERR_SOCK  3
+#define SA struct sockaddr
+
+int main(int argc, const char *argv[])
+{
+	int sockfd;
+	char buf[BUF_LEN];
+
+
+	LYLOGEINIT(USER_LOG_TAG);    
+	if(argc!=3)
+	{
+		LYDBGLOG("argv is wrong, please input ip and port\n");
+		LYVERBLOG("+[udpcli]: error num = %d\n", ERR_CMDVALID);
+		return ERR_CMDVALID;
+	}
+
+	sockfd=socket(AF_INET,SOCK_DGRAM,0);
+
+	if(sockfd<0)
+	{
+		LYDBGLOG("fail to sockfd\n");
+		return ERR_SOCK;
+	}
+
+	struct sockaddr_in seraddr;
+	seraddr.sin_family=AF_INET;
+	seraddr.sin_port=htons(atoi(argv[2]));
+	seraddr.sin_addr.s_addr=inet_addr(argv[1]);
+
+	int len=sizeof(seraddr);
+
+	while(1)
+	{
+		bzero(buf,sizeof(buf));
+
+		fgets(buf,sizeof(buf),stdin);
+
+		sendto(sockfd,buf,sizeof(buf),0,(SA *)&seraddr,len);
+
+		recvfrom(sockfd,buf,sizeof(buf),0,NULL,NULL);
+
+		LYVERBLOG("+[udpcli]: cli_rcv = %s\n",buf);
+	}
+	return 0;
+}
diff --git a/common_src/packages/apps/lynq-udpcli/makefile b/common_src/packages/apps/lynq-udpcli/makefile
new file mode 100644
index 0000000..71a4d23
--- /dev/null
+++ b/common_src/packages/apps/lynq-udpcli/makefile
@@ -0,0 +1,50 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+                -g -Os \
+                -flto \
+                -fpermissive \
+                -fPIC \
+
+
+
+LOCAL_PATH   = .
+
+LOCAL_C_INCLUDES = \
+  -I. \
+  -I$(ROOT)$(includedir)/logger \
+  -I$(ROOT)$(includedir)/liblog \
+  -I$(ROOT)$(includedir)/glib-2.0 \
+  -I$(ROOT)$(libdir)/glib-2.0/include \
+  -I$(ROOT)$(includedir)/dbus-1.0 \
+  -I$(ROOT)$(libdir)/dbus-1.0/include \
+
+
+LOCAL_LIBS := \
+    -L. \
+    -ldl \
+    -lpthread \
+    -llog-ril \
+    -lssl \
+    -lglib-2.0 \
+    -lgobject-2.0 \
+    -lgio-2.0 \
+    -ldbus-1 \
+
+SOURCES = $(wildcard *.c)
+
+EXECUTABLE = lynq-udpcli
+
+OBJECTS=$(SOURCES:.c=.o)
+all: $(EXECUTABLE)
+
+$(EXECUTABLE): $(OBJECTS)
+	$(CXX) -shared -Wl,--no-undefined $(OBJECTS) $(LOCAL_LIBS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES) -o $@
+
+%.o : %.c
+	$(CC) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+
+.PHONY: clean
+clean:
+	$(RM) $(OBJECTS) $(EXECUTABLE)
diff --git a/common_src/packages/apps/lynq-udpser/LICENSE b/common_src/packages/apps/lynq-udpser/LICENSE
new file mode 100644
index 0000000..77f59ed
--- /dev/null
+++ b/common_src/packages/apps/lynq-udpser/LICENSE
@@ -0,0 +1,31 @@
+Copyright Statement:
+
+This software/firmware and related documentation ("MediaTek Software") are
+protected under relevant copyright laws. The information contained herein is
+confidential and proprietary to MediaTek Inc. and/or its licensors. Without
+the prior written permission of MediaTek inc. and/or its licensors, any
+reproduction, modification, use or disclosure of MediaTek Software, and
+information contained herein, in whole or in part, shall be strictly
+prohibited.
+
+MediaTek Inc. (C) 2015. All rights reserved.
+
+BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
+ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
+WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
+NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH
+RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
+INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES
+TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
+RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
+OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK
+SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE
+RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S
+ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE
+RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE
+MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
+CHARGE PAID BY RECEIVER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
diff --git a/common_src/packages/apps/lynq-udpser/lynq_udpser.c b/common_src/packages/apps/lynq-udpser/lynq_udpser.c
new file mode 100644
index 0000000..fba98b0
--- /dev/null
+++ b/common_src/packages/apps/lynq-udpser/lynq_udpser.c
@@ -0,0 +1,56 @@
+#include <stdio.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <arpa/inet.h>
+#include <netinet/in.h>
+#include <strings.h>
+#include "liblog/liblog.h"
+#include "liblog/lynq_deflog.h"
+
+#define USER_LOG_TAG "UDPSER"
+#define BUF_LEN 128
+#define ERR_SOCK  3
+#define SA struct sockaddr
+
+int main(int argc, const char *argv[])
+{
+	int sockfd;
+	char buf[128];
+
+	LYLOGEINIT(USER_LOG_TAG);    
+	sockfd=socket(AF_INET,SOCK_DGRAM,0);
+
+	if(sockfd<0)
+	{
+		LYDBGLOG("fail to sockfd\n");
+		return -1;
+	}
+	
+	struct sockaddr_in seraddr,peeraddr;
+	seraddr.sin_family=AF_INET;
+	seraddr.sin_port=htons(50000);
+
+	seraddr.sin_addr.s_addr=inet_addr("0.0.0.0");
+
+	int ret_bind;
+	ret_bind=bind(sockfd,(struct sockaddr *)&seraddr,sizeof(seraddr));
+
+	if(ret_bind<0)
+	{
+	   LYDBGLOG("fail to bind\n");
+	   return -1;
+	}
+
+	int len=sizeof(peeraddr);
+
+	while(1)
+	{
+		bzero(buf,sizeof(buf));
+
+		recvfrom(sockfd,buf,sizeof(buf),0,(struct sockaddr*)&peeraddr,&len);
+
+		LYVERBLOG("+[udpser]: ser_rcv = %s\n", buf);
+		sendto(sockfd,buf,sizeof(buf),0,(SA *)&peeraddr,len);
+	}
+	return 0;
+}
diff --git a/common_src/packages/apps/lynq-udpser/makefile b/common_src/packages/apps/lynq-udpser/makefile
new file mode 100644
index 0000000..0a0559f
--- /dev/null
+++ b/common_src/packages/apps/lynq-udpser/makefile
@@ -0,0 +1,50 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+                -g -Os \
+                -flto \
+                -fpermissive \
+                -fPIC \
+
+
+
+LOCAL_PATH   = .
+
+LOCAL_C_INCLUDES = \
+  -I. \
+  -I$(ROOT)$(includedir)/logger \
+  -I$(ROOT)$(includedir)/liblog \
+  -I$(ROOT)$(includedir)/glib-2.0 \
+  -I$(ROOT)$(libdir)/glib-2.0/include \
+  -I$(ROOT)$(includedir)/dbus-1.0 \
+  -I$(ROOT)$(libdir)/dbus-1.0/include \
+
+
+LOCAL_LIBS := \
+    -L. \
+    -ldl \
+    -lpthread \
+    -llog-ril \
+    -lssl \
+    -lglib-2.0 \
+    -lgobject-2.0 \
+    -lgio-2.0 \
+    -ldbus-1 \
+
+SOURCES = $(wildcard *.c)
+
+EXECUTABLE = lynq-udpser
+
+OBJECTS=$(SOURCES:.c=.o)
+all: $(EXECUTABLE)
+
+$(EXECUTABLE): $(OBJECTS)
+	$(CXX) -shared -Wl,--no-undefined $(OBJECTS) $(LOCAL_LIBS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES) -o $@
+
+%.o : %.c
+	$(CC) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+
+.PHONY: clean
+clean:
+	$(RM) $(OBJECTS) $(EXECUTABLE)
diff --git a/common_src/packages/apps/lynq_dbus_test/src/LICENSE b/common_src/packages/apps/lynq_dbus_test/src/LICENSE
new file mode 100644
index 0000000..77f59ed
--- /dev/null
+++ b/common_src/packages/apps/lynq_dbus_test/src/LICENSE
@@ -0,0 +1,31 @@
+Copyright Statement:
+
+This software/firmware and related documentation ("MediaTek Software") are
+protected under relevant copyright laws. The information contained herein is
+confidential and proprietary to MediaTek Inc. and/or its licensors. Without
+the prior written permission of MediaTek inc. and/or its licensors, any
+reproduction, modification, use or disclosure of MediaTek Software, and
+information contained herein, in whole or in part, shall be strictly
+prohibited.
+
+MediaTek Inc. (C) 2015. All rights reserved.
+
+BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
+ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
+WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
+NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH
+RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
+INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES
+TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
+RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
+OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK
+SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE
+RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S
+ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE
+RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE
+MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
+CHARGE PAID BY RECEIVER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
diff --git a/common_src/packages/apps/lynq_dbus_test/src/lynq_dbus_test.c b/common_src/packages/apps/lynq_dbus_test/src/lynq_dbus_test.c
new file mode 100644
index 0000000..8a4ea04
--- /dev/null
+++ b/common_src/packages/apps/lynq_dbus_test/src/lynq_dbus_test.c
@@ -0,0 +1,263 @@
+#include <stdio.h>
+#include <string.h>
+#include <pthread.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <gio/gio.h>
+#include <log/log.h>
+#include <glib.h>
+
+#define TEST_SERVICE "test.lynq" /*well-known bus name */
+#define TEST_DATA_INTERFACE "test.lynq.Data" /*interface name*/
+#define TEST_DATA_PATH "/test/lynq/data" /*object name*/
+GMainLoop *loop = NULL;
+GDBusProxy *proxy = NULL;
+#define LOG_TAG "TEST_CONTROL"
+int test_decrease (int a,int b,int select_argvi){
+	GDBusConnection *c1;
+	GVariant *result;
+	GError *error;
+	GMainLoop *loop;
+	gint32  set_result = -1;
+	RLOGD("%dzqcstart%s, %s, %d",select_argvi, __FILE__, __FUNCTION__, __LINE__);
+	g_type_init();
+	loop = g_main_loop_new(NULL, FALSE);   
+	error = NULL;
+	c1 = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+	g_assert_no_error (error);
+	error = NULL;
+	g_assert (c1 != NULL);
+	g_assert (!g_dbus_connection_is_closed (c1));
+	result = g_dbus_connection_call_sync (c1,
+                                        TEST_SERVICE,  //bus name
+                                        TEST_DATA_PATH, //object path 
+                                        TEST_DATA_INTERFACE,  // interface name 
+                                        "reduce",                 // method name 
+                                        g_variant_new ("(ii)", a,select_argvi),   //parameters 
+                                         G_VARIANT_TYPE ("(i)"),                    // return type 
+                                        G_DBUS_CALL_FLAGS_NONE,
+                                        -1,
+                                        NULL,
+                                        &error);
+										
+										
+
+	g_assert_no_error (error);
+	g_assert (result != NULL);
+	g_variant_get(result, "(i)", &(set_result));
+	g_variant_unref (result);
+	RLOGD("%s, %s, %d,hgh %dzqcend:%d", __FILE__, __FUNCTION__, __LINE__,select_argvi,set_result);
+	//g_main_loop_run (loop);
+	g_main_loop_unref (loop);
+	
+    return set_result;
+}
+
+int test_add (int a,int b,int select_argvi){
+	GDBusConnection *c1;
+	GVariant *result;
+	GError *error;
+	GMainLoop *loop;
+	gint32  set_result = -1;
+	RLOGD("%dzqcstart%s, %s, %d",select_argvi, __FILE__, __FUNCTION__, __LINE__);
+	g_type_init();
+	loop = g_main_loop_new(NULL, FALSE);   
+	error = NULL;
+	c1 = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+	g_assert_no_error (error);
+	error = NULL;
+	g_assert (c1 != NULL);
+	g_assert (!g_dbus_connection_is_closed (c1));
+	result = g_dbus_connection_call_sync (c1,
+                                        TEST_SERVICE,  //bus name
+                                        TEST_DATA_PATH, //object path 
+                                        TEST_DATA_INTERFACE,  // interface name 
+                                        "add",                 // method name 
+                                        g_variant_new ("(ii)", a,select_argvi),   //parameters 
+                                         G_VARIANT_TYPE ("(i)"),                    // return type 
+                                        G_DBUS_CALL_FLAGS_NONE,
+                                        30000,
+                                        NULL,
+                                        &error);
+										
+										
+
+	g_assert_no_error (error);
+	g_assert (result != NULL);
+	g_variant_get(result, "(i)", &(set_result));
+	g_variant_unref (result);
+	RLOGD("%s, %s, %d,hgh %dzqcend:%d", __FILE__, __FUNCTION__, __LINE__,select_argvi,set_result);
+	//g_main_loop_run (loop);
+	g_main_loop_unref (loop);
+	
+    return set_result;
+}
+int test_call (int state,int select_argvi){
+	GDBusConnection *c1;
+	GVariant *result;
+	GError *error;
+	GMainLoop *loop;
+	gint32  set_result = -1;
+	RLOGD("select_argvi %d,start %s, %s, %d",select_argvi, __FILE__, __FUNCTION__, __LINE__);
+	g_type_init();
+	loop = g_main_loop_new(NULL, FALSE);   
+	error = NULL;
+	c1 = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+	g_assert_no_error (error);
+	error = NULL;
+	g_assert (c1 != NULL);
+	g_assert (!g_dbus_connection_is_closed (c1));
+	result = g_dbus_connection_call_sync (c1,
+                                        TEST_SERVICE,       //bus name
+                                        TEST_DATA_PATH,     //object path 
+                                        TEST_DATA_INTERFACE,  // interface name 
+                                                                        "callstate",// method name 
+                                        g_variant_new ("(i)", state,select_argvi),//parameters 
+                                        G_VARIANT_TYPE ("(i)"),             // return type 
+                                        G_DBUS_CALL_FLAGS_NONE,
+                                        30000,
+                                        NULL,
+                                        &error);
+										
+										
+
+	g_assert_no_error (error);
+	g_assert (result != NULL);
+	g_variant_get(result, "(i)", &(set_result));
+	g_variant_unref (result);
+	RLOGD("%s, %s, %d,hgh %d,state:%d", __FILE__, __FUNCTION__, __LINE__,select_argvi,set_result);
+	//g_main_loop_run (loop);
+	g_main_loop_unref (loop);
+	
+    return set_result;
+}
+
+/*
+static GVariantBuilder * 
+get_platform_data (void){
+GVariantBuilder builder;
+GVariant *value;
+RLOGD("%s, %s, %d", __FILE__, __FUNCTION__, __LINE__);
+ g_variant_builder_init (&builder, G_VARIANT_TYPE_STRING_ARRAY);
+ RLOGD("%s, %s, %d", __FILE__, __FUNCTION__, __LINE__);
+g_variant_builder_add (&builder, "s", "when");
+g_variant_builder_add (&builder, "s", "in");
+g_variant_builder_add (&builder, "s", "the");
+g_variant_builder_add (&builder, "s", "course");
+RLOGD("%s, %s, %d", __FILE__, __FUNCTION__, __LINE__);
+//value = g_variant_builder_end (&builder);
+return g_variant_builder_end (&builder);
+}
+    
+void gvariant_test(){
+	GVariant *value;
+	GVariantIter *iter;
+	gchar *str;
+	g_variant_get (get_platform_data(), "as", &iter);
+        while (g_variant_iter_loop (iter, "s", &str))
+		RLOGD("%s, %s, %d,%s\n", __FILE__, __FUNCTION__, __LINE__,str);
+		g_variant_iter_free (iter);
+}
+void gvariant_test2(int a,int b,int select_argvi,GVariant*parameters){
+  test_add (a, b, select_argvi,parameters);
+}
+int test_add (int a,int b,int select_argvi){
+	//,GVariant*parameters){
+	GDBusConnection *c1;
+	GVariant *result;
+	GVariantBuilder builder;
+	GError *error;
+	GMainLoop *loop;
+	gint32  set_result = -1;
+	RLOGD("%dzqcstart%s, %s, %d",select_argvi, __FILE__, __FUNCTION__, __LINE__);
+	//if(parameters == NULL)
+	//RLOGD("%s, %s, %d", __FILE__, __FUNCTION__, __LINE__);
+	
+	g_type_init();
+	loop = g_main_loop_new(NULL, FALSE);   
+	error = NULL;
+	c1 = g_bus_get_sync (G_BUS_TYPE_SYSTEM, NULL, &error);
+	g_assert_no_error (error);
+	error = NULL;
+	g_assert (c1 != NULL);
+	g_assert (!g_dbus_connection_is_closed (c1));
+    RLOGD("%s, %s, %d", __FILE__, __FUNCTION__, __LINE__);
+    g_variant_builder_init (&builder, G_VARIANT_TYPE_STRING_ARRAY);
+    RLOGD("%s, %s, %d", __FILE__, __FUNCTION__, __LINE__);
+    g_variant_builder_add (&builder, "s", "when");
+    g_variant_builder_add (&builder, "s", "in");
+    g_variant_builder_add (&builder, "s", "the");
+    g_variant_builder_add (&builder, "s", "course");
+	result = g_dbus_connection_call_sync (c1,
+                                        TEST_SERVICE,  //bus name
+                                        TEST_DATA_PATH, //object path 
+                                        TEST_DATA_INTERFACE,  // interface name 
+                                        "add",                 // method name 
+                                        g_variant_new ("(as)", builder),   //parameters 
+                                         G_VARIANT_TYPE ("(i)"),                    // return type 
+                                        G_DBUS_CALL_FLAGS_NONE,
+                                        -1,
+                                        NULL,
+                                        &error);
+										
+										
+
+	g_assert_no_error (error);
+	g_assert (result != NULL);
+	g_variant_get(result, "(i)", &(set_result));
+	g_variant_unref (result);
+	RLOGD("%s, %s, %d,hgh %dzqcend:%d", __FILE__, __FUNCTION__, __LINE__,select_argvi,set_result);
+	//g_main_loop_run (loop);
+	g_main_loop_unref (loop);
+	
+    return set_result;
+}
+*/
+int main(int agrc, char** argv)
+{
+    int select_argvi = 99;
+    if(argv[1] != NULL)
+    {
+        select_argvi = atoi(argv[1]);
+    }
+    for(int i=1;i<agrc;i++)
+    {
+        printf("initGDBus:%d\n",atoi(argv[i]));
+    }
+    if(select_argvi == 1)
+    {
+        for(int i=0;i<10000;i++)
+        {
+             //gvariant_test2(i,5,select_argvi,get_platform_data());
+             test_add(i,5,select_argvi);
+             //gvariant_test();
+        }
+    }
+    else if(select_argvi == 0)
+    {
+        for(int i=0;i<10000;i++)
+        {
+             //gvariant_test2(i,5,select_argvi,get_platform_data());
+             test_decrease(i,5,select_argvi);
+             //gvariant_test();
+        }
+    }
+    else if(select_argvi == 2)
+    {
+        for(int i=0;i<10;i++)
+        {
+             //gvariant_test2(i,5,select_argvi,get_platform_data());
+             test_call(i,select_argvi);
+             //gvariant_test();
+        }
+    }
+    else
+    {
+        RLOGD("other test");
+    }
+    while(1){sleep(10);}
+    return 0;
+}
+
diff --git "a/common_src/packages/apps/lynq_dbus_test/src/lynq_testprocess\050gpio\051.tmp" "b/common_src/packages/apps/lynq_dbus_test/src/lynq_testprocess\050gpio\051.tmp"
new file mode 100644
index 0000000..c07e271
--- /dev/null
+++ "b/common_src/packages/apps/lynq_dbus_test/src/lynq_testprocess\050gpio\051.tmp"
@@ -0,0 +1,144 @@
+#include <stdio.h>
+#include <string.h>
+#include <pthread.h>
+#include <ctype.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <gio/gio.h>
+#include <log/log.h>
+#include <glib.h>
+#define GPIO_SERVICE "lynq.gpio" /*well-known bus name */
+#define GPIO_DATA_INTERFACE "lynq.gpio.Data" /*interface name*/
+#define GPIO_DATA_PATH "/lynq/gpio/data" /*object name*/
+GMainLoop *loop = NULL;
+GDBusProxy *proxy = NULL;
+#define LOG_TAG "GPIO_CONTROL"
+int set_gpio (gchar * mode,guint *gpio_numb,guint param)
+{
+	GDBusConnection *c1;
+	GVariant *result;
+	GError *error;
+	guint  set_result = -1;
+	 g_type_init();
+	loop = g_main_loop_new(NULL, FALSE);   /** create main loop, but do not start it.*/
+	c1 = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
+	g_assert (c1 != NULL);
+	g_assert (!g_dbus_connection_is_closed (c1));
+	result = g_dbus_connection_call_sync (c1,
+                                        GPIO_SERVICE,  /* bus name */
+                                        GPIO_DATA_PATH, /* object path */
+                                        GPIO_DATA_INTERFACE,  /* interface name */
+                                        "setGpio",                 /* method name */
+                                        g_variant_new ("(sii)", mode,gpio_numb,param),  /* parameters */
+                                         G_VARIANT_TYPE ("(i)"),                    /* return type */
+                                        G_DBUS_CALL_FLAGS_NONE,
+                                        -1,
+                                        NULL,
+                                        &error);
+	g_assert_no_error (error);
+	g_assert (result != NULL);
+	g_variant_get(result, "((i))", &(set_result));
+	g_variant_unref (result);
+	g_main_loop_run (loop);
+	g_main_loop_unref (loop);
+    return set_result;
+}
+int get_gpio (guint *gpio_numb)
+{
+   	GDBusConnection *c1;
+	GVariant *result;
+	GError *error;
+	guint  parm=0;
+	 const gchar *set_result;
+	 const gchar *mode ="gpio";
+	if(set_gpio(mode,gpio_numb,parm)== -1)
+	{
+		RLOGD("get_gpio number error");
+		return -1;
+	}
+	c1 = g_bus_get_sync (G_BUS_TYPE_SESSION, NULL, NULL);
+	g_assert (c1 != NULL);
+	g_assert (!g_dbus_connection_is_closed (c1));
+	result = g_dbus_connection_call_sync (c1,
+                                        GPIO_SERVICE,  /* bus name */
+                                        GPIO_DATA_PATH, /* object path */
+                                        GPIO_DATA_INTERFACE,  /* interface name */
+                                        "getGpio",                 /* method name */
+                                        NULL,  /* parameters */
+                                         G_VARIANT_TYPE ("(s)"),                     /* return type */
+                                        G_DBUS_CALL_FLAGS_NONE,
+                                        -1,
+                                        NULL,
+                                        &error);
+	g_assert_no_error (error);
+	g_assert (result != NULL);
+	g_variant_get(result, "((s))", &(set_result));
+	RLOGD("get_gpio,%s",set_result);
+	g_variant_unref (result);
+    return 1;
+}
+void proxy_ready(GObject *source, GAsyncResult *result, gpointer user_data) {
+    GError *error;
+
+    error = NULL;
+    proxy = g_dbus_proxy_new_for_bus_finish(result, &error);
+    if (proxy == NULL) {
+        RLOGE("create proxy fail");
+        return ;
+    }
+    RLOGD("proxy is ready");
+    gulong signal_handler_id;
+
+  //  signal_handler_id = g_signal_connect(proxy, "g-signal",
+  //          G_CALLBACK (proxy_signals_on_signal), NULL);
+   // if (signal_handler_id == 0) {
+   //     RLOGE("listen singal fail!");
+   // }
+}
+
+void* init_data_gdbus_cb(void *param)
+{
+    /* all the tests rely on a shared main loop */
+    loop = g_main_loop_new(NULL, FALSE);
+
+    g_dbus_proxy_new_for_bus(G_BUS_TYPE_SYSTEM,
+            G_DBUS_PROXY_FLAGS_NONE,
+            NULL, /* GDBusInterfaceInfo */
+            GPIO_SERVICE, /* name */
+            GPIO_DATA_PATH, /* object path */
+            GPIO_DATA_INTERFACE, /* interface */
+            NULL, /* GCancellable */
+            proxy_ready,
+            NULL);
+
+    g_main_loop_run(loop);
+
+    RLOGD("data gdbus main loop run()");
+    if(proxy != NULL) {
+        g_object_unref (proxy);
+    }
+    if(loop != NULL) {
+        g_main_loop_unref(loop);
+    }
+}
+
+
+void startGdbusLoop(void)
+{
+    pthread_t gpioThread;
+
+    RLOGD("startGdbusLoop()");
+   // pthread_mutex_lock(&s_startupMutex);
+    pthread_attr_t attr;
+    pthread_attr_init(&attr);
+    pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
+
+    int result = pthread_create(&gpioThread, &attr, init_data_gdbus_cb, NULL);
+    if (result != 0) {
+        RLOGW("Failed to create gdbus thread: %s", strerror(result));
+        //goto done;
+    }
+//done:
+ //   pthread_mutex_unlock(&s_startupMutex);
+}
diff --git a/common_src/packages/apps/lynq_dbus_test/src/makefile b/common_src/packages/apps/lynq_dbus_test/src/makefile
new file mode 100644
index 0000000..7963d4a
--- /dev/null
+++ b/common_src/packages/apps/lynq_dbus_test/src/makefile
@@ -0,0 +1,65 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+                -g -Os \
+                -flto \
+                -DRIL_SHLIB \
+                -DATCI_PARSE \
+                -DKEEP_ALIVE \
+                -D__LINUX_OS__ \
+                -DECALL_SUPPORT
+                
+CXXFLAGS = -fpermissive
+LOCAL_PATH   = .
+#CFLAGS = $(LOCAL_CFLAGS) -std=c99 
+#CXXFLAGS = $(LOCAL_CFLAGS) -std=gnu++14
+$(warning ################# ZHOUQUNCHAO ROOT: $(ROOT),includedir:$(includedir),LOCAL_PATH:$(LOCAL_PATH))
+LOCAL_C_INCLUDES = \
+  -I. \
+  -I$(LOCAL_PATH) \
+  -I$(ROOT)$(includedir)/logger \
+  -I$(ROOT)$(includedir)/vendor-ril \
+  -I$(ROOT)$(includedir)/gstreamer-1.0 \
+  -I$(ROOT)$(includedir)/glib-2.0 \
+  -I$(ROOT)$(libdir)/glib-2.0/include \
+  -I$(ROOT)$(libdir)/gstreamer-1.0/include\
+  -I$(ROOT)$(includedir)/dbus-1.0 \
+  -I$(ROOT)$(libdir)/dbus-1.0/include \
+
+LOCAL_C_INCLUDES+=$(DNS_FLAGS)
+
+LOCAL_LIBS := \
+    -L. \
+    -ldl \
+    -lstdc++ \
+    -llog \
+    -lcutils \
+    -lutils \
+    -lpthread \
+    -lpal \
+    -lglib-2.0 \
+    -lgobject-2.0 \
+    -lgio-2.0 \
+    -lapn \
+    -ldbus-1 \
+
+LOCAL_SRC_FILES_CPP = $(wildcard *.cpp)
+LOCAL_SRC_FILES_C = $(wildcard *.c)
+EXECUTABLE = lynq_dbus_test
+
+OBJECTS=$(LOCAL_SRC_FILES_CPP:.cpp=.o) $(LOCAL_SRC_FILES_C:.c=.o)
+all: $(EXECUTABLE)
+
+$(EXECUTABLE): $(OBJECTS)
+	$(CXX) $(OBJECTS) $(LOCAL_LIBS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES) -o $@ 
+
+%.o: %.c
+	$(warning ----->build $<)
+	$(CC) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+%.o : %.cpp
+	$(CXX) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+
+.PHONY: clean
+clean:
+	$(RM) $(OBJECTS) $(EXECUTABLE)