diff options
author | kj7.sung <kj7.sung@samsung.com> | 2017-08-22 16:52:03 +0900 |
---|---|---|
committer | kj7.sung <kj7.sung@samsung.com> | 2017-09-25 17:17:41 +0900 |
commit | d243e5d89aea6bcecc5c1a1c0054ab9055da412f (patch) | |
tree | 0d47a60f7835c3aba65f49c90b6f9e4187d1f304 | |
parent | 85e9b33c1b7219e1b7a86b2c33ff8d80ead0d91b (diff) | |
download | location-manager-d243e5d89aea6bcecc5c1a1c0054ab9055da412f.tar.gz location-manager-d243e5d89aea6bcecc5c1a1c0054ab9055da412f.tar.bz2 location-manager-d243e5d89aea6bcecc5c1a1c0054ab9055da412f.zip |
sync : [ACR-1070] Fused Locationsubmit/tizen/20170927.014732accepted/tizen/unified/20170928.072411
Change-Id: I0ada46050dce984fa939a0fa45c96bebd405bead
Signed-off-by: kj7.sung <kj7.sung@samsung.com>
-rwxr-xr-x | include/location_internal.h | 1 | ||||
-rwxr-xr-x | include/locations.h | 24 | ||||
-rw-r--r-- | packaging/capi-location-manager.spec | 2 | ||||
-rw-r--r-- | src/location_internal.c | 15 | ||||
-rwxr-xr-x | src/locations.c | 39 | ||||
-rwxr-xr-x | test/location_test.c | 23 |
6 files changed, 90 insertions, 14 deletions
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 dda2f3a..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.11 +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); +} diff --git a/test/location_test.c b/test/location_test.c index 04d8210..95272ee 100755 --- a/test/location_test.c +++ b/test/location_test.c @@ -340,8 +340,7 @@ void _location_changed_cb(double latitude, double longitude, double altitude, do bool _get_location_cb(double latitude, double longitude, double altitude, double speed, double direction, double horizontal, double vertical, time_t timestamp, void *user_data) { - fprintf(stderr, "-------------------------- batch: get location --------------------------\n"); - fprintf(stderr, "[%ld] lat[%f] lon[%f] alt[%f] speed[%lf] direction[%lf], horizontal_accuracy[%lf]\n", timestamp, latitude, longitude, altitude, speed, direction, horizontal); + fprintf(stderr, "[%ld] pos[%f, %f, %f] spd[%.1f] dir[%.1f], hor[%.1f]\n", timestamp, latitude, longitude, altitude, speed, direction, horizontal); return TRUE; } @@ -387,7 +386,7 @@ static void print_location_status() fprintf(stderr, "gps: %d, ", is_enabled); location_manager_is_enabled_method(LOCATIONS_METHOD_WPS, &is_enabled); - fprintf(stderr, "wps: %d, ", is_enabled); + fprintf(stderr, "wps: %d \n", is_enabled); } static int enable_method(location_method_e method, bool enable) @@ -719,8 +718,19 @@ static void location_cleanup() { int ret = 0; if (manager != NULL) { - ret = location_manager_stop(manager); - fprintf(stderr, "stop: %d\n", ret); + if (menu == 31) { + ret = location_manager_stop_batch(manager); + fprintf(stderr, "stop_batch: %d\n", ret); + + ret = location_manager_unset_location_batch_cb(manager); + fprintf(stderr, "unset_batch_cb: %d\n", ret); + } else { + ret = location_manager_stop(manager); + fprintf(stderr, "stop: %d\n", ret); + + ret = gps_status_unset_satellite_updated_cb(manager); + fprintf(stderr, "gps_status_unset_satellite_updated_cb: %d\n", ret); + } ret = location_manager_unset_service_state_changed_cb(manager); fprintf(stderr, "unset_service_state_changed_cb: %d\n", ret); @@ -728,9 +738,6 @@ static void location_cleanup() ret = location_manager_unset_position_updated_cb(manager); fprintf(stderr, "unset_position_updated_cb: %d\n", ret); - ret = gps_status_unset_satellite_updated_cb(manager); - fprintf(stderr, "gps_status_unset_satellite_updated_cb: %d\n", ret); - ret = location_manager_destroy(manager); fprintf(stderr, "destroy: %d\n", ret); manager = NULL; |