summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAbhay Agarwal <ay.agarwal@samsung.com>2019-10-11 15:26:42 +0900
committersaerome.kim <saerome.kim@samsung.com>2019-10-11 16:15:32 +0900
commitb99c4dab74f0c79ec17612db0fd3035c05f5c4e1 (patch)
treeac45350872c33c4d127fb56d922d768ab146f7d8
parent66f04b2e121961f0d485575d23d0326ff591f57c (diff)
downloaduser-awareness-b99c4dab74f0c79ec17612db0fd3035c05f5c4e1.tar.gz
user-awareness-b99c4dab74f0c79ec17612db0fd3035c05f5c4e1.tar.bz2
user-awareness-b99c4dab74f0c79ec17612db0fd3035c05f5c4e1.zip
Add API to get service detection thresholds
Change-Id: Ib34bbba2555157823d8e098faae08c5f9d4e69df Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
-rw-r--r--include/user-awareness.h48
-rw-r--r--src/user-awareness-service.c25
-rw-r--r--test/uat-service.c18
3 files changed, 86 insertions, 5 deletions
diff --git a/include/user-awareness.h b/include/user-awareness.h
index c4a1394..a71dd6e 100644
--- a/include/user-awareness.h
+++ b/include/user-awareness.h
@@ -1594,6 +1594,28 @@ int ua_service_add(
/**
* @ingroup CAPI_NETWORK_UA_MODULE
+ * @brief Adds the service.
+ * @since_tizen 5.5
+ *
+ * @param[in] service_handle The service handle
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #UA_ERROR_NONE Successful
+ * @retval #UA_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #UA_ERROR_OPERATION_FAILED Operation failed
+ *
+ * @exception
+ * @pre
+ * @post
+ *
+ * @see ua_service_create()
+ * @see ua_service_remove()
+ */
+int ua_service_update(
+ ua_service_h service_handle);
+
+/**
+ * @ingroup CAPI_NETWORK_UA_MODULE
* @brief Removes the service.
* @since_tizen 5.5
*
@@ -1689,6 +1711,32 @@ int ua_service_set_detection_threshold(
/**
* @ingroup CAPI_NETWORK_UA_MODULE
+ * @brief Gets detection threshold info for service handle.
+ * @since_tizen 5.5
+ *
+ * @remarks You must release @a name using g_free().
+ *
+ * @param[in] service_handle The service handle
+ * @param[in] presence_threshold The service presence threshold information
+ * @param[in] absence_threshold The service absence threshold information
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #UA_ERROR_NONE Successful
+ * @retval #UA_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @exception
+ * @pre
+ * @post
+ *
+ * @see ua_service_set_detection_threshold()
+ */
+int ua_service_get_detection_threshold(
+ ua_service_h service_handle,
+ unsigned int *presence_threshold,
+ unsigned int *absence_threshold);
+
+/**
+ * @ingroup CAPI_NETWORK_UA_MODULE
* @brief Sets name info for service handle.
* @since_tizen 5.5
*
diff --git a/src/user-awareness-service.c b/src/user-awareness-service.c
index a860fc1..1cd9428 100644
--- a/src/user-awareness-service.c
+++ b/src/user-awareness-service.c
@@ -146,6 +146,8 @@ int _ua_service_add_info_to_list(ua_service_info_s* ua_info)
/* LCOV_EXCL_STOP */
}
+ service_info->presence_threshold = ua_info->presence_threshold;
+ service_info->absence_threshold = ua_info->absence_threshold;
service_info->isadded = true;
service_info->service_handle = (ua_service_h)service_info;
ua_services_list = g_slist_append(ua_services_list, service_info);
@@ -256,6 +258,9 @@ int _ua_foreach_registered_services(ua_service_added_service_cb foreach_cb,
}
service_info->name = g_strndup(ptr->name, UAM_SERVICE_MAX_STRING_LEN);
+ service_info->presence_threshold = ptr->presence_threshold;
+ UA_INFO("presence threshold: [%d]", service_info->presence_threshold);
+ service_info->absence_threshold = ptr->absence_threshold;
if (service_info->name == NULL) {
/* LCOV_EXCL_START */
UA_ERR("g_malloc0 failed");
@@ -466,8 +471,6 @@ int ua_service_set_detection_threshold(ua_service_h service_handle,
UA_VALIDATE_INPUT_PARAMETER(service_handle);
UA_VALIDATE_HANDLE(service_handle, ua_services_list);
- retv_if(service->isadded, UA_ERROR_NOT_PERMITTED);
-
service->presence_threshold = presence_threshold;
service->absence_threshold = absence_threshold;
@@ -498,6 +501,24 @@ int ua_service_get_name(ua_service_h service_handle, char **name)
return UA_ERROR_NONE;
}
+int ua_service_get_detection_threshold(ua_service_h service_handle,
+ unsigned int *presence_threshold, unsigned int *absence_threshold)
+{
+ FUNC_ENTRY;
+ ua_service_info_s *service = (ua_service_info_s *)service_handle;
+
+ UA_VALIDATE_INPUT_PARAMETER(service_handle);
+ UA_VALIDATE_HANDLE(service_handle, ua_services_list);
+
+ retv_if(NULL == service->name, UA_ERROR_NO_DATA);
+
+ *presence_threshold = service->presence_threshold;
+ *absence_threshold = service->absence_threshold;
+
+ FUNC_EXIT;
+ return UA_ERROR_NONE;
+}
+
int ua_service_get_default_service(ua_service_h* service_handle)
{
FUNC_ENTRY;
diff --git a/test/uat-service.c b/test/uat-service.c
index cbd43fe..0446bef 100644
--- a/test/uat-service.c
+++ b/test/uat-service.c
@@ -77,6 +77,8 @@ static bool __foreach_added_service_cb(
{
int ret = UA_ERROR_NONE;
char *name = NULL;
+ unsigned int presence_threshold = 0;
+ unsigned int absence_threshold = 0;
check_if(NULL == service_handle);
@@ -87,7 +89,17 @@ static bool __foreach_added_service_cb(
return RET_SUCCESS;
}
- msgb("[%d] %s", ++g_service_count, name);
+ ret = ua_service_get_detection_threshold(service_handle,
+ &presence_threshold, &absence_threshold);
+ if (UA_ERROR_NONE != ret) {
+ msg(" - ua_service_get_detection_threshold() ret: [0x%X] [%s]",
+ ret, uat_get_error_str(ret));
+ return RET_SUCCESS;
+ }
+
+ msgb("[%d] %s ", ++g_service_count, name);
+ msgb("presence threshold :[%d] absence threshold :[%d]",
+ presence_threshold, absence_threshold);
g_service_list = g_slist_append(g_service_list, service_handle);
@@ -173,8 +185,8 @@ static int run_ua_service_set_name(MManager *mm, struct menu_data *menu)
static int run_ua_service_set_detection_threshold(MManager *mm, struct menu_data *menu)
{
int ret = UA_ERROR_NONE;
- unsigned int presence_threshold = 0;
- unsigned int absence_threshold = 0;
+ unsigned int presence_threshold = 60;
+ unsigned int absence_threshold = 60;
msg("ua_service_set_threshold");