From a8eab71b77cdb2cd0f43ebfe2094ee3944ca610a Mon Sep 17 00:00:00 2001 From: "kj7.sung" Date: Tue, 19 Jul 2016 19:18:54 +0900 Subject: [PATCH] [ACR-746] Passive Location Signed-off-by: kj7.sung Change-Id: Ice011d8b67b05fd3a93f04d53a3aef0de74c9041 --- CMakeLists.txt | 1 - include/locations.h | 2 ++ packaging/capi-location-manager.changes | 6 ++++++ packaging/capi-location-manager.spec | 2 +- src/locations.c | 24 ++++++++++++++++++++---- 5 files changed, 29 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index edcb331..db1aff2 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,6 @@ FOREACH(flag ${dependents_CFLAGS}) ENDFOREACH(flag) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fvisibility=hidden -fPIC -Wall -Werror") -#SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fvisibility=hidden -fPIC -Wall -Werror -Wno-error=deprecated-declarations") SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") IF("${ARCH}" STREQUAL "arm") diff --git a/include/locations.h b/include/locations.h index 81c8c9a..952e27f 100755 --- a/include/locations.h +++ b/include/locations.h @@ -60,6 +60,7 @@ typedef enum { LOCATIONS_METHOD_HYBRID, /**< This method selects the best method available at the moment */ 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)*/ } location_method_e; /** @@ -345,6 +346,7 @@ int location_manager_destroy(location_manager_h manager); * @param[in] user_data The user data to be passed to the callback function * @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 Service not available * @retval #LOCATIONS_ERROR_NETWORK_FAILED Network failed * @retval #LOCATIONS_ERROR_GPS_SETTING_OFF GPS is not enabled diff --git a/packaging/capi-location-manager.changes b/packaging/capi-location-manager.changes index 04e87c9..f1ed36c 100644 --- a/packaging/capi-location-manager.changes +++ b/packaging/capi-location-manager.changes @@ -1,3 +1,9 @@ +[Version] capi-location-manager_0.7.4 +[Date] 6 Sep 2016 +[Title] Passive location +[Developer] Kyoungjun Sung + +================================================================================ [Version] capi-location-manager_0.7.3 [Date] 18 Aug 2016 [Title] Change mock location behavior diff --git a/packaging/capi-location-manager.spec b/packaging/capi-location-manager.spec index 7753586..7369f84 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.3 +Version: 0.7.4 Release: 1 Group: Location/API License: Apache-2.0 diff --git a/src/locations.c b/src/locations.c index 4a46c58..b148c9a 100755 --- a/src/locations.c +++ b/src/locations.c @@ -21,7 +21,7 @@ #include "locations.h" #include "location_internal.h" -static location_setting_changed_s g_location_setting[LOCATIONS_METHOD_WPS + 1]; +static location_setting_changed_s g_location_setting[LOCATIONS_METHOD_PASSIVE + 1]; static location_method_e __convert_location_method_e(LocationMethod method) { @@ -56,6 +56,9 @@ static LocationMethod __convert_LocationMethod(location_method_e method) case LOCATIONS_METHOD_WPS: _method = LOCATION_METHOD_WPS; break; + case LOCATIONS_METHOD_PASSIVE: + _method = LOCATION_METHOD_PASSIVE; + break; case LOCATIONS_METHOD_NONE: default: _method = LOCATION_METHOD_NONE; @@ -490,6 +493,11 @@ EXPORT_API int location_manager_create(location_method_e method, location_manage LOCATIONS_LOGE("LOCATIONS_ERROR_NOT_SUPPORTED(0x%08x) : fail to location feature", LOCATIONS_ERROR_NOT_SUPPORTED); return LOCATIONS_ERROR_NOT_SUPPORTED; } + } else if (method == LOCATIONS_METHOD_PASSIVE) { + if (__is_location_supported() == LOCATIONS_ERROR_NOT_SUPPORTED) { + LOCATIONS_LOGE("LOCATIONS_ERROR_NOT_SUPPORTED(0x%08x) : fail to location feature", LOCATIONS_ERROR_NOT_SUPPORTED); + return LOCATIONS_ERROR_NOT_SUPPORTED; + } } LocationMethod _method = __convert_LocationMethod(method); @@ -591,7 +599,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_WPS) { + if (handle->method >= LOCATIONS_METHOD_HYBRID && handle->method <= LOCATIONS_METHOD_PASSIVE) { 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); @@ -635,8 +643,13 @@ EXPORT_API int location_manager_request_single_location(location_manager_h manag return ret; ret = location_request_single_location(handle->object, timeout); - if (ret != LOCATION_ERROR_NONE) + if (ret != LOCATION_ERROR_NONE) { + if (ret == LOCATION_ERROR_NOT_SUPPORTED) { + LOCATIONS_LOGE("LOCATIONS_ERROR_INCORRECT_METHOD : method - %d", handle->method); + return LOCATIONS_ERROR_INCORRECT_METHOD; + } return __convert_error_code(ret); + } return LOCATIONS_ERROR_NONE; } @@ -654,7 +667,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_WPS) { + if (handle->method >= LOCATIONS_METHOD_HYBRID && handle->method <= LOCATIONS_METHOD_PASSIVE) { 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; @@ -750,6 +763,9 @@ EXPORT_API int location_manager_get_method(location_manager_h manager, location_ case LOCATION_METHOD_WPS: *method = LOCATIONS_METHOD_WPS; break; + case LOCATION_METHOD_PASSIVE: + *method = LOCATIONS_METHOD_PASSIVE; + break; default: { LOCATIONS_LOGE("[LOCATIONS_ERROR_INVALID_PARAMETER] method : %d ", method); return LOCATIONS_ERROR_INVALID_PARAMETER; -- 2.34.1