[Feature][T3TSK-5][systime] merge and fix systime

Change-Id: I96c8f49afde589ffd1e40e92b0f08bf12bc20fb8
diff --git a/meta/meta-mediatek-ivt/recipes-telephony/tel-demo/tel-demo.bb b/meta/meta-mediatek-ivt/recipes-telephony/tel-demo/tel-demo.bb
old mode 100644
new mode 100755
index 9cd770d..e8f3587
--- a/meta/meta-mediatek-ivt/recipes-telephony/tel-demo/tel-demo.bb
+++ b/meta/meta-mediatek-ivt/recipes-telephony/tel-demo/tel-demo.bb
@@ -3,7 +3,7 @@
 DESCRIPTION = "telephony demo"
 LICENSE = "MediaTekProprietary"
 LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
-DEPENDS += "platform-libs audio-mixer-ctrl libvendor-ril libpal gstreamer1.0 glib-2.0 dtmf libapn dbus"
+DEPENDS += "platform-libs audio-mixer-ctrl libvendor-ril libpal gstreamer1.0 glib-2.0 dtmf libapn dbus liblynq-systime"
 inherit workonsrc
 WORKONSRC = "${TOPDIR}/../src/telephony/tel-demo/src"
 
diff --git a/meta/meta-mediatek-mt2731/recipes-lynq/liblynq-systime/liblynq-systime.bb b/meta/meta-mediatek-mt2731/recipes-lynq/liblynq-systime/liblynq-systime.bb
new file mode 100755
index 0000000..0eead5e
--- /dev/null
+++ b/meta/meta-mediatek-mt2731/recipes-lynq/liblynq-systime/liblynq-systime.bb
@@ -0,0 +1,57 @@
+inherit externalsrc package
+
+DESCRIPTION = "liblynq-systime.so demo"
+LICENSE = "CLOSED"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+DEPENDS += "platform-libs dbus"
+inherit workonsrc
+WORKONSRC = "${TOPDIR}/../src/lynq/lib/liblynq-systime/"
+
+TARGET_CC_ARCH += "${LDFLAGS}"
+BB_INCLUDE_ADD = "--sysroot=${STAGING_DIR_HOST}"
+BB_LDFLAGS_ADD = "--sysroot=${STAGING_DIR_HOST} -Wl,--hash-style=gnu"
+
+FILES_${PN} = "${base_libdir}/*.so \
+               ${base_bindir}\
+               ${base_sbindir}"
+
+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 ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -mhard-float -Wl,--hash-style=gnu -DTELEPHONYWARE"
+	elif [ "${PACKAGE_ARCH}" = "cortexa7hf-neon-vfpv4" ]; then
+		oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -mhard-float -Wl,--hash-style=gnu -DTELEPHONYWARE"
+	elif [ "${PACKAGE_ARCH}" = "cortexa53hf-neon-fp-armv8" ]; then
+		oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -mhard-float -Wl,--hash-style=gnu -DTELEPHONYWARE -mhard-float -mfpu=neon-fp-armv8 -mfloat-abi=hard -mcpu=cortex-a53 -mtune=cortex-a53"
+	else
+		oe_runmake all ROOT=${STAGING_DIR_HOST} OFLAGS="--sysroot=${STAGING_DIR_HOST} -Os -Wl,--hash-style=gnu -DTELEPHONYWARE"
+	fi
+}
+
+do_install () {
+    oe_runmake install ROOT=${D}
+
+    if [ -d "${WORKONSRC}" ] ; then
+        install -d ${D}${includedir}/
+        cp -af ${S}/include/ ${D}${includedir}/
+
+    fi 
+}
+
+addtask bachclean
+do_bachclean () {
+    oe_runmake clean
+}
diff --git a/meta/meta-mediatek-mt2731/recipes-lynq/lynq-atsvc/lynq-atsvc.bb b/meta/meta-mediatek-mt2731/recipes-lynq/lynq-atsvc/lynq-atsvc.bb
index c3406f8..b6ef619 100755
--- a/meta/meta-mediatek-mt2731/recipes-lynq/lynq-atsvc/lynq-atsvc.bb
+++ b/meta/meta-mediatek-mt2731/recipes-lynq/lynq-atsvc/lynq-atsvc.bb
@@ -3,7 +3,7 @@
 DESCRIPTION = "lynq ril service"

 LICENSE = "MediaTekProprietary"

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

