Added a dbus property 'TimeUpdated' 47/261447/2 accepted/tizen/unified/20210726.135508 submit/tizen/20210723.060030
authorJaehyun Kim <jeik01.kim@samsung.com>
Mon, 19 Jul 2021 07:36:36 +0000 (16:36 +0900)
committerJaehyun Kim <jeik01.kim@samsung.com>
Mon, 19 Jul 2021 07:41:49 +0000 (16:41 +0900)
A property has been added to indicate
whether the time has been updated by NTP.

Change-Id: I86b8a0c2df377168f98656618efd82bb7da91800
Signed-off-by: Jaehyun Kim <jeik01.kim@samsung.com>
src/clock.c
src/connman.h
src/ntp.c

index f04cf17..40729b2 100755 (executable)
@@ -39,6 +39,9 @@ static enum time_updates time_updates_config = TIME_UPDATES_AUTO;
 static enum timezone_updates timezone_updates_config = TIMEZONE_UPDATES_AUTO;
 
 static char *timezone_config = NULL;
+#if defined TIZEN_EXT
+static bool time_updated = false;
+#endif
 
 static const char *time_updates2string(enum time_updates value)
 {
@@ -175,6 +178,9 @@ static DBusMessage *get_properties(DBusConnection *conn,
        DBusMessageIter array, dict;
        struct timeval tv;
        const char *str;
+#if defined TIZEN_EXT
+       dbus_bool_t val = time_updated;
+#endif
 
        DBG("conn %p", conn);
 
@@ -186,6 +192,12 @@ static DBusMessage *get_properties(DBusConnection *conn,
 
        connman_dbus_dict_open(&array, &dict);
 
+#if defined TIZEN_EXT
+       connman_dbus_dict_append_basic(&dict, "TimeUpdated",
+                                               DBUS_TYPE_BOOLEAN,
+                                               &val);
+#endif
+
        if (gettimeofday(&tv, NULL) == 0) {
                dbus_uint64_t val = tv.tv_sec;
 
@@ -392,6 +404,13 @@ static const GDBusSignalTable clock_signals[] = {
 
 static DBusConnection *connection = NULL;
 
+#if defined TIZEN_EXT
+void __connman_clock_set_time_updated(bool updated)
+{
+       time_updated = updated;
+}
+#endif
+
 void __connman_clock_update_timezone(void)
 {
        DBG("");
index 97bb80a..e92f2b1 100755 (executable)
@@ -79,6 +79,9 @@ int __connman_clock_init(void);
 void __connman_clock_cleanup(void);
 
 void __connman_clock_update_timezone(void);
+#if defined TIZEN_EXT
+void __connman_clock_set_time_updated(bool updated);
+#endif
 
 int __connman_timezone_init(void);
 void __connman_timezone_cleanup(void);
index ccea3ea..0de4df7 100755 (executable)
--- a/src/ntp.c
+++ b/src/ntp.c
@@ -407,6 +407,8 @@ static void decode_msg(struct ntp_data *nd, void *base, size_t len,
                DBG("%lu cur seconds, %lu cur nsecs, %lu req seconds, %lu req nsecs",
                        cur.tv_sec, cur.tv_nsec, req.tv_sec, req.tv_nsec);
                DBG("setting time");
+
+               __connman_clock_set_time_updated(true);
        }
 #else
        if (offset < STEPTIME_MIN_OFFSET && offset > -STEPTIME_MIN_OFFSET) {