From: Abhay Agarwal Date: Tue, 21 Jan 2020 05:40:44 +0000 (+0530) Subject: Simultaneously start presence and absence detection X-Git-Tag: accepted/tizen/unified/20200210.131729~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=738ef724a7cdb2baef04bc691428ca55b371e4d6;p=platform%2Fcore%2Fconnectivity%2Fua-manager.git Simultaneously start presence and absence detection 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 --- diff --git a/packaging/ua-manager.spec b/packaging/ua-manager.spec index e43a414..a06bec7 100644 --- a/packaging/ua-manager.spec +++ b/packaging/ua-manager.spec @@ -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 diff --git a/ua-daemon/src/ua-manager-core.c b/ua-daemon/src/ua-manager-core.c index f6965f1..da0b1f3 100644 --- a/ua-daemon/src/ua-manager-core.c +++ b/ua-daemon/src/ua-manager-core.c @@ -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);