-DEPENDS += "platform-libs audio-mixer-ctrl libvendor-ril libpal gstreamer1.0 glib-2.0 dtmf libapn dbus liblynq-protcl liblynq-logdata-handle liblynq-log liblynq-fota nandapi bootctrl liblynq-thermal"

+DEPENDS += "platform-libs audio-mixer-ctrl libvendor-ril libpal gstreamer1.0 glib-2.0 dtmf libapn dbus liblynq-protcl liblynq-logdata-handle liblynq-log liblynq-fota nandapi bootctrl liblynq-thermal liblynq-systime"

 inherit workonsrc

 WORKONSRC = "${TOPDIR}/../src/lynq/framework/lynq-atsvc/src"

 

diff --git a/meta/meta-mediatek-mt2731/recipes-lynq/packagegroups/packagegroup-lync-mt2731.bb b/meta/meta-mediatek-mt2731/recipes-lynq/packagegroups/packagegroup-lync-mt2731.bb
index d77f06a..e1aa12b 100755
--- a/meta/meta-mediatek-mt2731/recipes-lynq/packagegroups/packagegroup-lync-mt2731.bb
+++ b/meta/meta-mediatek-mt2731/recipes-lynq/packagegroups/packagegroup-lync-mt2731.bb
@@ -28,4 +28,7 @@
     lynq-gnss-test \
     liblynq-thermal \
     lynq-cv2x \
+    liblynq-systime \
+    ntp \
+    tzdata \
 "
diff --git a/meta/meta-openembedded/meta-networking/recipes-support/ntp/ntp/ntp.conf b/meta/meta-openembedded/meta-networking/recipes-support/ntp/ntp/ntp.conf
old mode 100644
new mode 100755
index 676e186..b51b4f9
--- a/meta/meta-openembedded/meta-networking/recipes-support/ntp/ntp/ntp.conf
+++ b/meta/meta-openembedded/meta-networking/recipes-support/ntp/ntp/ntp.conf
@@ -1,17 +1,57 @@
-# This is the most basic ntp configuration file
-# The driftfile must remain in a place specific to this
-# machine - it records the machine specific clock error
-driftfile /var/lib/ntp/drift
-# This should be a server that is close (in IP terms)
-# to the machine.  Add other servers as required.
-# Unless you un-comment the line below ntpd will sync
-# only against the local system clock.
+# /etc/ntp.conf, configuration for ntpd; see ntp.conf(5) for help
+
+driftfile /var/lib/ntp/ntp.drift
+
+# Enable this if you want statistics to be logged.
+#statsdir /var/log/ntpstats/
+
+statistics loopstats peerstats clockstats
+filegen loopstats file loopstats type day enable
+filegen peerstats file peerstats type day enable
+filegen clockstats file clockstats type day enable
+
+
+# You do need to talk to an NTP server or two (or three).
+#server ntp.your-provider.example
+
+# pool.ntp.org maps to about 1000 low-stratum NTP servers.  Your server will
+# pick a different set every time it starts up.  Please consider joining the
+# pool: <http://www.pool.ntp.org/join.html>
+pool 0.debian.pool.ntp.org iburst
+pool 1.debian.pool.ntp.org iburst
+pool 2.debian.pool.ntp.org iburst
+pool 3.debian.pool.ntp.org iburst
+
+
+# Access control configuration; see /usr/share/doc/ntp-doc/html/accopt.html for
+# details.  The web page <http://support.ntp.org/bin/view/Support/AccessRestrictions>
+# might also be helpful.
 #
