Simultaneously start presence and absence detection 66/223266/1
authorAbhay Agarwal <ay.agarwal@samsung.com>
Tue, 21 Jan 2020 05:40:44 +0000 (11:10 +0530)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Tue, 28 Jan 2020 06:12:42 +0000 (15:12 +0900)
Issue: when presence detection is follwed by absence detection,
       absence callback is missed in first cycle.
Solution: start both presence and absence detection

Change-Id: I353a2ecd985c86afefb322cad47283695853896c
Signed-off-by: Abhay Agarwal <ay.agarwal@samsung.com>
packaging/ua-manager.spec
ua-daemon/src/ua-manager-core.c

index e43a414..a06bec7 100644 (file)
@@ -1,6 +1,6 @@
 Name:       ua-manager
 Summary:    User awareness manager
-Version:    0.13.19
+Version:    0.13.20
 Release:    1
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
index f6965f1..da0b1f3 100644 (file)
@@ -2108,25 +2108,16 @@ static gboolean __start_detection(gpointer data)
        unsigned int sensors;
        gboolean start_detection = FALSE;
        GSList *l;
-       unsigned int presence_env_sensors;
-       unsigned int absence_env_sensors;
+       unsigned int env_sensors;
 
-       presence_env_sensors = _uam_core_get_active_env_sensors(UAM_DETECT_PRESENCE);
-       UAM_DBG("Presence Envionmental sensors: 0x%8.8X", presence_env_sensors);
+       env_sensors = _uam_core_get_active_env_sensors(UAM_DETECT_PRESENCE) |
+                       _uam_core_get_active_env_sensors(UAM_DETECT_ABSENCE);
+       UAM_DBG("Active envionmental sensors: 0x%8.8X", env_sensors);
 
-       absence_env_sensors = _uam_core_get_active_env_sensors(UAM_DETECT_ABSENCE);
-       UAM_DBG("Absence Envionmental sensors: 0x%8.8X", absence_env_sensors);
-
-       if (0 != presence_env_sensors) {
-               /* Stop PRESENCE detection on active envionmental sensors*/
-               ret = _uam_pm_stop_detection(UAM_DETECT_PRESENCE, presence_env_sensors);
-               if (UAM_ERROR_NONE != ret)
-                       UAM_ERR("Failed with error: %s (0x%4.4X)",
-                                       _uam_manager_error_to_str(ret), ret);
-       }
-       if (0 != absence_env_sensors) {
-               /* Stop ABSENCE detection on envionmental sensors*/
-               ret = _uam_pm_stop_detection(UAM_DETECT_ABSENCE, absence_env_sensors);
+       if (0 != env_sensors) {
+               /* stop detection on active envionmental sensors*/
+               ret = _uam_pm_stop_detection(UAM_DETECT_PRESENCE | UAM_DETECT_ABSENCE,
+                       env_sensors);
                if (UAM_ERROR_NONE != ret)
                        UAM_ERR("Failed with error: %s (0x%4.4X)",
                                        _uam_manager_error_to_str(ret), ret);
@@ -2149,49 +2140,30 @@ static gboolean __start_detection(gpointer data)
        if (!start_detection)
                goto done;
 
-       /* Get sensors on which PRESENCE detection to be started */
-       sensors = _uam_core_get_active_sensors(UAM_DETECT_PRESENCE);
-       UAM_DBG("PRESENCE sensors: 0x%8.8X", sensors);
-
-       /* Remove env sensors from active sensors */
-       sensors &= ~presence_env_sensors;
-       UAM_DBG("Presence Connectivity sensors: 0x%8.8X", sensors);
-
-       if (0 != sensors) {
-               /* Start PRESENCE detection */
-               ret = _uam_pm_start_detection(UAM_DETECT_PRESENCE, sensors);
-               if (UAM_ERROR_NONE != ret)
-                       UAM_ERR("Failed with error: %s (0x%4.4X)",
-                                       _uam_manager_error_to_str(ret), ret);
-       }
-
-       /* Get sensors on which ABSENCE detection to be started */
-       sensors = _uam_core_get_active_sensors(UAM_DETECT_ABSENCE);
-       UAM_DBG("ABSENCE sensors: 0x%8.8X", sensors);
+       /* Get sensors on which detection to be started */
+       sensors = _uam_core_get_active_sensors(UAM_DETECT_PRESENCE) |
+                       _uam_core_get_active_sensors(UAM_DETECT_ABSENCE);
+       UAM_DBG("Active sensors: 0x%8.8X", sensors);
 
        /* Remove env sensors from active sensors */
-       sensors &= ~absence_env_sensors;
-       UAM_DBG("ABSENCE Connectivity sensors: 0x%8.8X", sensors);
+       sensors &= ~env_sensors;
+       UAM_DBG("Active connectivity sensors: 0x%8.8X", sensors);
 
        if (0 != sensors) {
-               /* Start ABSENCE detection */
-               ret = _uam_pm_start_detection(UAM_DETECT_ABSENCE, sensors);
+               /* Start detection */
+               ret = _uam_pm_start_detection(UAM_DETECT_PRESENCE | UAM_DETECT_ABSENCE,
+                               sensors);
                if (UAM_ERROR_NONE != ret)
                        UAM_ERR("Failed with error: %s (0x%4.4X)",
                                        _uam_manager_error_to_str(ret), ret);
        }
 
 done:
-       if (0 != presence_env_sensors) {
-               /* Always Start PRESENCE detection on active envionmental sensors*/
-               ret = _uam_pm_start_detection(UAM_DETECT_PRESENCE, presence_env_sensors);
-               if (UAM_ERROR_NONE != ret)
-                       UAM_ERR("Failed with error: %s (0x%4.4X)",
-                                       _uam_manager_error_to_str(ret), ret);
-       }
-       if (0 != absence_env_sensors) {
-               /* Always Start ABSENCE detection on active envionmental sensors*/
-               ret = _uam_pm_start_detection(UAM_DETECT_ABSENCE, absence_env_sensors);
+       if (0 != env_sensors) {
+               /* continuous monitoring
+                * always start detection on active envionmental sensors */
+               ret = _uam_pm_start_detection(UAM_DETECT_PRESENCE | UAM_DETECT_ABSENCE,
+                       env_sensors);
                if (UAM_ERROR_NONE != ret)
                        UAM_ERR("Failed with error: %s (0x%4.4X)",
                                        _uam_manager_error_to_str(ret), ret);