Merge "[Feature][T106]version update to T106CN-ZS03.V2.01.01.02P50.AP.07.04_CAP.07.04"
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/conf/distro/vehicle_dc_ref.conf b/cap/zx297520v3/sources/meta-zxic-custom/conf/distro/vehicle_dc_ref.conf
index 31697ed..8d07dc3 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/conf/distro/vehicle_dc_ref.conf
+++ b/cap/zx297520v3/sources/meta-zxic-custom/conf/distro/vehicle_dc_ref.conf
@@ -193,6 +193,8 @@
         liblynq-qser-fota \
         libpoweralarm \
         liblynq-systime \
+        liblynq-autosuspend \
+        liblynq-qser-autosuspend \
 	"
 
 zxic_lib += "${@bb.utils.contains('CONFIG_TEL_API_SUPPORT', 'RIL', 'libril', 'libtelsvr', d)}"
@@ -266,6 +268,7 @@
         lynq-qser-sim-demo \
         lynq-qser-sms-demo \
         lynq-qser-data-demo \
+        lynq-autosuspend \
         "
 
 zxic_app_open += "${@bb.utils.contains('CONFIG_TEL_API_SUPPORT', 'RIL', 'rild', '', d)}"
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc/init.d/zcatlog_config.sh b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc/init.d/zcatlog_config.sh
index 064dd2b..604cd22 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc/init.d/zcatlog_config.sh
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-core/images/files/zx297520v3/vehicle_dc_ref/fs/normal/rootfs/etc/init.d/zcatlog_config.sh
@@ -1,5 +1,9 @@
 #!/bin/sh
 
+if [ ! -f "/mnt/userdata/config" ];then
+	cp -R /etc/config /mnt/userdata/
+fi
+
 # 0 for usb, 1 for net
 if [ -e /proc/sys/zcatkern/log_com_mode ]; then
   zcat_com_mode=`nv get zcat_mode`
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-autosuspend/liblynq-autosuspend.bb b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-autosuspend/liblynq-autosuspend.bb
new file mode 100644
index 0000000..fc81884
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-autosuspend/liblynq-autosuspend.bb
@@ -0,0 +1,53 @@
+#inherit externalsrc package
+
+DESCRIPTION = "liblynq-autosuspend"
+LICENSE = "CLOSED"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=b1e07e8d88e26263e71d3a9e2aa9a2ff"
+DEPENDS += "libbsp liblynq-log"
+#inherit workonsrc
+WORKONSRC = "${TOPDIR}/../src/lynq/lib/liblynq-autosuspend"
+FILESEXTRAPATHS_prepend :="${TOPDIR}/../src/lynq/lib/:"
+SRC_URI = " \
+          file://liblynq-autosuspend \
+          "
+
+SRC-DIR = "${S}/../liblynq-autosuspend"
+TARGET_CC_ARCH += "${LDFLAGS}"
+BB_INCLUDE_ADD = "--sysroot=${STAGING_DIR_HOST}"
+BB_LDFLAGS_ADD = "--sysroot=${STAGING_DIR_HOST} -Wl,--hash-style=gnu"
+#Parameters passed to do_compile()
+EXTRA_OEMAKE = "'TARGET_PLATFORM = ${TARGET_PLATFORM}'"
+
+FILES_${PN} = "${base_libdir}/*.so \
+               ${base_bindir}\
+               ${base_sbindir} \
+               /etc/dbus-1/system.d/"
+FILES_${PN}-dev = "/test \
+                   ${includedir}"
+FILES_${PN}-doc = "/doc"
+FILES_${PN}-dbg ="${base_bindir}/.debug \
+                  ${base_libdir}/.debug \
+                  ${base_sbindir}/.debug"
+INSANE_SKIP_${PN} += "already-stripped"
+INSANE_SKIP_${PN} += "installed-vs-shipped"
+#INHIBIT_PACKAGE_STRIP = "1"
+do_compile () {
+	if [ "${PACKAGE_ARCH}" = "cortexa7hf-vfp-vfpv4-neon" ]; then
+		oe_runmake all -C ${SRC-DIR} ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -mfpu=neon-vfpv4 -mhard-float -Wl,--hash-style=gnu"
+	elif [ "${PACKAGE_ARCH}" = "cortexa7hf-neon-vfpv4" ]; then
+		oe_runmake all -C ${SRC-DIR} ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -mfpu=neon-vfpv4 -mhard-float -Wl,--hash-style=gnu"
+	elif [ "${PACKAGE_ARCH}" = "cortexa53hf-neon-fp-armv8" ]; then
+		oe_runmake all -C ${SRC-DIR} ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -mfpu=neon-vfpv4 -mhard-float -Wl,--hash-style=gnu -mhard-float -mfpu=neon-fp-armv8 -mfloat-abi=hard -mcpu=cortex-a53 -mtune=cortex-a53"
+	else
+		oe_runmake all -C ${SRC-DIR} ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -Wl,--hash-style=gnu -DTELEPHONYWARE"
+	fi
+}
+
+do_install() {
+    oe_runmake install -C ${SRC-DIR} ROOT=${D}
+    if [ -d "${WORKONSRC}" ] ; then
+        install -d ${D}${includedir}
+        cp -af ${SRC-DIR}/include/libauto/ ${D}${includedir}/libauto
+    fi
+}
+
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-log/liblynq-log.bb b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-log/liblynq-log.bb
index cf8b12d..3400fdd 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-log/liblynq-log.bb
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-log/liblynq-log.bb
@@ -6,7 +6,7 @@
 LICENSE = "CLOSED"

 LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"

 #DEPENDS += "platform-libs libpal nandapi liblynq-uci"

-DEPENDS += "liblynq-uci libbinder"

+DEPENDS += "${@bb.utils.contains('TARGET_PLATFORM', 'T106', "libnvram", '', d)} liblynq-uci libbinder"

 #inherit workonsrc

 WORKONSRC = "${TOPDIR}/../src/lynq/lib/liblynq-log"

 FILESEXTRAPATHS_prepend :="${TOPDIR}/../src/lynq/lib/:"

diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-qser-autosuspend/liblynq-qser-autosuspend.bb b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-qser-autosuspend/liblynq-qser-autosuspend.bb
new file mode 100644
index 0000000..375742d
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/liblynq-qser-autosuspend/liblynq-qser-autosuspend.bb
@@ -0,0 +1,52 @@
+#inherit externalsrc package
+
+DESCRIPTION = "liblynq-qser-autosuspend"
+LICENSE = "CLOSED"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+
+DEPENDS += "${@bb.utils.contains('TARGET_PLATFORM', 'mt2735', 'audio-mixer-ctrl streamer1.0', '', d)}  liblynq-autosuspend liblynq-log"
+#inherit workonsrc
+WORKONSRC = "${TOPDIR}/../src/lynq/lib/liblynq-qser-autosuspend/"
+FILESEXTRAPATHS_prepend :="${TOPDIR}/../src/lynq/lib/:"
+SRC_URI = " \
+          file://liblynq-qser-autosuspend\
+          "
+
+SRC-DIR = "${S}/../liblynq-qser-autosuspend"
+TARGET_CC_ARCH += "${LDFLAGS}"
+BB_INCLUDE_ADD = "--sysroot=${STAGING_DIR_HOST}"
+BB_LDFLAGS_ADD = "--sysroot=${STAGING_DIR_HOST} -Wl,--hash-style=gnu"
+#Parameters passed to do_compile()
+FILES_${PN} = "${base_libdir}/*.so "
+
+FILES_${PN}-dev = "/test \
+                   ${includedir}"
+
+FILES_${PN}-doc = "/doc"
+
+FILES_${PN}-dbg ="${base_bindir}/.debug \
+                  ${base_libdir}/.debug \
+                  ${base_sbindir}/.debug"
+
+INSANE_SKIP_${PN} += "already-stripped"
+INSANE_SKIP_${PN} += "installed-vs-shipped"
+
+
+#INHIBIT_PACKAGE_STRIP = "1"
+do_compile () {
+		oe_runmake all -C ${SRC-DIR} ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -Wl,--hash-style=gnu"
+}
+
+do_install () {
+    oe_runmake install -C ${SRC-DIR} ROOT=${D}
+	
+    if [ -d "${WORKONSRC}" ] ; then
+        install -d ${D}${includedir}/
+        cp -af ${SRC-DIR}/include/ ${D}${includedir}/
+    fi 
+}
+
+addtask bachclean
+do_bachclean () {
+    oe_runmake clean
+}
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-autosuspend/lynq-autosuspend.bb b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-autosuspend/lynq-autosuspend.bb
index c646163..23076f4 100755
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-autosuspend/lynq-autosuspend.bb
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-autosuspend/lynq-autosuspend.bb
@@ -15,9 +15,7 @@
            file://makefile \
 "
 
-EXTRA_OEMAKE = "'RAT_CONFIG_C2K_SUPPORT = ${RAT_CONFIG_C2K_SUPPORT}'\
-                'MTK_MULTI_SIM_SUPPORT = ${MTK_MULTI_SIM_SUPPORT}'\
-                'TARGET_PLATFORM = ${TARGET_PLATFORM}'"
+EXTRA_OEMAKE = "'TARGET_PLATFORM = ${TARGET_PLATFORM}'"
 
 TARGET_CC_ARCH += "${LDFLAGS}"
 
@@ -30,11 +28,6 @@
 
 OBJECTS = "$(SOURCES:.c=.o)"
 