-# server time.server.example.com
-#
-# Using local hardware clock as fallback
-# Disable this when using ntpd -q -g -x as ntpdate or it will sync to itself
-server 127.127.1.0
-fudge 127.127.1.0 stratum 14
-# Defining a default security setting
-restrict default
+# Note that "restrict" applies to both servers and clients, so a configuration
+# that might be intended to block requests from certain clients could also end
+# up blocking replies from your own upstream servers.
+
+# By default, exchange time with everybody, but don't allow configuration.
+restrict -4 default kod notrap nomodify nopeer noquery limited
+restrict -6 default kod notrap nomodify nopeer noquery limited
+
+# Local users may interrogate the ntp server more closely.
+restrict 127.0.0.1
+restrict ::1
+
+# Needed for adding pool entries
+restrict source notrap nomodify noquery
+
+# Clients from this (example!) subnet have unlimited access, but only if
+# cryptographically authenticated.
+#restrict 192.168.123.0 mask 255.255.255.0 notrust
+
+
+# If you want to provide time to your local subnet, change the next line.
+# (Again, the address is an example only.)
+#broadcast 192.168.123.255
+
+# If you want to listen to time broadcasts on your local subnet, de-comment the
+# next lines.  Please do this only if you trust everybody on the network!
+#disable auth
+#broadcastclient
diff --git a/meta/meta-openembedded/meta-networking/recipes-support/ntp/ntp/ntpd.service b/meta/meta-openembedded/meta-networking/recipes-support/ntp/ntp/ntpd.service
old mode 100644
new mode 100755
index 0e3d7cd..b7c4268
--- a/meta/meta-openembedded/meta-networking/recipes-support/ntp/ntp/ntpd.service
+++ b/meta/meta-openembedded/meta-networking/recipes-support/ntp/ntp/ntpd.service
@@ -5,7 +5,7 @@
 [Service]
 Type=forking
 PIDFile=/run/ntpd.pid
-ExecStart=/usr/sbin/ntpd -u ntp:ntp -p /run/ntpd.pid -g
+ExecStart=/usr/sbin/ntpd -p /run/ntpd.pid -g
 
 [Install]
 WantedBy=multi-user.target
diff --git a/src/lynq/framework/lynq-atsvc/src/common.cpp b/src/lynq/framework/lynq-atsvc/src/common.cpp
index 74cf21a..2074714 100755
--- a/src/lynq/framework/lynq-atsvc/src/common.cpp
+++ b/src/lynq/framework/lynq-atsvc/src/common.cpp
@@ -36,6 +36,8 @@
 #include "utils.h"
 #include "data.h"
 #include "cc.h"
+#include "include/lynq_systime.h"
+
 
 static pthread_mutex_t s_DataMutex = PTHREAD_MUTEX_INITIALIZER;
 static pthread_cond_t s_DataCond = PTHREAD_COND_INITIALIZER;
@@ -851,6 +853,8 @@
     struct tm tm;
     time_t t;
     int dGMTval;
+    char modem_sync_enable[24] = "";
+    char modem_sync_enable_pre[48] = "persist.store_modem_sync_enable";
 
     if (data == NULL || datalen <= 0)
         return;
@@ -863,9 +867,12 @@
     memset(&tm, 0, sizeof(struct tm));
     strptime(strTime, "%Y/%m/%d,%H:%M:%S", &tm);
 
-    adjustGMT2LocalTime(&tm, dGMTval);
+    //adjustGMT2LocalTime(&tm, dGMTval);
 
     t = mktime(&tm);
+    property_get(modem_sync_enable_pre, modem_sync_enable, NULL);
+    if(!atoi(modem_sync_enable))
+        return ;
     stime(&t);
 
     return;
diff --git a/src/lynq/framework/lynq-atsvc/src/lynq_at_transfer_table.h b/src/lynq/framework/lynq-atsvc/src/lynq_at_transfer_table.h
index 57607b4..25edb74 100755
--- a/src/lynq/framework/lynq-atsvc/src/lynq_at_transfer_table.h
+++ b/src/lynq/framework/lynq-atsvc/src/lynq_at_transfer_table.h
@@ -22,6 +22,7 @@
 {LYNQ_REQUEST_LINFO,"LINFO",7},

 {LYNQ_REQUEST_FOTA,"LYNQFOTA",7},

 {LYNQ_REQUEST_TEMP,"LYNQMTSM",1},

+{LYNQ_REQUEST_TIME,"LYNQTIME",1},

 

 /*lei add*/

 {LYNQ_REQUEST_CSCLK,"CSCLK",7},

diff --git a/src/lynq/framework/lynq-atsvc/src/lynq_common.cpp b/src/lynq/framework/lynq-atsvc/src/lynq_common.cpp
index 318adfe..fff0c20 100755
--- a/src/lynq/framework/lynq-atsvc/src/lynq_common.cpp
+++ b/src/lynq/framework/lynq-atsvc/src/lynq_common.cpp
@@ -126,6 +126,8 @@
             return LYNQ_GOTO_FOTA;
         case LYNQ_REQUEST_TEMP:
             return LYNQ_GOTO_TEMP;
