DA: Add exception check for time logic 24/283624/1
authorJaehyun Kim <jeik01.kim@samsung.com>
Mon, 31 Oct 2022 11:46:26 +0000 (20:46 +0900)
committerJaehyun Kim <jeik01.kim@samsung.com>
Mon, 31 Oct 2022 11:46:26 +0000 (20:46 +0900)
1. Ignore next time server if current time server string is empty.
2. Check time_updates_config before set time.

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

index 58a52c0..54552ca 100755 (executable)
@@ -119,6 +119,17 @@ static void clock_properties_load(void)
 
        g_free(str);
 
+#if defined TIZEN_EXT
+       str = g_key_file_get_string(keyfile, "global", "Timeservers", NULL);
+
+       if (str && str[0] == ';') {
+               DBG("Set time_updates_config to MANUAL.");
+               time_updates_config = TIME_UPDATES_MANUAL;
+       }
+
+       g_free(str);
+#endif
+
        g_key_file_free(keyfile);
 }
 
@@ -387,6 +398,21 @@ static DBusMessage *set_property(DBusConnection *conn,
 
                __connman_timeserver_system_set(str);
 
+#if defined TIZEN_EXT
+               if (str) {
+                       if (str[0][0] == '\0') {
+                               DBG("Set time_updates_config to MANUAL.");
+                               time_updates_config = TIMEZONE_UPDATES_MANUAL;
+                       } else {
+                               DBG("Set time_updates_config to AUTO.");
+                               time_updates_config = TIMEZONE_UPDATES_AUTO;
+                       }
+               } else {
+                       DBG("Set time_updates_config to MANUAL.");
+                       time_updates_config = TIMEZONE_UPDATES_MANUAL;
+               }
+#endif
+
                if (str)
                        g_strfreev(str);
 
index 0de4df7..2218748 100755 (executable)
--- a/src/ntp.c
+++ b/src/ntp.c
@@ -527,6 +527,13 @@ static gboolean received_data(GIOChannel *channel, GIOCondition condition,
                }
        }
 
+#if defined TIZEN_EXT
+       if (__connman_clock_timeupdates() == TIME_UPDATES_MANUAL) {
+               DBG("Skip time update.");
+               return TRUE;
+       }
+#endif
+
        decode_msg(nd, iov.iov_base, iov.iov_len, tv, &mrx_time);
 
        return TRUE;
index b2707fa..2df609f 100755 (executable)
@@ -206,7 +206,12 @@ static void sync_next(void)
                        return;
                }
 #if defined TIZEN_EXT
-       if (!simplified_log)
+               if (ts_current[0] == '\0') {
+                       DBG("current time server is empty. ignore next time server..");
+                       return;
+               }
+
+               if (!simplified_log)
 #endif
                DBG("Resolving timeserver %s", ts_current);
 #if defined TIZEN_EXT