From: Atul Rai Date: Wed, 26 Dec 2018 03:14:08 +0000 (+0530) Subject: Fix param sequence in start/stop detection APIs X-Git-Tag: accepted/tizen/unified/20190315.061301~65 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=516c24963d1852f46990cd1cacf386311d786e58;p=platform%2Fcore%2Fconnectivity%2Fua-manager.git Fix param sequence in start/stop detection APIs This patch fixes param sequence in _uam_pm_start_detection and _uam_pm_stop_detection APIs. It also combines absence and presence start/stop functions and fixed typo error sesors -> sensors. Signed-off-by: Atul Rai --- diff --git a/ua-daemon/src/ua-manager-core.c b/ua-daemon/src/ua-manager-core.c index aa2f71e..1c891be 100644 --- a/ua-daemon/src/ua-manager-core.c +++ b/ua-daemon/src/ua-manager-core.c @@ -459,7 +459,7 @@ static uam_monitor_info_t *__uam_find_monitor( return NULL; } -static unsigned int __uam_get_active_sesors(uam_pm_detection_mode_e mode) +static unsigned int __uam_get_active_sensors(uam_pm_detection_mode_e mode) { FUNC_ENTRY; unsigned int sensors = 0; @@ -1127,7 +1127,7 @@ int _uam_core_set_detection_threshold(unsigned int sensor, return UAM_ERROR_NONE; } -int _uam_core_start_presence_detection(char *sender, unsigned int sensors) +static int __uam_core_start_detection(int detection_type, char *sender, unsigned int sensors) { FUNC_ENTRY; int ret; @@ -1137,15 +1137,15 @@ int _uam_core_start_presence_detection(char *sender, unsigned int sensors) retv_if(NULL == sender, UAM_ERROR_INVALID_PARAM); - monitor = __uam_find_monitor(sender, UAM_DETECT_PRESENCE); + monitor = __uam_find_monitor(sender, detection_type); if (!monitor) { monitor = g_malloc0(sizeof(uam_monitor_info_t)); monitor->name = g_strdup(sender); - monitor->mode = UAM_DETECT_PRESENCE; + monitor->mode = detection_type; } /* Find sensors which are already monitoring */ - active_sensors = __uam_get_active_sesors(UAM_DETECT_PRESENCE); + active_sensors = __uam_get_active_sensors(detection_type); UAM_DBG("sensors: 0x%8.8X, active_sensors: 0x%8.8X", sensors, active_sensors); inactive_sensors = (sensors & ~active_sensors); @@ -1159,7 +1159,7 @@ int _uam_core_start_presence_detection(char *sender, unsigned int sensors) } /* Start monitoring only for sensors which aren't already active */ - ret = _uam_pm_start_detection(inactive_sensors, UAM_DETECT_PRESENCE); + ret = _uam_pm_start_detection(detection_type, inactive_sensors); if (UAM_ERROR_NONE != ret) { UAM_ERR("Failed with error: %s (0x%4.4X)", _uam_manager_error_to_str(ret), ret); @@ -1177,7 +1177,7 @@ done: return UAM_ERROR_NONE; } -int _uam_core_stop_presence_detection(char *sender, unsigned int sensors) +static int __uam_core_stop_detection(int detection_type, char *sender, unsigned int sensors) { FUNC_ENTRY; int ret; @@ -1187,11 +1187,11 @@ int _uam_core_stop_presence_detection(char *sender, unsigned int sensors) retv_if(NULL == sender, UAM_ERROR_INVALID_PARAM); - monitor = __uam_find_monitor(sender, UAM_DETECT_PRESENCE); + monitor = __uam_find_monitor(sender, detection_type); retv_if(NULL == monitor, UAM_ERROR_NOT_IN_OPERATION); /* Find sensors which are already monitoring */ - active_sensors = __uam_get_active_sesors(UAM_DETECT_PRESENCE); + active_sensors = __uam_get_active_sensors(detection_type); UAM_DBG("sensors: 0x%8.8X, Active sensors: 0x%8.8X", sensors, active_sensors); @@ -1208,7 +1208,7 @@ int _uam_core_stop_presence_detection(char *sender, unsigned int sensors) } /* Find sensors which are already monitoring */ - remaining_sensors = __uam_get_active_sesors(UAM_DETECT_PRESENCE); + remaining_sensors = __uam_get_active_sensors(detection_type); UAM_DBG("Remaining sensors: 0x%8.8X", remaining_sensors); if (active_sensors == remaining_sensors) { @@ -1218,7 +1218,7 @@ int _uam_core_stop_presence_detection(char *sender, unsigned int sensors) /* Stop monitoring only for sensors which aren't required anymore */ sensors = (active_sensors & ~remaining_sensors); - ret = _uam_pm_stop_detection(sensors, UAM_DETECT_PRESENCE); + ret = _uam_pm_stop_detection(detection_type, sensors); if (UAM_ERROR_NONE != ret) UAM_ERR("Failed with error: %s (0x%4.4X)", _uam_manager_error_to_str(ret), ret); @@ -1227,104 +1227,48 @@ int _uam_core_stop_presence_detection(char *sender, unsigned int sensors) return UAM_ERROR_NONE; } -int _uam_core_start_absence_detection(char *sender, unsigned int sensors) +int _uam_core_start_presence_detection(char *sender, unsigned int sensors) { FUNC_ENTRY; int ret; - int active_sensors; - int inactive_sensors; - uam_monitor_info_t *monitor; - retv_if(NULL == sender, UAM_ERROR_INVALID_PARAM); + ret = __uam_core_start_detection(UAM_DETECT_PRESENCE, sender, sensors); - monitor = __uam_find_monitor(sender, UAM_DETECT_ABSENCE); - if (!monitor) { - monitor = g_malloc0(sizeof(uam_monitor_info_t)); - monitor->name = g_strdup(sender); - monitor->mode = UAM_DETECT_ABSENCE; - } + FUNC_EXIT; + return ret; +} - /* Find sensors which are already monitoring */ - active_sensors = __uam_get_active_sesors(UAM_DETECT_ABSENCE); - UAM_DBG("sensors: 0x%8.8X, active_sensors: 0x%8.8X", sensors, active_sensors); +int _uam_core_stop_presence_detection(char *sender, unsigned int sensors) +{ + FUNC_ENTRY; + int ret; - inactive_sensors = (sensors & ~active_sensors); - /* - * If all requested sensors are already active, just update - * monitor info for current application and return success. - */ - if (0 == inactive_sensors) { - UAM_DBG("All sensors are already monitoring"); - goto done; - } + ret = __uam_core_stop_detection(UAM_DETECT_PRESENCE, sender, sensors); - /* Start monitoring only for sensors which aren't already active */ - ret = _uam_pm_start_detection(inactive_sensors, UAM_DETECT_ABSENCE); - if (UAM_ERROR_NONE != ret) { - UAM_ERR("Failed with error: %s (0x%4.4X)", - _uam_manager_error_to_str(ret), ret); - g_free(monitor->name); - g_free(monitor); - return ret; - } + FUNC_EXIT; + return ret; +} - monitors = g_slist_append(monitors, monitor); +int _uam_core_start_absence_detection(char *sender, unsigned int sensors) +{ + FUNC_ENTRY; + int ret; -done: - monitor->sensors |= sensors; + ret = __uam_core_start_detection(UAM_DETECT_ABSENCE, sender, sensors); FUNC_EXIT; - return UAM_ERROR_NONE; + return ret; } int _uam_core_stop_absence_detection(char *sender, unsigned int sensors) { FUNC_ENTRY; int ret; - unsigned int remaining_sensors; - unsigned int active_sensors; - uam_monitor_info_t *monitor; - - retv_if(NULL == sender, UAM_ERROR_INVALID_PARAM); - - monitor = __uam_find_monitor(sender, UAM_DETECT_ABSENCE); - retv_if(NULL == monitor, UAM_ERROR_NOT_IN_OPERATION); - - /* Find sensors which are already monitoring */ - active_sensors = __uam_get_active_sesors(UAM_DETECT_ABSENCE); - UAM_DBG("sensors: 0x%8.8X, Active sensors: 0x%8.8X", - sensors, active_sensors); - - /* Update monitor info for application */ - monitor->sensors &= ~sensors; - if (0 == monitor->sensors) { - /* - * App requested to stop monitoring for all of its active sensors, - * remove its monitor info from list. - */ - monitors = g_slist_remove(monitors, monitor); - g_free(monitor->name); - g_free(monitor); - } - /* Find sensors which are already monitoring */ - remaining_sensors = __uam_get_active_sesors(UAM_DETECT_ABSENCE); - UAM_DBG("Remaining sensors: 0x%8.8X", remaining_sensors); - - if (active_sensors == remaining_sensors) { - UAM_INFO("NO need to stop monitoring"); - return UAM_ERROR_NONE; - } - - /* Stop monitoring only for sensors which aren't required anymore */ - sensors = (active_sensors & ~remaining_sensors); - ret = _uam_pm_stop_detection(sensors, UAM_DETECT_ABSENCE); - if (UAM_ERROR_NONE != ret) - UAM_ERR("Failed with error: %s (0x%4.4X)", - _uam_manager_error_to_str(ret), ret); + ret = __uam_core_stop_detection(UAM_DETECT_ABSENCE, sender, sensors); FUNC_EXIT; - return UAM_ERROR_NONE; + return ret; } static void __uam_core_add_dev_to_db(uam_db_user_info_t *user, const uam_device_info_t *dev_info)