+        case LYNQ_REQUEST_TIME:
+            return LYNQ_GOTO_TIME;
         default:
             return -1;
     }
diff --git a/src/lynq/framework/lynq-atsvc/src/lynq_common.h b/src/lynq/framework/lynq-atsvc/src/lynq_common.h
index fd227a6..95e8584 100755
--- a/src/lynq/framework/lynq-atsvc/src/lynq_common.h
+++ b/src/lynq/framework/lynq-atsvc/src/lynq_common.h
@@ -37,6 +37,9 @@
 #define LYNQ_GOTO_PMS 9
 /*TEMP*/
 #define LYNQ_GOTO_TEMP 10
+/*TIME*/
+#define LYNQ_GOTO_TIME 11
+
 
 #define LYNQ_APN_LEN_MAX 100
 #define LYNQ_APNTPYE_LEN_MAX 50
@@ -72,6 +75,7 @@
 #define LYNQ_REQUEST_RST (LYNQ_VERSION +25)
 /*lei add*/
 #define LYNQ_REQUEST_TEMP (LYNQ_VERSION +26)
+#define LYNQ_REQUEST_TIME (LYNQ_VERSION +27)
 #define LYNQ_USER_REQUEST_GNSS (LYNQ_VERSION +100)
 #define LYNQ_USER_REQUEST_OTHRE (LYNQ_VERSION +101)
 
diff --git a/src/lynq/framework/lynq-atsvc/src/makefile b/src/lynq/framework/lynq-atsvc/src/makefile
index bd6a53e..f3f7b8c 100755
--- a/src/lynq/framework/lynq-atsvc/src/makefile
+++ b/src/lynq/framework/lynq-atsvc/src/makefile
@@ -70,9 +70,11 @@
   -I$(LOCAL_PATH)/factory \
   -I$(LOCAL_PATH)/fota \
   -I$(LOCAL_PATH)/temp \
+  -I$(LOCAL_PATH)/time \
   -I$(ROOT)$(includedir)/ \
   -I$(ROOT)$(includedir)/liblog \
   -I$(ROOT)$(includedir)/liblynq-thermal \
+  -I$(ROOT)$(includedir)/liblynq-systime \
   -I$(ROOT)$(includedir)/include  \
   -I$(ROOT)$(includedir)/ftp \
   -I$(ROOT)$(includedir)/logger \
@@ -114,6 +116,7 @@
     -llynq-fota \
     -lnandapi  \
     -llynq-thermal  \
+    -llynq-systime \
 
 ifeq ($(strip $(TARGET_PLATFORM)), mt2735)
 LOCAL_LIBS += -luciwrapper
@@ -122,7 +125,7 @@
 endif
 
 
-SOURCES = $(wildcard util/*.cpp *.cpp ecall/*.cpp ecall/gost/*.cpp ecall/gost/utils/*.cpp ecall/gost/sslp/*.cpp ecall/gost/sslp/auth/*.cpp ecall/gost/sslp/firmware/*.cpp ecall/gost/sslp/commands/*.cpp ecall/gost/sslp/ecall/*.cpp ecall/gost/sslp/teledata/*.cpp data/*.cpp  em/rfdesense/*.cpp em/networkinfo/*.cpp em/*.cpp sms/*.cpp sms/gsm/*.cpp sms/cdma/*.cpp atci/*.cpp stateManager/*.cpp log/*.cpp rndis/*.cpp factory/*.cpp temp/*.cpp )
+SOURCES = $(wildcard util/*.cpp *.cpp ecall/*.cpp ecall/gost/*.cpp ecall/gost/utils/*.cpp ecall/gost/sslp/*.cpp ecall/gost/sslp/auth/*.cpp ecall/gost/sslp/firmware/*.cpp ecall/gost/sslp/commands/*.cpp ecall/gost/sslp/ecall/*.cpp ecall/gost/sslp/teledata/*.cpp data/*.cpp  em/rfdesense/*.cpp em/networkinfo/*.cpp em/*.cpp sms/*.cpp sms/gsm/*.cpp sms/cdma/*.cpp atci/*.cpp stateManager/*.cpp log/*.cpp rndis/*.cpp factory/*.cpp temp/*.cpp  time/*.cpp)
 
 EXECUTABLE = lynq-atsvc
 
diff --git a/src/lynq/framework/lynq-atsvc/src/ril.cpp b/src/lynq/framework/lynq-atsvc/src/ril.cpp
index ae34c5a..13ea16f 100755
--- a/src/lynq/framework/lynq-atsvc/src/ril.cpp
+++ b/src/lynq/framework/lynq-atsvc/src/ril.cpp
@@ -84,6 +84,7 @@
 #include "lynq_rndis.h"
 #include "lynq_factory.h"
 #include "lynq_at_temp.h"
+#include "lynq_at_time.h"
 /*Warren add for FAW platform 2021/9/28 end*/
 
 
@@ -6683,12 +6684,18 @@
                     lynq_pms(argv);
                     break;
                 }
