Support multiple timestamp for each service
authorLokesh <l.kasana@samsung.com>
Mon, 18 Nov 2019 14:00:04 +0000 (19:30 +0530)
committersaerome.kim <saerome.kim@samsung.com>
Tue, 19 Nov 2019 07:37:49 +0000 (16:37 +0900)
Change-Id: I67acdcfa5e4ba8a6d8de68f7e37dfcd4f58adf01
Signed-off-by: Lokesh <l.kasana@samsung.com>
packaging/ua-manager.spec
ua-daemon/include/ua-manager-core.h
ua-daemon/src/ua-manager-core.c
ua-daemon/src/ua-manager-device-db.c

index 192ff06..b9b40dd 100644 (file)
@@ -1,6 +1,6 @@
 Name:       ua-manager
 Summary:    User awareness manager
-Version:    0.13.1
+Version:    0.13.2
 Release:    1
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
index 1742e67..064fd1c 100644 (file)
@@ -59,6 +59,7 @@ typedef struct {
        uam_tech_type_e tech_type;
        char *service;
        int discriminant;
+       unsigned long long timestamp;
 } uam_svc_dev_info_t;
 
 typedef struct {
index fdda37b..a36ea54 100644 (file)
@@ -2344,6 +2344,7 @@ int _uam_core_init(void)
        } else {
                for (l = db_svc_dev_list; NULL != l; l = g_slist_next(l)) {
                        db_svc_dev_info_t *db_svc = l->data;
+
                        _uam_core_update_svc_dev_info((char *)&(db_svc->device_id), db_svc->type,
                                (char *)&(db_svc->svc), db_svc->discriminant);
                }
@@ -2720,6 +2721,7 @@ void __send_user_presence_event(uam_db_tech_info_t *tech, unsigned int sensor,
        GSList *l;
        uam_db_user_info_t *user;
        uam_svc_dev_info_t *svc_dev = NULL;
+       gboolean live_monitoring = FALSE;
 
        ret_if(NULL == tech);
        ret_if(NULL == tech->svc_list);
@@ -2756,6 +2758,12 @@ void __send_user_presence_event(uam_db_tech_info_t *tech, unsigned int sensor,
                        if (UAM_DETECT_PRESENCE != mon->mode)
                                continue;
 
+                       /*
+                        * For current service, if any its running monitor has same sensor
+                        * and detection_mode
+                        */
+                       live_monitoring = TRUE;
+
                        user->timestamp = _uam_get_timestamp();
 
                        UAM_INFO("sensor [%d]", sensor);
@@ -2771,6 +2779,9 @@ void __send_user_presence_event(uam_db_tech_info_t *tech, unsigned int sensor,
                                        svc->name,
                                        user->timestamp);
                }
+
+               if (live_monitoring)
+                       svc_dev->timestamp = _uam_get_timestamp();
        }
 
        FUNC_EXIT;
@@ -2783,7 +2794,6 @@ int _uam_core_handle_presence_detected(unsigned int sensor,
        int ret = UAM_ERROR_NONE;
 
        GSList *l;
-
        uam_db_user_info_t *user;
        uam_db_device_info_t *device;
        uam_db_tech_info_t *tech;
@@ -2899,6 +2909,7 @@ int _uam_core_handle_presence_detected(unsigned int sensor,
                return ret;
        }
 
+       /* Send user presence event and update service_device timestamp */
        __send_user_presence_event(tech, sensor, dev_info->device_id);
        __uam_db_end_transaction(1);
 
@@ -3587,8 +3598,11 @@ static int __get_service_dev_list(
 {
        FUNC_ENTRY;
        GSList *l1;
+       GSList *s;
        int indx = 0;
        int ret = UAM_ERROR_NONE;
+       uam_svc_dev_info_t *svc_dev = NULL;
+       uam_device_info_s *dev = NULL;
 
        *count = 0;
        /* Calculate number of devices */
@@ -3615,10 +3629,33 @@ static int __get_service_dev_list(
                        UAM_ERR("__copy_tech_info_to_device_info failed");
                        return ret;
                }
+
+               (*device_list)[indx].last_seen = 0;
                indx++;
        }
 
        UAM_INFO("Count = %d, indx = %d", *count, indx);
+
+       /* Update service specific device timestamp */
+       for (s = svc_devs; s; s = g_slist_next(s)) {
+               svc_dev = s->data;
+
+               if (!svc_dev || !svc_dev->device_id || !svc_dev->service)
+                       continue;
+               if (g_strcmp0(svc_dev->service, service->name))
+                       continue;
+
+               for (indx = 0; indx < *count; indx++) {
+                       dev = &((*device_list)[indx]);
+
+                       if (svc_dev->tech_type != dev->type ||
+                                       g_strcmp0(svc_dev->device_id, dev->device_id))
+                               continue;
+
+                       dev->last_seen = svc_dev->timestamp;
+               }
+       }
+
        FUNC_EXIT;
        return ret;
 }
index 1532232..c158f56 100644 (file)
@@ -272,8 +272,7 @@ handle_error:
 }
 
 int _uam_device_db_update_device_ip_address(char *device_id, int tech_type,
-       char *address,
-               char *ip_address)
+               char *address, char *ip_address)
 {
        int error_code = UAM_ERROR_NONE;
        sqlite3_stmt *stmt = update_ip_address;