Cleanup monitor list on application termination
authorAtul Rai <a.rai@samsung.com>
Wed, 9 Jan 2019 07:10:37 +0000 (12:40 +0530)
committer김새롬/Tizen Platform Lab(SR)/Staff Engineer/삼성전자 <saerome.kim@samsung.com>
Wed, 9 Jan 2019 13:36:49 +0000 (22:36 +0900)
Signed-off-by: Atul Rai <a.rai@samsung.com>
ua-daemon/include/ua-manager-core.h
ua-daemon/src/ua-manager-core.c
ua-daemon/src/ua-manager-request-handler.c

index 934ff1d..d3edc43 100644 (file)
@@ -142,6 +142,8 @@ void _uam_core_handle_presence_detected(unsigned int sensor,
 void _uam_core_handle_absence_detected(unsigned int sensor,
                int user_id, uam_device_info_t *dev_info);
 
+void _uam_core_cleanup_monitor(char *name);
+
 #ifdef __cplusplus
 }
 #endif
index 76f827b..bfd37b3 100644 (file)
@@ -439,7 +439,7 @@ static int __copy_tech_info_to_device_info(uam_db_tech_info_t *tech, uam_device_
 static uam_monitor_info_t *__uam_find_monitor(
                const char *name, uam_pm_detection_mode_e mode)
 {
-       FUNC_ENTRY;
+//     FUNC_ENTRY;
        GSList *l;
 
        retv_if(NULL == name, NULL);
@@ -457,7 +457,7 @@ static uam_monitor_info_t *__uam_find_monitor(
                }
        }
 
-       FUNC_EXIT;
+//     FUNC_EXIT;
        return NULL;
 }
 
@@ -1263,6 +1263,8 @@ static int __uam_core_start_detection(int detection_type, char *sender, unsigned
                monitor->mode = detection_type;
        }
 
+       UAM_DBG("Name: %s, Mode: %d", monitor->name, monitor->mode);
+
        /* Find sensors which are already monitoring */
        active_sensors = __uam_get_active_sensors(detection_type);
        UAM_DBG("sensors: 0x%8.8X, active_sensors: 0x%8.8X", sensors, active_sensors);
@@ -1809,7 +1811,7 @@ void _uam_core_handle_absence_detected(unsigned int sensor,
        user = l->data;
 
        l = g_slist_find_custom(user->devices,
-                       dev_info->device_id, __compare_user_id);
+                       dev_info->device_id, __compare_device_id);
        if (NULL == l) {
                UAM_ERR("Valid user_id [%d] but Invalid device_id [%s]",
                                user_id, dev_info->device_id);
@@ -1841,3 +1843,12 @@ void _uam_core_handle_absence_detected(unsigned int sensor,
 
        FUNC_EXIT;
 }
+
+void _uam_core_cleanup_monitor(char *name)
+{
+       if (__uam_find_monitor(name, UAM_DETECT_PRESENCE))
+               __uam_core_stop_detection(UAM_DETECT_PRESENCE, name, UAM_SENSOR_ALL);
+
+       if (__uam_find_monitor(name, UAM_DETECT_ABSENCE))
+               __uam_core_stop_detection(UAM_DETECT_ABSENCE, name, UAM_SENSOR_ALL);
+}
index 1c856b8..7e293b7 100644 (file)
@@ -630,6 +630,9 @@ static void __uam_manager_cleanup_requests_from_sender(const char *name)
                        g_free(info);
                }
        }
+
+       /* App terminated, cleanup monitor list */
+       _uam_core_cleanup_monitor((char *)name);
 //     FUNC_EXIT;
 }