-                /*lei add*/
+                /*rita add start*/
                 case LYNQ_GOTO_TEMP:
                 {
                     lynq_at_get_temp(argc, argv);
                     break;
                  }
+                case LYNQ_GOTO_TIME:
+                {
+                    lynq_at_sync_time(argc, argv);
+                    break;
+                 }
+                /*rita add end*/
                 default:
                     break;
             }
diff --git a/src/lynq/framework/lynq-atsvc/src/time/lynq_at_time.cpp b/src/lynq/framework/lynq-atsvc/src/time/lynq_at_time.cpp
new file mode 100755
index 0000000..ecf300f
--- /dev/null
+++ b/src/lynq/framework/lynq-atsvc/src/time/lynq_at_time.cpp
@@ -0,0 +1,103 @@
+/*============================================================================= 

+**     FileName: lynq_at_time

+**     Desc: lynq at time

+**     Author: rita

+**     Version: V1.0

+**     LastChange: 2022-07-03

+**     History: 

+=============================================================================*/

+

+#include "common.h"

+#include <stdio.h>

+#include <string.h>

+#include <stdlib.h>

+

+#ifdef __cplusplus

+extern "C" {

+#endif

+

+//#include <log/log.h>

+#include "lynq_systime.h"

+#include<cutils/properties.h>

+

+static void lynq_response_ttyGS3(char *log_buf)

+{

+//    sprintf(log_buf,"LYNQ_GOTO_LOGS_REQ\n");

+    write(ttyGS3_fd,log_buf,strlen(log_buf));

+    return;

+}

+

+int lynq_at_choose_time(int argc, char *argv[])

+{

+    int temp = 0;

+    int ret = 0;

+    int enable = 0;

+    char buf[20] = "";

+

+

+

+    if(NULL == argv[4] || argc!=5)

+    {

+        lynq_response_ttyGS3("+CME ERROR: para error!!\n");

+        return -1;

+    }

+

+    enable = atoi(argv[4]);

+

+    if(!strcmp(argv[3], "ntp"))

+    {

+        ret  = ntp_sync_time(enable);

+    }

+    else if(!strcmp(argv[3], "md"))

+    {

+        ret = modem_time_enable(enable);

+    }

+    else

+    {

+        lynq_response_ttyGS3("+CME ERROR: para error!!\n");

+    }

+    

+    if(ret!=0)

+    {

+        lynq_response_ttyGS3("+CME ERROR: para error!!\n");

+    }

+    else

+    {

+       sprintf(buf,"+LYNQSYNC: %d\n", enable);

+       lynq_response_ttyGS3(buf);

+    }

+

+    return ret;

+}

+

+int lynq_at_sync_time(int argc, char *argv[])

+{

+    int ret = 0;

+    if((!strcmp(argv[3], "usr")))

+    {

+        if(argc!=6)

+        {

+            lynq_response_ttyGS3("+CME ERROR: para error!!\n");

+            return -1;

+        }

+

+        ret = user_set_time(argv[4], argv[5]);

+        if(ret!=0)

+        {

+            lynq_response_ttyGS3("+CME ERROR: para error!\n");

+        }

+    }

+    else

+    {

+        ret = lynq_at_choose_time(argc, argv);

+        if(ret!=0)

+        {

+            lynq_response_ttyGS3("+CME ERROR: para error!\n");

+        }

+    }

+    

+    return ret;

+}

+#ifdef __cplusplus

+}

+#endif

diff --git a/src/lynq/framework/lynq-atsvc/src/time/lynq_at_time.h b/src/lynq/framework/lynq-atsvc/src/time/lynq_at_time.h
new file mode 100755
index 0000000..ed3f148
--- /dev/null
+++ b/src/lynq/framework/lynq-atsvc/src/time/lynq_at_time.h
@@ -0,0 +1,13 @@
+#ifndef __LYNQ_AT_TIME_H__

