[Feature]merge code from svn
Change-Id: Iabce86599e7d0249b405f443242aec87ceeadb8d
diff --git a/meta/meta-mediatek-ivt/classes/mkstatepart.bbclass b/meta/meta-mediatek-ivt/classes/mkstatepart.bbclass
index 5b5fa31..fc1545b 100644
--- a/meta/meta-mediatek-ivt/classes/mkstatepart.bbclass
+++ b/meta/meta-mediatek-ivt/classes/mkstatepart.bbclass
@@ -6,7 +6,8 @@
# Create Volatile failed work-around deal with symbolic link issue
ln -s -f /var/run/connman/resolv.conf ${IMAGE_ROOTFS}/etc/resolv.conf
ln -s -f ../proc/self/mounts ${IMAGE_ROOTFS}/etc/mtab
- ln -s -f /usr/share/zoneinfo/Universal ${IMAGE_ROOTFS}/etc/localtime
+ #ln -s -f /usr/share/zoneinfo/Universal ${IMAGE_ROOTFS}/etc/localtime
+ ln -s -f /usr/share/zoneinfo/Asia/Shanghai ${IMAGE_ROOTFS}/etc/localtime
# syslog failed work-around
install -d ${IMAGE_ROOTFS}/etc/syslog
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
index b811ffe..788a162 100644
--- 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 liblynq-uci"
inherit workonsrc
WORKONSRC = "${TOPDIR}/../src/telephony/tel-demo/src"
diff --git a/meta/meta-mediatek-mt2735/recipes-lynq/liblynq-systime/liblynq-systime.bb b/meta/meta-mediatek-mt2735/recipes-lynq/liblynq-systime/liblynq-systime.bb
new file mode 100755
index 0000000..ff9088a
--- /dev/null
+++ b/meta/meta-mediatek-mt2735/recipes-lynq/liblynq-systime/liblynq-systime.bb
@@ -0,0 +1,62 @@
+inherit externalsrc package
+
+DESCRIPTION = "liblynq-systime.so demo"
+LICENSE = "CLOSED"
+LIC_FILES_CHKSUM = "file://LICENSE;md5=e1696b147d49d491bcb4da1a57173fff"
+DEPENDS += "platform-libs dbus liblynq-uci "
+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"
+#Parameters passed to do_compile()
+EXTRA_OEMAKE = "'RAT_CONFIG_C2K_SUPPORT = ${RAT_CONFIG_C2K_SUPPORT}'\
+ 'MTK_MULTI_SIM_SUPPORT = ${MTK_MULTI_SIM_SUPPORT}'\
+ '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 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-mt2735/recipes-lynq/lynq-ril-service/lynq-ril-service.bb b/meta/meta-mediatek-mt2735/recipes-lynq/lynq-ril-service/lynq-ril-service.bb
index c009b6d..f8a63bc 100755
--- a/meta/meta-mediatek-mt2735/recipes-lynq/lynq-ril-service/lynq-ril-service.bb
+++ b/meta/meta-mediatek-mt2735/recipes-lynq/lynq-ril-service/lynq-ril-service.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-log"
+DEPENDS += "platform-libs audio-mixer-ctrl libvendor-ril libpal gstreamer1.0 glib-2.0 dtmf libapn dbus liblynq-log liblynq-systime liblynq-uci"
inherit workonsrc
WORKONSRC = "${TOPDIR}/../src/lynq/framework/lynq-ril-service/src"
diff --git a/meta/meta-mediatek-mt2735/recipes-lynq/packagegroups/packagegroup-lync-mt2735.bb b/meta/meta-mediatek-mt2735/recipes-lynq/packagegroups/packagegroup-lync-mt2735.bb
index 628f2ac..eb5569e 100755
--- a/meta/meta-mediatek-mt2735/recipes-lynq/packagegroups/packagegroup-lync-mt2735.bb
+++ b/meta/meta-mediatek-mt2735/recipes-lynq/packagegroups/packagegroup-lync-mt2735.bb
@@ -46,4 +46,6 @@
liblynq-wifi6 \
lynq-gnss-test \
lynq-cv2x \
+ ntp \
+ tzdata \
"
diff --git a/meta/meta-mediatek/recipes-connectivity/mnld/gnsstest6635.bb b/meta/meta-mediatek/recipes-connectivity/mnld/gnsstest6635.bb
index c3732fd..7ae7e2e 100644
--- a/meta/meta-mediatek/recipes-connectivity/mnld/gnsstest6635.bb
+++ b/meta/meta-mediatek/recipes-connectivity/mnld/gnsstest6635.bb
@@ -7,7 +7,7 @@
inherit systemd
SYSTEMD_PACKAGES = "${PN}"
-DEPENDS += "openssl curl gpshal6635"
+DEPENDS += "openssl curl gpshal6635 liblynq-systime liblynq-uci"
# Avoid QA Issue: No GNU_HASH in the elf binary
INSANE_SKIP_${PN} = "ldflags"
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
index 676e186..7702785 100644
--- 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,60 @@
-# 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
+
+# Leap seconds definition provided by tzdata
+leapfile /usr/share/zoneinfo/leap-seconds.list
+
+# 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
+
+# Specify one or more NTP servers.
+
+# Use servers from the NTP Pool Project. Approved by Ubuntu Technical Board
+# on 2011-02-08 (LP: #104525). See http://www.pool.ntp.org/join.html for
+# more information.
+pool 0.ubuntu.pool.ntp.org iburst
+pool 1.ubuntu.pool.ntp.org iburst
+pool 2.ubuntu.pool.ntp.org iburst
+pool 3.ubuntu.pool.ntp.org iburst
+
+# Use Ubuntu's ntp server as a fallback.
+pool ntp.ubuntu.com
+
+# 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/poky/meta/recipes-extended/timezone/tzdata.bb b/meta/poky/meta/recipes-extended/timezone/tzdata.bb
index 7542ce5..e519272 100644
--- a/meta/poky/meta/recipes-extended/timezone/tzdata.bb
+++ b/meta/poky/meta/recipes-extended/timezone/tzdata.bb
@@ -163,6 +163,7 @@
${datadir}/zoneinfo/Asia/Dhaka \
${datadir}/zoneinfo/Asia/Bangkok \
${datadir}/zoneinfo/Asia/Hong_Kong \
+ ${datadir}/zoneinfo/Asia/Shanghai \
${datadir}/zoneinfo/Asia/Tokyo \
${datadir}/zoneinfo/Australia/Darwin \
${datadir}/zoneinfo/Australia/Adelaide \
diff --git a/src/connectivity/gps/2.0/gnss_test/Makefile b/src/connectivity/gps/2.0/gnss_test/Makefile
index faf2872..0c2c117 100644
--- a/src/connectivity/gps/2.0/gnss_test/Makefile
+++ b/src/connectivity/gps/2.0/gnss_test/Makefile
@@ -34,6 +34,8 @@
-lrt \
-lpthread \
-lgnsshal \
+ -llynq-systime \
+ -llynq-uci \
-L$(GPS_HAL_PATH) \
-Wl,-rpath $(USR_LIB_DIR)
diff --git a/src/connectivity/gps/2.0/gnss_test/mnld_client/src/mnld_client_gps_cb.c b/src/connectivity/gps/2.0/gnss_test/mnld_client/src/mnld_client_gps_cb.c
index 0b8a52a..8c6ce5e 100644
--- a/src/connectivity/gps/2.0/gnss_test/mnld_client/src/mnld_client_gps_cb.c
+++ b/src/connectivity/gps/2.0/gnss_test/mnld_client/src/mnld_client_gps_cb.c
@@ -4,10 +4,13 @@
#include<errno.h>
#include<string.h>
#include<inttypes.h>
+#include <time.h>
#include"mnld_test.h"
#include"mtk_lbs_utility.h"
#include "mnldinf_log.h"
+#include "include/lynq_systime.h"
+#include "include/lynq_uci.h"
extern struct timespec mnld_test_gnss_open_tm;
extern int mnld_test_ttff;
@@ -85,9 +88,26 @@
#define NMEA_ACC "ACCURACY"
extern int valid_ttff_cnt;
extern int valid_ttff_sum;
+int gnss_set_time_flag=0;
+
+int update_gnss_time(GpsUtcTime sec)
+{
+ time_t t;
+ t = sec/1000;
+ stime(&t);
+ return 0;
+}
void mnld_test_gps_nmea_callback(GpsUtcTime timestamp, const char* nmea, int length)
{
- CB_DBG("NMEA report at %ld",timestamp);
+ char gnss_sync_enable[24] = "";
+ CB_DBG("NMEA report at %ld",timestamp);
+ lynq_get_value("lynq_uci", "lynq_sync_time", "lynq_gnss_sync_time_enable" , gnss_sync_enable);
+ if (1 == atoi(gnss_sync_enable)) {
+ if ((mnld_test_result_body.fix_type == 3) && (gnss_set_time_flag == 0)) {
+ update_gnss_time(timestamp);
+ gnss_set_time_flag = 1 ;
+ }
+ }
//$GPGSA,A,3,...
if( strncmp(nmea+3,NMEA_GSA,strlen(NMEA_GSA)) == 0 )
diff --git a/src/lynq/framework/lynq-ril-service/src/common.cpp b/src/lynq/framework/lynq-ril-service/src/common.cpp
index 7c5205d..16195e5 100755
--- a/src/lynq/framework/lynq-ril-service/src/common.cpp
+++ b/src/lynq/framework/lynq-ril-service/src/common.cpp
@@ -37,6 +37,8 @@
#include "utils.h"
#include "data.h"
#include "cc.h"
+#include "include/lynq_systime.h"
+#include <include/lynq_uci.h>
static pthread_mutex_t s_DataMutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t s_DataCond = PTHREAD_COND_INITIALIZER;
@@ -837,10 +839,14 @@
time_t t1, t2;
struct tm * ptm;
char buf[255];
+ char date_buf[32] = "";
int dShiftSec;
dShiftSec = dGMTval * 15 * 60;
t1 = mktime(src);
+ strftime(date_buf, sizeof(date_buf), "%Z", src);
+ if (strcmp(date_buf, "CST") == 0)
+ t1 = t1 + 8 * 60 * 60;
t2 = (time_t)(t1 + dShiftSec);
ptm = gmtime(&t2);
@@ -853,6 +859,7 @@
struct tm tm;
time_t t;
int dGMTval;
+ char modem_sync_enable[24] = "";
if (data == NULL || datalen <= 0)
return;
@@ -868,6 +875,11 @@
adjustGMT2LocalTime(&tm, dGMTval);
t = mktime(&tm);
+
+ lynq_get_value("lynq_uci", "lynq_sync_time", "lynq_modem_sync_time_enable" , modem_sync_enable);
+ if(!atoi(modem_sync_enable))
+ return ;
+
stime(&t);
return;
diff --git a/src/lynq/framework/lynq-ril-service/src/makefile b/src/lynq/framework/lynq-ril-service/src/makefile
index 39ae608..0f666a4 100755
--- a/src/lynq/framework/lynq-ril-service/src/makefile
+++ b/src/lynq/framework/lynq-ril-service/src/makefile
@@ -79,6 +79,7 @@
-I$(ROOT)$(libdir)/gstreamer-1.0/include\
-I$(ROOT)$(includedir)/dbus-1.0 \
-I$(ROOT)$(libdir)/dbus-1.0/include \
+ -I$(ROOT)$(includedir) \
LOCAL_LIBS := \
@@ -108,6 +109,8 @@
-llynq-log \
-lsqlite3 \
-lnandapi \
+ -llynq-systime \
+ -llynq-uci \
ifeq ($(strip $(TARGET_PLATFORM)), mt2735)
LOCAL_LIBS += -luciwrapper
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..4627d70
--- /dev/null
+++ b/src/lynq/lib/liblynq-systime/include/lynq_systime.h
@@ -0,0 +1,22 @@
+#include <stdio.h>
+#include <string.h>
+#include <stdlib.h>
+#include <time.h>
+#include <include/lynq_uci.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);
+
+#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..7ae3e10
--- /dev/null
+++ b/src/lynq/lib/liblynq-systime/makefile
@@ -0,0 +1,90 @@
+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 \
+ -llynq-uci \
+
+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..cd9fd57
--- /dev/null
+++ b/src/lynq/lib/liblynq-systime/src/lynq_systime.c
@@ -0,0 +1,132 @@
+#include <stdio.h>
+#include <string.h>
+#include<stdlib.h>
+#include <time.h>
+#include <include/lynq_uci.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 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
+
+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 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[BUF_LEN] = "";
+ int ret = 0;
+
+ if(enable != 0 && enable !=1)
+ return ERROR_PARA;
+
+ if(enable)
+ {
+ system("killall ntpd");
+ sprintf(buf,"%s.%s.%s=%d", LYNQ_UCI_FILE, LYNQ_SYNC_TIME_SECTION, LYNQ_MODEM_TIME_KEY, enable);
+ ret = lynq_uci_set(buf);
+ }
+ else
+ {
+ sprintf(buf,"%s.%s.%s=%d", LYNQ_UCI_FILE, LYNQ_SYNC_TIME_SECTION, LYNQ_MODEM_TIME_KEY, enable);
+ ret = lynq_uci_set(buf);
+ }
+
+ return ret;
+}
+
+int gnss_time_enable(int enable)
+{
+ char buf[BUF_LEN] = "";
+ int ret = 0;
+
+ if(enable != 0 && enable !=1)
+ return ERROR_PARA;
+
+ if(enable)
+ {
+ system("killall ntpd");
+ sprintf(buf,"%s.%s.%s=%d", LYNQ_UCI_FILE, LYNQ_SYNC_TIME_SECTION, LYNQ_GNSS_TIME_KEY, enable);
+ ret = lynq_uci_set(buf);
+ }
+ else
+ {
+ sprintf(buf,"%s.%s.%s=%d", LYNQ_UCI_FILE, LYNQ_SYNC_TIME_SECTION, LYNQ_GNSS_TIME_KEY, enable);
+ ret = lynq_uci_set(buf);
+ }
+
+ return ret;
+}
diff --git a/src/lynq/lib/liblynq-uci/lynq_uci.config b/src/lynq/lib/liblynq-uci/lynq_uci.config
index eb68dbe..f19ffc1 100644
--- a/src/lynq/lib/liblynq-uci/lynq_uci.config
+++ b/src/lynq/lib/liblynq-uci/lynq_uci.config
@@ -8,6 +8,8 @@
config lynq_wifi_rw 'lynq_wifi'
option gateway '192.168.11.1'
+config lynq_sync_time_rw 'lynq_sync_time'
+
config lynq_autosuspend 'lynq_autosuspend'
option auto_enable '0'
option debug '1'
diff --git a/src/telephony/tel-demo/src/common.cpp b/src/telephony/tel-demo/src/common.cpp
index c359cf8..4cb0018 100644
--- a/src/telephony/tel-demo/src/common.cpp
+++ b/src/telephony/tel-demo/src/common.cpp
@@ -37,6 +37,8 @@
#include "utils.h"
#include "data.h"
#include "cc.h"
+#include "include/lynq_systime.h"
+#include <include/lynq_uci.h>
static pthread_mutex_t s_DataMutex = PTHREAD_MUTEX_INITIALIZER;
static pthread_cond_t s_DataCond = PTHREAD_COND_INITIALIZER;
@@ -718,10 +720,14 @@
time_t t1, t2;
struct tm * ptm;
char buf[255];
+ char date_buf[32] = "";
int dShiftSec;
dShiftSec = dGMTval * 15 * 60;
t1 = mktime(src);
+ strftime(date_buf, sizeof(date_buf), "%Z", src);
+ if (strcmp(date_buf, "CST") == 0)
+ t1 = t1 + 8 * 60 * 60;
t2 = (time_t)(t1 + dShiftSec);
ptm = gmtime(&t2);
@@ -734,6 +740,7 @@
struct tm tm;
time_t t;
int dGMTval;
+ char modem_sync_enable[24] = "";
if (data == NULL || datalen <= 0)
return;
@@ -749,6 +756,11 @@
adjustGMT2LocalTime(&tm, dGMTval);
t = mktime(&tm);
+
+ lynq_get_value("lynq_uci", "lynq_sync_time", "lynq_modem_sync_time_enable" , modem_sync_enable);
+ if(!atoi(modem_sync_enable))
+ return ;
+
stime(&t);
return;
diff --git a/src/telephony/tel-demo/src/makefile b/src/telephony/tel-demo/src/makefile
index fe20046..c975c8b 100644
--- a/src/telephony/tel-demo/src/makefile
+++ b/src/telephony/tel-demo/src/makefile
@@ -72,6 +72,7 @@
-I$(ROOT)$(libdir)/gstreamer-1.0/include\
-I$(ROOT)$(includedir)/dbus-1.0 \
-I$(ROOT)$(libdir)/dbus-1.0/include \
+ -I$(ROOT)$(includedir) \
LOCAL_LIBS := \
@@ -97,6 +98,8 @@
-ldtmf \
-lapn \
-ldbus-1 \
+ -llynq-systime \
+ -llynq-uci \
ifeq ($(strip $(TARGET_PLATFORM)), mt2735)
LOCAL_LIBS += -luciwrapper