[ACR-656][MPR-657] Location batch APIs 93/72493/10 accepted/tizen/common/20160620.163155 accepted/tizen/ivi/20160617.083831 accepted/tizen/mobile/20160617.083801 accepted/tizen/tv/20160617.083519 accepted/tizen/wearable/20160617.083709 submit/tizen/20160616.234846
authorkj7.sung <kj7.sung@samsung.com>
Wed, 1 Jun 2016 08:12:54 +0000 (17:12 +0900)
committerkj7.sung <kj7.sung@samsung.com>
Thu, 16 Jun 2016 11:01:12 +0000 (20:01 +0900)
Signed-off-by: kj7.sung <kj7.sung@samsung.com>
Change-Id: I685933f75f4b69c543ebf62a1a6df29084f1b78e

include/location_batch.h
include/locations.h
src/location_batch.c
src/locations.c

index 3a66ef9..e86ab09 100644 (file)
@@ -30,65 +30,6 @@ extern "C" {
  * @{
  */
 
-/**
- * @brief Called when the batch interval is expired.
- * @param[in] num_of_location  The number of location batch data
- * @param[in] user_data                        The user data passed from the callback registration function
- */
-typedef void(*location_batch_cb)(int num_of_location, void *user_data);
-
-/**
- * @brief Gets called iteratively to receive location batch data.
- * @param[in] latitude         The updated latitude [-90.0 ~ 90.0] (degrees)
- * @param[in] longitude                The updated longitude [-180.0 ~ 180.0] (degrees)
- * @param[in] altitude         The updated altitude (meters)
- * @param[in] speed                    The updated speed (km/h)
- * @param[in] direction                The updated direction (in degrees from the north)
- * @param[in] horizontal       The horizontal accuracy (meters)
- * @param[in] vertical         The vertical accuracy (meters)
- * @param[in] timestamp                The timestamp (time when measurement took place or @c 0 if valid)
- * @param[in] user_data                The user data passed from the callback registration function
- * @pre location_batch_get_location_cb() will invoke this callback if you register this callback using location_manager_foreach_location_batch()
- */
-typedef bool(*location_batch_get_location_cb)(double latitude, double longitude, double altitude, double speed, double direction, double horizontal, double vertical, time_t timestamp, void *user_data);
-
-/**
- * @brief Registers a callback function to be invoked when batch_period is expired.
- * @param[in] manager                  The location manager handle
- * @param[in] callback                 The callback function to register
- * @param[in] batch_interval   The batch smpling interval
- * @param[in] batch_period             The batch period
- * @post location_batch_cb() will be invoked
- */
-int location_manager_set_location_batch_cb(location_manager_h manager, location_batch_cb callback, int batch_interval, int batch_period, void *user_data);
-
-/**
- * @brief Unregisters the callback function.
- * @param[in] manager                  The location manager handle
- */
-int location_manager_unset_location_batch_cb(location_manager_h manager);
-
-/**
- * @brief Start the location batch mode.
- * @param[in] manager                  The location manager handle
- */
-int location_manager_start_batch(location_manager_h manager);
-
-/**
- * @brief Stop the location batch mode.
- * @param[in] manager          The location manager handle
- */
-int location_manager_stop_batch(location_manager_h manager);
-
-/**
- * @brief Retrieves all location information by invoking a specific callback for each location data.
- * @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
- * @post location_batch_get_location_cb() will be invoked
- */
-int location_manager_foreach_location_batch(location_manager_h manager, location_batch_get_location_cb callback, void *user_data);
-
 int location_manager_enable_restriction(bool enable);
 
 /**
index f0a7219..a440454 100755 (executable)
@@ -203,6 +203,7 @@ typedef void(*location_setting_changed_cb)(location_method_e method, bool enable
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  * @param[in] bounds           The location bounds handle
  * @param[in] user_data                The user data passed from the callback registration function
+ * @return @c true to continue with the next iteration of the loop, otherwise @c false to break out of the loop.
  * @pre location_manager_foreach_boundary() will invoke this callback.
  * @see location_manager_foreach_boundary()
  */
@@ -227,6 +228,35 @@ typedef bool(*location_bounds_cb)(location_bounds_h bounds, void *user_data);
 typedef void(*location_changed_cb)(double latitude, double longitude, double altitude, double speed, double direction, double horizontal_accuracy, time_t timestamp, void *user_data);
 
 /**
+ * @brief Called when the batch interval is expired.
+ * @since_tizen @if MOBILE 3.0 @elseif WEARABLE 2.3.2 @endif
+ * @param[in] num_of_location  The number of location batch data
+ * @param[in] user_data                        The user data passed from the callback registration function
+ * @pre location_manager_start_batch() will invoke this callback if you register this callback using location_manager_set_location_batch_cb()
+ * @see location_manager_start_batch()
+ * @see location_manager_set_location_batch_cb()
+ */
+typedef void(*location_batch_cb)(int num_of_location, void *user_data);
+
+/**
+ * @brief Gets iteratively to receive location batch data.
+ * @since_tizen @if MOBILE 3.0 @elseif WEARABLE 2.3.2 @endif
+ * @param[in] latitude         The updated latitude [-90.0 ~ 90.0] (degrees)
+ * @param[in] longitude                The updated longitude [-180.0 ~ 180.0] (degrees)
+ * @param[in] altitude         The updated altitude (meters)
+ * @param[in] speed                    The updated speed (km/h)
+ * @param[in] direction                The updated direction (in degrees from the north)
+ * @param[in] horizontal       The horizontal accuracy (meters)
+ * @param[in] vertical         The vertical accuracy (meters)
+ * @param[in] timestamp                The timestamp (time when measurement took place or @c 0 if valid)
+ * @param[in] user_data                The user data passed from the callback registration function
+ * @return @c true to continue with the next iteration of the loop, otherwise @c false to break out of the loop.
+ * @pre location_manager_foreach_location_batch() will invoke this callback
+ * @see location_manager_foreach_location_batch()
+ */
+typedef bool(*location_batch_get_location_cb)(double latitude, double longitude, double altitude, double speed, double direction, double horizontal, double vertical, time_t timestamp, void *user_data);
+
+/**
  * @brief Checks whether the given location method is available.
  * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif
  * @remark The specific error code can be obtained using the get_last_result() method. Error codes are described in Exception section.
@@ -868,6 +898,103 @@ int location_manager_set_location_changed_cb(location_manager_h manager, locatio
 int location_manager_unset_location_changed_cb(location_manager_h manager);
 
 /**
+ * @brief Registers a callback function to be invoked when batch_period is expired.
+ * @since_tizen @if MOBILE 3.0 @elseif WEARABLE 2.3.2 @endif
+ * @remarks The batch_period should be greater than or equal to the batch_interval.
+ * @param[in] manager                  The location manager handle
+ * @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)
+ * @return @c 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
+ * @post location_batch_cb() will be invoked
+ * @see location_manager_start_batch()
+ * @see location_batch_cb()
+ * @see location_manager_unset_location_batch_cb()
+ */
+int location_manager_set_location_batch_cb(location_manager_h manager, location_batch_cb callback, int batch_interval, int batch_period, void *user_data);
+
+/**
+ * @brief Unregisters the callback function.
+ * @since_tizen @if MOBILE 3.0 @elseif WEARABLE 2.3.2 @endif
+ * @param[in] manager                  The location manager handle
+ * @return @c 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_set_location_batch_cb()
+ */
+int location_manager_unset_location_batch_cb(location_manager_h manager);
+
+/**
+ * @brief Starts the location batch service.
+ * @details Calling this function starts location batch service, location_batch_cb() will be invoked every @a batch_period seconds.
+                       After that, you can obtain all locations with location_manager_foreach_location_batch().
+ * @since_tizen @if MOBILE 3.0 @elseif WEARABLE 2.3.2 @endif
+ * @privlevel public
+ * @privilege %http://tizen.org/privilege/location
+ * @remarks Calling this function invokes a location service event. When the location service is enabled, the service state change callback
+ *             (set using location_manager_set_service_state_changed_cb()) notifies the user with #LOCATIONS_SERVICE_ENABLED as the first argument, and the service starts.
+ * @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 parameter
+ * @retval #LOCATIONS_ERROR_INCORRECT_METHOD           Incorrect method
+ * @retval #LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE      Service not available
+ * @retval #LOCATIONS_ERROR_NETWORK_FAILED                     Network failed
+ * @retval #LOCATIONS_ERROR_GPS_SETTING_OFF                    GPS 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
+ * @pre location_manager_set_location_batch_cb()
+ * @see location_manager_set_service_state_changed_cb()
+ * @see location_service_state_changed_cb()
+ * @see location_manager_foreach_location_batch()
+ * @see location_manager_stop_batch()
+ */
+int location_manager_start_batch(location_manager_h manager);
+
+/**
+ * @brief Stops the location batch service.
+ * @since_tizen @if MOBILE 3.0 @elseif WEARABLE 2.3.2 @endif
+ * @remarks This function initiates the process of stopping the service. When the process is finished, callback set using
+ * #location_manager_set_service_state_changed_cb() will be called, with #LOCATIONS_SERVICE_DISABLED as first argument.
+ * @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 parameter
+ * @retval #LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE              Service not available
+ * @retval #LOCATIONS_ERROR_NETWORK_FAILED                             Network failed
+ * @retval #LOCATIONS_ERROR_NOT_SUPPORTED                              Not supported
+ * @see location_manager_start_batch()
+ * @see location_manager_set_service_state_changed_cb()
+ * @see location_service_state_changed_cb()
+ */
+int location_manager_stop_batch(location_manager_h manager);
+
+/**
+ * @brief Retrieves all location information by invoking a specific callback for each location data.
+ * @since_tizen @if MOBILE 3.0 @elseif WEARABLE 2.3.2 @endif
+ * @privlevel public
+ * @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
+ * @return     @c 0 on success, otherwise a negative error value
+ * @retval #LOCATIONS_ERROR_NONE                                               Successful
+ * @retval #LOCATIONS_ERROR_INVALID_PARAMETER                  Invalid parameter
+ * @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 location_manager_foreach_location_batch() is available after location_batch_cb() is invoked
+ * @post location_batch_get_location_cb() will be invoked
+ * @see location_manager_start_batch()
+ * @see location_batch_cb()
+ * @see location_batch_get_location_cb()
+ */
+int location_manager_foreach_location_batch(location_manager_h manager, location_batch_get_location_cb callback, void *user_data);
+
+/**
  * @brief Enables mock location.
  * @remarks You can enable the mock location when developer mode is enabled.
  * @since_tizen 3.0
index 7017361..f852f1a 100644 (file)
 /*
 * Internal Implementation
 */
-
-static void __cb_batch_updated(GObject *self, guint num_of_location, gpointer userdata)
-{
-       LOCATIONS_LOGD("Batch callback function has been invoked.");
-       location_manager_s *handle = (location_manager_s *) userdata;
-
-       if (handle->user_cb[_LOCATIONS_EVENT_TYPE_BATCH])
-               ((location_batch_cb) handle->user_cb[_LOCATIONS_EVENT_TYPE_BATCH])(num_of_location, handle->user_data[_LOCATIONS_EVENT_TYPE_BATCH]);
-}
-
-/*/////////////////////////////////////// */
-/* Location Manager */
-/*////////////////////////////////////// */
-
-EXPORT_API int location_manager_set_location_batch_cb(location_manager_h manager, location_batch_cb callback, int batch_interval, int batch_period, void *user_data)
-{
-       LOCATIONS_LOGD("location_manager_set_location_batch_cb");
-       LOCATIONS_NOT_SUPPORTED_CHECK(__is_batch_supported());
-
-       LOCATIONS_CHECK_CONDITION(batch_interval >= 1 && batch_interval <= 255, LOCATIONS_ERROR_INVALID_PARAMETER, "LOCATIONS_ERROR_INVALID_PARAMETER");
-       LOCATIONS_CHECK_CONDITION(batch_period >= 1 && batch_period <= 60000, LOCATIONS_ERROR_INVALID_PARAMETER, "LOCATIONS_ERROR_INVALID_PARAMETER");
-       LOCATIONS_CHECK_CONDITION(batch_interval <= batch_period, LOCATIONS_ERROR_INVALID_PARAMETER, "LOCATIONS_ERROR_INVALID_PARAMETER");
-       LOCATIONS_NULL_ARG_CHECK(manager);
-       LOCATIONS_NULL_ARG_CHECK(callback);
-       location_manager_s *handle = (location_manager_s *) manager;
-       g_object_set(handle->object, "batch-period", batch_period, NULL);
-       g_object_set(handle->object, "batch-interval", batch_interval, NULL);
-       return __set_callback(_LOCATIONS_EVENT_TYPE_BATCH, manager, callback, user_data);
-}
-
-EXPORT_API int location_manager_unset_location_batch_cb(location_manager_h manager)
-{
-       LOCATIONS_LOGD("location_manager_unset_location_batch_cb");
-       LOCATIONS_NOT_SUPPORTED_CHECK(__is_batch_supported());
-       return __unset_callback(_LOCATIONS_EVENT_TYPE_BATCH, manager);
-}
-
-EXPORT_API int location_manager_start_batch(location_manager_h manager)
-{
-       LOCATIONS_LOGD("location_manager_start_batch");
-       LOCATIONS_NOT_SUPPORTED_CHECK(__is_batch_supported());
-       LOCATIONS_NULL_ARG_CHECK(manager);
-       location_manager_s *handle = (location_manager_s *) manager;
-
-       if (LOCATIONS_METHOD_GPS == handle->method) {
-               if (!handle->sig_id[_LOCATION_SIGNAL_BATCH_UPDATED])
-                       handle->sig_id[_LOCATION_SIGNAL_BATCH_UPDATED] = g_signal_connect(handle->object, "batch-updated", G_CALLBACK(__cb_batch_updated), handle);
-       } else {
-               LOCATIONS_LOGE("method is not GPS");
-       }
-
-       if (handle->user_cb[_LOCATIONS_EVENT_TYPE_BATCH] != NULL)
-               LOCATIONS_LOGD("batch status set : Start");
-
-       int ret = location_start_batch(handle->object);
-       if (ret != LOCATION_ERROR_NONE)
-               return __convert_error_code(ret);
-
-       return LOCATIONS_ERROR_NONE;
-}
-
-EXPORT_API int location_manager_stop_batch(location_manager_h manager)
-{
-       LOCATIONS_LOGD("location_manager_stop_batch");
-       LOCATIONS_NOT_SUPPORTED_CHECK(__is_batch_supported());
-       LOCATIONS_NULL_ARG_CHECK(manager);
-       location_manager_s *handle = (location_manager_s *) manager;
-
-       if (LOCATIONS_METHOD_GPS == handle->method) {
-               if (handle->sig_id[_LOCATION_SIGNAL_BATCH_UPDATED]) {
-                       g_signal_handler_disconnect(handle->object, handle->sig_id[_LOCATION_SIGNAL_BATCH_UPDATED]);
-                       handle->sig_id[_LOCATION_SIGNAL_BATCH_UPDATED] = 0;
-               }
-       } else {
-               LOCATIONS_LOGE("method is not GPS");
-       }
-
-       int ret = location_stop_batch(handle->object);
-       if (ret != LOCATION_ERROR_NONE)
-               return __convert_error_code(ret);
-
-       return LOCATIONS_ERROR_NONE;
-}
-
-EXPORT_API int location_manager_foreach_location_batch(location_manager_h manager, location_batch_get_location_cb callback, void *user_data)
-{
-       LOCATIONS_LOGD("location_manager_foreach_location_batch");
-       LOCATIONS_NOT_SUPPORTED_CHECK(__is_batch_supported());
-       LOCATIONS_NULL_ARG_CHECK(manager);
-       LOCATIONS_NULL_ARG_CHECK(callback);
-       location_manager_s *handle = (location_manager_s *) manager;
-       LocationBatch *batch = NULL;
-
-       int ret = location_get_batch(handle->object, &batch);
-       if (ret != LOCATION_ERROR_NONE || batch == NULL) {
-               if (ret == LOCATION_ERROR_NOT_SUPPORTED) {
-                       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) : batch is NULL ", LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE);
-               return LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE;
-       }
-
-       int i;
-       for (i = 0; i < batch->num_of_location; i++) {
-               gdouble latitude;
-               gdouble longitude;
-               gdouble altitude;
-               gdouble speed;
-               gdouble direction;
-               gdouble h_accuracy;
-               gdouble v_accuracy;
-               guint timestamp;
-
-               location_get_batch_details(batch, i, &latitude, &longitude, &altitude, &speed, &direction, &h_accuracy, &v_accuracy, &timestamp);
-               if (callback(latitude, longitude, altitude, speed, direction, h_accuracy, v_accuracy, timestamp, user_data) != TRUE)
-                       break;
-       }
-       location_batch_free(batch);
-       batch = NULL;
-       return LOCATIONS_ERROR_NONE;
-}
-
 EXPORT_API int location_manager_enable_restriction(bool enable)
 {
        int ret = LOCATION_ERROR_NONE;
index 0eb9de5..0cc3859 100755 (executable)
@@ -122,6 +122,15 @@ static void __cb_location_updated(GObject *self, int error, gpointer position, g
        }
 }
 
+static void __cb_batch_updated(GObject *self, guint num_of_location, gpointer userdata)
+{
+       LOCATIONS_LOGD("Batch callback function has been invoked.");
+       location_manager_s *handle = (location_manager_s *) userdata;
+
+       if (handle->user_cb[_LOCATIONS_EVENT_TYPE_BATCH])
+               ((location_batch_cb) handle->user_cb[_LOCATIONS_EVENT_TYPE_BATCH])(num_of_location, handle->user_data[_LOCATIONS_EVENT_TYPE_BATCH]);
+}
+
 static void __cb_service_enabled(GObject *self, guint status, gpointer userdata)
 {
        LOCATIONS_LOGD("Invoked. status = %d", status);
@@ -1433,6 +1442,115 @@ EXPORT_API int gps_status_foreach_last_satellites_in_view(location_manager_h man
 /**
  * Tizen 3.0
  */
+EXPORT_API int location_manager_set_location_batch_cb(location_manager_h manager, location_batch_cb callback, int batch_interval, int batch_period, void *user_data)
+{
+       LOCATIONS_LOGD("location_manager_set_location_batch_cb");
+       LOCATIONS_NOT_SUPPORTED_CHECK(__is_batch_supported());
+
+       LOCATIONS_CHECK_CONDITION(batch_interval >= 1 && batch_interval <= 255, LOCATIONS_ERROR_INVALID_PARAMETER, "LOCATIONS_ERROR_INVALID_PARAMETER");
+       LOCATIONS_CHECK_CONDITION(batch_period >= 1 && batch_period <= 60000, LOCATIONS_ERROR_INVALID_PARAMETER, "LOCATIONS_ERROR_INVALID_PARAMETER");
+       LOCATIONS_CHECK_CONDITION(batch_interval <= batch_period, LOCATIONS_ERROR_INVALID_PARAMETER, "LOCATIONS_ERROR_INVALID_PARAMETER");
+       LOCATIONS_NULL_ARG_CHECK(manager);
+       LOCATIONS_NULL_ARG_CHECK(callback);
+       location_manager_s *handle = (location_manager_s *) manager;
+       g_object_set(handle->object, "batch-period", batch_period, NULL);
+       g_object_set(handle->object, "batch-interval", batch_interval, NULL);
+       return __set_callback(_LOCATIONS_EVENT_TYPE_BATCH, manager, callback, user_data);
+}
+
+EXPORT_API int location_manager_unset_location_batch_cb(location_manager_h manager)
+{
+       LOCATIONS_LOGD("location_manager_unset_location_batch_cb");
+       LOCATIONS_NOT_SUPPORTED_CHECK(__is_batch_supported());
+       return __unset_callback(_LOCATIONS_EVENT_TYPE_BATCH, manager);
+}
+
+EXPORT_API int location_manager_start_batch(location_manager_h manager)
+{
+       LOCATIONS_LOGD("location_manager_start_batch");
+       LOCATIONS_NOT_SUPPORTED_CHECK(__is_batch_supported());
+       LOCATIONS_NULL_ARG_CHECK(manager);
+       location_manager_s *handle = (location_manager_s *) manager;
+
+       if (LOCATIONS_METHOD_GPS == handle->method) {
+               if (!handle->sig_id[_LOCATION_SIGNAL_BATCH_UPDATED])
+                       handle->sig_id[_LOCATION_SIGNAL_BATCH_UPDATED] = g_signal_connect(handle->object, "batch-updated", G_CALLBACK(__cb_batch_updated), handle);
+       } else {
+               LOCATIONS_LOGE("method is not GPS [LOCATIONS_ERROR_INCORRECT_METHOD]");
+               return LOCATIONS_ERROR_INCORRECT_METHOD;
+       }
+
+       if (handle->user_cb[_LOCATIONS_EVENT_TYPE_BATCH] != NULL)
+               LOCATIONS_LOGD("batch status set : Start");
+
+       int ret = location_start_batch(handle->object);
+       if (ret != LOCATION_ERROR_NONE)
+               return __convert_error_code(ret);
+
+       return LOCATIONS_ERROR_NONE;
+}
+
+EXPORT_API int location_manager_stop_batch(location_manager_h manager)
+{
+       LOCATIONS_LOGD("location_manager_stop_batch");
+       LOCATIONS_NOT_SUPPORTED_CHECK(__is_batch_supported());
+       LOCATIONS_NULL_ARG_CHECK(manager);
+       location_manager_s *handle = (location_manager_s *) manager;
+
+       if (LOCATIONS_METHOD_GPS == handle->method) {
+               if (handle->sig_id[_LOCATION_SIGNAL_BATCH_UPDATED]) {
+                       g_signal_handler_disconnect(handle->object, handle->sig_id[_LOCATION_SIGNAL_BATCH_UPDATED]);
+                       handle->sig_id[_LOCATION_SIGNAL_BATCH_UPDATED] = 0;
+               }
+       }
+
+       int ret = location_stop_batch(handle->object);
+       if (ret != LOCATION_ERROR_NONE)
+               return __convert_error_code(ret);
+
+       return LOCATIONS_ERROR_NONE;
+}
+
+EXPORT_API int location_manager_foreach_location_batch(location_manager_h manager, location_batch_get_location_cb callback, void *user_data)
+{
+       LOCATIONS_LOGD("location_manager_foreach_location_batch");
+       LOCATIONS_NOT_SUPPORTED_CHECK(__is_batch_supported());
+       LOCATIONS_NULL_ARG_CHECK(manager);
+       LOCATIONS_NULL_ARG_CHECK(callback);
+       location_manager_s *handle = (location_manager_s *) manager;
+       LocationBatch *batch = NULL;
+
+       int ret = location_get_batch(handle->object, &batch);
+       if (ret != LOCATION_ERROR_NONE || batch == NULL) {
+               if (ret == LOCATION_ERROR_NOT_ALLOWED) {
+                       LOCATIONS_LOGE("LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED");
+                       return LOCATIONS_ERROR_ACCESSIBILITY_NOT_ALLOWED;
+               }
+
+               LOCATIONS_LOGE("Batch is NULL [LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE]");
+               return LOCATIONS_ERROR_SERVICE_NOT_AVAILABLE;
+       }
+
+       int i;
+       for (i = 0; i < batch->num_of_location; i++) {
+               gdouble latitude;
+               gdouble longitude;
+               gdouble altitude;
+               gdouble speed;
+               gdouble direction;
+               gdouble h_accuracy;
+               gdouble v_accuracy;
+               guint timestamp;
+
+               location_get_batch_details(batch, i, &latitude, &longitude, &altitude, &speed, &direction, &h_accuracy, &v_accuracy, &timestamp);
+               if (callback(latitude, longitude, altitude, speed, direction, h_accuracy, v_accuracy, timestamp, user_data) != TRUE)
+                       break;
+       }
+       location_batch_free(batch);
+       batch = NULL;
+       return LOCATIONS_ERROR_NONE;
+}
+
 EXPORT_API int location_manager_enable_mock_location(const bool enable)
 {
        LOCATIONS_LOGD("enable: %d", enable);