Modify to add the sensor status to sensor information
authorsaerome.kim <saerome.kim@samsung.com>
Tue, 22 Oct 2019 07:24:41 +0000 (16:24 +0900)
committersaerome.kim <saerome.kim@samsung.com>
Wed, 23 Oct 2019 00:31:11 +0000 (09:31 +0900)
Change-Id: Ifc5394bde0f83e057b006072faebd254d3500ad9
Signed-off-by: saerome.kim <saerome.kim@samsung.com>
packaging/ua-manager.spec
ua-api/src/ua-event-handler.c
ua-daemon/include/ua-manager-core.h
ua-daemon/src/pm/ua-motion-plugin-handler.c
ua-daemon/src/pm/ua-pm-util.c
ua-daemon/src/ua-manager-core.c
ua-plugins/include/ua-plugin.h

index 6ab9eb4..07f8952 100644 (file)
@@ -1,6 +1,6 @@
 Name:       ua-manager
 Summary:    User awareness manager
-Version:    0.12.1
+Version:    0.12.2
 Release:    1
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
index 8a5bef8..682fd95 100644 (file)
@@ -151,8 +151,8 @@ static void __uam_event_handler(GDBusConnection *connection,
                                                &accuracy, &count, &values[0], &values[1],
                                                &values[2], &values[3]);
 
-               __uam_copy_sensor_data(&sensor_info, 0, sensor_bitmask, timestamp,
-                                       accuracy, count, values);
+               __uam_copy_sensor_data(&sensor_info, UAM_PRESENCE_STATE_PRESENT, sensor_bitmask,
+                       timestamp, accuracy, count, values);
 
                event = UAM_EVENT_PRESENCE_DETECTED;
 
@@ -169,8 +169,8 @@ static void __uam_event_handler(GDBusConnection *connection,
                                                &accuracy, &count, &values[0], &values[1],
                                                &values[2], &values[3]);
 
-               __uam_copy_sensor_data(&sensor_info, 0, sensor_bitmask, timestamp,
-                                       accuracy, count, values);
+               __uam_copy_sensor_data(&sensor_info, UAM_PRESENCE_STATE_ABSENT,
+                       sensor_bitmask, timestamp, accuracy, count, values);
 
                event = UAM_EVENT_ABSENCE_DETECTED;
 
