+
+
+/**
+ * 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