Fix for mock method feature check
[platform/core/api/location-manager.git] / src / locations.c
index 1f2951a..124ee3d 100755 (executable)
@@ -21,7 +21,7 @@
 #include "locations.h"
 #include "location_internal.h"
 
-static location_setting_changed_s g_location_setting[LOCATIONS_METHOD_WPS + 1];
+static location_setting_changed_s g_location_setting[LOCATIONS_METHOD_MOCK + 1];
 
 static location_method_e __convert_location_method_e(LocationMethod method)
 {
@@ -56,6 +56,9 @@ static LocationMethod __convert_LocationMethod(location_method_e method)
                case LOCATIONS_METHOD_WPS:
                        _method = LOCATION_METHOD_WPS;
                        break;
+               case LOCATIONS_METHOD_MOCK:
+                       _method = LOCATION_METHOD_MOCK;
+                       break;
                case LOCATIONS_METHOD_NONE:
                default:
                        _method = LOCATION_METHOD_NONE;
@@ -72,26 +75,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 +102,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,30 +118,49 @@ 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]);
        }
 }
 
 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)
 {
@@ -183,7 +205,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 +217,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 +247,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 +276,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 +342,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 +356,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 +381,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);
@@ -374,7 +408,7 @@ EXPORT_API int location_manager_is_enabled_method(location_method_e method, bool
 {
        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;
        }
@@ -389,8 +423,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;
@@ -400,30 +435,74 @@ EXPORT_API int location_manager_enable_method(const location_method_e method, co
 {
        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_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;
 
-       int ret = location_enable_method(_method, enable);
-       return __convert_error_code(ret);
-}
+       } 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;
+               } 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);
 
+               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;
+               }
+       } 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);
        if (_method == LOCATION_METHOD_NONE) {
                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;
@@ -461,6 +540,11 @@ EXPORT_API int location_manager_create(location_method_e method, location_manage
        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;
 }
@@ -472,6 +556,7 @@ EXPORT_API int location_manager_destroy(location_manager_h manager)
        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;
@@ -482,6 +567,18 @@ EXPORT_API int location_manager_destroy(location_manager_h manager)
                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);
@@ -500,7 +597,7 @@ EXPORT_API int location_manager_start(location_manager_h manager)
        if (!handle->sig_id[_LOCATION_SIGNAL_SERVICE_UPDATED])
                handle->sig_id[_LOCATION_SIGNAL_SERVICE_UPDATED] = g_signal_connect(handle->object, "service-updated", G_CALLBACK(__cb_service_updated), handle);
 
-       if (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);
 
@@ -564,7 +661,7 @@ EXPORT_API int location_manager_stop(location_manager_h manager)
                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;
@@ -660,18 +757,20 @@ EXPORT_API int location_manager_get_method(location_manager_h manager, location_
                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);
+                                                               LOCATIONS_ERROR_INVALID_PARAMETER, method);
                                return LOCATIONS_ERROR_INVALID_PARAMETER;
                        }
        }
-       /**method = handle->method; */
        return LOCATIONS_ERROR_NONE;
 }
 
 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 +878,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 +908,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 +1017,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 +1119,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 +1152,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 +1260,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 +1273,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 +1286,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 +1300,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 +1315,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 +1329,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 +1345,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 +1375,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 +1387,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,26 +1405,24 @@ 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;
-       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) {
-                       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;
        }
 
@@ -1353,3 +1441,175 @@ EXPORT_API int gps_status_foreach_last_satellites_in_view(location_manager_h man
        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());
+       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);
+       if (ret == LOCATIONS_ERROR_NONE) {
+               if (enabled == 0) {
+                       return __convert_error_code(LOCATION_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