Add an API for getting time update state. 60/261760/1 accepted/tizen_6.0_unified tizen_6.0 accepted/tizen/6.0/unified/20210801.211555 submit/tizen_6.0/20210726.071732
authorJaehyun Kim <jeik01.kim@samsung.com>
Tue, 20 Jul 2021 10:32:40 +0000 (19:32 +0900)
committerJaehyun Kim <jeik01.kim@samsung.com>
Fri, 23 Jul 2021 14:39:58 +0000 (23:39 +0900)
Change-Id: I11afee8a385517bac70599ec0268d65f421b3277
Signed-off-by: Jaehyun Kim <jeik01.kim@samsung.com>
include/connection_extension.h
include/net_connection_private.h
packaging/capi-network-connection.spec
src/connection.c
src/libnetwork.c
test/connection_test.c

index 4d6038c..9b28938 100755 (executable)
@@ -679,6 +679,20 @@ int connection_profile_save_ethernet_eap_config(connection_h connection,
                                                        connection_profile_h profile);
 
 /**
+ * @brief Check if the time has been updated by NTP.
+ * @since_tizen 6.5
+ * @param[in] connection       The connection handle
+ * @param[out] updated         true if the system time is updated by NTP, false otherwise
+ * @return 0 on success, otherwise a negative error value
+ * @retval #CONNECTION_ERROR_NONE                 Successful
+ * @retval #CONNECTION_ERROR_INVALID_OPERATION    Invalid operation
+ * @retval #CONNECTION_ERROR_INVALID_PARAMETER    Invalid parameter
+ * @retval #CONNECTION_ERROR_PERMISSION_DENIED    Permission denied
+ * @retval #CONNECTION_ERROR_NOT_SUPPORTED        Not supported
+ */
+int connection_clock_is_updated(connection_h connection, bool *updated);
+
+/**
 * @}
 */
 
index 08f27ea..ce383b8 100755 (executable)
@@ -211,6 +211,7 @@ int _connection_libnet_start_tcpdump(connection_handle_s *conn_handle);
 int _connection_libnet_stop_tcpdump(connection_handle_s *conn_handle);
 int _connection_libnet_get_tcpdump_state(connection_handle_s *conn_handle,
                        gboolean *tcpdump_state);
+int _connection_libnet_get_clock_updated(connection_handle_s *conn_handle, bool *updated);
 
 void _connection_lock(void);
 void _connection_unlock(void);
index 26d0699..8e0ec14 100755 (executable)
@@ -1,6 +1,6 @@
 Name:          capi-network-connection
 Summary:       Network Connection library in TIZEN C API
-Version:       1.0.123
+Version:       1.0.124
 Release:       1
 Group:         System/Network
 License:       Apache-2.0
index 9c14d5f..7e67df9 100755 (executable)
@@ -1834,3 +1834,29 @@ EXPORT_API int connection_profile_save_ethernet_eap_config(connection_h connecti
        CONN_UNLOCK;
        return CONNECTION_ERROR_NONE;
 }
+
+EXPORT_API int connection_clock_is_updated(connection_h connection, bool *updated)
+{
+       CONN_LOCK;
+
+       CHECK_FEATURE_SUPPORTED(TELEPHONY_FEATURE, WIFI_FEATURE, TETHERING_BLUETOOTH_FEATURE, ETHERNET_FEATURE);
+
+       if (!(_connection_check_handle_validity(connection))) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Invalid parameter"); //LCOV_EXCL_LINE
+               CONN_UNLOCK; //LCOV_EXCL_LINE
+               return CONNECTION_ERROR_INVALID_PARAMETER;//LCOV_EXCL_LINE
+       }
+
+       int rv = _connection_libnet_get_clock_updated(connection, updated);
+
+       if (rv != CONNECTION_ERROR_NONE) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Fail to get clock update information[%d]", rv); //LCOV_EXCL_LINE
+               CONN_UNLOCK; //LCOV_EXCL_LINE
+               return rv; //LCOV_EXCL_LINE
+       }
+
+       CONNECTION_LOG(CONNECTION_INFO, "Clock updated: %s", updated ? "true" : "false");
+       CONN_UNLOCK;
+
+       return CONNECTION_ERROR_NONE;
+}
index 401841c..66635ff 100755 (executable)
@@ -1543,6 +1543,22 @@ int _connection_libnet_get_tcpdump_state(connection_handle_s *conn_handle,
 }
 //LCOV_EXCL_STOP
 
+int _connection_libnet_get_clock_updated(connection_handle_s *conn_handle, bool *updated)
+{
+       int rv = 0;
+
+       rv = net_get_clock_update_info(conn_handle->network_info_handle, updated);
+       if (rv == NET_ERR_ACCESS_DENIED) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Access denied"); //LCOV_EXCL_LINE
+               return CONNECTION_ERROR_PERMISSION_DENIED; //LCOV_EXCL_LINE
+       } else if (rv != NET_ERR_NONE) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Failed to get clock update information[%d]", rv); //LCOV_EXCL_LINE
+               return CONNECTION_ERROR_OPERATION_FAILED; //LCOV_EXCL_LINE
+       }
+
+       return CONNECTION_ERROR_NONE;
+}
+
 void _connection_lock(void)
 {
        if (g_conn_thread_mutex_ref == 0)
index 5213018..b50da3f 100755 (executable)
@@ -2954,6 +2954,24 @@ out:
        return 1;
 }
 
+int test_get_clock_update_info(void)
+{
+       int rv = 0;
+       bool updated;
+
+       rv = connection_clock_is_updated(connection, &updated);
+
+       if (rv != CONNECTION_ERROR_NONE) {
+               printf("Fail to get clock update information [%s]\n", test_print_error(rv));
+               return -1;
+       }
+
+       printf("Retval = [%s] clock updated [%s]\n",
+               test_print_error(rv), updated ? "TRUE" : "FALSE");
+
+       return 1;
+}
+
 int main(int argc, char **argv)
 {
        GMainLoop *mainloop;
@@ -3045,6 +3063,7 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
                printf("R   - Destroy Handle(unset callbacks automatically in C# API)\n");
                printf("S   - Connect Ethernet EAP)\n");
                printf("T   - Get EAPoL info)\n");
+               printf("U   - Get Clock update info)\n");
                printf(LOG_RED "0   - Exit \n" LOG_END);
                printf("ENTER   - Show options menu.......\n");
        }
@@ -3208,7 +3227,9 @@ gboolean test_thread(GIOChannel *source, GIOCondition condition, gpointer data)
        case 'T':
                rv = test_get_eapol_info();
                break;
-
+       case 'U':
+               rv = test_get_clock_update_info();
+               break;
        }
 
        if (rv == 1)