Add an API for getting time update state. 19/261519/3 accepted/tizen/unified/20210726.135514 submit/tizen/20210723.060030
authorJaehyun Kim <jeik01.kim@samsung.com>
Tue, 20 Jul 2021 10:32:40 +0000 (19:32 +0900)
committerJaehyun Kim <jeik01.kim@samsung.com>
Thu, 22 Jul 2021 12:37:14 +0000 (21:37 +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 bee17ca..8b7eb36 100755 (executable)
@@ -680,6 +680,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 48ef312..5163a73 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 3e31541..5f50351 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:       2
 Group:         System/Network
 License:       Apache-2.0
index 08c5a26..0048efb 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 4788660..81aaf10 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 653f4cd..9c86789 100755 (executable)
@@ -2960,6 +2960,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;
@@ -3051,6 +3069,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");
        }
@@ -3214,7 +3233,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)