+#define __LYNQ_AT_TIME_H__

+#ifdef __cplusplus

+extern "C" {

+#endif

+

+int lynq_at_sync_time(int argc, char *argv[]);

+

+#ifdef __cplusplus

+}

+#endif

+

+#endif //__LYNQ_AT_TIME_H__

diff --git a/src/lynq/lib/liblynq-systime/LICENSE b/src/lynq/lib/liblynq-systime/LICENSE
new file mode 100755
index 0000000..77f59ed
--- /dev/null
+++ b/src/lynq/lib/liblynq-systime/LICENSE
@@ -0,0 +1,31 @@
+Copyright Statement:
+
+This software/firmware and related documentation ("MediaTek Software") are
+protected under relevant copyright laws. The information contained herein is
+confidential and proprietary to MediaTek Inc. and/or its licensors. Without
+the prior written permission of MediaTek inc. and/or its licensors, any
+reproduction, modification, use or disclosure of MediaTek Software, and
+information contained herein, in whole or in part, shall be strictly
+prohibited.
+
+MediaTek Inc. (C) 2015. All rights reserved.
+
+BY OPENING THIS FILE, RECEIVER HEREBY UNEQUIVOCALLY ACKNOWLEDGES AND AGREES
+THAT THE SOFTWARE/FIRMWARE AND ITS DOCUMENTATIONS ("MEDIATEK SOFTWARE")
+RECEIVED FROM MEDIATEK AND/OR ITS REPRESENTATIVES ARE PROVIDED TO RECEIVER
+ON AN "AS-IS" BASIS ONLY. MEDIATEK EXPRESSLY DISCLAIMS ANY AND ALL
+WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE IMPLIED
+WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE OR
+NONINFRINGEMENT. NEITHER DOES MEDIATEK PROVIDE ANY WARRANTY WHATSOEVER WITH
+RESPECT TO THE SOFTWARE OF ANY THIRD PARTY WHICH MAY BE USED BY,
+INCORPORATED IN, OR SUPPLIED WITH THE MEDIATEK SOFTWARE, AND RECEIVER AGREES
+TO LOOK ONLY TO SUCH THIRD PARTY FOR ANY WARRANTY CLAIM RELATING THERETO.
+RECEIVER EXPRESSLY ACKNOWLEDGES THAT IT IS RECEIVER'S SOLE RESPONSIBILITY TO
+OBTAIN FROM ANY THIRD PARTY ALL PROPER LICENSES CONTAINED IN MEDIATEK
+SOFTWARE. MEDIATEK SHALL ALSO NOT BE RESPONSIBLE FOR ANY MEDIATEK SOFTWARE
+RELEASES MADE TO RECEIVER'S SPECIFICATION OR TO CONFORM TO A PARTICULAR
+STANDARD OR OPEN FORUM. RECEIVER'S SOLE AND EXCLUSIVE REMEDY AND MEDIATEK'S
+ENTIRE AND CUMULATIVE LIABILITY WITH RESPECT TO THE MEDIATEK SOFTWARE
+RELEASED HEREUNDER WILL BE, AT MEDIATEK'S OPTION, TO REVISE OR REPLACE THE
+MEDIATEK SOFTWARE AT ISSUE, OR REFUND ANY SOFTWARE LICENSE FEES OR SERVICE
+CHARGE PAID BY RECEIVER TO MEDIATEK FOR SUCH MEDIATEK SOFTWARE AT ISSUE.
diff --git a/src/lynq/lib/liblynq-systime/include/lynq_systime.h b/src/lynq/lib/liblynq-systime/include/lynq_systime.h
new file mode 100755
index 0000000..6a580cf
--- /dev/null
+++ b/src/lynq/lib/liblynq-systime/include/lynq_systime.h
@@ -0,0 +1,24 @@
+#include <stdio.h>

+#include <string.h>

+#include <stdlib.h>

+#include <time.h>

+

+

+#ifndef _LYNQ_SYSTIME_H_

+#define _LYNQ_SYSTIME_H_

+

+#ifdef __cplusplus

+extern "C" {

+#endif

+int modem_time_enable(int enable);

+

+int gnss_time_enable(int enable);

+

+int ntp_sync_time(int enable);

+

+int user_set_time(char *date_input, char *time_input);

+

+#ifdef __cplusplus

+}

