gboolean start_detection = FALSE;
GSList *l;
unsigned int env_sensors;
+ unsigned int loc_sensors;
env_sensors = _uam_core_get_active_env_sensors(UAM_DETECT_PRESENCE) |
_uam_core_get_active_env_sensors(UAM_DETECT_ABSENCE);
_uam_manager_error_to_str(ret), ret);
}
+ /* location detection */
+ loc_sensors = _uam_core_get_active_sensors(UAM_DETECT_LOCATION);
+ UAM_DBG("Active sensors for location detection: 0x%8.8X", loc_sensors);
+
+ if (0 != loc_sensors) {
+ /* Start location detection */
+ ret = _uam_pm_start_detection(UAM_DETECT_LOCATION, loc_sensors);
+ if (UAM_ERROR_NONE != ret)
+ UAM_ERR("Failed with error: %s (0x%4.4X)",
+ _uam_manager_error_to_str(ret), ret);
+ }
+
FUNC_EXIT;
return TRUE;
}
int ret = UAM_ERROR_NONE;
unsigned int remaining_sensors;
unsigned int active_sensors;
+ unsigned int remaining_sensors_loc;
+ unsigned int active_sensors_loc;
uam_monitor_info_t *monitor;
uam_db_service_info_t *service;
/* Find sensors which are already monitoring */
active_sensors = _uam_core_get_active_sensors(UAM_DETECT_PRESENCE) |
_uam_core_get_active_sensors(UAM_DETECT_ABSENCE);
- UAM_DBG("sensors: 0x%8.8X, Active sensors: 0x%8.8X",
- sensors, active_sensors);
+ active_sensors_loc = _uam_core_get_active_sensors(UAM_DETECT_LOCATION);
+
+ UAM_DBG("sensors: 0x%8.8X, Active sensors: 0x%8.8X " \
+ "Active sensors location 0x%8.8X",
+ sensors, active_sensors, active_sensors_loc);
/* Update monitor info for application */
monitor->sensors &= ~sensors;
/* Find sensors which are already monitoring */
remaining_sensors = _uam_core_get_active_sensors(UAM_DETECT_PRESENCE) |
_uam_core_get_active_sensors(UAM_DETECT_ABSENCE);
- UAM_DBG("Remaining sensors: 0x%8.8X", remaining_sensors);
+ remaining_sensors_loc = _uam_core_get_active_sensors(UAM_DETECT_LOCATION);
+
+ UAM_DBG("Remaining sensors: 0x%8.8X Remaining sensors location: 0x%8.8X",
+ remaining_sensors, remaining_sensors_loc);
+
+ /* Stop location detection */
+ if (detection_type == UAM_DETECT_LOCATION &&
+ (active_sensors_loc != remaining_sensors_loc)) {
+
+ ret = _uam_pm_stop_detection(UAM_DETECT_LOCATION,
+ active_sensors_loc & ~remaining_sensors_loc);
+ if (UAM_ERROR_NONE != ret)
+ UAM_ERR("Failed with error: %s (0x%4.4X)",
+ _uam_manager_error_to_str(ret), ret);
+ return ret;
+ }
if (active_sensors == remaining_sensors) {
UAM_INFO("No need to stop monitoring");
return ret;
}
+int _uam_core_start_location_detection(const char *svc_name, char *sender,
+ unsigned int sensors, int app_num)
+{
+ FUNC_ENTRY;
+ int ret;
+
+ ret = __uam_core_start_detection(UAM_DETECT_LOCATION,
+ svc_name, sender, sensors, app_num);
+
+ FUNC_EXIT;
+ return ret;
+}
+
+int _uam_core_stop_location_detection(const char *svc_name, char *sender,
+ unsigned int sensors, int app_num)
+{
+ FUNC_ENTRY;
+ int ret;
+
+ ret = __uam_core_stop_detection(UAM_DETECT_LOCATION,
+ svc_name, sender, sensors, app_num);
+
+ FUNC_EXIT;
+ return ret;
+}
+
int _uam_core_set_low_power_mode(unsigned int bitmask, gboolean mode)
{
FUNC_ENTRY;
{ UAM_REQUEST_STOP_PRESENCE_DETECTION, UAM_PRIVTYPE_DEVICE | UAM_PRIVTYPE_LOCATION, UAM_SYNC_FUNCTION },
{ UAM_REQUEST_START_ABSENCE_DETECTION, UAM_PRIVTYPE_DEVICE | UAM_PRIVTYPE_LOCATION, UAM_SYNC_FUNCTION },
{ UAM_REQUEST_STOP_ABSENCE_DETECTION, UAM_PRIVTYPE_DEVICE | UAM_PRIVTYPE_LOCATION, UAM_SYNC_FUNCTION },
+ { UAM_REQUEST_START_LOCATION_DETECTION, UAM_PRIVTYPE_DEVICE | UAM_PRIVTYPE_LOCATION, UAM_SYNC_FUNCTION },
+ { UAM_REQUEST_STOP_LOCATION_DETECTION, UAM_PRIVTYPE_DEVICE | UAM_PRIVTYPE_LOCATION, UAM_SYNC_FUNCTION },
{ UAM_REQUEST_SET_LOW_POWER_MODE, UAM_PRIVTYPE_NA, UAM_SYNC_FUNCTION },
{ UAM_REQUEST_START_SEARCH_ACTIVE_DEVICES, UAM_PRIVTYPE_DEVICE | UAM_PRIVTYPE_LOCATION, UAM_SYNC_FUNCTION },
{ UAM_REQUEST_STOP_SEARCH_ACTIVE_DEVICES, UAM_PRIVTYPE_DEVICE | UAM_PRIVTYPE_LOCATION, UAM_SYNC_FUNCTION },
result = _uam_core_stop_absence_detection(svc_name, sender, sensors, app_num);
break;
}
+ case UAM_REQUEST_START_LOCATION_DETECTION: {
+ const char *svc_name;
+ unsigned int sensors;
+
+ __uam_manager_copy_params(in_param1,
+ &sensors, sizeof(unsigned int));
+ svc_name = (char *)g_variant_get_data(in_param2);
+
+ result = _uam_core_start_location_detection(svc_name,
+ sender, sensors, app_num);
+ break;
+ }
+ case UAM_REQUEST_STOP_LOCATION_DETECTION: {
+ unsigned int sensors;
+ const char *svc_name;
+
+ __uam_manager_copy_params(in_param1,
+ &sensors, sizeof(unsigned int));
+ svc_name = (char *)g_variant_get_data(in_param2);
+
+ result = _uam_core_stop_location_detection(svc_name,
+ sender, sensors, app_num);
+ break;
+ }
case UAM_REQUEST_SET_LOW_POWER_MODE: {
gboolean mode = FALSE;
unsigned int bitmask = 0;
case UAM_REQUEST_START_PRESENCE_DETECTION:
case UAM_REQUEST_STOP_PRESENCE_DETECTION:
case UAM_REQUEST_START_ABSENCE_DETECTION:
- case UAM_REQUEST_STOP_ABSENCE_DETECTION: {
+ case UAM_REQUEST_STOP_ABSENCE_DETECTION:
+ case UAM_REQUEST_START_LOCATION_DETECTION:
+ case UAM_REQUEST_STOP_LOCATION_DETECTION: {
unsigned int bitmask = 0;
__uam_manager_copy_params(in_param1,