@@ -338,9 +338,11 @@ static void __uam_event_handler(GDBusConnection *connection,
                int status, accuracy, count;
                double values[UAM_SENSOR_MAX_VALUES];
 
-               g_variant_get(parameters, "(uutiidddd)", &status, &sensor_bitmask, &timestamp,
+               g_variant_get(parameters, "(uutiidddd)", &sensor_bitmask, &status, &timestamp,
                                                &accuracy, &count, &values[0], &values[1],&values[2], &values[3]);
 
+               UAM_DBG("%d %d %llu %d %d", sensor_bitmask, status, timestamp, accuracy, count);
+
                __uam_copy_sensor_data(&sensor_info, status, sensor_bitmask, timestamp,
                                        accuracy, count, values);
 
index d66752b..dfac5f1 100644 (file)
@@ -231,8 +231,7 @@ int _uam_core_update_device(const uam_device_info_s *a_device);
 
 int _uam_core_add_ibeacon_adv(unsigned int adv_len, const char *iadv);
 
-void _uam_core_handle_status_changed(unsigned int sensor,
-       unsigned int type, void *info);
+void _uam_core_handle_status_changed(unsigned int sensor, void *info);
 
 #ifdef __cplusplus
 }
index bb366f9..39b8d41 100644 (file)
@@ -58,7 +58,7 @@ static void motion_detection_status_changed_cb(uas_detection_type_e type,
                info = sensor_info;
        motion_info = _pm_util_uas_sensor_info_to_uam_sensor_info(info);
 
-       _uam_core_handle_status_changed(UAM_SENSOR_BITMASK_MOTION, type, motion_info);
+       _uam_core_handle_status_changed(UAM_SENSOR_BITMASK_MOTION, motion_info);
 
        g_free(motion_info);
 
index db0a297..1375849 100644 (file)
@@ -369,6 +369,7 @@ uam_sensor_info_s *_pm_util_uas_sensor_info_to_uam_sensor_info(
        sensor_info = g_new0(uam_sensor_info_s, 1);
        retv_if(NULL == sensor_info, NULL);
 
+       sensor_info->status = info->status;
        sensor_info->timestamp = info->timestamp;
        sensor_info->accuracy = info->accuracy;
        sensor_info->count = info->count;
index fc29fff..6314bc0 100644 (file)
@@ -2700,7 +2700,7 @@ void __send_user_presence_event(uam_db_tech_info_t *tech, unsigned int sensor,
                        if (UAM_DETECT_PRESENCE != mon->mode)
                                continue;
 
-                       user->timestamp = (unsigned long long) time(NULL);
+                       user->timestamp = (unsigned long long)time(NULL);
                        UAM_INFO("sensor [%d]", sensor);
                        _uam_manager_send_event(mon->name,
                                        UAM_EVENT_USER_PRESENCE_DETECTED,
@@ -2912,7 +2912,7 @@ static void __send_user_absence_event(uam_tech_type_e type, unsigned int sensor)
                                if (!user)
                                        continue;
 
-                               user->timestamp = (unsigned long long) time(NULL);
+                               user->timestamp = (unsigned long long)time(NULL);
                                _uam_manager_send_event(mon->name,
                                                UAM_EVENT_USER_ABSENCE_DETECTED,
                                                g_variant_new("(usst)", sensor,
@@ -3695,8 +3695,7 @@ int _uam_core_add_ibeacon_adv(unsigned int adv_len, const char *iadv)
        return UAM_ERROR_NONE;
 }
 
-void _uam_core_handle_status_changed(unsigned int sensor, unsigned int type,
-       void *info)
+void _uam_core_handle_status_changed(unsigned int sensor, void *info)
 {
        FUNC_ENTRY;
 
@@ -3704,20 +3703,16 @@ void _uam_core_handle_status_changed(unsigned int sensor, unsigned int type,
 
        ret_if(NULL == info);
 
-       sensor_info->status = type;
+       UAM_DBG("%d %d %llu %d %d", sensor, sensor_info->status, sensor_info->timestamp,
+               sensor_info->accuracy, sensor_info->count);
 
-       UAM_INFO("sensor: 0x%8.8X, detection_type: %d", sensor, type);
+       UAM_INFO("sensor: 0x%8.8X %s", sensor, sensor_info->status == UAS_ABSENCE ?
+               "UAM_EVENT_ABSENCE_DETECTED" : "UAM_EVENT_PRESENCE_DETECTED");
 
-       if (UAS_ABSENCE == type) {
-               _uam_manager_send_event(NULL, UAM_EVENT_SENSOR_STATUS_CHANGED,
-                       g_variant_new("(uutiidddd)", type, sensor, 0, 0, 0, 0, 0, 0, 0));
-               UAM_DBG("Sent UAM_EVENT_ABSENCE_DETECTED for 0x%8.8X", sensor);
-       } else {
-               _uam_manager_send_event(NULL, UAM_EVENT_SENSOR_STATUS_CHANGED,
-                       g_variant_new("(uutiidddd)", type, sensor, sensor_info->timestamp,
-                       sensor_info->accuracy, sensor_info->count, sensor_info->values[0],
-                       sensor_info->values[1], sensor_info->values[2], sensor_info->values[3]));
-       }
+       _uam_manager_send_event(NULL, UAM_EVENT_SENSOR_STATUS_CHANGED,
+               g_variant_new("(uutiidddd)", sensor, sensor_info->status, sensor_info->timestamp,
+               sensor_info->accuracy, sensor_info->count, sensor_info->values[0],
+               sensor_info->values[1], sensor_info->values[2], sensor_info->values[3]));
 
        FUNC_EXIT;
 }
index 705e2f5..6a60f86 100644 (file)
@@ -122,10 +122,11 @@ typedef struct {
 
 /* Sensor information structure */
 typedef struct {
-       unsigned long long timestamp;
-       int accuracy;
-       int count;
-       double *values;
+       unsigned int status; /**< Sensor status */
+       unsigned long long timestamp; /**< Timestamp */
+       int accuracy; /**< Accuracy */
+       int count; /**< How many sensor data are there */
+       double *values; /**< Sensor data */
 } uas_sensor_info_t;
 
 /* Active scan event types */