summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorhyunuk.tak <hyunuk.tak@samsung.com>2021-01-20 16:39:37 +0900
committerhyunuk.tak <hyunuk.tak@samsung.com>2021-01-20 16:42:28 +0900
commit375ef8f3cc395f6f1ea070ee92fc8c01387713aa (patch)
tree4e586248982dbcadca98d45ac97cd83ff3a14aad
parenta64d966160757c0558118b297e243edef5d107fa (diff)
downloaduser-awareness-375ef8f3cc395f6f1ea070ee92fc8c01387713aa.tar.gz
user-awareness-375ef8f3cc395f6f1ea070ee92fc8c01387713aa.tar.bz2
user-awareness-375ef8f3cc395f6f1ea070ee92fc8c01387713aa.zip
Modify some APIs appropriately
Add APIs ua_device_get_parent_user ua_device_get_parent_service Modify APIs ua_monitor_cancel_scan_devices ua_sensor_status_changed_cb Change-Id: I3e6d885b4ace313d4b0ac38f385a5a0abcd37802 Signed-off-by: hyunuk.tak <hyunuk.tak@samsung.com>
-rwxr-xr-xinclude/user-awareness-private.h1
-rwxr-xr-xinclude/user-awareness.h46
-rwxr-xr-xsrc/user-awareness-device.c66
-rwxr-xr-xsrc/user-awareness-monitors.c3
-rwxr-xr-x[-rw-r--r--]src/user-awareness-payload.c0
-rwxr-xr-xsrc/user-awareness-service.c4
-rwxr-xr-xtest/uat-detections.c12
-rwxr-xr-xtest/uat-init.c20
8 files changed, 126 insertions, 26 deletions
diff --git a/include/user-awareness-private.h b/include/user-awareness-private.h
index 37d7917..0cff468 100755
--- a/include/user-awareness-private.h
+++ b/include/user-awareness-private.h
@@ -273,6 +273,7 @@ typedef struct {
* @since_tizen 6.5
*/
typedef struct {
+ ua_service_h service_handle; /**< Service handle */
ua_user_h user_handle; /**< User handle */
ua_presence_state_e state; /**< Presence state */
unsigned int sensor_bitmask; /**< Detected user devices bitmask */
diff --git a/include/user-awareness.h b/include/user-awareness.h
index 2baca5e..eb1858d 100755
--- a/include/user-awareness.h
+++ b/include/user-awareness.h
@@ -292,6 +292,8 @@ typedef void *ua_device_h;
typedef void (*ua_sensor_status_changed_cb)(
ua_monitor_h handle,
ua_sensor_h sensor_handle,
+ ua_sensor_e sensor_type,
+ ua_sensor_status_e status,
void *user_data);
/**
@@ -767,7 +769,7 @@ int ua_monitor_unset_sensor_status_cb(
*
* @see UA_SCAN_TIME_MULTIPLIER
* @see ua_scan_completed_cb()
- * @see ua_monitor_cancel_scan_devices()
+ * @see ua_monitor_stop_scan_devices()
*/
int ua_monitor_start_scan_devices(
ua_monitor_h handle,
@@ -794,7 +796,7 @@ int ua_monitor_start_scan_devices(
*
* @see ua_monitor_start_scan_devices()
*/
-int ua_monitor_cancel_scan_devices(ua_monitor_h monitor);
+int ua_monitor_stop_scan_devices(ua_monitor_h monitor);
/**
@@ -1617,6 +1619,46 @@ int ua_device_destroy(
/**
* @ingroup CAPI_NETWORK_UA_MODULE
+ * @brief Gets parent user handle from device.
+ * @since_tizen 6.5
+ *
+ * @param[in] device_handle The device handle
+ * @param[out] user_handle The user handle
+ *
+ * @return 0 on success, otherwise a negative error value
+ * @retval #UA_ERROR_NONE Successful
+ * @retval #UA_ERROR_INVALID_PARAMETER Invalid parameter
+ *
+ * @exception
+ * @pre
+ * @post
+ */
+int ua_device_get_parent_user(
+ ua_device_h device_handle,
+ ua_user_h *user_handle);
+
+/**
+ * @ingroup CAPI_NETWORK_UA_MODULE
+ * @brief Gets parent service handle from device.
+ * @since_tizen 6.5
+ *
+ * @param[in] device_handle The device handle
+ * @param[out] 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
+ *
+ * @exception
+ * @pre
+ * @post
+ */
+int ua_device_get_parent_service(
+ ua_device_h device_handle,
+ ua_service_h *service_handle);
+
+/**
+ * @ingroup CAPI_NETWORK_UA_MODULE
* @brief Sets a device type info for a device.
* @since_tizen 6.5
*
diff --git a/src/user-awareness-device.c b/src/user-awareness-device.c
index dc768f3..d138a67 100755
--- a/src/user-awareness-device.c
+++ b/src/user-awareness-device.c
@@ -499,6 +499,72 @@ int ua_device_destroy(ua_device_h device_handle)
return UA_ERROR_NONE;
}
+int ua_device_get_parent_user(ua_device_h handle, ua_user_h *user_handle)
+{
+ FUNC_ENTRY;
+
+ UA_CHECK_INIT_STATUS();
+ UA_VALIDATE_INPUT_PARAMETER(handle);
+
+ ua_dev_info_s *device = (ua_dev_info_s *)handle;
+
+ UA_VALIDATE_INPUT_PARAMETER(user_handle);
+ UA_PRINT_DEVICE_HANDLE(handle);
+
+ if (device->user == NULL) {
+ int ret = _ua_intr_get_default_user(user_handle);
+ if (ret != UA_ERROR_NONE) {
+ UA_ERR("Failed to get default user with error");
+ return ret;
+ }
+ } else {
+ *user_handle = device->user;
+ }
+
+ FUNC_EXIT;
+ return UA_ERROR_NONE;
+}
+
+int ua_device_get_parent_service(ua_device_h handle, ua_service_h *service_handle)
+{
+ FUNC_ENTRY;
+
+ UA_CHECK_INIT_STATUS();
+ UA_VALIDATE_INPUT_PARAMETER(handle);
+
+ ua_dev_info_s *device = (ua_dev_info_s *)handle;
+ ua_user_info_s *user = NULL;
+ ua_service_info_s *service = NULL;
+
+ UA_VALIDATE_INPUT_PARAMETER(service_handle);
+ UA_PRINT_DEVICE_HANDLE(handle);
+
+ if (device->user == NULL) {
+ int ret = _ua_intr_get_default_user((ua_user_h *)user);
+ if (ret != UA_ERROR_NONE) {
+ UA_ERR("Failed to get default user with error");
+ return ret;
+ }
+ } else {
+ user = device->user;
+ }
+
+ if (user->service_handle == NULL) {
+ int ret = ua_service_get_default_service((ua_service_h *)service);
+ if (ret != UA_ERROR_NONE) {
+ UA_ERR("Failed to get default service with error");
+ return ret;
+ }
+ } else {
+ service = user->service_handle;
+ }
+
+ *service_handle = service;
+
+ FUNC_EXIT;
+ return UA_ERROR_NONE;
+}
+
int ua_device_set_mac_type(ua_device_h handle, ua_mac_type_e mac_type)
{
FUNC_ENTRY;
diff --git a/src/user-awareness-monitors.c b/src/user-awareness-monitors.c
index 2d0b344..b542588 100755
--- a/src/user-awareness-monitors.c
+++ b/src/user-awareness-monitors.c
@@ -959,6 +959,7 @@ void _ua_monitor_handle_sensor_status_changed(uam_sensor_info_s *info)
if (monitor->sensor_status_cb.callback)
((ua_sensor_status_changed_cb)monitor->sensor_status_cb.callback)(
(ua_monitor_h)monitor, (ua_sensor_h)sensor_info,
+ sensor_info->bitmask, sensor_info->status,
monitor->sensor_status_cb.user_data);
}
_ua_free_sensor_info(sensor_info);
@@ -1356,7 +1357,7 @@ int ua_monitor_start_scan_devices(
return UA_ERROR_NONE;
}
-int ua_monitor_cancel_scan_devices(ua_monitor_h handle)
+int ua_monitor_stop_scan_devices(ua_monitor_h handle)
{
FUNC_ENTRY;
int ret;
diff --git a/src/user-awareness-payload.c b/src/user-awareness-payload.c
index aa64be1..aa64be1 100644..100755
--- a/src/user-awareness-payload.c
+++ b/src/user-awareness-payload.c
diff --git a/src/user-awareness-service.c b/src/user-awareness-service.c
index ee55c71..0cd5017 100755
--- a/src/user-awareness-service.c
+++ b/src/user-awareness-service.c
@@ -619,7 +619,7 @@ int ua_service_add_user(ua_service_h service_handle, ua_user_h user_handle)
FUNC_ENTRY;
int ret;
- ua_service_info_s* service_info = (ua_service_info_s*)service_handle;
+ ua_service_info_s* service_info = (ua_service_info_s *)service_handle;
ua_user_info_s* user_info = (ua_user_info_s*)user_handle;
UA_CHECK_INIT_STATUS();
@@ -641,6 +641,8 @@ int ua_service_add_user(ua_service_h service_handle, ua_user_h user_handle)
return ret;
}
+ user_info->service_handle = service_handle;
+
FUNC_EXIT;
return UA_ERROR_NONE;
}
diff --git a/test/uat-detections.c b/test/uat-detections.c
index 001546b..ae4aa44 100755
--- a/test/uat-detections.c
+++ b/test/uat-detections.c
@@ -365,18 +365,18 @@ static int run_ua_monitor_start_scan_devices(
return RET_SUCCESS;
}
-static int run_ua_monitor_cancel_scan_devices(
+static int run_ua_monitor_stop_scan_devices(
MManager *mm, struct menu_data *menu)
{
int ret = UA_ERROR_NONE;
- msg("ua_monitor_cancel_scan_devices,");
+ msg("ua_monitor_stop_scan_devices,");
check_if(NULL == g_ua_mon_h);
- ret = ua_monitor_cancel_scan_devices(g_ua_mon_h);
+ ret = ua_monitor_stop_scan_devices(g_ua_mon_h);
- msg("ua_monitor_cancel_scan_devices,() ret: [0x%X] [%s]",
+ msg("ua_monitor_stop_scan_devices,() ret: [0x%X] [%s]",
ret, uat_get_error_str(ret));
return RET_SUCCESS;
@@ -652,8 +652,8 @@ struct menu_data menu_ua_detections[] = {
{ "8", "ua_monitor_start_device_scan",
menu_start_device_scan, NULL, NULL },
- { "9", "ua_monitor_cancel_scan_devices",
- NULL, run_ua_monitor_cancel_scan_devices, NULL },
+ { "9", "ua_monitor_stop_scan_devices",
+ NULL, run_ua_monitor_stop_scan_devices, NULL },
{ "10", "ua_enable_low_power_mode",
NULL, run_ua_enable_low_power_mode, NULL },
diff --git a/test/uat-init.c b/test/uat-init.c
index 4521836..4705fb8 100755
--- a/test/uat-init.c
+++ b/test/uat-init.c
@@ -50,30 +50,18 @@ const char * uat_convert_device_mac_type_to_txt(ua_mac_type_e mac_type)
}
static void __sensor_status_changed_cb(ua_monitor_h handle,
- ua_sensor_h sensor_handle, void *user_data)
+ ua_sensor_h sensor_handle, ua_sensor_e sensor_type,
+ ua_sensor_status_e status, void *user_data)
{
int ret;
- ua_sensor_e sensor;
- ua_sensor_status_e status;
unsigned long long timestamp;
char *pbuf = uat_get_time();
msgc("\n[%s]", pbuf);
free(pbuf);
- ret = ua_sensor_get_status(sensor_handle, &status);
- if (UA_ERROR_NONE != ret) {
- msg(" - ua_sensor_get_status() ret: [0x%X] [%s]",
- ret, uat_get_error_str(ret));
- }
- ret = ua_sensor_get_bitmask(sensor_handle, &sensor);
- if (UA_ERROR_NONE != ret) {
- msg(" - ua_sensor_get_bitmask() ret: [0x%X] [%s]",
- ret, uat_get_error_str(ret));
- }
-
msgc("[%s] Sensor Status Changed -> %s",
- uat_get_sensor_bitmask_str(sensor),
+ uat_get_sensor_bitmask_str(sensor_type),
status == UA_SENSOR_PRESENCE ? "PRESENCE" : "ABSENCE");
ret = ua_sensor_get_timestamp(sensor_handle, &timestamp);
@@ -83,7 +71,7 @@ static void __sensor_status_changed_cb(ua_monitor_h handle,
}
msgc("[%s] timestamp [%llu]",
- uat_get_sensor_bitmask_str(sensor), timestamp);
+ uat_get_sensor_bitmask_str(sensor_type), timestamp);
}
int _uat_monitor_create()