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;
/**
* @param[in] callback The callback function to register
* @param[in] batch_interval The batch sampling interval [1 ~ 255] (seconds)
* @param[in] batch_period The batch period [1 ~ 60000] (seconds)
+ * @param[in] user_data The user data to be passed to the callback function
* @return @c 0 on success, otherwise a negative error value
* @retval #LOCATIONS_ERROR_NONE Successful
* @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter
* @privilege %http://tizen.org/privilege/location
* @param[in] manager The location manager handle
* @param[in] callback The iteration callback function
- * @param[in] user_data The user data passed from the callback registration function
+ * @param[in] user_data The user data to be passed to the callback function
* @return @c 0 on success, otherwise a negative error value
* @retval #LOCATIONS_ERROR_NONE Successful
* @retval #LOCATIONS_ERROR_INVALID_PARAMETER Invalid parameter
int location_manager_foreach_location_batch(location_manager_h manager, location_batch_get_location_cb callback, void *user_data);
/**
+ * @brief Checks whether the mock location is enabled.
+ * @since_tizen 3.0
+ * @param[out] enabled Indicates whether the mock location is enabled
+ * @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_enable_mock_location()
+ * @see location_manager_set_mock_location()
+ * @see location_manager_clear_mock_location()
+ */
+int location_manager_is_enabled_mock_location(bool *enabled);
+
+/**
* @brief Enables mock location.
- * @remarks You can enable the mock location when developer mode is enabled.
+ * @details The mock location is a testing function to make location API and callback deliver a mock location
+ * set by location_manager_set_mock_location() instead of real positioning data even in the other applications.
+ * @remarks The mock location can only be enabled if developer mode is enabled.
* @since_tizen 3.0
* @privlevel public
* @privilege %http://tizen.org/privilege/location
* @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_is_enabled_mock_location()
* @see location_manager_set_mock_location()
+ * @see location_manager_clear_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] 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] 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_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_is_enabled_mock_location()
+ * @see location_manager_enable_mock_location()
* @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
* @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_is_enabled_mock_location()
+ * @see location_manager_enable_mock_location()
* @see location_manager_set_mock_location()
*/
int location_manager_clear_mock_location(location_manager_h manager);
#include "locations.h"
#include "location_internal.h"
-static location_setting_changed_s g_location_setting[LOCATIONS_METHOD_MOCK + 1];
+static location_setting_changed_s g_location_setting[LOCATIONS_METHOD_WPS + 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;
{
LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported());
- if (method < LOCATIONS_METHOD_HYBRID || method > LOCATIONS_METHOD_MOCK) {
+ if (method < LOCATIONS_METHOD_HYBRID || method > LOCATIONS_METHOD_WPS) {
LOCATIONS_LOGE("Not supported method [%d]", method);
return LOCATIONS_ERROR_INCORRECT_METHOD;
}
return LOCATIONS_ERROR_INCORRECT_METHOD;
return __convert_error_code(ret);
}
+
if (is_enabled_val == -1)
return TIZEN_ERROR_PERMISSION_DENIED;
{
LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported());
- if (method < LOCATIONS_METHOD_HYBRID || method > LOCATIONS_METHOD_MOCK) {
+ if (method < LOCATIONS_METHOD_HYBRID || method > LOCATIONS_METHOD_WPS) {
LOCATIONS_LOGE("Not supported method [%d]", method);
return LOCATIONS_ERROR_INCORRECT_METHOD;
}
}
return LOCATIONS_ERROR_NONE;
- } 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);
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_MOCK) {
- 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;
- }
}
LocationMethod _method = __convert_LocationMethod(method);
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;
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_MOCK) {
+ if (handle->method >= LOCATIONS_METHOD_HYBRID && handle->method <= LOCATIONS_METHOD_WPS) {
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 (handle->method >= LOCATIONS_METHOD_HYBRID && handle->method <= LOCATIONS_METHOD_MOCK) {
+ if (handle->method >= LOCATIONS_METHOD_HYBRID && handle->method <= LOCATIONS_METHOD_WPS) {
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] method : %d ", method);
return LOCATIONS_ERROR_INVALID_PARAMETER;
LOCATIONS_NULL_ARG_CHECK(timestamp);
location_manager_s *handle = (location_manager_s *) manager;
- int ret;
LocationPosition *pos = NULL;
LocationAccuracy *acc = NULL;
- ret = location_get_position(handle->object, &pos, &acc);
+ int ret = location_get_position(handle->object, &pos, &acc);
if (ret != LOCATION_ERROR_NONE)
return __convert_error_code(ret);
LOCATIONS_NULL_ARG_CHECK(timestamp);
location_manager_s *handle = (location_manager_s *) manager;
- int ret;
LocationPosition *pos = NULL;
LocationVelocity *vel = NULL;
LocationAccuracy *acc = NULL;
- ret = location_get_position_ext(handle->object, &pos, &vel, &acc);
+ int ret = location_get_position_ext(handle->object, &pos, &vel, &acc);
if (ret != LOCATION_ERROR_NONE)
return __convert_error_code(ret);
LOCATIONS_NULL_ARG_CHECK(timestamp);
location_manager_s *handle = (location_manager_s *) manager;
- int ret;
LocationVelocity *vel = NULL;
LocationAccuracy *acc = NULL;
- ret = location_get_velocity(handle->object, &vel, &acc);
+
+ int ret = location_get_velocity(handle->object, &vel, &acc);
if (ret != LOCATION_ERROR_NONE)
return __convert_error_code(ret);
return LOCATIONS_ERROR_NONE;
}
+EXPORT_API int location_manager_is_enabled_mock_location(bool *enabled)
+{
+ LOCATIONS_NOT_SUPPORTED_CHECK(__is_location_supported());
+ LOCATIONS_NULL_ARG_CHECK(enabled);
+ int is_enabled_val = -1;
+ int ret = location_is_enabled_method(INTERNAL_METHOD_MOCK, &is_enabled_val);
+ if (ret != LOCATION_ERROR_NONE)
+ return __convert_error_code(ret);
+
+ if (is_enabled_val == -1)
+ return TIZEN_ERROR_PERMISSION_DENIED;
+
+ *enabled = (is_enabled_val == 0) ? FALSE : TRUE;
+ return LOCATIONS_ERROR_NONE;
+}
+
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);
+ ret = location_enable_mock(enable);
return __convert_error_code(ret);
}
LocationVelocity *vel = NULL;
LocationAccuracy *acc = NULL;
- ret = location_is_enabled_method(LOCATION_METHOD_MOCK, &enabled);
+ ret = location_is_enabled_method(INTERNAL_METHOD_MOCK, &enabled);
LOCATIONS_LOGD("enable: %d, ret: %d", enabled, ret);
if (ret == LOCATIONS_ERROR_NONE) {
if (enabled == 0)
}
vel = location_velocity_new(0, speed, direction, 0);
if (!vel) {
- LOCATIONS_LOGE("Failed to create volocity");
+ LOCATIONS_LOGE("Failed to create velocity");
location_position_free(pos);
return LOCATIONS_ERROR_OUT_OF_MEMORY;
}
location_accuracy_free(acc);
return __convert_error_code(ret);
-
}
EXPORT_API int location_manager_clear_mock_location(location_manager_h manager)
LOCATIONS_NULL_ARG_CHECK(manager);
location_manager_s *handle = (location_manager_s *) manager;
- int ret = LOCATION_ERROR_NONE;
int enabled;
- ret = location_is_enabled_method(LOCATION_METHOD_MOCK, &enabled);
+ int ret = location_is_enabled_method(INTERNAL_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);