return sensors;
}
+unsigned int _uam_core_get_active_env_sensors(int detection_mode)
+{
+ FUNC_ENTRY;
+ unsigned int sensors = 0;
+ GSList *l;
+
+ retv_if((UAM_DETECT_PRESENCE != detection_mode) &&
+ (UAM_DETECT_ABSENCE != detection_mode), 0);
+
+ for (l = monitors; NULL != l; l = g_slist_next(l)) {
+ uam_monitor_info_t *monitor = l->data;
+
+ if (!monitor || !monitor->name || (detection_mode != monitor->mode))
+ continue;
+
+ sensors |= monitor->sensors & _uam_core_get_env_sensors();
+ }
+
+ FUNC_EXIT;
+ return sensors;
+}
+
static GSList *__convert_db_svc_list_to_uam_svc_list(GSList *db_svc_list)
{
FUNC_ENTRY;
unsigned int sensors;
gboolean start_detection = FALSE;
GSList *l;
- unsigned int env_sensors;
+ unsigned int presence_env_sensors;
+ unsigned int absence_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_env_sensors();
- UAM_DBG("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);
for (l = services; NULL != l; l = g_slist_next(l)) {
service = l->data;
UAM_DBG("PRESENCE sensors: 0x%8.8X", sensors);
/* Remove env sensors from active sensors */
- sensors &= ~env_sensors;
- UAM_DBG("Connectivity sensors: 0x%8.8X", sensors);
+ sensors &= ~presence_env_sensors;
+ UAM_DBG("Presence Connectivity sensors: 0x%8.8X", sensors);
if (0 != sensors) {
/* Start PRESENCE detection */
UAM_DBG("ABSENCE sensors: 0x%8.8X", sensors);
/* Remove env sensors from active sensors */
- sensors &= ~env_sensors;
- UAM_DBG("Connectivity sensors: 0x%8.8X", sensors);
+ sensors &= ~absence_env_sensors;
+ UAM_DBG("ABSENCE Connectivity sensors: 0x%8.8X", sensors);
if (0 != sensors) {
/* Start ABSENCE detection */
}
done:
- if (0 != env_sensors) {
- /* Stop PRESENCE detection on envionmental sensors*/
- ret = _uam_pm_stop_detection(UAM_DETECT_PRESENCE, 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);
- /* Stop ABSENCE detection on envionmental sensors*/
- ret = _uam_pm_stop_detection(UAM_DETECT_ABSENCE, 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);
+ }
- /* Always Start PRESENCE detection on envionmental sensors*/
- ret = _uam_pm_start_detection(UAM_DETECT_PRESENCE, env_sensors);
+ if (0 != absence_env_sensors) {
+ /* Stop ABSENCE detection on envionmental sensors*/
+ ret = _uam_pm_stop_detection(UAM_DETECT_ABSENCE, absence_env_sensors);
if (UAM_ERROR_NONE != ret)
UAM_ERR("Failed with error: %s (0x%4.4X)",
_uam_manager_error_to_str(ret), ret);
- /* Always Start ABSENCE detection on envionmental sensors*/
- ret = _uam_pm_start_detection(UAM_DETECT_ABSENCE, env_sensors);
+ /* Always Start ABSENCE detection on active envionmental sensors*/
+ ret = _uam_pm_start_detection(UAM_DETECT_ABSENCE, absence_env_sensors);
if (UAM_ERROR_NONE != ret)
UAM_ERR("Failed with error: %s (0x%4.4X)",
_uam_manager_error_to_str(ret), ret);