Modify some APIs appropriately 75/251875/1
authorhyunuk.tak <hyunuk.tak@samsung.com>
Wed, 20 Jan 2021 07:39:37 +0000 (16:39 +0900)
committerhyunuk.tak <hyunuk.tak@samsung.com>
Wed, 20 Jan 2021 07:42:28 +0000 (16:42 +0900)
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>
include/user-awareness-private.h
include/user-awareness.h
src/user-awareness-device.c
src/user-awareness-monitors.c
src/user-awareness-payload.c [changed mode: 0644->0755]
src/user-awareness-service.c
test/uat-detections.c
test/uat-init.c

index 37d79171a46b0d44a153378e738aaf3390c21869..0cff4689a77da5d67e8a05b6a759247a4b96bdc0 100755 (executable)
@@ -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 */
index 2baca5ec85b98cd54b4f8d825f53f9514b6fde70..eb1858dac221dfdd8ec2cfe7a1a95ddb9a7b91d2 100755 (executable)
@@ -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);
 
 
 /**
@@ -1615,6 +1617,46 @@ int ua_device_clone(
 int ua_device_destroy(
                ua_device_h device_handle);
 
+/**
+ * @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.
index dc768f38418cf214d221234867acfa06fc8bfb51..d138a6705594c2727566e8eb23eb5cd2c697ac12 100755 (executable)
@@ -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;
index 2d0b3442f103e36698cb90e79a92fcbb17771b61..b542588291588e9dc5d1aa0a670eb4c12d6ac3ef 100755 (executable)
@@ -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;
old mode 100644 (file)
new mode 100755 (executable)
index ee55c7197fbfaa6876b73757cf7ef6a2c54b7936..0cd5017861fa58e913f971c9ed6f7f903e5f2436 100755 (executable)
@@ -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;
 }
index 001546b4aab9a52ad14620c10d817b13e674d6c1..ae4aa44b199b26f984c6c7c184da8ae58f80e44a 100755 (executable)
@@ -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 },
index 45218366ddf2af2cfbd43844131af64692506e51..4705fb8d1346487ae4479db68ab1704612c482ce 100755 (executable)
@@ -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()