-EXTRA_OEMAKE += "'MOBILETEK_SUSPEND_CFG = ${MOBILETEK_SUSPEND_CFG}'\
-                 'TARGET_PLATFORM = ${TARGET_PLATFORM}'\
-                 'MTK_LED_SUPPORT = ${MTK_LED_SUPPORT}'\
-                 'TARGET_PLATFORM = ${TARGET_PLATFORM}'"
-
 EXECUTABLE = "autosuspend"
 S = "${WORKDIR}"
 TARGET_CC_ARCH += "${LDFLAGS}"
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-autosuspend-demo/lynq-qser-autosuspend-demo.bb b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-autosuspend-demo/lynq-qser-autosuspend-demo.bb
new file mode 100644
index 0000000..ab8d052
--- /dev/null
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/lynq-qser-autosuspend-demo/lynq-qser-autosuspend-demo.bb
@@ -0,0 +1,40 @@
+inherit externalsrc package
+DESCRIPTION = "autosuspend-client demo"
+
+LICENSE = "MobileTekProprietary"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=4f60c98fa94e02f659ef5939f67fa8ae"
+#DEPENDS = "platform-libs"
+
+
+inherit workonsrc
+WORKONSRC = "${TOPDIR}/../src/lynq/packages/apps/lynq-qser-autosuspend-demo"
+FILESEXTRAPATHS_prepend :="${TOPDIR}/../src/lynq/packages/apps:"
+SRC_URI = " \
+          file://lynq-qser-autosuspend-demo \
+          "
+
+SRC-DIR = "${S}/../lynq-qser-autosuspend-demo"
+TARGET_CC_ARCH += "${LDFLAGS}"
+
+SYSTEMD_PACKAGES = "${PN}"
+#Parameters passed to do_compile()
+EXTRA_OEMAKE = "'TARGET_PLATFORM = ${TARGET_PLATFORM}'\"
+EXTRA_OEMAKE += "'MOBILETEK_RIL_CFG = ${MOBILETEK_RIL_CFG}'"
+
+EXTRA_OEMAKE += "'MOBILETEK_FOTA_CFG = ${MOBILETEK_FOTA_CFG}'"
+
+#INHIBIT_PACKAGE_STRIP = "1"
+do_compile () {
+	if test "${PACKAGE_ARCH}" = "cortexa7hf-vfp-vfpv4-neon" || test "${PACKAGE_ARCH}" = "cortexa7hf-neon-vfpv4"; then
+		oe_runmake all -C ${SRC-DIR} ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -mhard-float"
+	else
+		oe_runmake all -C ${SRC-DIR} ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST}"
+	fi
+}
+
+
+do_install() {
+	install -d ${D}${bindir}/
+	install -m 0755 ${SRC-DIR}/lynq-qser-autosuspend-demo ${D}${bindir}/
+	install -d ${D}${includedir}
+}
diff --git a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/uci/files/uci.patch b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/uci/files/uci.patch
index c6e4720..2787896 100644
--- a/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/uci/files/uci.patch
+++ b/cap/zx297520v3/sources/meta-zxic-custom/recipes-lynq/uci/files/uci.patch
@@ -1,32 +1,3 @@
-diff --git a/libuci.c b/libuci.c
-index ae4c964..dcf3e8b 100644
---- a/libuci.c
-+++ b/libuci.c
-@@ -25,7 +25,7 @@
- #include <dlfcn.h>
- #include <glob.h>
- #include "uci.h"
--
-+#include <unistd.h>
- static const char *uci_errstr[] = {
- 	[UCI_OK] =            "Success",
- 	[UCI_ERR_MEM] =       "Out of memory",
-@@ -174,6 +174,15 @@ uci_get_errorstr(struct uci_context *ctx, char **dest, const char *prefix)
- 
- int uci_list_configs(struct uci_context *ctx, char ***list)
- {
-+	int ret;
-+	if(access("/mnt/userdata/config", 0) != 0)
-+	{
-+	    ret = system("cp -R /etc/config /mnt/userdata/");
-+	    if(ret!=0)
-+	    {
-+		printf("uci_list_configs: cp fail\n");
-+	    }
-+	}
- 	UCI_HANDLE_ERR(ctx);
- 	UCI_ASSERT(ctx, list != NULL);
- 	UCI_ASSERT(ctx, ctx->backend && ctx->backend->list_configs);
 diff --git a/uci.h b/uci.h
 index d0374f2..8ed49d9 100644
 --- a/uci.h
diff --git a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/ril.cpp b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/ril.cpp
index c23afae..bde5a93 100755
--- a/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/ril.cpp
+++ b/cap/zx297520v3/src/lynq/framework/lynq-ril-service/src/ril.cpp
@@ -7828,6 +7828,8 @@
 #endif /* KEEP_ALIVE*/
 } /* namespace android */
 
+DEFINE_LYNQ_EXE_LOG(LYNQ_RIL)
+
 #if 0
 void rilEventAddWakeup_helper(struct ril_event *ev) {
     android::rilEventAddWakeup(ev);
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-autosuspend/LICENSE b/cap/zx297520v3/src/lynq/lib/liblynq-autosuspend/LICENSE
new file mode 100644
index 0000000..605b7ea
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-autosuspend/LICENSE
@@ -0,0 +1,31 @@
+Copyright Statement:
+
+This software/firmware and related documentation ("MobileTek Software") are
+protected under relevant copyright laws. The information contained herein is
+confidential and proprietary to MobileTek Inc. and/or its licensors. Without
+the prior written permission of MobileTek inc. and/or its licensors, any
+reproduction, modification, use or disclosure of MobileTek Software, and
+information contained herein, in whole or in part, shall be strictly
+prohibited.
+
+MobileTek Inc. (C) 2015. All rights reserved.
+
+BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MobileTek SOFTWARE")
+RECEIVED FROM MobileTek AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
+ON AN "AS-IS" BASIS ONLY. MobileTek 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 MobileTek PROVIDE ANY WARRANTY WHATSOEVER WITH
+RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
+INCORPORATED IN, OR SUPPLIED WITH THE MobileTek 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 MobileTek
+SOFTWARE. MobileTek SHALL ALSO NOT BE RESPONSIBLE FOR ANY MobileTek SOFTWARE
+RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MobileTek'S
+ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MobileTek SOFTWARE
+RELEASED HEREUNDER WILL BE, AT MobileTek'S OPTION, TO REVISE OR REPLACE THE
+MobileTek SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
+CHARGE PAID BY RECEIVER TO MobileTek FOR SUCH MobileTek SOFTWARE AT ISSUE.
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-autosuspend/include/libauto/lynq_autosuspend.h b/cap/zx297520v3/src/lynq/lib/liblynq-autosuspend/include/libauto/lynq_autosuspend.h
new file mode 100644
index 0000000..efd1219
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-autosuspend/include/libauto/lynq_autosuspend.h
@@ -0,0 +1,37 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <unistd.h>
+#include <dlfcn.h>
+#include <pthread.h>
+#include <stdbool.h>
+#include <time.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+struct time_info_t
+{
+    long sleep_start_time;
+    long wakeup_time;
+};
+
+int lynq_autosleep_enable(void);
+int lynq_autosleep_disable(void);
+int lynq_wait_wakeup_event(long *sleep_start_time, long * wakeup_time);
+
+#ifdef MOBILETEK_TARGET_PLATFORM_T106
+int lynq_set_lpmode(int lp_mode);
+int release_wake_lock(char *name);
+int acquire_wake_lock(int lock, char *name);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-autosuspend/lynq-autosuspend.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-autosuspend/lynq-autosuspend.cpp
new file mode 100644
index 0000000..54c88fd
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-autosuspend/lynq-autosuspend.cpp
@@ -0,0 +1,445 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <unistd.h>
+#include <dlfcn.h>
+#include <pthread.h>
+#include <stdbool.h>
+#include <time.h>
+#include "include/libauto/lynq_autosuspend.h"
+#ifdef MOBILETEK_TARGET_PLATFORM_T106
+#include <sc_bsp.h>
+#endif
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+#define LOG_TAG "libautosuspend"
+// #include <liblog/lynq_deflog.h>
+#include <log/log.h>
+#define SERVER_CMD_PATH "/tmp/autosuspend.cmd.server"
+#define SERVER_DATA_PATH "/tmp/autosuspend.data.server"
+// #define CLIENT_PATH "/tmp/autosuspend.client"
+static int client_sock_fd;
+static int client_data_sock_fd;
+static bool libautosuspend_inited;
+bool feedback_flag = true; //add for after sleeping once calling lynq_wailt_wakeup_event does not return sleep time
+// static bool libautosuspend_enabled;
+// static pthread_mutex_t get_feedback_mutex = PTHREAD_MUTEX_INITIALIZER;
+// static pthread_cond_t get_feedback_cond = PTHREAD_COND_INITIALIZER;
+static pthread_mutex_t client_fd_mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t client_data_fd_mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_mutex_t feedback_got_mutex = PTHREAD_MUTEX_INITIALIZER;
+static pthread_cond_t feedback_got_cond = PTHREAD_COND_INITIALIZER;
+
+static struct time_info_t time_info_client; 
+static ssize_t Read(int fd, void *ptr, size_t nbytes)
+{
+    ssize_t n;
+    
+    while((n = read(fd, ptr, nbytes)) == -1)
+    {
+       //printf("READ,%d\n",fd);
+        if (errno == EINTR)
+        {    
+            printf("read error eintr\n");
+            continue;
+        }
+        else if(errno == EAGAIN || errno == EWOULDBLOCK)
+        {
+            printf("read time out\n");
+            return -2;
+        }
+        else
+        {
+            printf("read error\n");
+            return -1;
+        }
+    }
+    //sleep(2);
+    //printf("READ1,%d\n", fd);
+    return n;
+}
+static ssize_t Write(int fd, const void *ptr, size_t nbytes)
+{
+    ssize_t n;
+    while((n = write(fd, ptr, nbytes)) == -1)
+    {
+        if (errno == EINTR)
+            continue;
+        else if(errno == EPIPE)
+        {
+            printf("write error epipe\n");
+            return -1;
+        }  
+        else
+            return -1;
+    }
+    return n;
+}
+static int Close(int fd)
+{
+    if (Close(fd) == -1)
+    {
+        printf("Close error\n");
+        return -1;
+    }
+    return 0;
+}
+static int connect_to_server(int *cfd, char *client_path, char *server_path)
+{
+    int rc;
+    struct sockaddr_un server_sockaddr; 
+    struct sockaddr_un client_sockaddr; 
+    printf("Start bind and connect to the service.\n");
+    /**************************************/
+    /* Create a UNIX domain stream socket */
+    /**************************************/
+    *cfd = socket(AF_UNIX, SOCK_STREAM, 0);
+    if (*cfd == -1) {
+        printf("SOCKET ERROR ");
+        return -1;
+    }
+    /***************************************/
+    /* Set up the UNIX sockaddr structure  */
+    /* by using AF_UNIX for the family and */
+    /* giving it a filepath to bind to.    */
+    /*                                     */
+    /* Unlink the file so the bind will    */
+    /* succeed, then bind to that file.    */
+    /***************************************/
+    client_sockaddr.sun_family = AF_UNIX;  
+    strcpy(client_sockaddr.sun_path, client_path); 
+    
+    unlink(client_sockaddr.sun_path);
+    rc = bind(*cfd, (struct sockaddr *) &client_sockaddr, sizeof(client_sockaddr));
+    if (rc == -1){
+        printf("BIND ERROR ");
+        Close(*cfd);
+        return -1;
+    }
+        
+    /***************************************/
+    /* Set up the UNIX sockaddr structure  */
+    /* for the server socket and connect   */
+    /* to it.                              */
+    /***************************************/
+    server_sockaddr.sun_family = AF_UNIX;
+    
+    strcpy(server_sockaddr.sun_path, server_path);
+    rc = connect(*cfd, (struct sockaddr *) &server_sockaddr, sizeof(client_sockaddr));
+    if(rc == -1){
+        printf("CONNECT ERROR ");
+        Close(*cfd);
+        return -3;
+    }
+    return 0;
+    
+}
+static void *deal_get_feedback(void *sockfd)
+{
+    int rc;
+    int client_sock = *((int *)sockfd);
+    // pthread_mutex_lock(&feedback_got_mutex);
+    
+    while (1)
+    {
+        // printf("deal_get_feedback thread wait.\n");
+        // pthread_cond_wait(&get_feedback_cond,&get_feedback_mutex);
+        printf("start get feedback from the service.\n");
+        pthread_mutex_lock(&feedback_got_mutex);
+        memset(&time_info_client,0,sizeof(struct time_info_t));
+        rc = Read(client_sock,&time_info_client,sizeof(struct time_info_t));
+        if(rc == -1)
+        {           
+            printf("client read wakeup_feedback struct fail.\n");
+            Close(client_sock);
+            pthread_mutex_unlock(&feedback_got_mutex);
+            break ;
+        }
+        else if(rc == -2)
+        {
+            printf("client read wakeup_feedback struct timeout.\n");
+            pthread_mutex_unlock(&feedback_got_mutex);
+            continue;
+        }
+        printf("system sleep_start timestamps : %ld ms\n",time_info_client.sleep_start_time);
+        printf("system wakeup timestamps : %ld ms\n",time_info_client.wakeup_time);
+        // pthread_cond_broadcast(&feedback_got_cond);
+        pthread_mutex_unlock(&feedback_got_mutex);
+        usleep(10000);  //给libautosuspend_get_feedback函数时间进入wait,不可删除,但可以减少
+        pthread_cond_broadcast(&feedback_got_cond);
+        usleep(10000); //希望多给libautosuspend_get_feedback函数拿到锁的机会,不可删除,但可以减少
+        
+    }
+    
+}
+static int libautosuspend_init()
+{
+    if (libautosuspend_inited)
+    {
+        return 0;
+    }
+    printf("Start libautosuspend_init.\n");
+    char client_cmd_path[40];
+    char client_data_path[40];
+    sprintf(client_cmd_path,"/tmp/autosuspend.%d.cmd.client",(int)getpid());
+    sprintf(client_data_path,"/tmp/autosuspend.%d.data.client",(int)getpid());
+    pthread_mutex_lock(&client_fd_mutex);
+    if(connect_to_server(&client_sock_fd,client_cmd_path,SERVER_CMD_PATH) < 0)
+    {
+        printf("cmd channel connect error.\n");
+        pthread_mutex_unlock(&client_fd_mutex);
+        return -1;
+    }
+    if(connect_to_server(&client_data_sock_fd,client_data_path,SERVER_DATA_PATH) < 0)
+    {
+        printf("data channel connect error.\n");
+        pthread_mutex_unlock(&client_fd_mutex);
+        return -1;
+    }
+    pthread_t feedback_tid;
+    pthread_create(&feedback_tid,NULL,deal_get_feedback,(void*)&client_data_sock_fd);
+    pthread_detach(feedback_tid);
+    libautosuspend_inited = true;
+    pthread_mutex_unlock(&client_fd_mutex);
+    
+    return 0;
+    
+}
+static int send_cmd(char * value,int len)
+{
+    int rc;
+    if(value == NULL)
+    {
+       return -1;
+    }
+    
+    /************************************/
+    /* Copy the data to the buffer and  */
+    /* send it to the server socket.    */
+    /************************************/
+    // strcpy(buf, DATA);
+    printf("Sending data...\n");
+    rc = send(client_sock_fd, value, len, 0);
+    if (rc == -1) {
+        printf("SEND ERROR ");
+        Close(client_sock_fd);
+        return -2;
+    }   
+    else {
+        printf("Data sent: %s\n",value);
+    }
+    // Close(client_sock);
+    return rc;
+}
+int lynq_autosleep_enable(void)
+{
+    char value[15]="enable";
+    char res[15];
+    if(libautosuspend_init() != 0)
+    {
+        return -1;
+    }
+    // if(libautosuspend_enabled)
+    // {
+    //     return 0;
+    // }
+    pthread_mutex_lock(&client_fd_mutex);
+    int rc = send_cmd(value,strlen(value));
+    if(rc < 0)
+    {
+        printf("libautosuspend send enable cmd fail.\n");
+        pthread_mutex_unlock(&client_fd_mutex);
+        return -1;
+    }
+    // if(Read(client_sock_fd,res,sizeof(res)) <= 0)
+    // {
+    //     printf("libautosuspend get respond fail.\n");
+    //     pthread_mutex_unlock(&client_fd_mutex);
+    //     return -1;
+    // }
+    // printf("libautosuspend get respond : %s.\n",res);
+    // if(strcmp(res,"enabled") != 0)
+    // {
+    //     pthread_mutex_unlock(&client_fd_mutex);
+    //     return -1;
+    // }
+    // libautosuspend_enabled = true;
+    pthread_mutex_unlock(&client_fd_mutex);
+    return 1;
+  
+}
+int lynq_autosleep_disable(void)
+{
+    char value[15]="disable";
+    char res[15];
+    if(libautosuspend_init() != 0)
+    {
+        return -1;
+    }
+    // if(!libautosuspend_enabled)
+    // {
+    //     return 0;
+    // }
+    pthread_mutex_lock(&client_fd_mutex);
+    int rc = send_cmd(value,strlen(value));
+    if(rc < 0)
+    {
+        printf("libautosuspend send disable cmd fail.\n");
+        pthread_mutex_unlock(&client_fd_mutex);
+        return -1;
+    }
+    // if(Read(client_sock_fd,res,sizeof(res)) <= 0)
+    // {
+    //     printf("libautosuspend get respond fail.\n");
+    //     pthread_mutex_unlock(&client_fd_mutex);
+    //     return -1;
+    // }
+    // printf("libautosuspend get respond : %s.\n",res);
+    // if(strcmp(res,"disabled") != 0)
+    // {
+    //     pthread_mutex_unlock(&client_fd_mutex);
+    //     return -1;
+    // }
+    // libautosuspend_enabled = false;
+    pthread_mutex_unlock(&client_fd_mutex);
+    return 1;
+}
+int libautosuspend_get_feedback(struct time_info_t *time_info)
+{
+    // char value[15]="feedback";
+    // char res[15];    
+    // if(!libautosuspend_enabled)
+    // {
+    //     printf("system autosuspend disabled, can not get wakeup feedback.\n");
+    //     return -1;
+    // }
+    printf("start get feedback from the service.\n");
+    memset(time_info,0,sizeof(struct time_info_t));
+    // if(timeout == NULL)
+    // {
+    //     printf("client set timeout for receiving wakeup_feedback: NULL.\n");
+    // }
+    // else
+    // {
+    //     struct timeval recv_timeout = {(*timeout),0};
+    //     pthread_mutex_lock(&client_data_fd_mutex);
+    //     if(setsockopt(client_data_sock_fd,SOL_SOCKET,SO_RCVTIMEO,(char*)&recv_timeout,sizeof(struct timeval)) == -1)
+    //     {
+    //         printf("client set timeout for receiving wakeup_feedback: error.\n");
+    //         pthread_mutex_unlock(&client_data_fd_mutex);
+    //         return -1;
+    //     }
+            
+    //     printf("client set timeout for receiving wakeup_feedback: %d s.\n",(*timeout));
+    //     pthread_mutex_unlock(&client_data_fd_mutex);
+        
+    // }
+    // int rc = send_cmd(value,strlen(value));
+    // if(rc < 0)
+    // {
+    //     printf("libautosuspend send feedback cmd fail.\n");
+    //     pthread_mutex_unlock(&client_fd_mutex);
+    //     return -1;
+    // }
+    // if(Read(client_data_sock_fd,time_info,sizeof(struct time_info_t)) <= 0)
+    // {
+    //     printf("libautosuspend_get_feedback fail.\n");
+    //     pthread_mutex_unlock(&client_fd_mutex);
+    //     return -1;
+    // }
+    printf("libautosuspend_get_feedback wait.\n");
+    pthread_mutex_lock(&feedback_got_mutex);
+    pthread_cond_wait(&feedback_got_cond,&feedback_got_mutex);
+    memcpy(time_info,&time_info_client,sizeof(struct time_info_t));
+    printf("libautosuspend_get_feedback success.\n");
+    pthread_mutex_unlock(&feedback_got_mutex);
+    // printf("[client] system sleep_start timestamps : %ld ms\n",time_info.sleep_start_time);
+    // printf("[client] system wakeup timestamps : %ld ms\n",time_info.wakeup_time);
+    return 0;
+}
+int lynq_wait_wakeup_event(long *sleep_start_time, long * wakeup_time)
+{
+   int *socket_timeout = NULL;
+   struct time_info_t time_info;
+   int ret = 0;
+   /*add for after sleeping once calling lynq_wailt_wakeup_event does not return sleep time start*/
+   if(feedback_flag == true)
+   {
+       if(libautosuspend_init() != 0)
+       {
+           return -1;
+       }
+   }
+   feedback_flag = false; 
+   /*add for after sleeping once calling lynq_wailt_wakeup_event does not return sleep time end*/
+   memset(&time_info,0,sizeof(struct time_info_t));
+   if(sleep_start_time == NULL || wakeup_time == NULL )
+   {
+      printf("lynq_wait_wakeup_event input errors.\n");
+      return -1;
+   }
+   ret=libautosuspend_get_feedback(&time_info);
+   if(ret == 0)
+   {
+     *sleep_start_time = time_info.sleep_start_time;
+     *wakeup_time = time_info.wakeup_time;
+     return 0;
+   }
+   else
+   {
+      return -1;
+   }
+   
+}
+#ifdef MOBILETEK_TARGET_PLATFORM_T106
+int acquire_wake_lock(int lock, char *name)
+{
+    int ret;
+    printf("Get param:%s \n", name);
+    ret = sc_pm_wakelock_lock(name);
+    if (ret)
+    {
+        printf("do_wakelock failed, err:%d", ret);
+        return ret;
+    }
+    printf("do_wakelock succeed\n");
+    return ret;
+}
+int release_wake_lock(char *name)
+{
+    int ret;
+    printf("Get param:%s \n", name);
+    ret = sc_pm_wakelock_unlock(name);
+    if (ret)
+    {
+        printf("do_wakeunlock failed, err:%d", ret);
+        return ret;
+    }
+    printf("do_wakeunlock succeed\n");
+    return ret;
+}
+int lynq_set_lpmode(int lp_mode)
+{
+    int ret;
+    printf("Get param:%d \n", lp_mode);
+    ret = sc_pm_set_lp_mode(lp_mode);
+    if (ret) {
+        printf("do_set_lpmode failed, err:%d", ret);
+        exit(1);
+    }
+    printf("do_set_lpmode succeed\n");
+    return ret;
+}
+#endif
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-autosuspend/lynq_autosuspend.h b/cap/zx297520v3/src/lynq/lib/liblynq-autosuspend/lynq_autosuspend.h
new file mode 100644
index 0000000..efd1219
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-autosuspend/lynq_autosuspend.h
@@ -0,0 +1,37 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <errno.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/socket.h>
+#include <sys/un.h>
+#include <unistd.h>
+#include <dlfcn.h>
+#include <pthread.h>
+#include <stdbool.h>
+#include <time.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+struct time_info_t
+{
+    long sleep_start_time;
+    long wakeup_time;
+};
+
+int lynq_autosleep_enable(void);
+int lynq_autosleep_disable(void);
+int lynq_wait_wakeup_event(long *sleep_start_time, long * wakeup_time);
+
+#ifdef MOBILETEK_TARGET_PLATFORM_T106
+int lynq_set_lpmode(int lp_mode);
+int release_wake_lock(char *name);
+int acquire_wake_lock(int lock, char *name);
+#endif
+
+#ifdef __cplusplus
+}
+#endif
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-autosuspend/makefile b/cap/zx297520v3/src/lynq/lib/liblynq-autosuspend/makefile
new file mode 100644
index 0000000..b97b48c
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-autosuspend/makefile
@@ -0,0 +1,74 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+                -std=c++11 \
+                -g -Os \
+                -flto \
+                -fPIC \
+                -fpermissive \
+
+
+ifeq ($(strip $(TARGET_PLATFORM)), T106)
+    LOCAL_CFLAGS += -DBINDER_IPC_32BIT=1 -DHAVE_ENDIAN_H -DHAVE_PTHREADS -DHAVE_SYS_UIO_H -DHAVE_POSIX_FILEMAP -DHAVE_STRLCPY -DHAVE_PRCTL -DHAVE_MEMSET16 -DHAVE_MEMSET32 -DANDROID_SMP=0
+endif
+
+ifeq ($(strip $(TARGET_PLATFORM)), T106)
+    LOCAL_CFLAGS += -DMOBILETEK_TARGET_PLATFORM_T106
+endif
+
+
+
+$(warning ################# lynq autosuspend API ROOT: $(ROOT),includedir:$(includedir))
+LOCAL_PATH   = .
+
+LOCAL_C_INCLUDES = \
+  -I. \
+  -I$(LOCAL_PATH)/include/libauto \
+  -I$(ROOT)$(includedir)/logger \
+  -I$(ROOT)$(includedir)/liblog \
+
+
+
+LOCAL_LIBS := \
+    -L. \
+    -ldl \
+    -lstdc++ \
+    -llog \
+    -lcutils \
+    -lpthread \
+    -llynq-log \
+    -lbsp \
+
+SOURCES = $(wildcard *.cpp)
+
+EXECUTABLE = liblynq-autosuspend.so
+
+OBJECTS=$(SOURCES:.cpp=.o)
+
+
+.PHONY: build clean install pack_rootfs 
+all: build
+$(EXECUTABLE): $(OBJECTS)
+	$(CXX) -shared -Wl,--no-undefined $(OBJECTS) $(LOCAL_LIBS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES) -o $@
+
+%.o : %.cpp
+	$(CXX) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+
+build:  $(EXECUTABLE)
+	$(warning ########## build $(EXECUTABLE)  ##########)
+install:
+	mkdir -p $(ROOT)$(base_libdir)/
+	install $(EXECUTABLE) $(ROOT)$(base_libdir)/
+	mkdir -p $(ROOT)$(includedir)/$(NAME)/sdk
+pack_rootfs:
+	mkdir -p $(PACK_INITRAMFS_TO)$(base_libdir)/
+	cp -af $(EXECUTABLE) $(PACK_INITRAMFS_TO)$(base_libdir)/
+	$(CROSS)strip $(PACK_INITRAMFS_TO)$(base_libdir)/$(EXECUTABLE)
+	mkdir -p $(PACK_TO)$(base_libdir)/
+	cp -af $(EXECUTABLE) $(PACK_TO)$(base_libdir)/
+	$(CROSS)strip $(PACK_TO)$(base_libdir)/$(EXECUTABLE)
+.PHONY: clean
+clean:
+	$(RM) $(OBJECTS) $(EXECUTABLE)
+	-find . -name "*.o" -delete
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-call/lynq_call.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-call/lynq_call.cpp
index b775838..0dc22bc 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-call/lynq_call.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-call/lynq_call.cpp
@@ -1503,6 +1503,8 @@
     }

 }

 

+DEFINE_LYNQ_LIB_LOG(LYNQ_CALL)

+

 #if 0

 int main(int argc,char **argv)

 {

diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-data/lynq_data.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-data/lynq_data.cpp
index 97b72b0..975db3a 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-data/lynq_data.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-data/lynq_data.cpp
@@ -1995,3 +1995,6 @@
 {
     pthread_cond_signal(&s_lynq_urc_vector_cond);
 }
+
+DEFINE_LYNQ_LIB_LOG(LYNQ_DATA)
+
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-log/include/liblog/liblog.h b/cap/zx297520v3/src/lynq/lib/liblynq-log/include/liblog/liblog.h
index 03b183a..c9772b4 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-log/include/liblog/liblog.h
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-log/include/liblog/liblog.h
@@ -5,14 +5,6 @@
 extern "C" {
 #endif
 
-#define LOG_ENABLE  1      
-
-//#if LOG_ENABLE
-#if LOG_ENABLE
-
-#define ENABLE(X)               (1<<(X))
-#define LOG_LEVEL_ENABLE      	  ENABLE(LOG_VERBOSE)
-
 typedef enum
 {
     LOG_VERBOSE = 0,   
@@ -23,15 +15,9 @@
     LOG_LEVEL_MAX
 }log_level_enum;
 
-const static char * LogLevelNameInfoTable[LOG_LEVEL_MAX] =
-{
-    "[VERBOSE]","[ERROR]","[WARNING]","[INFO]","[DEBUG]" //lt add @2021.7.22 for []
-};
-#endif //LOG_ENABLE
-
 void lynq_log_global_output(log_level_enum Level,const char *format,...);
-void lynq_log_configuration_set(char *log_name,char log_data_arr);
 void lynq_log_configuration_init(char *log_name);
+const char* lynq_read_log_version();
 #ifdef __cplusplus
 }
 #endif
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-log/include/liblog/lynq_deflog.h b/cap/zx297520v3/src/lynq/lib/liblynq-log/include/liblog/lynq_deflog.h
index 667ae1a..3fecfc7 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-log/include/liblog/lynq_deflog.h
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-log/include/liblog/lynq_deflog.h
@@ -6,36 +6,68 @@
 extern "C" {

 #endif

 

-void lynq_log_configuration_init(char *log_name);

-void lynq_log_configuration_set(char *log_name,char log_data_arr);

-void lynq_log_verbose(const char *format,...);

-void lynq_log_error(const char *format,...);

-void lynq_log_warning(const char *format,...);

-void lynq_log_info(const char *format,...);

-void lynq_log_debug(const char *format,...);

+typedef void (*LYNQ_WRITE_LOG_PTR)(log_level_enum level, const char *format, ...);

+extern LYNQ_WRITE_LOG_PTR lynq_write_log;

+LYNQ_WRITE_LOG_PTR lynq_log_function_init(const char *log_name);

 

+int lynq_syslog_set_file_size(int value);

+int lynq_syslog_get_file_size(void);

+int lynq_syslog_set_file_rotate(int value);

+int lynq_syslog_get_file_rotate(void);

 

-#ifndef USER_LOG_TAG 

-#define LYVERBLOG(X...)  lynq_log_global_output(LOG_VERBOSE,X)

-#define LYERRLOG(X...)  lynq_log_global_output(LOG_ERROR,X)

-#define LYWARNLOG(X...)  lynq_log_global_output(LOG_WARNING,X)

-#define LYINFLOG(X...)  lynq_log_global_output(LOG_INFO,X)

-#define LYDBGLOG(X...)  lynq_log_global_output(LOG_DEBUG,X)

-#define LYLOGSET(a) lynq_log_configuration_set(USER_LOG_TAG,a)

-#define LYLOGEINIT(Y) lynq_log_configuration_init(Y)

-#else

-#define LYVERBLOG(X...)  

-#define LYERRLOG(X...)  

-#define LYWARNLOG(X...)  

-#define LYINFLOG(X...)  

-#define LYDBGLOG(X...)  

-#define LYLOGSET(a)

-#define LYLOGEINIT(Y)

-#endif

-

-char* lynq_read_log_version();

 #ifdef __cplusplus

 }

 #endif

 

-#endif  //__LYNQ_DEFLOG_H__
\ No newline at end of file
+#define lynq_log_verbose(...)  do { lynq_write_log(LOG_VERBOSE,__VA_ARGS__);} while (0)

+#define lynq_log_error(...)  do {lynq_write_log(LOG_ERROR,__VA_ARGS__);} while (0)

+#define lynq_log_warning(...)  do {lynq_write_log(LOG_WARNING,__VA_ARGS__);} while (0)

+#define lynq_log_info(...)  do {lynq_write_log(LOG_INFO,__VA_ARGS__);} while (0)

+#define lynq_log_debug(...)  do {lynq_write_log(LOG_DEBUG,__VA_ARGS__);} while (0)

+

+#define LYVERBLOG(...)  do {lynq_write_log(LOG_VERBOSE,__VA_ARGS__);} while (0)

+#define LYERRLOG(...)  do {lynq_write_log(LOG_ERROR,__VA_ARGS__);} while (0)

+#define LYWARNLOG(...)  do {lynq_write_log(LOG_WARNING,__VA_ARGS__);} while(0)

+#define LYINFLOG(...)  do {lynq_write_log(LOG_INFO,__VA_ARGS__);} while (0)

+#define LYDBGLOG(...)  do {lynq_write_log(LOG_DEBUG,__VA_ARGS__);} while (0)

+

+// just for comcompatibility, do nothing

+#define LYLOGSET(a) do{;}while(0)

+#define LYLOGEINIT(Y) do{;}while(0)

+

+#ifndef ALOGV

+#define ALOGV(...) do {lynq_write_log(LOG_VERBOSE,__VA_ARGS__);} while (0)

+#endif

+

+#ifndef ALOGE

+#define ALOGE(...) do {lynq_write_log(LOG_ERROR,__VA_ARGS__);} while (0)

+#endif

+

+#ifndef ALOGW

+#define ALOGW(...) do {lynq_write_log(LOG_WARNING,__VA_ARGS__);} while (0)

+#endif

+

+#ifndef ALOGI

+#define ALOGI(...) do {lynq_write_log(LOG_INFO,__VA_ARGS__);} while (0)

+#endif

+

+#ifndef ALOGD

+#define ALOGD(...) do {lynq_write_log(LOG_DEBUG,__VA_ARGS__);} while (0)

+#endif

+

+#define DEFINE_LYNQ_LIB_LOG(tag) \

+    LYNQ_WRITE_LOG_PTR __attribute__ ((visibility ("hidden"))) lynq_write_log = NULL; \

+    void __attribute__((constructor)) tag##_init() \

+    { \

+        lynq_write_log = lynq_log_function_init(#tag); \

+    }

+

+#define DEFINE_LYNQ_EXE_LOG(tag) \

+    LYNQ_WRITE_LOG_PTR __attribute__ ((visibility ("hidden"))) lynq_write_log = NULL; \

+    void __attribute__((constructor)) tag##_init() \

+    { \

+        lynq_write_log = lynq_log_function_init(#tag); \

+        lynq_log_configuration_init(#tag); \

+    }

+

+#endif  //__LYNQ_DEFLOG_H__

diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-log/log-riltel/log.c b/cap/zx297520v3/src/lynq/lib/liblynq-log/log-riltel/log.c
deleted file mode 100755
index c59374b..0000000
--- a/cap/zx297520v3/src/lynq/lib/liblynq-log/log-riltel/log.c
+++ /dev/null
@@ -1,367 +0,0 @@
-#include "liblog.h"
-#include <stdarg.h>
-#include <stdio.h>
-#include <stdlib.h> 
-#include <unistd.h>
-#include <string.h>
-#include <log/log.h>
-#include <include/lynq_uci.h>
-
-#define LOG_NAME_LEN 128
-#define LOG_OUT_LEN 2*1024+100 //lt add @2021.9.22 for write outbuf define len 
-#define LOG_LEN 2*1024 //lt add @2021.9.22 for write buf define len 
-#define LOG_UCI_MODULE "lynq_log"
-#define LOG_UCI_FILE "lynq_uci"
-static unsigned int log_level = 0; 
-static unsigned char log_name_arr[LOG_NAME_LEN] = {0};
-
-int lynq_log_set_value(char *key, char *value);
-int lynq_log_get_value(char *key, char *tmp);
-
-void lynq_log_global_output(log_level_enum Level,const char *format,...)
-{
-#if LOG_ENABLE
-
-    char out_buf[LOG_OUT_LEN] = {0};    
-    char buf[LOG_LEN] = {0};
-	
-    if(Level >=  LOG_LEVEL_MAX)
-        return;
-    if((log_level >> Level)&0x00000001)
-    {
-        va_list args;
-        //TagName
-        if(log_name_arr[0]  > 0)
-        {
-		printf("[%s]",log_name_arr);
-	 }
-        
-        //LevelName
-        printf("%s:",LogLevelNameInfoTable[Level]); //lt dele @2021.7.22 for []
-
-        va_start(args,format);
-        vprintf(format,args);
-        vsnprintf(buf, sizeof(buf), format, args);  //lt add @2021.7.22 for write buf
-        va_end(args);
-        printf("\r\n");
-
-        sprintf(out_buf, "%s %s", LogLevelNameInfoTable[Level], buf);//lt add @2021.7.22 for write outbuf
-        switch(Level) //lt mod @2021.9.22 for matching MTK log level 
-        {
-            case LOG_VERBOSE:
-                __android_log_print(ANDROID_LOG_VERBOSE,log_name_arr, "%s",out_buf); //lt add @2021.9.22 for write syslog.log		
-                break;
-            case LOG_ERROR:
-                __android_log_print(ANDROID_LOG_ERROR,log_name_arr, "%s",out_buf); //lt add @2021.9.22 for write syslog.log		
-                break;
-            case LOG_WARNING:
-                __android_log_print(ANDROID_LOG_WARN,log_name_arr, "%s",out_buf); //lt add @2021.9.22 for write syslog.log		
-                break;		
-            case LOG_INFO:
-                __android_log_print(ANDROID_LOG_INFO,log_name_arr, "%s",out_buf); //lt add @2021.9.22 for write syslog.log		
-                break;
-            case LOG_DEBUG:
-                __android_log_print(ANDROID_LOG_DEBUG,log_name_arr, "%s",out_buf); //lt add @2021.7.22 for write syslog.log		
-                break;
-            default :
-                __android_log_print(ANDROID_LOG_DEBUG,log_name_arr, "Log Level is Error!!!!!!"); //lt add @2021.9.22 for write syslog.log		
-                break;
-        }
-	
-    }
-    return ;
-#endif //LOG_ENABLE
-}
-
-void lynq_log_configuration_set(char *log_name,char log_data_arr)
-{
-    char log_data_str[32] = {0};
-    if(log_name == NULL)
-    {
-        return ;
-    }
-    if(log_data_arr < LOG_LEVEL_MAX)
-    {
-        sprintf(log_data_str,"%d",log_data_arr);
-        if((strlen(log_name)) < LOG_NAME_LEN)
-        {
-            lynq_log_set_value(log_name, log_data_str);//lt mod @2021.8.3 for uci
-        }
-    }
-    lynq_log_configuration_init(log_name);  
-    return ;
-}
-
-void lynq_deal_with_level(unsigned int get_log_level)
-{
-    switch(get_log_level)
-    {
-        case LOG_DEBUG:
-            log_level |= ENABLE(LOG_DEBUG);
-        case LOG_INFO:
-            log_level |= ENABLE(LOG_INFO);
-        case LOG_WARNING:
-            log_level |= ENABLE(LOG_WARNING);
-        case LOG_ERROR:
-            log_level |= ENABLE(LOG_ERROR);
-        case LOG_VERBOSE:
-            log_level |= ENABLE(LOG_VERBOSE);
-            break;
-        default:
-            log_level |= ENABLE(LOG_VERBOSE);
-            break;
-    }
-    return ;
-}
-
-void lynq_log_configuration_init(char *log_name)
-{
-    char get_propty_log_data[32] ={0};
-    unsigned int get_log_level = 0;
-    if(log_name == NULL)
-    {
-        return ;
-    }
-    if((strlen(log_name)) < LOG_NAME_LEN)
-    {
-        strcpy(log_name_arr,log_name);
-        if(0 == lynq_log_get_value(log_name,get_propty_log_data))//lt mod @2021.8.3 for uci
-        {
-            get_log_level = atoi(get_propty_log_data);
-        }
-        else
-        {
-            lynq_log_configuration_set(log_name, get_log_level);//lt add @2021.09.06 for uci
-        }
-    }
-    lynq_deal_with_level(get_log_level);
-    return ;
-}
-
-//lt add @2021.8.3 for in encapsulating the UCI set function
-int lynq_log_set_value(char *key, char *value)
-{
-    return lynq_set_value(LOG_UCI_MODULE, key, value);
-}
-
-//lt add @2021.8.3 for in encapsulating the UCI get function
-int lynq_log_get_value(char *key, char *tmp)
-{
-	return lynq_get_value(LOG_UCI_FILE, LOG_UCI_MODULE, key, tmp);
-}
-
-//lt add @2022.1.5 for  add fota lib name.
-char* lynq_read_log_version()
-{
-	return "LOG-V1.0";
-}
-
-/**
- * @brief Verbose logs are printed and stored
- * 
- * @param log data
- * @return void 
- */
-void lynq_log_verbose(const char *format,...)
-{
-#if LOG_ENABLE
-
-    char out_buf[LOG_OUT_LEN] = {0};    
-    char buf[LOG_LEN] = {0};
-    log_level_enum lynq_level = LOG_VERBOSE;
-    
-    if(lynq_level >=  LOG_LEVEL_MAX)
-        return;
-    if((log_level >> lynq_level)&0x00000001)
-    {
-        va_list args;
-        //TagName
-        if(log_name_arr[0]  > 0)
-        {
-            printf("[%s]",log_name_arr);
-        }
-
-        //LevelName
-        printf("%s:",LogLevelNameInfoTable[lynq_level]); //lt dele @2021.7.22 for []
-
-        va_start(args,format);
-        vprintf(format,args);
-        vsnprintf(buf, sizeof(buf), format, args);  //lt add @2021.7.22 for write buf
-        va_end(args);
-        printf("\r\n");
-
-        sprintf(out_buf, "%s %s",LogLevelNameInfoTable[lynq_level], buf);//lt add @2021.7.22 for write outbuf
-        __android_log_print(ANDROID_LOG_VERBOSE,log_name_arr, "%s",out_buf); //lt add @2021.9.22 for write syslog.log		
-    }
-    return ;
-#endif //LOG_ENABLE
-}
-
-/**
- * @brief Error logs are printed and stored
- * 
- * @param log data
- * @return void 
- */
-void lynq_log_error(const char *format,...)
-{
-#if LOG_ENABLE
-
-    char out_buf[LOG_OUT_LEN] = {0};    
-    char buf[LOG_LEN] = {0};
-    log_level_enum lynq_level = LOG_ERROR;
-
-    if(lynq_level >=  LOG_LEVEL_MAX)
-        return;
-    if((log_level >> lynq_level)&0x00000001)
-    {
-        va_list args;
-        //TagName
-        if(log_name_arr[0]  > 0)
-        {
-            printf("[%s]",log_name_arr);
-        }
-
-        //LevelName
-        printf("%s:",LogLevelNameInfoTable[lynq_level]); //lt dele @2021.7.22 for []
-
-        va_start(args,format);
-        vprintf(format,args);
-        vsnprintf(buf, sizeof(buf), format, args);  //lt add @2021.7.22 for write buf
-        va_end(args);
-        printf("\r\n");
-
-        sprintf(out_buf, "%s %s",LogLevelNameInfoTable[lynq_level], buf);//lt add @2021.7.22 for write outbuf
-        __android_log_print(ANDROID_LOG_ERROR,log_name_arr, "%s",out_buf); //lt add @2021.9.22 for write syslog.log		
-    }
-    return ;
-#endif //LOG_ENABLE
-    return ;
-}
-
-/**
- * @brief Warning logs are printed and stored
- * 
- * @param log data
- * @return void 
- */
-void lynq_log_warning(const char *format,...)
-{
- #if LOG_ENABLE
-
-    char out_buf[LOG_OUT_LEN] = {0};    
-    char buf[LOG_LEN] = {0};
-    log_level_enum lynq_level = LOG_WARNING;
-
-    if(lynq_level >=  LOG_LEVEL_MAX)
-        return;
-    if((log_level >> lynq_level)&0x00000001)
-    {
-        va_list args;
-        //TagName
-        if(log_name_arr[0]  > 0)
-        {
-            printf("[%s]",log_name_arr);
-        }
-
-        //LevelName
-        printf("%s:",LogLevelNameInfoTable[lynq_level]); //lt dele @2021.7.22 for []
-
-        va_start(args,format);
-        vprintf(format,args);
-        vsnprintf(buf, sizeof(buf), format, args);  //lt add @2021.7.22 for write buf
-        va_end(args);
-        printf("\r\n");
-
-        sprintf(out_buf, "%s %s",LogLevelNameInfoTable[lynq_level], buf);//lt add @2021.7.22 for write outbuf
-        __android_log_print(ANDROID_LOG_WARN,log_name_arr, "%s",out_buf); //lt add @2021.9.22 for write syslog.log		
-    }
-    return ;
-#endif //LOG_ENABLE
-    return ;
-}
-
-/**
- * @brief Info logs are printed and stored
- * 
- * @param log data
- * @return void 
- */
-void lynq_log_info(const char *format,...)
-{
- #if LOG_ENABLE
-
-    char out_buf[LOG_OUT_LEN] = {0};    
-    char buf[LOG_LEN] = {0};
-    log_level_enum lynq_level = LOG_INFO;
-
-    if(lynq_level >=  LOG_LEVEL_MAX)
-        return;
-    if((log_level >> lynq_level)&0x00000001)
-    {	
-        va_list args;
-        //TagName
-        if(log_name_arr[0]  > 0)
-        {
-            printf("[%s]",log_name_arr);
-        }
-
-        //LevelName
-        printf("%s:",LogLevelNameInfoTable[lynq_level]); //lt dele @2021.7.22 for []
-
-        va_start(args,format);
-        vprintf(format,args);
-        vsnprintf(buf, sizeof(buf), format, args);  //lt add @2021.7.22 for write buf
-        va_end(args);
-        printf("\r\n");
-
-        sprintf(out_buf, "%s %s",LogLevelNameInfoTable[lynq_level], buf);//lt add @2021.7.22 for write outbuf
-        __android_log_print(ANDROID_LOG_INFO,log_name_arr, "%s",out_buf); //lt add @2021.9.22 for write syslog.log		
-    }
-    return ;
-#endif //LOG_ENABLE
-    return ;
-}
-
-/**
- * @brief debug logs are printed and stored
- * 
- * @param log data
- * @return void 
- */
-void lynq_log_debug(const char *format,...)
-{
-#if LOG_ENABLE
-
-    char out_buf[LOG_OUT_LEN] = {0};    
-    char buf[LOG_LEN] = {0};
-    log_level_enum lynq_level = LOG_DEBUG;
-
-    if(lynq_level >=  LOG_LEVEL_MAX)
-        return;
-    if((log_level >> lynq_level)&0x00000001)
-    {	
-        va_list args;
-        //TagName
-        if(log_name_arr[0]  > 0)
-        {
-            printf("[%s]",log_name_arr);
-        }
-
-        //LevelName
-        printf("%s:",LogLevelNameInfoTable[lynq_level]); //lt dele @2021.7.22 for []
-
-        va_start(args,format);
-        vprintf(format,args);
-        vsnprintf(buf, sizeof(buf), format, args);  //lt add @2021.7.22 for write buf
-        va_end(args);
-        printf("\r\n");
-
-        sprintf(out_buf, "%s %s",LogLevelNameInfoTable[lynq_level], buf);//lt add @2021.7.22 for write outbuf
-        __android_log_print(ANDROID_LOG_DEBUG,log_name_arr, "%s",out_buf); //lt add @2021.9.22 for write syslog.log		
-    }
-    return ;
-#endif //LOG_ENABLE
-    return ;
-}
-
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-log/log-riltel/log.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-log/log-riltel/log.cpp
new file mode 100755
index 0000000..5feff58
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-log/log-riltel/log.cpp
@@ -0,0 +1,497 @@
+#include "lynq_deflog.h"
+#include <stdarg.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <pthread.h>
+#include <log/log.h>
+#include <include/lynq_uci.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <signal.h>
+
+#ifdef MOBILETEK_TARGET_PLATFORM_T106
+extern "C" {
+#include <cfg_api.h>
+}
+#endif
+
+// log entry for each module
+struct log_module_entry
+{
+    LYNQ_WRITE_LOG_PTR log_ptr; // function ptr of write log
+    log_level_enum level; // current log level of module;
+    char module_name[32]; // log tag
+    log_level_enum special_level; // defined by uci of [main module tag]__[module_tag]
+    log_level_enum exe_level; // defined by uci of [main module tag]
+    log_level_enum lib_level; // defined by uci of [module tag]
+    log_level_enum global_level; // defined by uci of "global_level"
+
+    log_module_entry() // constuctor of struct
+    {
+        level = LOG_INFO; // default log level when no uci value
+        special_level = LOG_LEVEL_MAX;
+        lib_level = LOG_LEVEL_MAX;
+        exe_level = LOG_LEVEL_MAX;
+        global_level = LOG_LEVEL_MAX;
+    }
+
+    void calc_level() // to calc the current log level
+    {
+        level = LOG_INFO;
+        if (special_level != LOG_LEVEL_MAX) // [exe]_[lib] level as the first consideration
+        {
+            level = special_level;
+        }
+        else if (exe_level != LOG_LEVEL_MAX) // when [exe] level is set
+        {
+            level = exe_level;
+        }
+        else if (lib_level != LOG_LEVEL_MAX) // when [lib] level is set
+        {
+            level = lib_level;
+        }
+        else if (global_level != LOG_LEVEL_MAX) // global log level is set
+        {
+            level = global_level;
+        }
+    }
+};
+
+
+static pthread_mutex_t s_lynq_log_mutex = PTHREAD_MUTEX_INITIALIZER; //lock for module entry array
+const int entry_count = 32; // max count of modules
+static int s_curr_reg_count = 0; // current reg modules count
+static int s_log_module_array_init_flag = 0;
+static struct log_module_entry *s_log_module_entries[entry_count] = {0};
+static volatile int s_main_module_entry_index = -1;
+
+#define LOG_UCI_MODULE "lynq_log"
+#define LOG_UCI_FILE "lynq_uci"
+
+template <int n>
+void lynq_write_log_func(log_level_enum level, const char *format, ...)
+{
+    log_module_entry *log_entry;
+    va_list args;
+    va_start(args,format);
+
+    log_entry = s_log_module_entries[n];
+    if (log_entry == NULL || level > log_entry->level)
+        return;
+
+    switch(level)
+    {
+        case LOG_VERBOSE:
+            __android_log_vprint(ANDROID_LOG_VERBOSE,log_entry->module_name, format, args);
+            break;
+        case LOG_ERROR:
+            __android_log_vprint(ANDROID_LOG_ERROR,log_entry->module_name, format, args);
+            break;
+        case LOG_WARNING:
+            __android_log_vprint(ANDROID_LOG_WARN,log_entry->module_name, format, args);
+            break;
+        case LOG_INFO:
+            __android_log_vprint(ANDROID_LOG_INFO,log_entry->module_name, format, args);
+            break;
+        case LOG_DEBUG:
+            __android_log_vprint(ANDROID_LOG_DEBUG,log_entry->module_name, format, args);
+            break;
+        default :
+            __android_log_print(ANDROID_LOG_DEBUG,log_entry->module_name, "Log Level is Error!!!!!!");
+            break;
+    }
+    va_end(args);
+    //return 0;
+}
+
+template <int n>
+void reg_write_log_function()
+{
+    s_log_module_entries[n] = new struct log_module_entry;
+    s_log_module_entries[n]->log_ptr = &lynq_write_log_func<n>;
+    reg_write_log_function<n-1>();
+}
+
+template <>
+void reg_write_log_function<0>()
+{
+    s_log_module_entries[0] = new struct log_module_entry;
+    s_log_module_entries[0]->log_ptr = &lynq_write_log_func<0>;
+}
+
+const static char * LogLevelNameInfoTable[LOG_LEVEL_MAX] =
+{
+    "[VERBOSE]","[ERROR]","[WARNING]","[INFO]","[DEBUG]"
+};
+
+static log_level_enum convert_log_level_from_string(const char * level_string)
+{
+    for(int level=LOG_VERBOSE; level < LOG_LEVEL_MAX; level++)
+    {
+        if (strcmp(LogLevelNameInfoTable[level], level_string) == 0)
+        {
+            return (log_level_enum)level;
+        }
+    }
+    return LOG_LEVEL_MAX;
+}
+
+static log_level_enum get_uci_log_value(const char *key)
+{
+    char level_buf[64] = {0};
+    if (key == NULL || key[0] == '\0')
+    {
+        return LOG_LEVEL_MAX;
+    }
+
+    if (0 == lynq_get_value((char*)LOG_UCI_FILE, (char*)LOG_UCI_MODULE, (char*)key, level_buf))
+    {
+        return convert_log_level_from_string(level_buf);
+    }
+
+    return LOG_LEVEL_MAX;
+}
+
+static void get_module_log_level(struct log_module_entry *entry) // calc module log level from uci
+{
+    int main_module_flag = 0;
+    char uci_key[64] = {0};
+
+    pthread_mutex_lock(&s_lynq_log_mutex);
+    if (s_main_module_entry_index >= 0) //to check if this entry is main module if main module is set
+    {
+        strcpy(uci_key, s_log_module_entries[s_main_module_entry_index]->module_name);
+        if (s_log_module_entries[s_main_module_entry_index] == entry)
+        {
+            main_module_flag = 1;
+        }
+    }
+    pthread_mutex_unlock(&s_lynq_log_mutex);
+
+    entry->global_level = get_uci_log_value("global_level");
+    entry->exe_level = get_uci_log_value(uci_key);
+    if (main_module_flag == 1) // if this entry is main module no need to get the special level
+    {
+        entry->lib_level = LOG_LEVEL_MAX;
+        entry->special_level = LOG_LEVEL_MAX;
+    }
+    else
+    {
+        entry->lib_level = get_uci_log_value(entry->module_name);
+        strcat(uci_key, "__");
+        strcat(uci_key, entry->module_name);
+        entry->special_level = get_uci_log_value(uci_key);
+    }
+    entry->calc_level();
+}
+
+static LYNQ_WRITE_LOG_PTR inner_log_function_init(const char *log_name, int main_module_flag)
+{
+    struct log_module_entry *entry = NULL;
+    if(log_name == NULL)
+    {
+        log_name = "MAIN";
+    }
+    pthread_mutex_lock(&s_lynq_log_mutex);
+    if (s_log_module_array_init_flag == 0) // to init module array if is not init
+    {
+        reg_write_log_function<entry_count-1>();
+        s_log_module_array_init_flag = 1;
+    }
+
+    if (s_curr_reg_count < entry_count) // if module entry is not use out
+    {
+        entry = s_log_module_entries[s_curr_reg_count];
+        if (main_module_flag == 1) // set s_main_module_entry_index when main module call
+        {
+            s_main_module_entry_index = s_curr_reg_count;
+        }
+        s_curr_reg_count++;
+
+        entry->level = LOG_DEBUG;
+        strncpy(entry->module_name, log_name, sizeof(entry->module_name));
+    }
+    pthread_mutex_unlock(&s_lynq_log_mutex);
+
+    if (entry == NULL)
+    {
+        return NULL;
+    }
+
+    get_module_log_level(entry); // init the log level
+
+    return entry->log_ptr;
+}
+
+/**
+ * @brief lynq_log_function_init , this function called by lib
+ * @param log_name
+ * @return
+ */
+LYNQ_WRITE_LOG_PTR lynq_log_function_init(const char *log_name)
+{
+    return inner_log_function_init(log_name, 0);
+}
+
+/**
+ * @brief lynq_log_configuration_init , this function called by main module
+ * @param log_name
+ */
+void lynq_log_configuration_init(const char *log_name)
+{
+    log_level_enum exe_level;
+    char exe_key[64] = {0};
+    char special_key[64] = {0};
+
+    pthread_mutex_lock(&s_lynq_log_mutex);
+    for(int i=0; i < s_curr_reg_count; i++) // to check if log module is registered, bring it to main module
+    {
+        if (strcmp(log_name, s_log_module_entries[i]->module_name) == 0)
+        {
+            s_main_module_entry_index = i;
+            break;
+        }
+    }
+    pthread_mutex_unlock(&s_lynq_log_mutex);
+
+    if (s_main_module_entry_index == -1) // if not registered yet, init a main module entry
+    {
+        inner_log_function_init(log_name, 1);
+    }
+
+    pthread_mutex_lock(&s_lynq_log_mutex);
+    strcpy(exe_key, s_log_module_entries[s_main_module_entry_index]->module_name);
+    exe_level = get_uci_log_value(exe_key);
+    for(int i=0; i < s_curr_reg_count; i++) //recalc the module level when main module is set
+    {
+        s_log_module_entries[i]->exe_level = exe_level; // set the main module level
+        if (i == s_main_module_entry_index)
+            continue;
+
+        sprintf(special_key, "%s__%s", exe_key, s_log_module_entries[i]->module_name);
+        s_log_module_entries[i]->special_level = get_uci_log_value(special_key); // get the special level again
+        s_log_module_entries[i]->calc_level();
+    }
+    pthread_mutex_unlock(&s_lynq_log_mutex);
+}
+
+void lynq_log_global_output(log_level_enum level,const char *format,...)
+{
+    if (s_main_module_entry_index == -1)
+        return;
+
+    va_list args;
+    va_start(args,format);
+    s_log_module_entries[s_main_module_entry_index]->log_ptr(level, format, args);
+    va_end(args);
+}
+
+const char* lynq_read_log_version()
+{
+    return "LOG-V1.0";
+}
+
+#ifdef MOBILETEK_TARGET_PLATFORM_T106
+/**
+ * @brief Set the syslog file size
+ *
+ * @param syslog file size (M)
+ * @return 0:success other:fail
+ */
+int lynq_syslog_set_file_size(int value)
+{
+    char lynq_syslog_data[64] = {0};
+
+    if(value > 100)
+    {
+        value = 100;
+    }
+    snprintf(lynq_syslog_data,sizeof(lynq_syslog_data),"%d",value);//Converts bytes to M
+    if (0 != sc_cfg_set("syslog_file_size", lynq_syslog_data))
+    {
+        return -1;
+    }
+    return sc_cfg_save();
+}
+
+/**
+ * @brief Get the syslog file size
+ *
+ * @param log data
+ * @return 1-100:success -1:fial
+ */
+int lynq_syslog_get_file_size(void)
+{
+    int lynq_syslog_size = 0;
+    char lynq_syslog_data[64] = {0};
+    if(0 == sc_cfg_get("syslog_file_size", lynq_syslog_data, 64))
+    {
+        lynq_syslog_size = atoi(lynq_syslog_data);
+        return lynq_syslog_size;
+    }
+    return -1;
+}
+
+/**
+ * @brief Set the syslog file rotate
+ *
+ * @param syslog file rotate number
+ *
+ * @return 0:success other:fial
+ */
+int lynq_syslog_set_file_rotate(int value)
+{
+    char lynq_syslog_data[64] = {0};
+
+    if(value < 0)
+    {
+        value = 0;
+    }
+    else if(value > 99)
+    {
+        value = 99;
+    }
+
+    snprintf(lynq_syslog_data,sizeof(lynq_syslog_data),"%d",value);
+    if (0 != sc_cfg_set("syslog_file_num", lynq_syslog_data))
+    {
+        return -1;
+    }
+    return sc_cfg_save();
+}
+
+/**
+ * @brief Example Set the number of syslog files cut
+ *
+ * @param log data
+ * @return 0-99:success -1:fial
+ */
+int lynq_syslog_get_file_rotate(void)
+{
+    int lynq_syslog_rotate = 0;
+    char lynq_syslog_data[64] = {0};
+    if(0 == sc_cfg_get("syslog_file_num", lynq_syslog_data, 64))
+    {
+        lynq_syslog_rotate = atoi(lynq_syslog_data);
+        return lynq_syslog_rotate;
+    }
+    return -1;
+}
+
+#else
+/**
+ * @brief Set the syslog file size
+ *
+ * @param syslog file size (M)
+ * @return 0:success other:fial
+ */
+int lynq_syslog_set_file_size(int value)
+{
+    char lynq_syslog_data[64] = {0};
+
+    if(value <10)
+    {
+      value = 10;
+    }
+    else if(value > 1024)
+    {
+        value = 1024;
+    }
+    snprintf(lynq_syslog_data,sizeof(lynq_syslog_data),"%d",(value*1024*1024));//Converts bytes to M
+    return lynq_set_value(LOG_UCI_MODULE,"syslog_flie_size", lynq_syslog_data);
+}
+
+/**
+ * @brief Get the syslog file size
+ *
+ * @param log data
+ * @return 10-1024:success -1:fial
+ */
+int lynq_syslog_get_file_size(void)
+{
+    int lynq_syslog_size = 0;
+    char lynq_syslog_data[64] = {0};
+    if(0 == lynq_get_value(LOG_UCI_FILE, LOG_UCI_MODULE, "syslog_flie_size", lynq_syslog_data))
+    {
+        lynq_syslog_size = ((atoi(lynq_syslog_data)) / 1024) /1024;
+        return lynq_syslog_size;
+    }
+    return -1;
+}
+
+/**
+ * @brief Set the syslog file rotate
+ *
+ * @param syslog file rotate number
+ *
+ * @return 0:success other:fial
+ */
+int lynq_syslog_set_file_rotate(int value)
+{
+    char lynq_syslog_data[64] = {0};
+
+    if(value < 0)
+    {
+        value = 0;
+    }
+    else if(value > 100)
+    {
+        value = 100;
+    }
+
+    snprintf(lynq_syslog_data,sizeof(lynq_syslog_data),"%d",value);
+    return lynq_set_value(LOG_UCI_MODULE, "syslog_flie_rotate", lynq_syslog_data);
+}
+
+/**
+ * @brief Example Set the number of syslog files cut
+ *
+ * @param log data
+ * @return 10-1024:success -1:fial
+ */
+int lynq_syslog_get_file_rotate(void)
+{
+    int lynq_syslog_rotate = 0;
+    char lynq_syslog_data[64] = {0};
+    if(0 == lynq_get_value(LOG_UCI_FILE, LOG_UCI_MODULE, "syslog_flie_rotate", lynq_syslog_data))
+    {
+        lynq_syslog_rotate = atoi(lynq_syslog_data);
+        return lynq_syslog_rotate;
+    }
+    return -1;
+}
+#endif
+
+
+static void log_signal_handler(int signum) {
+    if (SIGUSR1 != signum)
+        return;
+    // 处理信号
+    for(int i=0; i < s_curr_reg_count; i++)
+    {
+        get_module_log_level(s_log_module_entries[i]);
+    }
+}
+
+void __attribute__((constructor)) lynq_log_init()
+{
+
+    pid_t pid;
+    char cmd_buf[64];
+    if (SIG_ERR != signal(SIGUSR1, log_signal_handler))
+    {
+        pid = getpid();
+        sprintf(cmd_buf, "mkdir -p /tmp/log_level/%d", pid);
+        system(cmd_buf);
+    }
+
+    pthread_mutex_lock(&s_lynq_log_mutex);
+    if (s_log_module_array_init_flag == 0)
+    {
+        reg_write_log_function<entry_count-1>();
+        s_log_module_array_init_flag = 1;
+    }
+    pthread_mutex_unlock(&s_lynq_log_mutex);
+}
+
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-log/log-riltel/makefile b/cap/zx297520v3/src/lynq/lib/liblynq-log/log-riltel/makefile
index ee97243..94fb918 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-log/log-riltel/makefile
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-log/log-riltel/makefile
@@ -2,6 +2,7 @@
 RM = rm -f
 
 LOCAL_CFLAGS := -Wall \
+                -std=c++11 \
                 -g -Os \
                 -flto \
                 -fPIC \
@@ -17,21 +18,26 @@
 LOCAL_C_INCLUDES = \
   -I. \
   -I$(LOCAL_PATH)/../include/liblog \
-  -I$(ROOT)$(includedir) \
  -I$(ROOT)$(includedir)/logger \
 
 
 LOCAL_LIBS := \
     -L. \
     -ldl \
+    -std=c++11 \
     -llynq-uci \
     -llog \
 
-SOURCES = $(wildcard *.c wildcard *.h)
+ifeq ($(strip $(TARGET_PLATFORM)), T106)
+LOCAL_CFLAGS += -DMOBILETEK_TARGET_PLATFORM_T106
+LOCAL_LIBS += -lnvram
+endif
+
+SOURCES = $(wildcard *.cpp wildcard *.h)
 
 EXECUTABLE = liblynq-log.so
 
-OBJECTS=$(SOURCES:.c=.o)
+OBJECTS=$(SOURCES:.cpp=.o)
 
 
 .PHONY: build clean install pack_rootfs 
@@ -41,7 +47,10 @@
 	$(CXX) -shared -Wl,--no-undefined $(OBJECTS) $(LOCAL_LIBS) $(CFLAGS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES) -o $@
 
 %.o : %.c
-	$(CC) $(LOCAL_C_INCLUDES) $(CFLAGS) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $< 
+	$(CXX) $(LOCAL_C_INCLUDES) $(CFLAGS) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $< 
+
+%.o : %.cpp
+	$(CXX) $(LOCAL_C_INCLUDES) $(CFLAGS) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $< 
 
 build:  $(EXECUTABLE)
 	$(warning ########## build $(EXECUTABLE)  ##########)
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-network/lynq_network.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-network/lynq_network.cpp
index bba641e..116503e 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-network/lynq_network.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-network/lynq_network.cpp
@@ -1549,5 +1549,8 @@
     return ret;      

  

 }

+

+DEFINE_LYNQ_LIB_LOG(LYNQ_NETWORK)

+

 #endif

 

diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-autosuspend/LICENSE b/cap/zx297520v3/src/lynq/lib/liblynq-qser-autosuspend/LICENSE
new file mode 100644
index 0000000..cb88533
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-autosuspend/LICENSE
@@ -0,0 +1,31 @@
+Copyright Statement:
+
+This software/firmware and related documentation ("Mobiletek Software") are
+protected under relevant copyright laws. The information contained herein is
+confidential and proprietary to Mobiletek Inc. and/or its licensors. Without
+the prior written permission of Mobiletek inc. and/or its licensors, any
+reproduction, modification, use or disclosure of Mobiletek Software, and
+information contained herein, in whole or in part, shall be strictly
+prohibited.
+
+Mobiletek Inc. (C) 2015. All rights reserved.
+
+BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("Mobiletek SOFTWARE")
+RECEIVED FROM Mobiletek AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
+ON AN "AS-IS" BASIS ONLY. Mobiletek 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 Mobiletek PROVIDE ANY WARRANTY WHATSOEVER WITH
+RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
+INCORPORATED IN, OR SUPPLIED WITH THE Mobiletek 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 Mobiletek
+SOFTWARE. Mobiletek SHALL ALSO NOT BE RESPONSIBLE FOR ANY Mobiletek SOFTWARE
+RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND Mobiletek'S
+ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE Mobiletek SOFTWARE
+RELEASED HEREUNDER WILL BE, AT Mobiletek'S OPTION, TO REVISE OR REPLACE THE
+Mobiletek SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
+CHARGE PAID BY RECEIVER TO Mobiletek FOR SUCH Mobiletek SOFTWARE AT ISSUE.
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-autosuspend/include/lynq-qser-autosuspend.h b/cap/zx297520v3/src/lynq/lib/liblynq-qser-autosuspend/include/lynq-qser-autosuspend.h
new file mode 100644
index 0000000..54b663f
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-autosuspend/include/lynq-qser-autosuspend.h
@@ -0,0 +1,69 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <stdlib.h>
+#include <pthread.h>
+
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define MAX_LOCK_NUM 128
+
+#define E_READ -2
+#define E_WRITE -3
+#define E_INIT -4
+
+typedef enum 
+{
+    E_QL_LPM_FALLING = 0, /* Falling, Means wakeupin falling to wakeup the module, or wakeupout falling to wakeup mcu
+. */
+    E_QL_LPM_RISING = 1, /* Rising, Means  wakeupin rising to wakeup the module,  or wakeupout rising to wakeup  mcu. 
+*/
+}qser_lpm_edge_t;
+
+typedef int qser_lpm_pin_t;
+
+
+typedef struct{
+    qser_lpm_pin_t wakeupin_pin;
+    qser_lpm_edge_t wakeupin_edge;
+}qser_lpm_wakeupin_data_t;
+
+typedef struct{
+    qser_lpm_pin_t wakeupout_pin;
+    qser_lpm_edge_t wakeupout_edge;
+}qser_lpm_wakeupout_data_t;
+
+
+typedef void (*qser_lpm_Handler_t)
+(
+    qser_lpm_edge_t lpm_edge
+);
+
+typedef struct{
+    qser_lpm_wakeupin_data_t wakeupin;
+    qser_lpm_wakeupout_data_t wakeupout;
+}qser_pm_cfg_t;
+
+
+typedef struct
+{
+    char lock_name[MAX_LOCK_NUM][64];
+} LOCK_TABLE;
+
+int read_lock_table(void);
+int qser_lpm_init(qser_lpm_Handler_t qser_lpm_handler, qser_pm_cfg_t *qser_lpm_cfg);
+int qser_lpm_deinit(void);
+int qser_autosuspend_enable(char enable);
+int qser_wakelock_create(const char *name, size_t len);
+int qser_wakelock_lock(int fd);
+int qser_wakelock_unlock(int fd);
+int qser_wakelock_destroy(int fd);
+
+
+#ifdef __cplusplus
+}
+#endif
+
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-autosuspend/lynq-qser-autosuspend.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-qser-autosuspend/lynq-qser-autosuspend.cpp
new file mode 100755
index 0000000..b6fcdea
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-autosuspend/lynq-qser-autosuspend.cpp
@@ -0,0 +1,337 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+#include <errno.h>
+#include <pthread.h>
+
+#include<unistd.h>
+
+
+
+#include <lynq_autosuspend.h>
+#include "lynq-qser-autosuspend.h"
+#include "liblog/lynq_deflog.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+extern int lynq_autosleep_enable(void);
+extern int lynq_autosleep_disable(void);
+extern int release_wake_lock(char *name);
+extern int acquire_wake_lock(int lock, char *name);
+
+#define USER_LOG_TAG "LYNQ_QSER_AUTOSUSPEND"
+#define FILE_LOCK_TABLE "/tmp/.lock_table"
+
+
+LOCK_TABLE lock_status;
+
+
+int file_fd;
+int first_run = 0;
+
+
+int lock_table_init(void)
+{
+    int ret;
+    int err;
+
+    file_fd = open(FILE_LOCK_TABLE, O_RDWR| O_CREAT,0777);
+    if(file_fd < 0)
+    {
+        err = errno;
+        LYINFLOG("Error open lock_table file:%s\n", strerror(errno));
+        return -err;
+    }
+    memset(&lock_status, 0, sizeof(lock_status));
+    ret = write(file_fd, (char*)&lock_status, sizeof(lock_status));
+    if(ret <= 0)
+    {
+        LYINFLOG("write fail\n");
+        close(file_fd);
+        return -1;
+    }
+    sync();
+    close(file_fd);
+    return 0;
+}
+
+
+int read_lock_table(void)
+{
+    int err;
+    int ret;
+    int i;
+    LYLOGSET(LOG_INFO);
+    LYLOGEINIT(USER_LOG_TAG);
+
+    if(access(FILE_LOCK_TABLE,0) < 0)
+    {
+        ret = lock_table_init();
+        if(ret < 0)
+        {
+            return -2;
+        }
+    }
+
+    file_fd = open(FILE_LOCK_TABLE,O_RDWR);
+    if(file_fd < 0)
+    {
+        err = errno;
+        LYINFLOG("Error open lock_table file:%s\n", strerror(errno));
+        return -2;
+    }
+
+    memset(&lock_status, 0, sizeof(lock_status));
+    lseek(file_fd,0,SEEK_SET);
+    ret = read(file_fd,(unsigned char *)&lock_status,sizeof(lock_status));
+    LYINFLOG("read ret=%d\n", ret);
+    if(ret <= 0)
+    {
+        close(file_fd);
+        return -2;
+    }
+
+    for(i=0;i<MAX_LOCK_NUM;i++)
+    {
+        if(strlen(lock_status.lock_name[i]) != 0)
+        {
+            LYINFLOG("fd: %d lock_name:%s strlen:%d\n", i, lock_status.lock_name[i], strlen(lock_status.lock_name[i]));
+        }
+    }
+
+    close(file_fd);
+    return 0;
+}
+
+
+int save_lock_table(void)
+{
+    int err;
+    int ret;
+    file_fd = open(FILE_LOCK_TABLE,O_RDWR);
+    if(file_fd < 0)
+    {
+        err = errno;
+        LYINFLOG("Error open lock_table file:%s\n", strerror(errno));
+        return -3;
+    }
+    LYINFLOG("write lock_name[0]: %s\n", lock_status.lock_name[0]);
+    ret = write(file_fd, (unsigned char *)&lock_status, sizeof(lock_status));
+    LYINFLOG("write ret=%d\n", ret);
+    if(ret <= 0)
+    {
+        LYINFLOG("write fail\n");
+        close(file_fd);
+        return -3;
+    }
+    sync();
+    close(file_fd);
+
+    return 0;
+}
+
+
+int check_lock(char *name)
+{
+    int j;
+    int num;
+    for(j=0;j<MAX_LOCK_NUM;j++)
+    {
+        if(strcmp(lock_status.lock_name[j], name) == 0)
+        {
+            num = j;
+            break;
+        }
+    }
+
+    if(j < MAX_LOCK_NUM)
+    {
+        return num;
+    }
+
+    return -1;
+}
+
+
+int add_lock(char *name)
+{
+    int ret;
+    int i = 0;
+    int num;
+    int check_flag;
+    
+    LYINFLOG("name:%s\n", name);
+    ret = read_lock_table();
+    LYINFLOG("read_lock_table ret = %d\n", ret);
+    if(ret <0)
+    {
+        return ret;
+    }
+
+    check_flag = check_lock(name);
+
+    if(check_flag < 0)
+    {
+        for(i=0;i<MAX_LOCK_NUM;i++)
+        {
+            if(strlen(lock_status.lock_name[i]) == 0)
+            {
+                strcpy(lock_status.lock_name[i], name);
+                LYINFLOG("lock_name[%d] %s\n", i, lock_status.lock_name[i]);
+                break;
+            }
+        }
+        if(i == MAX_LOCK_NUM)
+        {
+            return -1;
+        }
+        else
+        {
+            num = i;
+        }
+    }
+    else
+    {
+        num = check_flag;
+    }
+
+    LYINFLOG("num = %d\n", num);
+    ret = save_lock_table();
+    if(ret < 0)
+    {
+        return ret;
+    }
+    return num;
+}
+
+int delete_lock(int fd)
+{
+    int ret;
+    int i;
+    ret = read_lock_table();
+    memset(lock_status.lock_name[fd], 0, sizeof(lock_status.lock_name[fd]));
+    ret = save_lock_table();
+    return ret;
+}
+
+int qser_lpm_init(qser_lpm_Handler_t qser_lpm_handler, qser_pm_cfg_t *qser_lpm_cfg)
+{
+    int ret;
+    ret = system("uci set lynq_uci.lynq_autosuspend.init='1'");
+    system("uci commit");
+    if(ret != 0)
+    {
+        LYINFLOG("uci set fail");
+    }
+    ret = system("./etc/init.d/lynq-autosuspend.sh restart");
+    if(ret != 0)
+    {
+        LYINFLOG("restart service fail");
+    }
+    return ret;
+}
+
+
+int qser_lpm_deinit(void)
+{
+    int ret;
+    system("uci set lynq_uci.lynq_autosuspend.init='0'");
+    system("uci commit");
+    if(ret != 0)
+    {
+        LYINFLOG("uci set fail");
+    }
+    system("./etc/init.d/lynq-autosuspend.sh restarts");
+    if(ret != 0)
+    {
+        LYINFLOG("restart service fail");
+    }
+    return 0;
+}
+
+int qser_autosuspend_enable(char enable)
+{
+    int ret;
+    if(enable == '0')
+    {
+        ret = lynq_autosleep_disable();
+
+    }
+    else if(enable == '1')
+    {
+        ret = lynq_autosleep_enable();
+    }
+    else
+    {
+        ret = -1;
+
+    }
+    return ret;
+
+}
+
+int qser_wakelock_create(const char *name, size_t len)
+{
+    int ret;
+    if(name == NULL)
+    {
+        return -1;
+    }
+    LYINFLOG("%s\n", name);
+    ret = add_lock(name);
+    return ret;
+}
+
+int qser_wakelock_lock(int fd)
+{
+
+    int ret;
+    if(fd < 0 || fd >= MAX_LOCK_NUM)
+    {
+        return -4;
+    }
+    ret = read_lock_table();
+    ret = acquire_wake_lock( 0, lock_status.lock_name[fd]);
+    return ret;
+}
+
+int qser_wakelock_unlock(int fd)
+{
+    int ret;
+    if(fd < 0 || fd >= MAX_LOCK_NUM)
+    {
+        return -4;
+    }
+    ret = read_lock_table();
+    if(strlen(lock_status.lock_name[fd]) == 0)
+    {
+        LYINFLOG("%d is null\n", fd);
+        return -1;
+    }
+    ret = release_wake_lock(lock_status.lock_name[fd]);
+    return ret;
+}
+
+int qser_wakelock_destroy(int fd)
+{
+    int ret;
+    if(fd < 0 || fd >= MAX_LOCK_NUM)
+    {
+        return -4;
+    }
+    ret = delete_lock(fd);
+    return ret;
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+
+
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-autosuspend/makefile b/cap/zx297520v3/src/lynq/lib/liblynq-qser-autosuspend/makefile
new file mode 100644
index 0000000..510b40e
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-autosuspend/makefile
@@ -0,0 +1,67 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+                -std=gnu++14 \
+                -g -Os \
+                -flto \
+                -fPIC \
+                -fpermissive \
+
+
+
+$(warning ################# lynq qser autosuspend API ROOT: $(ROOT),includedir:$(includedir))
+LOCAL_PATH   = .
+
+LOCAL_C_INCLUDES = \
+  -I. \
+  -I$(LOCAL_PATH)/include/ \
+  -I$(LOCAL_PATH)/ \
+  -I$(ROOT)$(includedir)/logger \
+  -I$(ROOT)$(includedir)/liblog \
+  -I$(ROOT)$(includedir)/libauto/ \
+
+  
+
+LOCAL_LIBS := \
+    -L. \
+    -lstdc++ \
+    -lcutils \
+    -lutils \
+    -lpthread \
+    -llynq-autosuspend \
+    -llynq-log \
+
+
+SOURCES = $(wildcard *.cpp)
+
+EXECUTABLE = liblynq-qser-autosuspend.so
+
+OBJECTS=$(SOURCES:.cpp=.o)
+
+
+.PHONY: build clean install pack_rootfs 
+all: build
+$(EXECUTABLE): $(OBJECTS)
+	$(CXX) -shared -Wl,--no-undefined $(OBJECTS) $(LOCAL_LIBS) $(LOCAL_CFLAGS) $(LOCAL_C_INCLUDES) -o $@
+
+%.o : %.cpp
+	$(CXX) $(LOCAL_C_INCLUDES) $(LOCAL_CFLAGS) $(LOCAL_LIBS) -o $@ -c $<
+
+build:  $(EXECUTABLE)
+	$(warning ########## build $(EXECUTABLE)  ##########)
+install:
+	mkdir -p $(ROOT)$(base_libdir)/
+	install $(EXECUTABLE) $(ROOT)$(base_libdir)/
+	mkdir -p $(ROOT)$(includedir)/$(NAME)/sdk
+pack_rootfs:
+	mkdir -p $(PACK_INITRAMFS_TO)$(base_libdir)/
+	cp -af $(EXECUTABLE) $(PACK_INITRAMFS_TO)$(base_libdir)/
+	$(CROSS)strip $(PACK_INITRAMFS_TO)$(base_libdir)/$(EXECUTABLE)
+	mkdir -p $(PACK_TO)$(base_libdir)/
+	cp -af $(EXECUTABLE) $(PACK_TO)$(base_libdir)/
+	$(CROSS)strip $(PACK_TO)$(base_libdir)/$(EXECUTABLE)
+.PHONY: clean
+clean:
+	$(RM) $(OBJECTS) $(EXECUTABLE)
+	-find . -name "*.o" -delete
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/lynq-qser-data.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/lynq-qser-data.cpp
index c716522..6a79c6c 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/lynq-qser-data.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-data/lynq-qser-data.cpp
@@ -1173,3 +1173,6 @@
     }
     return ret;
 }
+
+DEFINE_LYNQ_LIB_LOG(LYNQ_QSER_DATA)
+
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-fota/lynq-qser-fota.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-qser-fota/lynq-qser-fota.cpp
index e0dcafd..8be66f8 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-fota/lynq-qser-fota.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-fota/lynq-qser-fota.cpp
@@ -809,6 +809,7 @@
     return 0;

 }

 

+DEFINE_LYNQ_LIB_LOG(LYNQ_FOTA)

 

 #ifdef __cplusplus

 }

diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-network/lynq_qser_network.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-qser-network/lynq_qser_network.cpp
index ec4097c..0a32515 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-network/lynq_qser_network.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-network/lynq_qser_network.cpp
@@ -550,3 +550,6 @@
    
     return RESULT_OK;
 }
+
+DEFINE_LYNQ_LIB_LOG(LYNQ_QSER_NETWORK)
+
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-sim/lynq_qser_sim.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-qser-sim/lynq_qser_sim.cpp
index 29b14e2..d95945d 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-sim/lynq_qser_sim.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-sim/lynq_qser_sim.cpp
@@ -207,4 +207,7 @@
     ret = lynq_get_sim_status((int*)&pt_info->e_card_state);
     LYINFLOG("[%s-%d] QSER_CARD_STATUS: %d\n", __FUNCTION__, __LINE__, (int *)pt_info->e_card_state);
     return ret;
-}
\ No newline at end of file
+}
+
+DEFINE_LYNQ_LIB_LOG(LYNQ_QSER_SIM)
+
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-qser-voice/lynq-qser-voice.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-qser-voice/lynq-qser-voice.cpp
index 1799ea1..b7c3d7a 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-qser-voice/lynq-qser-voice.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-qser-voice/lynq-qser-voice.cpp
@@ -208,4 +208,7 @@
         return RESULT_ERROR;
     }
     return lynq_switch_waiting_or_holding_and_active();
