CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
SET(fw_name "capi-location-manager")
-PROJECT(${fw_name})
+PROJECT(${fw_name} C)
SET(CMAKE_INSTALL_PREFIX /usr)
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
_LOCATION_SIGNAL_LOCATION_UPDATED,
_LOCATION_SIGNAL_BATCH_UPDATED,
_LOCATION_SIGNAL_ERROR_EMITTED,
+ _LOCATION_SIGNAL_STATUS_CHANGED,
_LOCATION_SIGNAL_NUM
} _location_signal_e;
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 */
LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE = TIZEN_ERROR_LOCATION_MANAGER | 0x03, /**< Location service is not available */
- LOCATIONS_ERROR_GPS_SETTING_OFF = TIZEN_ERROR_LOCATION_MANAGER | 0x04, /**< GPS/WPS setting is not enabled */
+ LOCATIONS_ERROR_GPS_SETTING_OFF = TIZEN_ERROR_LOCATION_MANAGER | 0x04, /**< Setting for GPS, WPS, or MOCK is turned off */
LOCATIONS_ERROR_SECURITY_RESTRICTED = TIZEN_ERROR_LOCATION_MANAGER | 0x05, /**< Restricted by security system policy */
+ LOCATIONS_ERROR_SETTING_OFF = LOCATIONS_ERROR_GPS_SETTING_OFF, /**< Setting for GPS, WPS, or MOCK is turned off (Since 3.0) */
} location_error_e;
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_MOCK, /**< This method uses mock location for testing (Since 3.0)*/
} location_method_e;
/**
/**
* @platform
- * @brief Enable the given location method.
+ * @brief Enables the given location method.
* @since_tizen 2.3.1
* @privlevel platform
* @privilege %http://tizen.org/privilege/location.enable
int location_manager_unset_location_changed_cb(location_manager_h manager);
/**
+ * @brief Enables mock location.
+ * @remarks You can enable the mock location when developer mode is enabled.
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/location
+ * @param[in] enable The value to set
+ * @return 0 on success, otherwise a negative error value
+ * @retval #LOCATIONS_ERROR_NONE Successful
+ * @retval #LOCATIONS_ERROR_SETTING_OFF MOCK location is not enabled
+ * @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()
+ * @see location_manager_set_mock_location()
+ */
+int location_manager_enable_mock_location(const bool enable);
+
+/**
+ * @brief Sets a mock location for the given location method.
+ * @details The location sets the given altitude, latitude, longitude, climb, direction, speed, level, horizontal and vertical accuracy.
+ *
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/location
+ * @param[in] manager The location manager handle
+ * @param[in] latitude The current latitude [-90.0 ~ 90.0] (degrees)
+ * @param[in] longitude The current longitude [-180.0 ~ 180.0] (degrees)
+ * @param[in] altitude The current altitude (meters)
+ * @param[in] speed The speed (km/h)
+ * @param[in] direction The direction, degrees from the north [0.0 ~ 360.0]
+ * @param[in] accuracy The horizontal accuracy (meters)
+ * @return 0 on success, otherwise a negative error value
+ * @retval #LOCATIONS_ERROR_NONE Successful
+ * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid argument
+ * @retval #LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE Service not available
+ * @retval #LOCATIONS_ERROR_SETTING_OFF MOCK location is not enabled
+ * @retval #LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED The application does not have the privilege to call this method
+ * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported
+ * @see location_manager_is_enabled_method()
+ * @see location_manager_enable_mock_location()
+ * @see location_manager_create()
+ * @see location_manager_clear_mock_location()
+ */
+int location_manager_set_mock_location(location_manager_h manager, const double latitude, const double longitude, const double altitude, const double speed, const double direction, const double accuracy);
+
+/**
+ * @brief Clears a mock location.
+ *
+ * @since_tizen 3.0
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/location
+ * @param[in] manager The location manager handle
+ * @return 0 on success, otherwise a negative error value
+ * @retval #LOCATIONS_ERROR_NONE Successful
+ * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid argument
+ * @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_SETTING_OFF MOCK location is not enabled
+ * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported
+ * @see location_manager_is_enabled_method()
+ * @see location_manager_enable_mock_location()
+ * @see location_manager_create()
+ * @see location_manager_set_mock_location()
+ */
+int location_manager_clear_mock_location(location_manager_h manager);
+
+/**
* @}
*/
Name: capi-location-manager
Summary: A Location Manager library in Tizen Native API
-Version: 0.6.3
+Version: 0.7.0
Release: 1
Group: Location/API
License: Apache-2.0
msg = "LOCATIONS_ERROR_NETWORK_FAILED";
break;
case LOCATION_ERROR_SETTING_OFF:
- ret = LOCATIONS_ERROR_GPS_SETTING_OFF;
- msg = "LOCATIONS_ERROR_GPS_SETTING_OFF";
+ ret = LOCATIONS_ERROR_SETTING_OFF;
+ msg = "LOCATIONS_ERROR_SETTING_OFF";
break;
case LOCATION_ERROR_SECURITY_DENIED:
ret = LOCATIONS_ERROR_SECURITY_RESTRICTED;
#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_MOCK + 1];
static location_method_e __convert_location_method_e(LocationMethod method)
{
case LOCATIONS_METHOD_WPS:
_method = LOCATION_METHOD_WPS;
break;
+ case LOCATIONS_METHOD_MOCK:
+ _method = LOCATION_METHOD_MOCK;
+ break;
case LOCATIONS_METHOD_NONE:
default:
_method = LOCATION_METHOD_NONE;
static void __cb_service_enabled(GObject *self, guint status, gpointer userdata)
{
- LOCATIONS_LOGD("Callback function has been invoked. ");
+ LOCATIONS_LOGD("Invoked. status = %d", status);
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]);
}
}
static void __cb_service_disabled(GObject *self, guint status, gpointer userdata)
{
- LOCATIONS_LOGD("Callback function has been invoked. ");
+ LOCATIONS_LOGD("Invoked. status = %d", status);
location_manager_s *handle = (location_manager_s *) userdata;
- if (handle->user_cb[_LOCATIONS_EVENT_TYPE_SERVICE_STATE])
+ 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]);
+ }
}
+#if 0
+static void __cb_service_status_changed(GObject *self, guint status, gpointer userdata)
+{
+ LOCATIONS_LOGD("Invoked. status = %u", status);
+ location_manager_s *handle = (location_manager_s *) userdata;
+
+ if (handle->user_cb[_LOCATIONS_EVENT_TYPE_SERVICE_STATE]) {
+ if (status == LOCATION_STATUS_2D_FIX || status == LOCATION_STATUS_3D_FIX)
+ ((location_service_state_changed_cb)
+ handle->user_cb[_LOCATIONS_EVENT_TYPE_SERVICE_STATE])(LOCATIONS_SERVICE_ENABLED, handle->user_data[_LOCATIONS_EVENT_TYPE_SERVICE_STATE]);
+ else if (status == LOCATION_STATUS_NO_FIX)
+ ((location_service_state_changed_cb)
+ handle->user_cb[_LOCATIONS_EVENT_TYPE_SERVICE_STATE])(LOCATIONS_SERVICE_DISABLED, handle->user_data[_LOCATIONS_EVENT_TYPE_SERVICE_STATE]);
+ else if (status == LOCATION_STATUS_MOCK_FAIL)
+ ((location_service_state_changed_cb)
+ handle->user_cb[_LOCATIONS_EVENT_TYPE_SERVICE_STATE])(LOCATIONS_SERVICE_ERROR, handle->user_data[_LOCATIONS_EVENT_TYPE_SERVICE_STATE]);
+ }
+}
+#endif
+
static int __compare_position(gconstpointer a, gconstpointer b)
{
if (location_position_equal((LocationPosition *) a, (LocationPosition *)b) == TRUE) {
{
LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported());
- if (LOCATIONS_METHOD_HYBRID > method || LOCATIONS_METHOD_WPS < method) {
+ if (LOCATIONS_METHOD_HYBRID > method || LOCATIONS_METHOD_MOCK < method) {
LOCATIONS_LOGE("Not supported method [%d]", method);
return LOCATIONS_ERROR_INCORRECT_METHOD;
}
{
LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported());
- if (LOCATIONS_METHOD_HYBRID > method || LOCATIONS_METHOD_WPS < method) {
+ if (LOCATIONS_METHOD_HYBRID > method || LOCATIONS_METHOD_MOCK < method) {
LOCATIONS_LOGE("Not supported method [%d]", method);
return LOCATIONS_ERROR_INCORRECT_METHOD;
}
}
return LOCATIONS_ERROR_NONE;
- } else {
+ } else if (LOCATIONS_METHOD_MOCK == method) {
+ ret = location_enable_mock(LOCATION_METHOD_MOCK, enable);
+ return __convert_error_code(ret);
+ } 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;
}
}
-
EXPORT_API int location_manager_create(location_method_e method, location_manager_h *manager)
{
LOCATIONS_LOGD("location_manager_create (method : %d)", method);
LOCATIONS_LOGE("LOCATIONS_ERROR_NOT_SUPPORTED(0x%08x) : fail to location_init", LOCATIONS_ERROR_NOT_SUPPORTED);
return LOCATIONS_ERROR_NOT_SUPPORTED;
}
+
if (!location_is_supported_method(_method)) {
LOCATIONS_LOGE("LOCATIONS_ERROR_NOT_SUPPORTED(0x%08x) : fail to location_is_supported_method", LOCATIONS_ERROR_NOT_SUPPORTED);
return LOCATIONS_ERROR_NOT_SUPPORTED;
if (!handle->sig_id[_LOCATION_SIGNAL_SERVICE_DISABLED])
handle->sig_id[_LOCATION_SIGNAL_SERVICE_DISABLED] = g_signal_connect(handle->object, "service-disabled", G_CALLBACK(__cb_service_disabled), handle);
+#if 0
+ if (!handle->sig_id[_LOCATION_SIGNAL_STATUS_CHANGED])
+ handle->sig_id[_LOCATION_SIGNAL_STATUS_CHANGED] = g_signal_connect(handle->object, "status-changed", G_CALLBACK(__cb_service_status_changed), handle);
+#endif
+
*manager = (location_manager_h) handle;
return LOCATIONS_ERROR_NONE;
}
LOCATIONS_NULL_ARG_CHECK(manager);
location_manager_s *handle = (location_manager_s *) manager;
+
if (handle->sig_id[_LOCATION_SIGNAL_SERVICE_ENABLED]) {
g_signal_handler_disconnect(handle->object, handle->sig_id[_LOCATION_SIGNAL_SERVICE_ENABLED]);
handle->sig_id[_LOCATION_SIGNAL_SERVICE_ENABLED] = 0;
handle->sig_id[_LOCATION_SIGNAL_SERVICE_DISABLED] = 0;
}
+#if 0
+ if (handle->sig_id[_LOCATION_SIGNAL_STATUS_CHANGED]) {
+ g_signal_handler_disconnect(handle->object, handle->sig_id[_LOCATION_SIGNAL_STATUS_CHANGED]);
+ handle->sig_id[_LOCATION_SIGNAL_STATUS_CHANGED] = 0;
+ }
+#endif
+
+ if (handle->sig_id[_LOCATION_SIGNAL_ERROR_EMITTED]) {
+ g_signal_handler_disconnect(handle->object, handle->sig_id[_LOCATION_SIGNAL_ERROR_EMITTED]);
+ handle->sig_id[_LOCATION_SIGNAL_ERROR_EMITTED] = 0;
+ }
+
int ret = location_free(handle->object);
if (ret != LOCATIONS_ERROR_NONE) {
return __convert_error_code(ret);
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 (LOCATIONS_METHOD_HYBRID <= handle->method && LOCATIONS_METHOD_WPS >= handle->method) {
+ if (LOCATIONS_METHOD_HYBRID <= handle->method && LOCATIONS_METHOD_MOCK >= handle->method) {
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);
handle->sig_id[_LOCATION_SIGNAL_SERVICE_UPDATED] = 0;
}
- if (LOCATIONS_METHOD_HYBRID <= handle->method && LOCATIONS_METHOD_WPS >= handle->method) {
+ if (LOCATIONS_METHOD_HYBRID <= handle->method && LOCATIONS_METHOD_MOCK >= handle->method) {
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;
case LOCATION_METHOD_WPS:
*method = LOCATIONS_METHOD_WPS;
break;
+ case LOCATION_METHOD_MOCK:
+ *method = LOCATIONS_METHOD_MOCK;
+ break;
default: {
LOCATIONS_LOGE("LOCATIONS_ERROR_INVALID_PARAMETER(0x%08x) : Out of range (location_method_e) - method : %d ",
LOCATIONS_ERROR_INVALID_PARAMETER, method);
return LOCATIONS_ERROR_INVALID_PARAMETER;
}
}
- /**method = handle->method; */
return LOCATIONS_ERROR_NONE;
}
LOCATIONS_NULL_ARG_CHECK(manager);
LOCATIONS_NULL_ARG_CHECK(callback);
location_manager_s *handle = (location_manager_s *) manager;
- int ret;
+ int ret = LOCATION_ERROR_NONE;
LocationSatellite *last_sat = NULL;
+
ret = location_get_last_satellite(handle->object, &last_sat);
if (ret != LOCATION_ERROR_NONE || last_sat == NULL) {
if (ret == LOCATION_ERROR_NOT_SUPPORTED) {
location_satellite_free(last_sat);
return LOCATIONS_ERROR_NONE;
}
+
+
+/**
+ * Tizen 3.0
+ */
+EXPORT_API int location_manager_enable_mock_location(const bool enable)
+{
+ LOCATIONS_LOGD("enable: %d", enable);
+ LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported());
+ int ret = LOCATION_ERROR_NONE;
+
+ ret = location_enable_mock(LOCATION_METHOD_MOCK, enable);
+ return __convert_error_code(ret);
+}
+
+EXPORT_API int location_manager_set_mock_location(location_manager_h manager, const double latitude, const double longitude, const double altitude,
+ const double speed, const double direction, const double accuracy)
+{
+ LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported());
+ LOCATIONS_NULL_ARG_CHECK(manager);
+
+ LOCATIONS_CHECK_CONDITION(latitude >= -90 && latitude <= 90, LOCATIONS_ERROR_INVALID_PARAMETER, "LOCATIONS_ERROR_INVALID_PARAMETER");
+ LOCATIONS_CHECK_CONDITION(longitude >= -180 && longitude <= 180, LOCATIONS_ERROR_INVALID_PARAMETER, "LOCATIONS_ERROR_INVALID_PARAMETER");
+ LOCATIONS_CHECK_CONDITION(direction >= 0 && direction <= 360, LOCATIONS_ERROR_INVALID_PARAMETER, "LOCATIONS_ERROR_INVALID_PARAMETER");
+
+ location_manager_s *handle = (location_manager_s *) manager;
+ int ret = LOCATION_ERROR_NONE;
+ int enabled;
+ LocationPosition *pos = NULL;
+ LocationVelocity *vel = NULL;
+ LocationAccuracy *acc = NULL;
+
+ ret = location_is_enabled_method(LOCATION_METHOD_MOCK, &enabled);
+ LOCATIONS_LOGD("enable: %d, ret: %d", enabled, ret);
+ if (ret == LOCATIONS_ERROR_NONE) {
+ if (enabled == 0) {
+ return __convert_error_code(LOCATION_ERROR_SETTING_OFF);
+ }
+
+ } else {
+ return __convert_error_code(ret);
+ }
+
+ pos = location_position_new(0, latitude, longitude, 0, LOCATION_STATUS_3D_FIX);
+ if (!pos) {
+ LOCATIONS_LOGE("Failed to create position");
+ return LOCATIONS_ERROR_OUT_OF_MEMORY;
+ }
+ vel = location_velocity_new(0, speed, direction, 0);
+ if (!vel) {
+ LOCATIONS_LOGE("Failed to create volocity");
+ return LOCATIONS_ERROR_OUT_OF_MEMORY;
+ }
+
+ acc = location_accuracy_new(LOCATION_ACCURACY_LEVEL_DETAILED, accuracy, -1);
+ if (!vel) {
+ LOCATIONS_LOGE("Failed to create accuracy");
+ return LOCATIONS_ERROR_OUT_OF_MEMORY;
+ }
+
+ ret = location_set_mock_location(handle->object, pos, vel, acc);
+ return __convert_error_code(ret);
+
+}
+
+EXPORT_API int location_manager_clear_mock_location(location_manager_h manager)
+{
+ LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported());
+ location_manager_s *handle = (location_manager_s *) manager;
+ int ret = LOCATION_ERROR_NONE;
+ int enabled;
+
+ ret = location_is_enabled_method(LOCATION_METHOD_MOCK, &enabled);
+ if (ret == LOCATIONS_ERROR_NONE) {
+ if (enabled == 0) {
+ return __convert_error_code(LOCATIONS_ERROR_SETTING_OFF);
+ }
+ } else {
+ return __convert_error_code(ret);
+ }
+
+ ret = location_clear_mock_location(handle->object);
+ return __convert_error_code(ret);
+}
+
+
+#if 0
+/**
+ * @brief Gets the state of location service.
+ * @since_tizen 3.0
+ * @param[in] manager The location manager handle
+ * @param[out] state The current state of location service
+ * @return 0 on success, otherwise a negative error value
+ * @retval #LOCATIONS_ERROR_NONE Successful
+ * @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter
+ * @retval #LOCATIONS_ERROR_NOT_SUPPORTED Not supported
+ * @see location_manager_create()
+ * @see location_manager_set_setting_changed_cb()
+ * @see location_manager_unset_setting_changed_cb()
+ */
+int location_manager_get_service_state(location_manager_h manager, location_service_state_e *state);
+
+EXPORT_API int location_manager_get_service_state(location_manager_h manager, location_service_state_e *state)
+{
+ LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported());
+ LOCATIONS_NULL_ARG_CHECK(manager);
+ LOCATIONS_NULL_ARG_CHECK(state);
+
+ location_manager_s *handle = (location_manager_s *) manager;
+
+ int service_state = -1;
+
+ int ret = location_get_service_state(handle->object, &service_state);
+ if (ret != LOCATION_ERROR_NONE) {
+ if (ret == LOCATION_ERROR_NOT_SUPPORTED)
+ return LOCATIONS_ERROR_INCORRECT_METHOD;
+ return __convert_error_code(ret);
+ }
+
+ switch (service_state) {
+ case -1:
+ ret = LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE;
+ *state = LOCATIONS_SERVICE_DISABLED;
+ break;
+ case 0:
+ *state = LOCATIONS_SERVICE_DISABLED;
+ break;
+ case 1:
+ *state = LOCATIONS_SERVICE_ENABLED;
+ break;
+ default:
+ *state = LOCATIONS_SERVICE_ERROR;
+ break;
+
+ }
+
+ return ret;
+}
+
+EXPORT_API int location_add_test_provider(const LocationMethod method, const int enable)
+{
+ int ret = 0;
+ char *_key = NULL;
+
+#ifndef TIZEN_PROFILE_TV
+ ret = location_check_privilege(LOCATION_ENABLE_PRIVILEGE);
+ if (ret != LOCATION_ERROR_NONE) {
+ LOCATION_LOGE("Cannot use location service for privacy[%d]", ret);
+ return LOCATION_ERROR_NOT_ALLOWED;
+ }
+#endif
+
+ if (method == LOCATION_METHOD_MOCK) {
+ _key = __convert_setting_key(method);
+ if (!_key) {
+ LOCATION_LOGE("Invalid method[%d]", method);
+ return LOCATION_ERROR_NOT_SUPPORTED;
+ }
+ ret = vconf_set_int(_key, enable);
+ if (ret != VCONF_OK) {
+ LOCATION_SECLOG("vconf_set_int failed [%s], ret=[%d]", _key, ret);
+ g_free(_key);
+ return LOCATION_ERROR_NOT_ALLOWED;
+ }
+
+ g_free(_key);
+ }
+ return ret;
+}
+#endif
<manifest>
<request>
- <domain name="_" />
+ <domain name="_"/>
</request>
</manifest>
#include <locations.h>
#include <location_bounds.h>
#include <location_batch.h>
+#include <unistd.h>
+
static location_manager_h manager;
static GMainLoop *g_mainloop = NULL;
if (ret != LOCATIONS_ERROR_NONE) {
fprintf(stderr, " Fail: location_manager_get_position ---> %d \n", ret);
} else {
- fprintf(stderr, "[%ld] alt: %g, lat %g, long %g\n", timestamp, altitude, latitude, longitude);
+ fprintf(stderr, "[%ld] lat: %f, lng: %f, alt: %f\n", timestamp, latitude, longitude, altitude);
}
location_accuracy_level_e level;
if (ret != LOCATIONS_ERROR_NONE) {
fprintf(stderr, " Fail: location_manager_get_accuracy ---> %d \n", ret);
} else {
- fprintf(stderr, "Level: %d, horizontal: %g, vertical %g\n", level, horizontal, vertical);
+ fprintf(stderr, "Level: %d, horizontal: %f, vertical %f\n", level, horizontal, vertical);
}
#if 0
char *nmea;
void _position_updated_cb(double latitude, double longitude, double altitude, time_t timestamp, void *user_data)
{
fprintf(stderr, "-------------------------- position updated --------------------------\n");
- fprintf(stderr, "[%ld] lat[%f] lon[%f] alt[%f]\n", timestamp, latitude, longitude, altitude);
+ fprintf(stderr, "[%ld] lat: %f, lng: %f, alt: %f\n", timestamp, latitude, longitude, altitude);
location_manager_h lm = (location_manager_h) user_data;
location_accuracy_level_e level;
if (ret != LOCATIONS_ERROR_NONE) {
fprintf(stderr, " Fail: location_manager_get_accuracy ---> %d \n", ret);
} else {
- fprintf(stderr, "Level: %d, horizontal: %g, vertical %g\n", level, horizontal, vertical);
+ fprintf(stderr, "Level: %d, horizontal: %f, vertical %f\n", level, horizontal, vertical);
}
repeat_count++;
- if (repeat_count > 2) {
+ if (repeat_count > 9) {
test_timer = g_timeout_add_seconds(1, wait_test, NULL);
}
}
repeat_count++;
- if (repeat_count > 2) {
+ if (repeat_count > 5) {
test_timer = g_timeout_add_seconds(1, wait_test, NULL);
}
}
fprintf(stderr, "gps: %d, ", is_enabled);
location_manager_is_enabled_method(LOCATIONS_METHOD_WPS, &is_enabled);
- fprintf(stderr, "wps: %d\n", is_enabled);
+ fprintf(stderr, "wps: %d, ", is_enabled);
+
+ /* location_manager_is_test_location_enabled(&is_enabled); */
+ location_manager_is_enabled_method(LOCATIONS_METHOD_MOCK, &is_enabled);
+ fprintf(stderr, "mock: %d\n", is_enabled);
}
static int enable_method(location_method_e method, bool enable)
return ret;
}
+static int test_clear_mock_location(gpointer user_data)
+{
+ location_manager_h manager = (location_manager_h) user_data;
+ int ret = 0;
+
+ ret = location_manager_clear_mock_location(manager);
+ fprintf(stderr, "\n==== location_manager_clear_mock_location: %d ====\n\n", ret);
+
+ /*
+ int state = 0;
+ ret = location_manager_get_service_state(manager, &state);
+ fprintf(stderr, "the current state: %d, ret = %d\n", state, ret);
+ */
+
+ return FALSE;
+}
+
+
+static int test_set_mock_location(gpointer user_data)
+{
+ location_manager_h manager = (location_manager_h) user_data;
+ int ret = 0;
+
+ /*
+ int state = 0;
+ ret = location_manager_get_service_state(manager, &state);
+ fprintf(stderr, "the current state: %d, ret = %d\n", state, ret);
+ */
+
+ ret = location_manager_set_mock_location(manager, 20, 20, 0, 40, 50, 100);
+ fprintf(stderr, "\n==== location_manager_set_location: %d ====\n\n", ret);
+ if (ret != LOCATIONS_ERROR_NONE) {
+ g_timeout_add_seconds(3, test_clear_mock_location, manager);
+ }
+
+ return FALSE;
+}
+
static void print_menu()
{
fprintf(stderr, "============= LOCATION TEST =============\n");
fprintf(stderr, "[22] Distance based location update: LOCATIONS_METHOD_GPS\n");
fprintf(stderr, "[23] Distance based location update: LOCATIONS_METHOD_WPS\n\n");
fprintf(stderr, "[31] Location batch update: LOCATIONS_METHOD_GPS\n\n");
- fprintf(stderr, "[41] Turn on/off method: LOCATIONS_METHOD_HYBRID\n");
- fprintf(stderr, "[42] Turn on/off method: LOCATIONS_METHOD_GPS\n");
- fprintf(stderr, "[43] Turn on/off method: LOCATIONS_METHOD_WPS\n\n");
- fprintf(stderr, "[51] Boundary Test\n\n");
+ fprintf(stderr, "[41] Turn on/off mock test: LOCATIONS_METHOD_MOCK\n");
+ fprintf(stderr, "[42] Set & Clear location: LOCATIONS_METHOD_HYBRID\n\n");
+ fprintf(stderr, "[51] Turn on/off method: LOCATIONS_METHOD_HYBRID\n");
+ fprintf(stderr, "[52] Turn on/off method: LOCATIONS_METHOD_GPS\n");
+ fprintf(stderr, "[53] Turn on/off method: LOCATIONS_METHOD_WPS\n\n");
+ fprintf(stderr, "[61] Boundary Test\n\n");
fprintf(stderr, "[0] Exit!!!\n\n");
fprintf(stderr, "Select menu: ");
fprintf(stderr, " Input batch period ==> ");
ret = scanf("%d", &period);
-
ret = location_manager_create(LOCATIONS_METHOD_GPS, &manager);
fprintf(stderr, "location_manager_create (method : %d)\n", LOCATIONS_METHOD_GPS);
fprintf(stderr, "start_batch: %d\n", ret);
break;
}
- case 41:
- case 42:
- case 43: {
- int method = menu - 41;
+ case 41: {
+ basic = 1;
+ int onoff = 1;
+
+ fprintf(stderr, "\n Mock Location (ON: 1 or OFF: 0) Input ==> ");
+ ret = scanf("%d", &onoff);
+
+ ret = location_manager_enable_mock_location(onoff);
+ fprintf(stderr, "Enabling mock test: ret=%d\n", ret);
+
+ ret = location_manager_create(LOCATIONS_METHOD_MOCK, &manager);
+ fprintf(stderr, "location_manager_create (method: %d): %d\n", LOCATIONS_METHOD_MOCK, ret);
+
+ ret = location_manager_set_mock_location(manager, 10, 20, 0, 40, 50, 100);
+ fprintf(stderr, "location_manager_set_mock_location: %d\n", ret);
+ if (ret == LOCATIONS_ERROR_SETTING_OFF) {
+ fprintf(stderr, "Setting for Mock Location is turned OFF!!!\n");
+ break;
+ }
+
+ ret = location_manager_start(manager);
+ fprintf(stderr, "start: %d\n", ret);
+
+ g_timeout_add_seconds(3, test_clear_mock_location, manager);
+
+ g_timeout_add_seconds(10, wait_test, NULL);
+
+ break;
+ }
+ case 42: {
+ basic = 1;
+
+ ret = location_manager_create(LOCATIONS_METHOD_HYBRID, &manager);
+ fprintf(stderr, "location_manager_create (method: %d): %d\n", LOCATIONS_METHOD_HYBRID, ret);
+
+ ret = location_manager_start(manager);
+ fprintf(stderr, "start: %d\n", ret);
+
+ /*
+ int state = 0;
+ ret = location_manager_get_service_state(manager, &state);
+ fprintf(stderr, "the current state: %d, ret = %d\n", state, ret);
+ */
+
+ g_timeout_add_seconds(5, test_set_mock_location, manager);
+
+ break;
+ }
+ case 51:
+ case 52:
+ case 53: {
+ int method = menu - 51;
int onoff = 1;
fprintf(stderr, "\n Input ON: 1 or OFF: 0 ==> ");
ret = scanf("%d", &onoff);
- ret = enable_method(method, onoff);
- fprintf(stderr, "Enabling method: [%d], ret=%d\n", method, ret);
+ if (onoff == 0 || onoff == 1) {
+ ret = enable_method(method, onoff);
+ fprintf(stderr, "Enabling method: [%d], ret=%d\n", method, ret);
+ }
break;
}
-
- case 51: {
+ case 61: {
location_bounds_h hPolyLocationBound = NULL;
bool bIsContained = false;
int nPolySize = 3;
return 0;
}
- if (menu < 40) {
+ if (menu > 0 && menu < 50) {
ret = location_manager_set_service_state_changed_cb(manager, _state_change_cb, (void *)manager);
fprintf(stderr, "set_service_state_changed_cb: %d\n", ret);