+#endif

+#endif
\ No newline at end of file
diff --git a/src/lynq/lib/liblynq-systime/makefile b/src/lynq/lib/liblynq-systime/makefile
new file mode 100755
index 0000000..cf6494b
--- /dev/null
+++ b/src/lynq/lib/liblynq-systime/makefile
@@ -0,0 +1,91 @@
+SHELL = /bin/sh
+RM = rm -f
+
+LOCAL_CFLAGS := -Wall \
+                -std=gnu++14 \
+                -g -Os \
+                -flto \
+                -fPIC \
+                -DRIL_SHLIB \
+                -DATCI_PARSE \
+                -DKEEP_ALIVE \
+                -DECALL_SUPPORT \
+                -fpermissive \
+
+$(warning ################# C2K support: $(RAT_CONFIG_C2K_SUPPORT))
+ifeq ($(strip $(RAT_CONFIG_C2K_SUPPORT)), yes)
+    LOCAL_CFLAGS += -DC2K_SUPPORT
+
+endif
+
+ifeq ($(strip $(MTK_MULTI_SIM_SUPPORT)), dsds)
+    LOCAL_CFLAGS += -DANDROID_SIM_COUNT_2 \
+                     -DANDROID_MULTI_SIM \
+                     -DMODE_DSDS
+endif
+
+ifeq ($(strip $(MTK_MULTI_SIM_SUPPORT)), dsss)
+    LOCAL_CFLAGS += -DMODE_DSSS
+endif
+
+$(warning ################# TARGET_PLATFORM: $(TARGET_PLATFORM))
+ifeq ($(strip $(TARGET_PLATFORM)), mt2731)
+#$(warning #################add for debug $(ROOT), $(includedir))
+$(warning ################# TARGET_PLATFORM_MT2731)
+    LOCAL_CFLAGS += -DTARGET_PLATFORM_MT2731 \
+                    -DMD_93_SUPPORT
+else ifeq ($(strip $(TARGET_PLATFORM)), mt2635)
+$(warning ################# TARGET_PLATFORM_MT2635)
+    LOCAL_CFLAGS += -DTARGET_PLATFORM_MT2635 \
+                    -DMD_90_SUPPORT
+endif
+
+$(warning ################# RITA ROOT: $(ROOT),includedir:$(includedir))
+LOCAL_PATH   = .
+
+LOCAL_C_INCLUDES = \
+  -I. \
+  -I$(LOCAL_PATH)/include \
+
+
+LOCAL_LIBS := \
+    -L. \
+    -ldl \
+    -lpthread \
+    -lcutils \
+    -lsncfg \
+
+SOURCES = $(wildcard *.c wildcard *.h src/*.c)
+
+EXECUTABLE = liblynq-systime.so
+
+OBJECTS=$(SOURCES:.c=.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 : %.c
+	$(CC) $(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)
diff --git a/src/lynq/lib/liblynq-systime/src/lynq_systime.c b/src/lynq/lib/liblynq-systime/src/lynq_systime.c
new file mode 100755
index 0000000..18d09e8
--- /dev/null
+++ b/src/lynq/lib/liblynq-systime/src/lynq_systime.c
@@ -0,0 +1,183 @@
+#include <stdio.h>

+#include <string.h>

+#include<stdlib.h>

+#include <time.h>

+#include "lynq_systime.h"

+

+

+#define LYNQ_SYNC_TIME_SECTION "lynq_sync_time"

+#define LYNQ_MODEM_TIME_KEY "lynq_modem_sync_time_enable"

+#define LYNQ_GNSS_TIME_KEY "lynq_gnss_sync_time_enable"

+

+#define BUF_LEN 258

+#define  TIME_BUF 100

+

+#define  NTP_RESTART_BUF "systemctl restart ntpd"

+#define  NTP_STOP_BUF "systemctl stop ntpd"

+

+#define SYNC_TIME_SUCCESS 0

+

+#define NTP_ALREADY_ENABLE  1

+#define NTP_ALREADY_DISABLE 2

+#define INPUT_ERROR 9

+

+//#define NITZ_ALREADY_ENABLE  3

+//#define NITZ_ALREADY_DISABLE 4

+//#define GNSS_ALREADY_ENABLE  5

+//#define GNSS_ALREADY_DISABLE 6

+#define OPEN_ERROR 7

+#define ERROR_PARA 8

+

+

+//rita merge code from T800

+char* lynq_read_version()

+{

+    return "SYSTIME_V1.0";

+}

+

+int get_cmd_value(char *input_cmd, char *value)

+{

+    FILE * fp = NULL;

+    char buf[TIME_BUF] = {0};

+

+    fp = popen (input_cmd, "r");

+

+    if (!fp) {  

+        printf("popen error\n");

+        return OPEN_ERROR;

+    } 

+	

+    while(fgets(buf, sizeof(buf), fp)!=NULL){

+        strcat(value, buf);

+    }

+

+    pclose(fp);

+    return 0;

+}

+

+int check_time(char *date, char* time)

+{

+    int y,m,d,h,min,s;

+    int md[12]={31,28,31,30,31,30,31,31,30,31,30,31};

+    

+    if(strlen(date)> 10 || strlen(time) > 8)

+    {

+        //printf("+CMD ERROR: error\n");

+        return INPUT_ERROR;

+    }

+	

+    sscanf(date,"%d/%d/%d", &y, &m, &d);

+    md[1] = y%4==0 && y%100 || y%400==0 ? 29 : 28;

+    if(y>0 && m>0 && m<13 && d>0 && d<=md[m-1])

+    {

+        sscanf(time,"%d:%d:%d",&h, &min, &s);

+        if(h<0 ||h>23 || min<0 ||min>59 || s<0 ||s>59)

+        {

+    	    //printf("Error\n");

+            return INPUT_ERROR;

+        }

+    }

+    else

+    {

+        //printf("Error...\n");

+        return INPUT_ERROR;

+    }

+    return 0;

+}

+

+int user_set_time(char *date_input, char *time_input)

+{

+    char date[TIME_BUF] = "";

+    char time[TIME_BUF] = "";

+    int ret = 0;

+

+    if(NULL == date_input || NULL == time_input)

+        return ERROR_PARA;

+    

+    ret = check_time(date_input, time_input);

+    if(ret!= 0)

+    {

+        //printf("======error!\n");

+        return ret;

+    }

+

+    sprintf(date, "date -s %s", date_input);

+    sprintf(time, "date -s %s", time_input);

+

+    system(date);

+    system(time);

+

+    return 0;

+}

+

+int ntp_sync_time(int enable)

+{

+    char cmd_buf[TIME_BUF] = "pgrep ntpd";

+    char out_value[TIME_BUF] = {0};

+    

+    if(enable != 0 && enable !=1)

+        return ERROR_PARA;

+	

+    get_cmd_value(cmd_buf, out_value);

+    

+    if(strlen(out_value))

+    {

+        if(enable)

+        {

+            return NTP_ALREADY_ENABLE;

+        }

+        else

+        {

+            system(NTP_STOP_BUF);

+            return SYNC_TIME_SUCCESS;

+        }

+    }

+    else{

+        if(enable)

+        {

+            system(NTP_RESTART_BUF);

+            return SYNC_TIME_SUCCESS;

+        }

+        else{

+            return NTP_ALREADY_DISABLE;

+        }	

+    }

+}

+

+int modem_time_enable(int enable)

+{

+    char buf[TIME_BUF] = "";

+    int ret = 0;

+    char modem_sync_enable_pre[48] = "persist.store_modem_sync_enable";

+    

+    if(enable != 0 && enable !=1)

+    {

+        //printf("+CME ERROR: aaaaaaaaa!!\n");

+        return INPUT_ERROR;

+    }

+

+    sprintf(buf,"%d", enable);

+    //lynq_response_ttyGS3("333333\n");

+    //lynq_response_ttyGS3(buf);

+    ret = property_set(modem_sync_enable_pre, buf);

+

+    return ret;

+}

+

+int gnss_time_enable(int enable)

+{

+    char buf[BUF_LEN] = "";

+    int ret = 0;

+    

+    if(enable != 0 && enable !=1)

+        return ERROR_PARA;

+

+    char modem_sync_enable_pre[48] = "persist.store_gnss_sync_enable";

+

+    sprintf(buf,"%s", enable);

+    //printf("==>buf = %s\n", buf);

+    

+    ret = property_set(modem_sync_enable_pre,(char *)buf);

+    

+    return ret;

+}