-}
\ No newline at end of file
+}
+
+DEFINE_LYNQ_LIB_LOG(LYNQ_QSER_CALL)
+
diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-sms/lynq_sms.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-sms/lynq_sms.cpp
index f0b2bbd..9d5ef30 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-sms/lynq_sms.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-sms/lynq_sms.cpp
@@ -364,3 +364,5 @@
     }

 }

 

+DEFINE_LYNQ_LIB_LOG(LYNQ_SMS)

+

diff --git a/cap/zx297520v3/src/lynq/lib/liblynq-systime/lynq_systime.cpp b/cap/zx297520v3/src/lynq/lib/liblynq-systime/lynq_systime.cpp
index 8eaba2a..4109b21 100755
--- a/cap/zx297520v3/src/lynq/lib/liblynq-systime/lynq_systime.cpp
+++ b/cap/zx297520v3/src/lynq/lib/liblynq-systime/lynq_systime.cpp
@@ -374,6 +374,7 @@
     return ret;

 }

 

+DEFINE_LYNQ_LIB_LOG(LYNQ_SYSTIME)

 #ifdef __cplusplus

 }

 #endif

diff --git a/cap/zx297520v3/src/lynq/lib/libpoweralarm/libpoweralarm.cpp b/cap/zx297520v3/src/lynq/lib/libpoweralarm/libpoweralarm.cpp
index 5aeb496..3d17411 100755
--- a/cap/zx297520v3/src/lynq/lib/libpoweralarm/libpoweralarm.cpp
+++ b/cap/zx297520v3/src/lynq/lib/libpoweralarm/libpoweralarm.cpp
@@ -350,6 +350,7 @@
 

 }

 

