Add new API to check whether metered or non metered
[platform/core/api/connection.git] / src / libnetwork.c
index 86c94d7..9e5b09a 100755 (executable)
@@ -606,6 +606,27 @@ bool _connection_libnet_check_profile_cb_validity(connection_profile_h profile)
 }
 //LCOV_EXCL_STOP
 
+int _connection_libnet_get_metered_state(bool* is_metered)
+{
+       int rv = 0;
+       int status = 0;
+
+       rv = net_get_metered_state(&status);
+       if (rv == NET_ERR_ACCESS_DENIED) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Access denied");
+               return CONNECTION_ERROR_PERMISSION_DENIED;
+       } else if (rv != NET_ERR_NONE) {
+               CONNECTION_LOG(CONNECTION_ERROR, "Failed to get metered state[%d]", rv);
+               return CONNECTION_ERROR_OPERATION_FAILED;
+       }
+
+       if (status == 1)
+               *is_metered = true;
+       else
+               *is_metered = false;
+       return CONNECTION_ERROR_NONE;
+}
+
 int _connection_libnet_get_wifi_state(connection_wifi_state_e *state)
 {
        int rv;