From e961bdc7e9e1e96b78015788558d6ca48a979ac6 Mon Sep 17 00:00:00 2001 From: "kj7.sung" Date: Wed, 9 Sep 2015 13:33:21 +0900 Subject: [PATCH] Sync with 2.4 Signed-off-by: kj7.sung Change-Id: I2bd9f69e865d1da493f01a4413eafd8c1fdaf46c --- doc/location-manager-doc.h | 7 +- include/location_bounds.h | 22 ++--- include/location_internal.h | 26 ++--- include/locations.h | 44 ++++----- packaging/capi-location-manager.changes | 5 - packaging/capi-location-manager.spec | 27 +++-- src/location_bounds.c | 42 +++----- src/location_internal.c | 15 +++ src/locations.c | 170 +++++++++++++++++++------------- test/location_test.c | 90 ++++++++--------- 10 files changed, 239 insertions(+), 209 deletions(-) diff --git a/doc/location-manager-doc.h b/doc/location-manager-doc.h index ada3251..84a93f1 100644 --- a/doc/location-manager-doc.h +++ b/doc/location-manager-doc.h @@ -153,10 +153,11 @@ * This API is related with the following features:\n * - http://tizen.org/feature/location\n * - http://tizen.org/feature/location.gps\n + * - http://tizen.org/feature/location.gps.satellite\n * * It is recommended to design feature related codes in your application for reliability.\n * - * You can check if a devrice supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n + * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n * * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n * @@ -186,7 +187,7 @@ * * It is recommended to design feature related codes in your application for reliability.\n * - * You can check if a devrice supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n + * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n * * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n * @@ -216,7 +217,7 @@ * * It is recommended to design feature related codes in your application for reliability.\n * - * You can check if a devrice supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n + * You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n * * To ensure your application is only running on the device with specific features, please define the features in your manifest file using the manifest editor in the SDK.\n * diff --git a/include/location_bounds.h b/include/location_bounds.h index 05526ed..f5a2f07 100644 --- a/include/location_bounds.h +++ b/include/location_bounds.h @@ -44,12 +44,12 @@ typedef struct { * @brief Enumeration for error code for Location manager. */ typedef enum { - LOCATION_BOUNDS_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ - LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ - LOCATION_BOUNDS_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ - LOCATION_BOUNDS_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */ - LOCATION_BOUNDS_ERROR_INCORRECT_TYPE = LOCATION_BOUNDS_ERROR_CLASS | 0x01, /**< Incorrect bounds type for a given call */ - LOCATION_BOUNDS_ERROR_IS_ADDED = LOCATION_BOUNDS_ERROR_CLASS | 0x02, /**< Cannot remove bounds handle from location manager */ + LOCATION_BOUNDS_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ + LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ + LOCATION_BOUNDS_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ + LOCATION_BOUNDS_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */ + LOCATION_BOUNDS_ERROR_INCORRECT_TYPE = LOCATION_BOUNDS_ERROR_CLASS | 0x01, /**< Incorrect bounds type for a given call */ + LOCATION_BOUNDS_ERROR_IS_ADDED = LOCATION_BOUNDS_ERROR_CLASS | 0x02, /**< Cannot remove bounds handle from location manager */ } location_bound_error_e; /** @@ -57,9 +57,9 @@ typedef enum { * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { - LOCATION_BOUNDS_RECT = 1, /**< Rectangular geographical area type. */ - LOCATION_BOUNDS_CIRCLE, /**< Circle geographical area type.. */ - LOCATION_BOUNDS_POLYGON, /**< Polygon geographical area type.. */ + LOCATION_BOUNDS_RECT = 1, /**< Rectangular geographical area type. */ + LOCATION_BOUNDS_CIRCLE, /**< Circle geographical area type.. */ + LOCATION_BOUNDS_POLYGON, /**< Polygon geographical area type.. */ } location_bounds_type_e; /** @@ -67,8 +67,8 @@ typedef enum { * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { - LOCATIONS_BOUNDARY_IN, /**< Boundary In (Zone In) */ - LOCATIONS_BOUNDARY_OUT /**< Boundary Out (Zone Out) */ + LOCATIONS_BOUNDARY_IN, /**< Boundary In (Zone In) */ + LOCATIONS_BOUNDARY_OUT /**< Boundary Out (Zone Out) */ } location_boundary_state_e; /** diff --git a/include/location_internal.h b/include/location_internal.h index cbb2668..1dd6a7d 100644 --- a/include/location_internal.h +++ b/include/location_internal.h @@ -57,10 +57,10 @@ extern "C" { #define LOCATIONS_NULL_ARG_CHECK(arg) \ LOCATIONS_CHECK_CONDITION((arg != NULL),LOCATION_BOUNDS_ERROR_INVALID_PARAMETER,"LOCATION_BOUNDS_ERROR_INVALID_PARAMETER") \ - + #define LOCATIONS_NOT_SUPPORTED_CHECK(arg) \ LOCATIONS_CHECK_CONDITION((arg == LOCATIONS_ERROR_NONE),LOCATIONS_ERROR_NOT_SUPPORTED,"LOCATIONS_ERROR_NOT_SUPPORTED") \ - + typedef enum { _LOCATIONS_EVENT_TYPE_SERVICE_STATE, _LOCATIONS_EVENT_TYPE_POSITION, @@ -74,19 +74,18 @@ typedef enum { _LOCATIONS_EVENT_TYPE_DISTANCE, _LOCATIONS_EVENT_TYPE_POS_VEL, _LOCATIONS_EVENT_TYPE_NUM -} -_location_event_e; +} _location_event_e; typedef enum { - _LOCATION_SIGNAL_SERVICE_ENABLED, - _LOCATION_SIGNAL_SERVICE_DISABLED, - _LOCATION_SIGNAL_SERVICE_UPDATED, - _LOCATION_SIGNAL_ZONE_IN, - _LOCATION_SIGNAL_ZONE_OUT, - _LOCATION_SIGNAL_LOCATION_UPDATED, - _LOCATION_SIGNAL_BATCH_UPDATED, - _LOCATION_SIGNAL_ERROR_EMITTED, - _LOCATION_SIGNAL_NUM + _LOCATION_SIGNAL_SERVICE_ENABLED, + _LOCATION_SIGNAL_SERVICE_DISABLED, + _LOCATION_SIGNAL_SERVICE_UPDATED, + _LOCATION_SIGNAL_ZONE_IN, + _LOCATION_SIGNAL_ZONE_OUT, + _LOCATION_SIGNAL_LOCATION_UPDATED, + _LOCATION_SIGNAL_BATCH_UPDATED, + _LOCATION_SIGNAL_ERROR_EMITTED, + _LOCATION_SIGNAL_NUM } _location_signal_e; typedef struct _location_manager_s { @@ -118,6 +117,7 @@ typedef struct _location_setting_changed_s { */ int __convert_error_code(int code); int __is_gps_supported(void); +int __is_gps_satellite_supported(void); int __is_wps_supported(void); int __is_location_supported(void); int __set_callback(_location_event_e type, location_manager_h manager, void *callback, void *user_data); diff --git a/include/locations.h b/include/locations.h index 35e69e3..3715e6c 100644 --- a/include/locations.h +++ b/include/locations.h @@ -39,7 +39,7 @@ typedef enum { LOCATIONS_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ LOCATIONS_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ LOCATIONS_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ - LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */ + LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */ LOCATIONS_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Not supported */ LOCATIONS_ERROR_INCORRECT_METHOD = TIZEN_ERROR_LOCATION_MANAGER | 0x01, /**< Location manager contains incorrect method for a given call */ LOCATIONS_ERROR_NETWORK_FAILED = TIZEN_ERROR_LOCATION_MANAGER | 0x02, /**< Network unavailable */ @@ -54,10 +54,10 @@ typedef enum { * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { - LOCATIONS_METHOD_NONE = -1, /**< Undefined method */ - 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_NONE = -1, /**< Undefined method */ + 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 */ } location_method_e; /** @@ -65,13 +65,13 @@ typedef enum { * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { - LOCATIONS_ACCURACY_NONE = 0, /**< Invalid data */ - LOCATIONS_ACCURACY_COUNTRY, /**< Country accuracy level */ - LOCATIONS_ACCURACY_REGION, /**< Regional accuracy level */ - LOCATIONS_ACCURACY_LOCALITY, /**< Local accuracy level */ - LOCATIONS_ACCURACY_POSTALCODE, /**< Postal accuracy level */ - LOCATIONS_ACCURACY_STREET, /**< Street accuracy level */ - LOCATIONS_ACCURACY_DETAILED, /**< Detailed accuracy level */ + LOCATIONS_ACCURACY_NONE = 0, /**< Invalid data */ + LOCATIONS_ACCURACY_COUNTRY, /**< Country accuracy level */ + LOCATIONS_ACCURACY_REGION, /**< Regional accuracy level */ + LOCATIONS_ACCURACY_LOCALITY, /**< Local accuracy level */ + LOCATIONS_ACCURACY_POSTALCODE, /**< Postal accuracy level */ + LOCATIONS_ACCURACY_STREET, /**< Street accuracy level */ + LOCATIONS_ACCURACY_DETAILED, /**< Detailed accuracy level */ } location_accuracy_level_e; /** @@ -79,8 +79,8 @@ typedef enum { * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { - LOCATIONS_SERVICE_DISABLED, /**< Service is disabled */ - LOCATIONS_SERVICE_ENABLED, /**< Service is enabled */ + LOCATIONS_SERVICE_DISABLED, /**< Service is disabled */ + LOCATIONS_SERVICE_ENABLED, /**< Service is enabled */ } location_service_state_e; /** @@ -88,9 +88,9 @@ typedef enum { * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif */ typedef enum { - LOCATIONS_ACCESS_STATE_NONE, /**< Access state is not determined */ - LOCATIONS_ACCESS_STATE_DENIED, /**< Access denied */ - LOCATIONS_ACCESS_STATE_ALLOWED, /**< Access authorized */ + LOCATIONS_ACCESS_STATE_NONE, /**< Access state is not determined */ + LOCATIONS_ACCESS_STATE_DENIED, /**< Access denied */ + LOCATIONS_ACCESS_STATE_ALLOWED, /**< Access authorized */ } location_accessibility_state_e; /** @@ -259,12 +259,12 @@ int location_manager_is_enabled_method(location_method_e method, bool *enable); * @since_tizen 2.3.1 * @privlevel platform * @privilege %http://tizen.org/privilege/location.enable - * @param[in] method The location method to be checked - * @param[in] enable The value to set + * @param[in] method The location method to be checked + * @param[in] enable The value to set * @return 0 on success, otherwise a negative error value * @retval #LOCATIONS_ERROR_NONE Successful * @retval #LOCATIONS_ERROR_INCORRECT_METHOD Incorrect method - * @retval #LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED Permission denied + * @retval #LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED Permission denied * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported * @see location_manager_is_enabled_method() * @see location_manager_create() @@ -915,9 +915,8 @@ typedef void(*gps_status_satellite_updated_cb)(int num_of_active, int num_of_inv * @return @c 0 on success, otherwise a negative error value * @retval #LOCATIONS_ERROR_NONE Successful * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid argument - * @retval #LOCATIONS_ERROR_INCORRECT_METHOD Incorrect method * @retval #LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE Service not available - * @retval #LOCATIONS_ERROR_OUT_OF_MEMORY Out of memory + * @retval #LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED The application does not have the privilege to call this method * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported * @pre The location service state must be #LOCATIONS_SERVICE_ENABLED with location_manager_start() * @see location_manager_start() @@ -937,7 +936,6 @@ int gps_status_get_nmea(location_manager_h manager, char **nmea); * @return @c 0 on success, otherwise a negative error value * @retval #LOCATIONS_ERROR_NONE Successful * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid argument - * @retval #LOCATIONS_ERROR_INCORRECT_METHOD Incorrect method * @retval #LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE Service not available * @retval #LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED The application does not have the privilege to call this method * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported diff --git a/packaging/capi-location-manager.changes b/packaging/capi-location-manager.changes index aa2d833..6e5df2a 100644 --- a/packaging/capi-location-manager.changes +++ b/packaging/capi-location-manager.changes @@ -217,9 +217,6 @@ ================================================================================ -* Fri May 31 2013 Anas Nashif accepted/tizen/20130520.100703@f7a18ab -- Remove placeholders and cleanup spec - capi-location-manager (0.1.7-1) precise; urgency=low * Change Dlog Format @@ -493,5 +490,3 @@ capi-location-manager (0.0.1-1) unstable; urgency=low * Tag: capi-location-manager_0.0.1-1 -- Kangho Hur Thu, 04 Aug 2011 16:51:02 +0900 - - diff --git a/packaging/capi-location-manager.spec b/packaging/capi-location-manager.spec index 2c77208..7842f31 100755 --- a/packaging/capi-location-manager.spec +++ b/packaging/capi-location-manager.spec @@ -1,17 +1,17 @@ -Name: capi-location-manager -Summary: A Location Manager library in Tizen Native API -Version: 0.6.1 -Release: 1 -Group: Location/API -License: Apache-2.0 -Source0: %{name}-%{version}.tar.gz +Name: capi-location-manager +Summary: A Location Manager library in Tizen Native API +Version: 0.6.3 +Release: 1 +Group: Location/API +License: Apache-2.0 +Source0: %{name}-%{version}.tar.gz Source1001: %{name}.manifest -BuildRequires: cmake -BuildRequires: pkgconfig(dlog) -BuildRequires: pkgconfig(lbs-location) -BuildRequires: pkgconfig(capi-base-common) -BuildRequires: pkgconfig(capi-system-info) -BuildRequires: pkgconfig(vconf) +BuildRequires: cmake +BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(lbs-location) +BuildRequires: pkgconfig(capi-base-common) +BuildRequires: pkgconfig(capi-system-info) +BuildRequires: pkgconfig(vconf) Requires(post): /sbin/ldconfig Requires(postun): /sbin/ldconfig @@ -39,7 +39,6 @@ export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE" export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE" MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` -#cmake . -DCMAKE_INSTALL_PREFIX=/usr -DFULLVER=%{version} -DMAJORVER=${MAJORVER} \ cmake . -DCMAKE_INSTALL_PREFIX=%{_prefix} -DLIBDIR=%{_libdir} -DINCLUDEDIR=%{_includedir} \ -DFULLVER=%{version} -DMAJORVER=${MAJORVER} \ diff --git a/src/location_bounds.c b/src/location_bounds.c index f4f0201..3f16f6f 100755 --- a/src/location_bounds.c +++ b/src/location_bounds.c @@ -59,6 +59,16 @@ EXPORT_API int location_bounds_create_rect(location_coords_s top_left, location_ LOCATIONS_CHECK_CONDITION(bottom_right.latitude >= -90 && bottom_right.latitude <= 90, LOCATION_BOUNDS_ERROR_INVALID_PARAMETER, "LOCATION_BOUNDS_ERROR_INVALID_PARAMETER"); LOCATIONS_CHECK_CONDITION(bottom_right.longitude >= -180 && bottom_right.longitude <= 180, LOCATION_BOUNDS_ERROR_INVALID_PARAMETER, "LOCATION_BOUNDS_ERROR_INVALID_PARAMETER"); + if ((bottom_right.longitude - top_left.longitude) < 180 && (bottom_right.longitude - top_left.longitude) > -180) { + if (bottom_right.longitude <= top_left.longitude || bottom_right.latitude >= top_left.latitude) { + return LOCATION_BOUNDS_ERROR_INVALID_PARAMETER; + } + } else { + if (bottom_right.latitude >= top_left.latitude) { + return LOCATION_BOUNDS_ERROR_INVALID_PARAMETER; + } + } + LocationPosition *lt = location_position_new(0, top_left.latitude, top_left.longitude, 0, LOCATION_STATUS_2D_FIX); if (lt == NULL) { LOCATIONS_LOGE("LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY(0x%08x) : fail to location_position_new", LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY); @@ -90,8 +100,6 @@ EXPORT_API int location_bounds_create_rect(location_coords_s top_left, location_ free(handle); return LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY; } - handle->user_cb = NULL; - handle->user_data = NULL; *bounds = (location_bounds_h) handle; return LOCATION_BOUNDS_ERROR_NONE; @@ -101,7 +109,7 @@ EXPORT_API int location_bounds_create_circle(location_coords_s center, double ra { LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); LOCATIONS_NULL_ARG_CHECK(bounds); - LOCATIONS_CHECK_CONDITION(radius >= 0, LOCATION_BOUNDS_ERROR_INVALID_PARAMETER, "LOCATION_BOUNDS_ERROR_INVALID_PARAMETER"); + LOCATIONS_CHECK_CONDITION(radius > 0, LOCATION_BOUNDS_ERROR_INVALID_PARAMETER, "LOCATION_BOUNDS_ERROR_INVALID_PARAMETER"); LOCATIONS_CHECK_CONDITION(center.latitude >= -90 && center.latitude <= 90, LOCATION_BOUNDS_ERROR_INVALID_PARAMETER, "LOCATION_BOUNDS_ERROR_INVALID_PARAMETER"); LOCATIONS_CHECK_CONDITION(center.longitude >= -180 && center.longitude <= 180, LOCATION_BOUNDS_ERROR_INVALID_PARAMETER, "LOCATION_BOUNDS_ERROR_INVALID_PARAMETER"); @@ -123,18 +131,10 @@ EXPORT_API int location_bounds_create_circle(location_coords_s center, double ra handle->boundary = location_boundary_new_for_circle(ct, radius); location_position_free(ct); if (handle->boundary == NULL) { - int ret = get_last_result(); free(handle); - if (ret == LOCATION_ERROR_PARAMETER) { - LOCATIONS_LOGE("LOCATION_BOUNDS_ERROR_INVALID_PARAMETER(0x%08x) fail to location_boundary_new_for_circle", LOCATION_BOUNDS_ERROR_INVALID_PARAMETER); - return LOCATION_BOUNDS_ERROR_INVALID_PARAMETER; - } else { - LOCATIONS_LOGE("LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY(0x%08x) : fail to location_boundary_new_for_circle", LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY); - return LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY; - } + LOCATIONS_LOGE("LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY(0x%08x) : fail to location_boundary_new_for_circle", LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY); + return LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY; } - handle->user_cb = NULL; - handle->user_data = NULL; *bounds = (location_bounds_h) handle; return LOCATION_BOUNDS_ERROR_NONE; @@ -160,8 +160,7 @@ EXPORT_API int location_bounds_create_polygon(location_coords_s *coords_list, in } position = location_position_new(0, coords_list[i].latitude, coords_list[i].longitude, 0.0, LOCATION_STATUS_2D_FIX); position_list = g_list_append(position_list, position); - - /* We should not remove position + /* We should not remove position. location_position_free(position); */ isValid = TRUE; @@ -188,20 +187,11 @@ EXPORT_API int location_bounds_create_polygon(location_coords_s *coords_list, in handle->is_added = FALSE; handle->boundary = location_boundary_new_for_polygon(position_list); if (handle->boundary == NULL) { - int ret = get_last_result(); free(handle); - if (ret == LOCATION_ERROR_PARAMETER) { - LOCATIONS_LOGE("LOCATION_BOUNDS_ERROR_INVALID_PARAMETER(0x%08x) fail to location_boundary_new_for_polygon", LOCATION_BOUNDS_ERROR_INVALID_PARAMETER); - return LOCATION_BOUNDS_ERROR_INVALID_PARAMETER; - } else { - LOCATIONS_LOGE("LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY(0x%08x) : fail to location_boundary_new_for_polygon", LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY); - return LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY; - } + LOCATIONS_LOGE("LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY(0x%08x) : fail to location_boundary_new_for_polygon", LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY); + return LOCATION_BOUNDS_ERROR_OUT_OF_MEMORY; } - handle->user_cb = NULL; - handle->user_data = NULL; - *bounds = (location_bounds_h) handle; return LOCATION_BOUNDS_ERROR_NONE; } diff --git a/src/location_internal.c b/src/location_internal.c index 7b9867f..5f4d378 100644 --- a/src/location_internal.c +++ b/src/location_internal.c @@ -83,6 +83,21 @@ int __is_gps_supported(void) return LOCATIONS_ERROR_NONE; } +int __is_gps_satellite_supported(void) +{ + bool is_supported = false; + int retval = 0; + + retval = system_info_get_platform_bool("http://tizen.org/feature/location.gps.satellite", &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; +} + int __is_wps_supported(void) { bool is_supported = false; diff --git a/src/locations.c b/src/locations.c index 1f2951a..3fe8cce 100755 --- a/src/locations.c +++ b/src/locations.c @@ -72,26 +72,26 @@ static void __cb_service_updated(GObject *self, guint type, gpointer data, gpoin if (type == SATELLITE_UPDATED && handle->user_cb[_LOCATIONS_EVENT_TYPE_SATELLITE]) { LocationSatellite *sat = (LocationSatellite *)data; LOCATIONS_LOGD("Current satellite information: timestamp : %d, number of active : %d, number of inview : %d", - sat->timestamp, sat->num_of_sat_used, sat->num_of_sat_inview); + sat->timestamp, sat->num_of_sat_used, sat->num_of_sat_inview); ((gps_status_satellite_updated_cb) handle->user_cb[_LOCATIONS_EVENT_TYPE_SATELLITE])(sat->num_of_sat_used, sat->num_of_sat_inview, - sat->timestamp, handle->user_data[_LOCATIONS_EVENT_TYPE_SATELLITE]); + sat->timestamp, handle->user_data[_LOCATIONS_EVENT_TYPE_SATELLITE]); } else if (type == DISTANCE_UPDATED && handle->user_cb[_LOCATIONS_EVENT_TYPE_DISTANCE]) { LocationPosition *pos = (LocationPosition *) data; LocationVelocity *vel = (LocationVelocity *) velocity; /* current velocity */ ((location_changed_cb) handle->user_cb[_LOCATIONS_EVENT_TYPE_DISTANCE])(0, pos->latitude, pos->longitude, pos->altitude, - vel->speed, vel->direction, pos->timestamp, handle->user_data[_LOCATIONS_EVENT_TYPE_DISTANCE]); + vel->speed, vel->direction, pos->timestamp, handle->user_data[_LOCATIONS_EVENT_TYPE_DISTANCE]); } else { if (handle->user_cb[_LOCATIONS_EVENT_TYPE_POSITION] && (type & POSITION_UPDATED) != 0) { LocationPosition *pos = (LocationPosition *) data; ((location_position_updated_cb) handle->user_cb[_LOCATIONS_EVENT_TYPE_POSITION])(pos->latitude, pos->longitude, pos->altitude, pos->timestamp, - handle->user_data[_LOCATIONS_EVENT_TYPE_POSITION]); + handle->user_data[_LOCATIONS_EVENT_TYPE_POSITION]); } if (handle->user_cb[_LOCATIONS_EVENT_TYPE_VELOCITY] && (type & VELOCITY_UPDATED) != 0) { - LocationVelocity *vel = (LocationVelocity *) data; + LocationVelocity *vel = (LocationVelocity *) velocity; ((location_velocity_updated_cb) handle->user_cb[_LOCATIONS_EVENT_TYPE_VELOCITY])(vel->speed, vel->direction, vel->climb, vel->timestamp, - handle->user_data[_LOCATIONS_EVENT_TYPE_VELOCITY]); + handle->user_data[_LOCATIONS_EVENT_TYPE_VELOCITY]); } if (handle->user_cb[_LOCATIONS_EVENT_TYPE_POS_VEL] && (type & LOCATION_CHANGED) != 0) { @@ -99,7 +99,7 @@ static void __cb_service_updated(GObject *self, guint type, gpointer data, gpoin LocationVelocity *vel = (LocationVelocity *) velocity; LocationAccuracy *acc = (LocationAccuracy *) accuracy; ((location_changed_cb) handle->user_cb[_LOCATIONS_EVENT_TYPE_POS_VEL])(pos->latitude, pos->longitude, pos->altitude, - vel->speed, vel->direction, acc->horizontal_accuracy, pos->timestamp, handle->user_data[_LOCATIONS_EVENT_TYPE_POS_VEL]); + vel->speed, vel->direction, acc->horizontal_accuracy, pos->timestamp, handle->user_data[_LOCATIONS_EVENT_TYPE_POS_VEL]); } } } @@ -115,7 +115,7 @@ static void __cb_location_updated(GObject *self, int error, gpointer position, g LOCATIONS_LOGD("Current position: timestamp : %d", pos->timestamp); if (handle->user_cb[_LOCATIONS_EVENT_TYPE_LOCATION]) { ((location_updated_cb) handle->user_cb[_LOCATIONS_EVENT_TYPE_LOCATION])(converted_err, pos->latitude, pos->longitude, pos->altitude, - pos->timestamp, vel->speed, vel->climb, vel->direction, handle->user_data[_LOCATIONS_EVENT_TYPE_LOCATION]); + pos->timestamp, vel->speed, vel->climb, vel->direction, handle->user_data[_LOCATIONS_EVENT_TYPE_LOCATION]); } } @@ -125,8 +125,7 @@ static void __cb_service_enabled(GObject *self, guint status, gpointer userdata) location_manager_s *handle = (location_manager_s *) userdata; if (handle->user_cb[_LOCATIONS_EVENT_TYPE_SERVICE_STATE]) { ((location_service_state_changed_cb) - handle->user_cb[_LOCATIONS_EVENT_TYPE_SERVICE_STATE])(LOCATIONS_SERVICE_ENABLED, - handle->user_data[_LOCATIONS_EVENT_TYPE_SERVICE_STATE]); + handle->user_cb[_LOCATIONS_EVENT_TYPE_SERVICE_STATE])(LOCATIONS_SERVICE_ENABLED, handle->user_data[_LOCATIONS_EVENT_TYPE_SERVICE_STATE]); } } @@ -136,8 +135,7 @@ static void __cb_service_disabled(GObject *self, guint status, gpointer userdata location_manager_s *handle = (location_manager_s *) userdata; if (handle->user_cb[_LOCATIONS_EVENT_TYPE_SERVICE_STATE]) ((location_service_state_changed_cb) - handle->user_cb[_LOCATIONS_EVENT_TYPE_SERVICE_STATE])(LOCATIONS_SERVICE_DISABLED, - handle->user_data[_LOCATIONS_EVENT_TYPE_SERVICE_STATE]); + handle->user_cb[_LOCATIONS_EVENT_TYPE_SERVICE_STATE])(LOCATIONS_SERVICE_DISABLED,handle->user_data[_LOCATIONS_EVENT_TYPE_SERVICE_STATE]); } static int __compare_position(gconstpointer a, gconstpointer b) @@ -183,7 +181,7 @@ static int __boundary_compare(LocationBoundary *bound1, LocationBoundary *bound2 boundary1_next = g_list_next(bound1->polygon.position_list); if (boundary1_next != NULL && boundary2_prev != NULL && - location_position_equal((LocationPosition *)boundary1_next->data, (LocationPosition *)boundary2_prev->data) == TRUE) { + location_position_equal((LocationPosition *)boundary1_next->data, (LocationPosition *)boundary2_prev->data) == TRUE) { boundary1_next = g_list_next(boundary1_next); while (boundary1_next) { boundary2_prev = g_list_previous(boundary2_prev); @@ -195,7 +193,7 @@ static int __boundary_compare(LocationBoundary *bound1, LocationBoundary *bound2 } ret = 0; } else if (boundary1_next != NULL && boundary2_next != NULL && - location_position_equal((LocationPosition *)boundary1_next->data, (LocationPosition *)boundary2_next->data) == TRUE) { + location_position_equal((LocationPosition *)boundary1_next->data, (LocationPosition *)boundary2_next->data) == TRUE) { boundary1_next = g_list_next(boundary1_next); while (boundary1_next) { boundary2_next = g_list_next(boundary2_next); @@ -225,10 +223,10 @@ static void __cb_zone_in(GObject *self, gpointer boundary, gpointer position, gp if (handle->user_cb[_LOCATIONS_EVENT_TYPE_BOUNDARY]) { LocationPosition *pos = (LocationPosition *) position; ((location_zone_changed_cb) handle->user_cb[_LOCATIONS_EVENT_TYPE_BOUNDARY])(LOCATIONS_BOUNDARY_IN, - pos->latitude, pos->longitude, - pos->altitude, pos->timestamp, - handle->user_data - [_LOCATIONS_EVENT_TYPE_BOUNDARY]); + pos->latitude, pos->longitude, + pos->altitude, pos->timestamp, + handle->user_data + [_LOCATIONS_EVENT_TYPE_BOUNDARY]); } location_bounds_s *bounds; @@ -254,10 +252,10 @@ static void __cb_zone_out(GObject *self, gpointer boundary, gpointer position, g if (handle->user_cb[_LOCATIONS_EVENT_TYPE_BOUNDARY]) { LocationPosition *pos = (LocationPosition *) position; ((location_zone_changed_cb) handle->user_cb[_LOCATIONS_EVENT_TYPE_BOUNDARY])(LOCATIONS_BOUNDARY_OUT, - pos->latitude, pos->longitude, - pos->altitude, pos->timestamp, - handle->user_data - [_LOCATIONS_EVENT_TYPE_BOUNDARY]); + pos->latitude, pos->longitude, + pos->altitude, pos->timestamp, + handle->user_data + [_LOCATIONS_EVENT_TYPE_BOUNDARY]); } location_bounds_s *bounds; @@ -320,10 +318,10 @@ static void __foreach_boundary(LocationBoundary *boundary, void *user_data) } else { if (handle->is_continue_foreach_bounds) { handle->is_continue_foreach_bounds = - ((location_bounds_cb) handle->user_cb[_LOCATIONS_EVENT_TYPE_FOREACH_BOUNDS])(bounds, - handle-> - user_data - [_LOCATIONS_EVENT_TYPE_FOREACH_BOUNDS]); + ((location_bounds_cb) handle->user_cb[_LOCATIONS_EVENT_TYPE_FOREACH_BOUNDS])(bounds, + handle-> + user_data + [_LOCATIONS_EVENT_TYPE_FOREACH_BOUNDS]); } location_bounds_destroy(bounds); } @@ -334,7 +332,7 @@ static void __foreach_boundary(LocationBoundary *boundary, void *user_data) static void __setting_changed_cb(LocationMethod method, gboolean enable, void *user_data) { - LOCATIONS_LOGD("__setting_changed_cb method [%d]", method); + LOCATIONS_LOGD("method: [%d]", method); location_method_e _method = __convert_location_method_e(method); location_setting_changed_s *_setting_changed = (location_setting_changed_s *)user_data; if (_setting_changed == NULL) { @@ -359,6 +357,18 @@ EXPORT_API bool location_manager_is_supported_method(location_method_e method) return false; } + if (method == LOCATIONS_METHOD_GPS) { + if (__is_gps_supported() == LOCATIONS_ERROR_NOT_SUPPORTED) { + set_last_result(LOCATIONS_ERROR_NOT_SUPPORTED); + return false; + } + } else if (method == LOCATIONS_METHOD_WPS) { + if (__is_wps_supported() == LOCATIONS_ERROR_NOT_SUPPORTED) { + set_last_result(LOCATIONS_ERROR_NOT_SUPPORTED); + return false; + } + } + LocationMethod _method = __convert_LocationMethod(method); if (_method == LOCATION_METHOD_NONE) { LOCATIONS_LOGE("Not supported method [%d]", method); @@ -389,8 +399,9 @@ EXPORT_API int location_manager_is_enabled_method(location_method_e method, bool return LOCATIONS_ERROR_INCORRECT_METHOD; return __convert_error_code(ret); } - if (is_enabled_val == -1) + if (is_enabled_val == -1) { return TIZEN_ERROR_PERMISSION_DENIED; + } *enable = (is_enabled_val == 0) ? FALSE : TRUE; return LOCATIONS_ERROR_NONE; @@ -407,17 +418,54 @@ EXPORT_API int location_manager_enable_method(const location_method_e method, co LOCATIONS_LOGD("method: %d, enable: %d", method, enable); - LocationMethod _method = __convert_LocationMethod(method); + int ret = 0; + if (LOCATIONS_METHOD_HYBRID == method) { + if (__is_gps_supported() == LOCATIONS_ERROR_NONE) { + ret = location_enable_method(LOCATION_METHOD_GPS, enable); + if (ret != LOCATIONS_ERROR_NONE) return __convert_error_code(ret); + } + if (__is_wps_supported() == LOCATIONS_ERROR_NONE) { + ret = location_enable_method(LOCATION_METHOD_WPS, enable); + return __convert_error_code(ret); + } + return LOCATIONS_ERROR_NONE; + + } else { + if ((LOCATIONS_METHOD_GPS == method) && (__is_gps_supported() == LOCATIONS_ERROR_NOT_SUPPORTED)) { + LOCATIONS_LOGE("LOCATIONS_ERROR_NOT_SUPPORTED(0x%08x)", LOCATIONS_ERROR_NOT_SUPPORTED); + return LOCATIONS_ERROR_NOT_SUPPORTED; + } + else if ((LOCATIONS_METHOD_WPS == method) && (__is_wps_supported() == LOCATIONS_ERROR_NOT_SUPPORTED)) { + LOCATIONS_LOGE("LOCATIONS_ERROR_NOT_SUPPORTED(0x%08x)", LOCATIONS_ERROR_NOT_SUPPORTED); + return LOCATIONS_ERROR_NOT_SUPPORTED; + } + + LocationMethod _method = __convert_LocationMethod(method); + + int ret = location_enable_method(_method, enable); - int ret = location_enable_method(_method, enable); - return __convert_error_code(ret); + return __convert_error_code(ret); + } } EXPORT_API int location_manager_create(location_method_e method, location_manager_h *manager) { LOCATIONS_LOGD("location_manager_create (method : %d)", method); - LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); + + if (method == LOCATIONS_METHOD_HYBRID) { + LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); + } else if (method == LOCATIONS_METHOD_GPS) { + if (__is_gps_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; + } + } else if (method == LOCATIONS_METHOD_WPS) { + if (__is_wps_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); if (_method == LOCATION_METHOD_NONE) { @@ -662,7 +710,7 @@ EXPORT_API int location_manager_get_method(location_manager_h manager, location_ break; default: { LOCATIONS_LOGE("LOCATIONS_ERROR_INVALID_PARAMETER(0x%08x) : Out of range (location_method_e) - method : %d ", - LOCATIONS_ERROR_INVALID_PARAMETER, method); + LOCATIONS_ERROR_INVALID_PARAMETER, method); return LOCATIONS_ERROR_INVALID_PARAMETER; } } @@ -671,7 +719,7 @@ EXPORT_API int location_manager_get_method(location_manager_h manager, location_ } EXPORT_API int location_manager_get_position(location_manager_h manager, double *altitude, double *latitude, double *longitude, - time_t *timestamp) + time_t *timestamp) { LOCATIONS_LOGD("location_manager_get_position"); LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); @@ -779,7 +827,7 @@ EXPORT_API int location_manager_get_velocity(location_manager_h manager, double } EXPORT_API int location_manager_get_accuracy(location_manager_h manager, location_accuracy_level_e *level, double *horizontal, - double *vertical) + double *vertical) { LOCATIONS_LOGD("location_manager_get_accuracy"); LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); @@ -809,8 +857,7 @@ EXPORT_API int location_manager_get_accuracy(location_manager_h manager, locatio return LOCATIONS_ERROR_NONE; } -EXPORT_API int location_manager_get_last_position(location_manager_h manager, double *altitude, double *latitude, double *longitude, - time_t *timestamp) +EXPORT_API int location_manager_get_last_position(location_manager_h manager, double *altitude, double *latitude, double *longitude, time_t *timestamp) { LOCATIONS_LOGD("location_manager_get_last_position"); LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); @@ -919,8 +966,7 @@ EXPORT_API int location_manager_get_last_velocity(location_manager_h manager, do return LOCATIONS_ERROR_NONE; } -EXPORT_API int location_manager_get_last_accuracy(location_manager_h manager, location_accuracy_level_e *level, double *horizontal, - double *vertical) +EXPORT_API int location_manager_get_last_accuracy(location_manager_h manager, location_accuracy_level_e *level, double *horizontal, double *vertical) { LOCATIONS_LOGD("location_manager_get_last_accuracy"); LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); @@ -1022,8 +1068,7 @@ EXPORT_API int location_manager_set_position_updated_cb(location_manager_h manag { LOCATIONS_LOGD("location_manager_set_position_updated_cb"); LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); - LOCATIONS_CHECK_CONDITION(interval >= 1 - && interval <= 120, LOCATIONS_ERROR_INVALID_PARAMETER, "LOCATIONS_ERROR_INVALID_PARAMETER"); + LOCATIONS_CHECK_CONDITION(interval >= 1 && interval <= 120, LOCATIONS_ERROR_INVALID_PARAMETER, "LOCATIONS_ERROR_INVALID_PARAMETER"); LOCATIONS_NULL_ARG_CHECK(manager); location_manager_s *handle = (location_manager_s *) manager; g_object_set(handle->object, "pos-interval", interval, NULL); @@ -1056,7 +1101,7 @@ EXPORT_API int location_manager_unset_velocity_updated_cb(location_manager_h man } EXPORT_API int location_manager_set_service_state_changed_cb(location_manager_h manager, location_service_state_changed_cb callback, - void *user_data) + void *user_data) { LOCATIONS_LOGD("location_manager_set_service_state_changed_cb"); LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported()); @@ -1164,7 +1209,7 @@ EXPORT_API int location_manager_get_distance(double start_latitude, double start EXPORT_API int gps_status_get_nmea(location_manager_h manager, char **nmea) { LOCATIONS_LOGD("gps_status_get_nmea"); - LOCATIONS_NOT_SUPPORTED_CHECK(__is_gps_supported()); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_gps_satellite_supported()); LOCATIONS_NULL_ARG_CHECK(manager); LOCATIONS_NULL_ARG_CHECK(nmea); location_manager_s *handle = (location_manager_s *) manager; @@ -1177,8 +1222,7 @@ EXPORT_API int gps_status_get_nmea(location_manager_h manager, char **nmea) return LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED; } - LOCATIONS_LOGE("LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE(0x%08x) : NMEA is NULL ", - LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE); + LOCATIONS_LOGE("LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE(0x%08x) : NMEA is NULL ", LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE); return LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE; } @@ -1191,7 +1235,7 @@ EXPORT_API int gps_status_get_nmea(location_manager_h manager, char **nmea) EXPORT_API int gps_status_get_satellite(location_manager_h manager, int *num_of_active, int *num_of_inview, time_t *timestamp) { LOCATIONS_LOGD("gps_status_get_satellite"); - LOCATIONS_NOT_SUPPORTED_CHECK(__is_gps_supported()); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_gps_satellite_supported()); LOCATIONS_NULL_ARG_CHECK(manager); LOCATIONS_NULL_ARG_CHECK(num_of_active); LOCATIONS_NULL_ARG_CHECK(num_of_inview); @@ -1205,8 +1249,7 @@ EXPORT_API int gps_status_get_satellite(location_manager_h manager, int *num_of_ return LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED; } - LOCATIONS_LOGE("LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE(0x%08x) : satellite is NULL ", - LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE); + LOCATIONS_LOGE("LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE(0x%08x) : satellite is NULL ", LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE); return LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE; } @@ -1221,7 +1264,7 @@ EXPORT_API int gps_status_get_satellite(location_manager_h manager, int *num_of_ EXPORT_API int gps_status_set_satellite_updated_cb(location_manager_h manager, gps_status_satellite_updated_cb callback, int interval, void *user_data) { LOCATIONS_LOGD("gps_status_set_satellite_updated_cb"); - LOCATIONS_NOT_SUPPORTED_CHECK(__is_gps_supported()); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_gps_satellite_supported()); LOCATIONS_CHECK_CONDITION(interval >= 1 && interval <= 120, LOCATIONS_ERROR_INVALID_PARAMETER, "LOCATIONS_ERROR_INVALID_PARAMETER"); LOCATIONS_NULL_ARG_CHECK(manager); LOCATIONS_NULL_ARG_CHECK(callback); @@ -1235,14 +1278,14 @@ EXPORT_API int gps_status_set_satellite_updated_cb(location_manager_h manager, g EXPORT_API int gps_status_unset_satellite_updated_cb(location_manager_h manager) { LOCATIONS_LOGD("gps_status_unset_satellite_updated_cb"); - LOCATIONS_NOT_SUPPORTED_CHECK(__is_gps_supported()); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_gps_satellite_supported()); return __unset_callback(_LOCATIONS_EVENT_TYPE_SATELLITE, manager); } EXPORT_API int gps_status_foreach_satellites_in_view(location_manager_h manager, gps_status_get_satellites_cb callback, void *user_data) { LOCATIONS_LOGD("gps_status_foreach_satellites_in_view"); - LOCATIONS_NOT_SUPPORTED_CHECK(__is_gps_supported()); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_gps_satellite_supported()); LOCATIONS_NULL_ARG_CHECK(manager); LOCATIONS_NULL_ARG_CHECK(callback); @@ -1251,16 +1294,14 @@ EXPORT_API int gps_status_foreach_satellites_in_view(location_manager_h manager, int ret = location_get_satellite(handle->object, &sat); if (ret != LOCATION_ERROR_NONE || sat == NULL) { if (ret == LOCATION_ERROR_NOT_SUPPORTED) { - LOCATIONS_LOGE("LOCATIONS_ERROR_INCORRECT_METHOD(0x%08x) : method - %d", - LOCATIONS_ERROR_INCORRECT_METHOD, handle->method); + LOCATIONS_LOGE("LOCATIONS_ERROR_INCORRECT_METHOD(0x%08x) : method - %d", LOCATIONS_ERROR_INCORRECT_METHOD, handle->method); return LOCATIONS_ERROR_INCORRECT_METHOD; } else if (ret == LOCATION_ERROR_NOT_ALLOWED) { LOCATIONS_LOGE("LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED"); return LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED; } - LOCATIONS_LOGE("LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE(0x%08x) : satellite is NULL ", - LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE); + LOCATIONS_LOGE("LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE(0x%08x) : satellite is NULL ", LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE); return LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE; } @@ -1283,7 +1324,7 @@ EXPORT_API int gps_status_foreach_satellites_in_view(location_manager_h manager, EXPORT_API int gps_status_get_last_satellite(location_manager_h manager, int *num_of_active, int *num_of_inview, time_t *timestamp) { LOCATIONS_LOGD("gps_status_get_last_satellite"); - LOCATIONS_NOT_SUPPORTED_CHECK(__is_gps_supported()); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_gps_satellite_supported()); LOCATIONS_NULL_ARG_CHECK(manager); LOCATIONS_NULL_ARG_CHECK(num_of_active); LOCATIONS_NULL_ARG_CHECK(num_of_inview); @@ -1295,16 +1336,14 @@ EXPORT_API int gps_status_get_last_satellite(location_manager_h manager, int *nu ret = location_get_last_satellite(handle->object, &last_sat); if (ret != LOCATION_ERROR_NONE || last_sat == NULL) { if (ret == LOCATION_ERROR_NOT_SUPPORTED) { - LOCATIONS_LOGE("LOCATIONS_ERROR_INCORRECT_METHOD(0x%08x) : method - %d", - LOCATIONS_ERROR_INCORRECT_METHOD, handle->method); + LOCATIONS_LOGE("LOCATIONS_ERROR_INCORRECT_METHOD(0x%08x) : method - %d", LOCATIONS_ERROR_INCORRECT_METHOD, handle->method); return LOCATIONS_ERROR_INCORRECT_METHOD; } else if (ret == LOCATION_ERROR_NOT_ALLOWED) { LOCATIONS_LOGE("LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED"); return LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED; } - LOCATIONS_LOGE("LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE(0x%08x) : satellite is NULL ", - LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE); + LOCATIONS_LOGE("LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE(0x%08x) : satellite is NULL ", LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE); return LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE; } @@ -1315,11 +1354,10 @@ EXPORT_API int gps_status_get_last_satellite(location_manager_h manager, int *nu return LOCATIONS_ERROR_NONE; } -EXPORT_API int gps_status_foreach_last_satellites_in_view(location_manager_h manager, gps_status_get_satellites_cb callback, - void *user_data) +EXPORT_API int gps_status_foreach_last_satellites_in_view(location_manager_h manager, gps_status_get_satellites_cb callback, void *user_data) { LOCATIONS_LOGD("gps_status_foreach_last_satellites_in_view"); - LOCATIONS_NOT_SUPPORTED_CHECK(__is_gps_supported()); + LOCATIONS_NOT_SUPPORTED_CHECK(__is_gps_satellite_supported()); LOCATIONS_NULL_ARG_CHECK(manager); LOCATIONS_NULL_ARG_CHECK(callback); location_manager_s *handle = (location_manager_s *) manager; @@ -1328,13 +1366,11 @@ EXPORT_API int gps_status_foreach_last_satellites_in_view(location_manager_h man ret = location_get_last_satellite(handle->object, &last_sat); if (ret != LOCATION_ERROR_NONE || last_sat == NULL) { if (ret == LOCATION_ERROR_NOT_SUPPORTED) { - LOCATIONS_LOGE("LOCATIONS_ERROR_INCORRECT_METHOD(0x%08x) : method - %d", - LOCATIONS_ERROR_INCORRECT_METHOD, handle->method); + LOCATIONS_LOGE("LOCATIONS_ERROR_INCORRECT_METHOD(0x%08x) : method - %d", LOCATIONS_ERROR_INCORRECT_METHOD, handle->method); return LOCATIONS_ERROR_INCORRECT_METHOD; } - LOCATIONS_LOGE("LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE(0x%08x) : satellite is NULL ", - LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE); + LOCATIONS_LOGE("LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE(0x%08x) : satellite is NULL ", LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE); return LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE; } diff --git a/test/location_test.c b/test/location_test.c index e4aacf4..bed24cb 100755 --- a/test/location_test.c +++ b/test/location_test.c @@ -29,6 +29,7 @@ static int menu; static int repeat_count; static void location_cleanup(); static int location_test(); +static guint test_timer; static gboolean exit_program(gpointer data) { @@ -39,6 +40,11 @@ static gboolean exit_program(gpointer data) static gboolean wait_test() { + if (test_timer) { + g_source_remove(test_timer); + test_timer = 0; + } + location_cleanup(); location_test(); @@ -302,7 +308,7 @@ void _position_updated_cb(double latitude, double longitude, double altitude, ti repeat_count++; if (repeat_count > 2) { - g_timeout_add_seconds(1, wait_test, NULL); + test_timer = g_timeout_add_seconds(1, wait_test, NULL); } } @@ -318,7 +324,7 @@ void _location_cb(int error, double latitude, double longitude, double altitude, printf("location_cb: lat[%f] lon[%f] alt[%f]\n", latitude, longitude, altitude); printf("speed[%f] climb[%f] direction[%f]\n", speed, climb, direction); - g_timeout_add_seconds(1, wait_test, NULL); + test_timer = g_timeout_add_seconds(1, wait_test, NULL); } void _location_changed_cb(double latitude, double longitude, double altitude, double speed, double direction, double horizontal_accuracy, time_t timestamp, void *user_data) @@ -329,7 +335,7 @@ void _location_changed_cb(double latitude, double longitude, double altitude, do repeat_count++; if (repeat_count > 2) { - g_timeout_add_seconds(1, wait_test, NULL); + test_timer = g_timeout_add_seconds(1, wait_test, NULL); } } @@ -353,7 +359,7 @@ void _location_batch_cb(int num_of_location, void *user_data) repeat_count++; if (repeat_count > 1) { - g_timeout_add_seconds(1, wait_test, NULL); + test_timer = g_timeout_add_seconds(1, wait_test, NULL); } } @@ -364,7 +370,7 @@ static void __setting_cb(location_method_e method, bool enable, void *user_data) static void print_location_status() { - printf("==== LOCATION STATUS ======\n"); + printf("==== LOCATION Setting state =====\n"); bool is_enabled = FALSE; location_manager_is_enabled_method(LOCATIONS_METHOD_HYBRID, &is_enabled); printf("hybrid: %d, ", is_enabled); @@ -379,20 +385,20 @@ static void print_location_status() static int enable_method(location_method_e method, bool enable) { int ret = 0; - printf("==== LOCATION STATUS ======\n"); + printf("==== LOCATION Setting changed =====\n"); location_manager_set_setting_changed_cb(LOCATIONS_METHOD_HYBRID, __setting_cb, NULL); - location_manager_set_setting_changed_cb(LOCATIONS_METHOD_GPS, __setting_cb, NULL); - location_manager_set_setting_changed_cb(LOCATIONS_METHOD_WPS, __setting_cb, NULL); + printf("method[%d], enable[%d]\n", method, enable); ret = location_manager_enable_method(method, enable); - printf("method[%d]: %d\n", method, enable); + + location_manager_unset_setting_changed_cb(LOCATIONS_METHOD_HYBRID); return ret; } static void print_menu() { - printf("==== LOCATION TEST ======\n"); + printf("============= LOCATION TEST =============\n"); printf("[1] Get location: LOCATIONS_METHOD_HYBRID\n"); printf("[2] Get location: LOCATIONS_METHOD_GPS\n"); printf("[3] Get location: LOCATIONS_METHOD_WPS\n"); @@ -422,30 +428,23 @@ static int location_test() int ret = LOCATIONS_ERROR_NONE; int basic = 0; int interval = 1; + repeat_count = 0; print_location_status(); print_menu(); switch (menu) { case 1: - basic = 1; - ret = location_manager_create(LOCATIONS_METHOD_HYBRID, &manager); - printf("LOCATIONS_METHOD_HYBRID create: %d\n", ret); - ret = location_manager_start(manager); - printf("start: %d\n", ret); - break; case 2: + case 3: { basic = 1; - ret = location_manager_create(LOCATIONS_METHOD_GPS, &manager); - printf("LOCATIONS_METHOD_GPS create: %d\n", ret); - ret = location_manager_start(manager); - printf("start: %d\n", ret); - break; - case 3: - basic = 1; - ret = location_manager_create(LOCATIONS_METHOD_WPS, &manager); + + int method = menu - 1; + ret = location_manager_create(method, &manager); + printf("location_manager_create (method: %d): %d\n", method, ret); ret = location_manager_start(manager); printf("start: %d\n", ret); + } break; case 4: case 5: @@ -464,35 +463,33 @@ static int location_test() case 11: case 12: case 13: { - repeat_count = 0; int interval = 1; printf("\n Input position interval ==> "); ret = scanf("%d", &interval); - int method = menu - 4; + int method = menu - 11; ret = location_manager_create(method, &manager); printf("location_manager_create (method: %d): %d\n", method, ret); ret = location_manager_set_position_updated_cb(manager, _position_updated_cb, interval, (void *)manager); - printf("set position changed callback: %d\n", ret); + printf("set_position_updated_cb: %d\n", ret); /* ret = location_manager_set_velocity_updated_cb(manager, _velocity_updated_cb, interval*2, (void *)manager); - printf("set velocity changed callback: %d\n", ret); + printf("set_velocity_updated_cb: %d\n", ret); */ ret = location_manager_set_location_changed_cb(manager, _location_changed_cb, interval * 2, (void *)manager); - printf("set location changed callback: %d\n", ret); + printf("set_location_changed_cb: %d\n", ret); ret = location_manager_start(manager); - repeat_count = 0; + printf("start: %d\n", ret); break; } case 21: case 22: case 23: { - repeat_count = 0; int interval = 1; int method = menu - 21; @@ -506,13 +503,13 @@ static int location_test() /*printf("set position changed callback: %d\n", ret); */ ret = location_manager_set_distance_based_location_changed_cb(manager, _location_changed_cb, interval, 30, (void *)manager); - printf("set location changed callback: %d\n", ret); + printf("set_distance_based_location_changed_cb: %d\n", ret); ret = location_manager_start(manager); + printf("start: %d\n", ret); break; } case 31: { - repeat_count = 0; int interval = 1; printf("\n Input batch interval ==> "); ret = scanf("%d", &interval); @@ -526,9 +523,10 @@ static int location_test() printf("location_manager_create (method : %d)\n", LOCATIONS_METHOD_GPS); ret = location_manager_set_location_batch_cb(manager, _location_batch_cb, interval, period, (void *)manager); - printf("set location batch callback: %d\n", ret); + printf("set_location_batch_cb: %d\n", ret); ret = location_manager_start_batch(manager); + printf("start_batch: %d\n", ret); break; } case 41: @@ -541,7 +539,7 @@ static int location_test() ret = scanf("%d", &onoff); ret = enable_method(method, onoff); - printf("Enabling method[%d]: %d\n", method, ret); + printf("Enabling method: [%d], ret=%d\n", method, ret); break; } @@ -563,40 +561,40 @@ static int location_test() testLocationCoordinates.longitude = 12; location_bound_error_e nRet = location_bounds_create_polygon(location_coord_list, nPolySize, &hPolyLocationBound); - printf("location_bounds_create_polygon= %d\n", nRet); + printf("location_bounds_create_polygon: %d\n", nRet); bIsContained = location_bounds_contains_coordinates(hPolyLocationBound, testLocationCoordinates);// Target API - printf("bIsContained : %d\n", bIsContained); + printf("bIsContained: %d\n", bIsContained); location_bounds_destroy(hPolyLocationBound); break; } case 0: - g_timeout_add_seconds(0.1, exit_program, NULL); + g_timeout_add_seconds(1, exit_program, NULL); return 0; default: printf("Exit!!! Input: %d\n", menu); - g_timeout_add_seconds(0.1, exit_program, NULL); + g_timeout_add_seconds(1, exit_program, NULL); return 0; } if (ret != LOCATIONS_ERROR_NONE) { printf("Test Failed!!! [%d]\n", ret); - g_timeout_add_seconds(0.1, exit_program, NULL); + g_timeout_add_seconds(1, exit_program, NULL); return 0; } if (menu < 40) { ret = location_manager_set_service_state_changed_cb(manager, _state_change_cb, (void *)manager); - printf("set state changed callback: %d\n", ret); + printf("set_service_state_changed_cb: %d\n", ret); if (basic) { ret = location_manager_set_position_updated_cb(manager, _position_updated_cb, interval, (void *)manager); - printf("set position changed callback: %d\n", ret); + printf("set_position_updated_cb: %d\n", ret); } } else { - g_timeout_add_seconds(0.1, wait_test, NULL); + g_timeout_add_seconds(1, wait_test, NULL); } return 0; @@ -610,17 +608,15 @@ static void location_cleanup() printf("stop: %d\n", ret); ret = location_manager_unset_service_state_changed_cb(manager); - printf("unset: %d\n", ret); + printf("unset_service_state_changed_cb: %d\n", ret); ret = location_manager_unset_position_updated_cb(manager); - printf("unset: %d\n", ret); + printf("unset_position_updated_cb: %d\n", ret); ret = location_manager_destroy(manager); printf("destroy: %d\n", ret); manager = NULL; } - location_manager_unset_setting_changed_cb(LOCATIONS_METHOD_GPS); - location_manager_unset_setting_changed_cb(LOCATIONS_METHOD_WPS); } int main(int argc, char **argv) -- 2.7.4