+DEFINE_LYNQ_LIB_LOG(LYNQ_POWERALARM)

 

 #ifdef __cplusplus

 }

diff --git a/cap/zx297520v3/src/lynq/packages/apps/lynq-qser-autosuspend-demo/LICENSE b/cap/zx297520v3/src/lynq/packages/apps/lynq-qser-autosuspend-demo/LICENSE
new file mode 100755
index 0000000..cb88533
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/packages/apps/lynq-qser-autosuspend-demo/LICENSE
@@ -0,0 +1,31 @@
+Copyright Statement:
+
+This software/firmware and related documentation ("Mobiletek Software") are
+protected under relevant copyright laws. The information contained herein is
+confidential and proprietary to Mobiletek Inc. and/or its licensors. Without
+the prior written permission of Mobiletek inc. and/or its licensors, any
+reproduction, modification, use or disclosure of Mobiletek Software, and
+information contained herein, in whole or in part, shall be strictly
+prohibited.
+
+Mobiletek Inc. (C) 2015. All rights reserved.
+
+BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("Mobiletek SOFTWARE")
+RECEIVED FROM Mobiletek AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
+ON AN "AS-IS" BASIS ONLY. Mobiletek 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 Mobiletek PROVIDE ANY WARRANTY WHATSOEVER WITH
+RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
+INCORPORATED IN, OR SUPPLIED WITH THE Mobiletek 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 Mobiletek
+SOFTWARE. Mobiletek SHALL ALSO NOT BE RESPONSIBLE FOR ANY Mobiletek SOFTWARE
+RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND Mobiletek'S
+ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE Mobiletek SOFTWARE
+RELEASED HEREUNDER WILL BE, AT Mobiletek'S OPTION, TO REVISE OR REPLACE THE
+Mobiletek SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
+CHARGE PAID BY RECEIVER TO Mobiletek FOR SUCH Mobiletek SOFTWARE AT ISSUE.
diff --git a/cap/zx297520v3/src/lynq/packages/apps/lynq-qser-autosuspend-demo/lynq-qser-autosuspend-demo.c b/cap/zx297520v3/src/lynq/packages/apps/lynq-qser-autosuspend-demo/lynq-qser-autosuspend-demo.c
new file mode 100755
index 0000000..6c1b489
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/packages/apps/lynq-qser-autosuspend-demo/lynq-qser-autosuspend-demo.c
@@ -0,0 +1,284 @@
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <unistd.h>
+#include <dlfcn.h>
+#include <errno.h>
+#include <fcntl.h>
+
+
+#define FILE_LOCK_TABLE "/tmp/.lock_table"
+
+void *dlHandle_wakelock;
+
+int (*qser_lpm_deinit)(void);
+int (*qser_autosuspend_enable)(char enable);
+int (*qser_wakelock_create)(const char *value, size_t len);
+int (*qser_wakelock_lock)(int fd);
+int (*qser_wakelock_unlock)(int fd);
+int (*qser_wakelock_destroy)(int fd);
+
+#define MAX_LOCK_NUM 128
+
+typedef struct
+{
+    char lock_name[MAX_LOCK_NUM][64];
+} LOCK_TABLE;
+
+void init_autosuspend_func(void)
+{
+
+    const char *lynqLibPath_WakeLock = "/lib/liblynq-qser-autosuspend.so";
+
+
+    dlHandle_wakelock = dlopen(lynqLibPath_WakeLock, RTLD_NOW);
+    if (dlHandle_wakelock == NULL) 
+    {
+        printf("dlopen lynqLibPath_WakeLock failed: %s", dlerror());
+        exit(EXIT_FAILURE);
+    }
+
+    qser_lpm_deinit = (int(*)(void))dlsym(dlHandle_wakelock, "qser_lpm_deinit");
+    if (qser_lpm_deinit == NULL)
+    {
+        printf("qser_lpm_deinit not defined or exported in %s", lynqLibPath_WakeLock);
+        exit(EXIT_FAILURE);
+    }
+
+    qser_autosuspend_enable = (int(*)(char))dlsym(dlHandle_wakelock, "qser_autosuspend_enable");
+    if (qser_autosuspend_enable == NULL)
+    {
+        printf("qser_autosuspend_enable not defined or exported in %s", lynqLibPath_WakeLock);
+        exit(EXIT_FAILURE);
+    }
+
+    qser_wakelock_create = (int(*)(const char *value, size_t len))dlsym(dlHandle_wakelock, "qser_wakelock_create");
+    if (qser_wakelock_create == NULL)
+    {
+        printf("qser_wakelock_create not defined or exported in %s", lynqLibPath_WakeLock);
+        exit(EXIT_FAILURE);
+    }
+
+    qser_wakelock_lock = (int(*)(int))dlsym(dlHandle_wakelock, "qser_wakelock_lock");
+    if (qser_wakelock_lock == NULL)
+    {
+        printf("qser_wakelock_lock not defined or exported in %s", lynqLibPath_WakeLock);
+        exit(EXIT_FAILURE);
+    }
+
+    qser_wakelock_unlock = (int(*)(int))dlsym(dlHandle_wakelock, "qser_wakelock_unlock");
+    if (qser_wakelock_unlock == NULL)
+    {
+        printf("qser_wakelock_unlock not defined or exported in %s", lynqLibPath_WakeLock);
+        exit(EXIT_FAILURE);
+    }
+
+    qser_wakelock_destroy = (int(*)(int))dlsym(dlHandle_wakelock, "qser_wakelock_destroy");
+    if (qser_wakelock_destroy == NULL)
+    {
+        printf("qser_wakelock_unlock not defined or exported in %s", lynqLibPath_WakeLock);
+        exit(EXIT_FAILURE);
+    }
+    
+    dlerror(); // Clear any previous dlerror
+
+    return;
+}
+
+
+int check_lock(void)
+{
+    int err;
+    int file_fd;
+    int i;
+    int ret;
+    LOCK_TABLE lock_status;
+    file_fd = open(FILE_LOCK_TABLE,O_RDWR);
+    if(file_fd < 0)
+    {
+        err = errno;
+        printf("Error open lock_table file:%s\n", strerror(errno));
+        return -2;
+    }
+
+    memset(&lock_status, 0, sizeof(lock_status));
+    lseek(file_fd,0,SEEK_SET);
+    ret = read(file_fd,(unsigned char *)&lock_status,sizeof(lock_status));
+    for(i=0;i<128;i++)
+    {
+        if(strlen(lock_status.lock_name[i]) != 0)
+        {
+            printf("fd: %d lock_name:%s strlen:%d\n", i, lock_status.lock_name[i], strlen(lock_status.lock_name[i]));
+        }
+    }
+    if(ret <= 0)
+    {
+        return -2;
+    }
+    close(file_fd);
+    return 0;
+
+}
+
+int main(int argc,char** argv)
+{
+
+    int num;
+    int ret;
+    int len;
+    init_autosuspend_func();
+    if(argc < 2)
+    {
+        printf("wrong input format, please -h \n");
+        return -1;
+    }
+    if(strcmp(argv[1],"-h") == 0)
+    {
+        printf("        -h                  --help\n");
+        printf("        -i                  --qseq_lpm_init\n");
+        printf("        -d                  --qser_lpm_deinit\n");
+        printf("        -e                  --qser_autosuspend_enable\n");
+        printf("        -cl [wakelock name] --qser_wakelock_create \n");
+        printf("        -al [wakelock num]  --qser_wakelock_lock \n");
+        printf("        -rl [wakelock num]  --qser_wakelock_unlock \n");
+        printf("        -dl [wakelock num]  --qser_wakelock_destroy\n");
+        printf("        -ccl                --check created locks\n");
+        printf("        -cll                --check lockup locks\n");
+    }
+    else if(strcmp(argv[1],"-d") == 0)
+    {
+        ret = qser_lpm_deinit();
+        if(ret != 0)
+        {
+            printf("lpm deinit fail\n");
+        }
+        else
+        {
+            printf("lpm deinit success\n");
+        }
+    }
+    else if(strcmp(argv[1],"-e") == 0)
+    {
+        char num='1';
+        ret = qser_autosuspend_enable(num);
+        if(ret != 0)
+        {
+            printf("qser_autosuspend_enable fail\n");
+        }
+        else
+        {
+            printf("qser_autosuspend_enable success\n");
+        }
+    }
+    else if(strcmp(argv[1],"-cl") == 0)
+    {
+        if(argv[2] == NULL)
+        {
+            printf("name is null\n");
+            return -1;
+        }
+        len = strlen(argv[2]);
+        printf("len =%d\n", len);
+        ret = qser_wakelock_create(argv[2], len);
+        if(ret < 0)
+        {
+            printf("wakelock create fail\n");
+            printf("ret=%d\n", ret);
+        }
+        else
+        {
+            printf("wakelock create success\n");
+            printf("fd=%d\n", ret);
+        }
+    }
+    else if (strcmp(argv[1],"-al") == 0)
+    {
+        if(argv[2] == NULL)
+        {
+            printf("fd is null\n");
+            return -1;
+        }
+        num = atoi(argv[2]);
+        ret = qser_wakelock_lock(num);
+        if(ret != 0)
+        {
+            printf("wakelock lock fail\n");
+            printf("ret=%d\n", ret);
+        }
+        else
+        {
+            printf("wakelock lock success\n");
+        }
+    }
+
+    else if (strcmp(argv[1],"-rl") == 0)
+    {
+        if(argv[2] == NULL)
+        {
+            printf("fd is null\n");
+            return -1;
+        }
+        num = atoi(argv[2]);
+        ret = qser_wakelock_unlock(num);
+        if(ret != 0)
+        {
+            printf("wakelock unlock fail\n");
+            printf("ret=%d\n", ret);
+        }
+        else
+        {
+            printf("wakelock unlock success\n");
+        }
+    }
+    else if(strcmp(argv[1],"-dl") == 0)
+    {
+        if(argv[2] == NULL)
+        {
+            printf("fd is null\n");
+            return -1;
+        }
+        num = atoi(argv[2]);
+        ret = qser_wakelock_destroy(num);
+        if(ret != 0)
+        {
+            printf("wakelock destroy fail\n");
+            printf("ret=%d\n", ret);
+        }
+        else
+        {
+            printf("wakelock destroy success\n");
+        }
+    }
+    else if(strcmp(argv[1],"-ccl") == 0)
+    {
+        int ret;
+        ret = check_lock();
+        if(ret != 0)
+        {
+            printf("check lock fail\n");
+            printf("ret=%d\n", ret);
+        }
+        else
+        {
+            printf("check lock success\n");
+        }
+    }
+    else if(strcmp(argv[1],"-cll") == 0)
+    {
+        int ret;
+        ret = system("cat /sys/power/wake_lock");
+        if(ret != 0)
+        {
+            printf("check created lock fail\n");
+        }
+    }
+    else
+    {
+        printf("wrong input format, please -h \n");
+        return -1;
+    }
+    return 0;
+
+}
diff --git a/cap/zx297520v3/src/lynq/packages/apps/lynq-qser-autosuspend-demo/makefile b/cap/zx297520v3/src/lynq/packages/apps/lynq-qser-autosuspend-demo/makefile
new file mode 100755
index 0000000..b3638ea
--- /dev/null
+++ b/cap/zx297520v3/src/lynq/packages/apps/lynq-qser-autosuspend-demo/makefile
@@ -0,0 +1,42 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+                -g -Os \
+                -flto \
+                -fpermissive \
+                -fPIC \
+
+ifeq ($(strip $(TARGET_PLATFORM)), T106)
+LOCAL_CFLAGS += -DBINDER_IPC_32BIT=1 -DHAVE_ENDIAN_H -DHAVE_PTHREADS -DHAVE_SYS_UIO_H -DHAVE_POSIX_FILEMAP -DHAVE_STRLCPY -DHAVE_PRCTL -DHAVE_MEMSET16 -DHAVE_MEMSET32 -DANDROID_SMP=0
+endif
+
+LOCAL_CFLAGS += -DZXW
+
+LOCAL_PATH   = .
+
+LOCAL_C_INCLUDES = \
+  -I. \
+
+
+LOCAL_LIBS := \
+    -L. \
+    -ldl \
+    -lpthread \
+
+SOURCES = $(wildcard *.c)
+
+EXECUTABLE = lynq-qser-autosuspend-demo
+
+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)