From: kj7.sung Date: Mon, 25 Sep 2017 07:46:29 +0000 (+0900) Subject: [ACR-1070] Fused Location X-Git-Tag: submit/tizen_4.0/20170927.014342^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F73%2F152173%2F1;p=platform%2Fcore%2Fapi%2Flocation-manager.git [ACR-1070] Fused Location Change-Id: Idc1cf763e606520e26106f9cf3233bb53a44d00d Signed-off-by: kj7.sung --- diff --git a/include/location_internal.h b/include/location_internal.h index ce979d2..b3be567 100755 --- a/include/location_internal.h +++ b/include/location_internal.h @@ -121,6 +121,7 @@ int __is_gps_supported(void); int __is_gps_satellite_supported(void); int __is_wps_supported(void); int __is_batch_supported(void); +int __is_fused_supported(void); int __is_location_supported(void); int __set_callback(_location_event_e type, location_manager_h manager, void *callback, void *user_data); int __unset_callback(_location_event_e type, location_manager_h manager); diff --git a/include/locations.h b/include/locations.h index a619fd1..5a121be 100755 --- a/include/locations.h +++ b/include/locations.h @@ -63,6 +63,7 @@ typedef enum { LOCATIONS_METHOD_GPS, /**< This method uses Global Positioning System */ LOCATIONS_METHOD_WPS, /**< This method uses WiFi Positioning System */ LOCATIONS_METHOD_PASSIVE, /**< This method can be used to passively receive location updates without power consumption (Since 3.0)*/ + LOCATIONS_METHOD_FUSED, /**< This method uses Fused location (Since 4.0) */ } location_method_e; @@ -102,6 +103,14 @@ typedef enum { LOCATIONS_ACCESS_STATE_ALLOWED, /**< Access authorized */ } location_accessibility_state_e; +/** + * @brief Enumeration for the fused location service. + * @since_tizen 4.0 + */ +typedef enum { + LOCATIONS_FUSED_HIGH_ACCURACY = 0, /**< High accuracy */ + LOCATIONS_FUSED_BALANCED_POWER, /**< Balanced power */ +} location_fused_mode_e; /** * @brief The location manager handle. @@ -1177,6 +1186,21 @@ int location_manager_set_mock_location(location_manager_h manager, const double */ int location_manager_clear_mock_location(location_manager_h manager); +/** + * @brief Changes behavior of the location source selection in the fused location method. + * @since_tizen 4.0 + * @param[in] manager The location manager handle + * @param[in] mode The fused mode. + * @return @c 0 on success, otherwise a negative error value + * @retval #LOCATIONS_ERROR_NONE Successful + * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #LOCATIONS_ERROR_INCORRECT_METHOD Incorrect method + * @retval #LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE The service is not available + * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported + * @see location_manager_create() + */ +int location_manager_set_fused_mode(location_manager_h manager, location_fused_mode_e mode); + /** * @} diff --git a/packaging/capi-location-manager.spec b/packaging/capi-location-manager.spec index 87d8e31..67f1652 100644 --- a/packaging/capi-location-manager.spec +++ b/packaging/capi-location-manager.spec @@ -1,6 +1,6 @@ Name: capi-location-manager Summary: A Location Manager library in Tizen Native API -Version: 0.7.12 +Version: 0.8.0 Release: 1 Group: Location/API License: Apache-2.0 diff --git a/src/location_internal.c b/src/location_internal.c index 9cc78fe..0ad81f5 100644 --- a/src/location_internal.c +++ b/src/location_internal.c @@ -146,6 +146,21 @@ int __is_batch_supported(void) return LOCATIONS_ERROR_NONE; //LCOV_EXCL_LINE } +int __is_fused_supported(void) +{ + bool is_supported = false; + int retval = 0; + + retval = system_info_get_platform_bool("http://tizen.org/feature/location.fused", &is_supported); + if (retval != SYSTEM_INFO_ERROR_NONE) + LOCATIONS_LOGW("system_info_get_platform_bool failed: retval = %d", retval); + + if (is_supported == false) + return LOCATIONS_ERROR_NOT_SUPPORTED; + + return LOCATIONS_ERROR_NONE; //LCOV_EXCL_LINE +} + int __set_callback(_location_event_e type, location_manager_h manager, void *callback, void *user_data) { LOCATIONS_NULL_ARG_CHECK(manager); diff --git a/src/locations.c b/src/locations.c index 5fdab0d..3fe8082 100755 --- a/src/locations.c +++ b/src/locations.c @@ -21,7 +21,10 @@ #include "locations.h" #include "location_internal.h" -static location_setting_changed_s g_location_setting[LOCATIONS_METHOD_PASSIVE + 1]; +#define LOCATIONS_METHOD_FIRST LOCATIONS_METHOD_HYBRID +#define LOCATIONS_METHOD_LAST LOCATIONS_METHOD_FUSED + +static location_setting_changed_s g_location_setting[LOCATIONS_METHOD_LAST + 1]; static location_method_e __convert_location_method_e(LocationMethod method) { @@ -59,6 +62,9 @@ static LocationMethod __convert_LocationMethod(location_method_e method) case LOCATIONS_METHOD_PASSIVE: _method = LOCATION_METHOD_PASSIVE; break; + case LOCATIONS_METHOD_FUSED: + _method = LOCATION_METHOD_FUSED; + break; case LOCATIONS_METHOD_NONE: default: _method = LOCATION_METHOD_NONE; @@ -488,6 +494,8 @@ EXPORT_API int location_manager_create(location_method_e method, location_manage LOCATIONS_NOT_SUPPORTED_CHECK(__is_wps_supported()); else if (method == LOCATIONS_METHOD_PASSIVE) LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); + else if (method == LOCATIONS_METHOD_FUSED) + LOCATIONS_NOT_SUPPORTED_CHECK(__is_fused_supported()); LocationMethod _method = __convert_LocationMethod(method); if (_method == LOCATION_METHOD_NONE) { @@ -578,7 +586,7 @@ EXPORT_API int location_manager_start(location_manager_h manager) if (!handle->sig_id[_LOCATION_SIGNAL_SERVICE_UPDATED]) handle->sig_id[_LOCATION_SIGNAL_SERVICE_UPDATED] = g_signal_connect(handle->object, "service-updated", G_CALLBACK(__cb_service_updated), handle); - if (handle->method >= LOCATIONS_METHOD_HYBRID && handle->method <= LOCATIONS_METHOD_PASSIVE) { + if (handle->method >= LOCATIONS_METHOD_FIRST && handle->method <= LOCATIONS_METHOD_LAST) { if (!handle->sig_id[_LOCATION_SIGNAL_ZONE_IN]) handle->sig_id[_LOCATION_SIGNAL_ZONE_IN] = g_signal_connect(handle->object, "zone-in", G_CALLBACK(__cb_zone_in), handle); @@ -648,7 +656,7 @@ EXPORT_API int location_manager_stop(location_manager_h manager) handle->sig_id[_LOCATION_SIGNAL_SERVICE_UPDATED] = 0; } - if (handle->method >= LOCATIONS_METHOD_HYBRID && handle->method <= LOCATIONS_METHOD_PASSIVE) { + if (handle->method >= LOCATIONS_METHOD_FIRST && handle->method <= LOCATIONS_METHOD_LAST) { if (handle->sig_id[_LOCATION_SIGNAL_ZONE_IN]) { g_signal_handler_disconnect(handle->object, handle->sig_id[_LOCATION_SIGNAL_ZONE_IN]); handle->sig_id[_LOCATION_SIGNAL_ZONE_IN] = 0; @@ -747,6 +755,9 @@ EXPORT_API int location_manager_get_method(location_manager_h manager, location_ case LOCATION_METHOD_PASSIVE: *method = LOCATIONS_METHOD_PASSIVE; break; + case LOCATION_METHOD_FUSED: + *method = LOCATIONS_METHOD_FUSED; + break; default: { LOCATIONS_LOGE("[LOCATIONS_ERROR_INVALID_PARAMETER] invalid method"); //LCOV_EXCL_LINE return LOCATIONS_ERROR_INVALID_PARAMETER; //LCOV_EXCL_LINE @@ -1166,7 +1177,7 @@ EXPORT_API int location_manager_set_setting_changed_cb(location_method_e method, if (_method == LOCATION_METHOD_NONE) { return __convert_error_code(LOCATION_ERROR_PARAMETER); - } else if (_method == LOCATION_METHOD_PASSIVE) { + } else if (_method == LOCATION_METHOD_PASSIVE || _method == LOCATION_METHOD_FUSED) { LOCATIONS_LOGE("LOCATIONS_ERROR_INCORRECT_METHOD"); //LCOV_EXCL_LINE return LOCATIONS_ERROR_INCORRECT_METHOD; //LCOV_EXCL_LINE } @@ -1190,7 +1201,7 @@ EXPORT_API int location_manager_unset_setting_changed_cb(location_method_e metho if (_method == LOCATION_METHOD_NONE) { return __convert_error_code(LOCATION_ERROR_PARAMETER); - } else if (_method == LOCATION_METHOD_PASSIVE) { + } else if (_method == LOCATION_METHOD_PASSIVE || _method == LOCATION_METHOD_FUSED) { LOCATIONS_LOGE("LOCATIONS_ERROR_INCORRECT_METHOD"); //LCOV_EXCL_LINE return LOCATIONS_ERROR_INCORRECT_METHOD; //LCOV_EXCL_LINE } @@ -1676,3 +1687,21 @@ EXPORT_API int location_manager_clear_mock_location(location_manager_h manager) return __convert_error_code(ret); } + +EXPORT_API int location_manager_set_fused_mode(location_manager_h manager, location_fused_mode_e mode) +{ + LOCATIONS_NOT_SUPPORTED_CHECK(__is_fused_supported()); + LOCATIONS_NULL_ARG_CHECK(manager); + LOCATIONS_CHECK_CONDITION(mode >= LOCATIONS_FUSED_HIGH_ACCURACY && mode <= LOCATIONS_FUSED_BALANCED_POWER, LOCATIONS_ERROR_INVALID_PARAMETER, "LOCATIONS_ERROR_INVALID_PARAMETER"); + + location_manager_s *handle = (location_manager_s *) manager; + int ret = LOCATION_ERROR_NONE; + + ret = location_set_fused_mode(handle->object, mode); + if (ret == LOCATION_ERROR_NOT_SUPPORTED) { + LOCATIONS_LOGE("LOCATIONS_ERROR_INCORRECT_METHOD"); + return LOCATIONS_ERROR_INCORRECT_METHOD; + } + + return __convert_error_code(ret); +}