From 12dadc2c295081674e6df28b7dc42cc99220038c Mon Sep 17 00:00:00 2001 From: "kj7.sung" Date: Thu, 1 Sep 2016 11:42:22 +0900 Subject: [PATCH] [UTC][location-manager][Non-ACR][Fix some bugs for multi handle] Signed-off-by: kj7.sung Change-Id: I7ad61a3588793fce75d4ea985f2dcc7476d58837 --- .../location-manager/utc-location-manager-batch.c | 5 ++++ src/utc/location-manager/utc-location-manager.c | 27 +++++++++++++++++----- 2 files changed, 26 insertions(+), 6 deletions(-) diff --git a/src/utc/location-manager/utc-location-manager-batch.c b/src/utc/location-manager/utc-location-manager-batch.c index 00d0b64..45dace2 100755 --- a/src/utc/location-manager/utc-location-manager-batch.c +++ b/src/utc/location-manager/utc-location-manager-batch.c @@ -115,6 +115,11 @@ int utc_location_manager_start_batch_n(void) CHECK_INVALID_PARAMETER(is_batch_supported, ret); if(is_wps_supported) { + if(manager) { + location_manager_destroy(manager); + manager = NULL; + } + location_manager_h manager2 = NULL; ret = location_manager_create(LOCATIONS_METHOD_WPS, &manager2); assert_eq(ret, LOCATIONS_ERROR_NONE); diff --git a/src/utc/location-manager/utc-location-manager.c b/src/utc/location-manager/utc-location-manager.c index 5c7a8cd..9f32575 100755 --- a/src/utc/location-manager/utc-location-manager.c +++ b/src/utc/location-manager/utc-location-manager.c @@ -62,6 +62,15 @@ static void __location_updated_cb(location_error_e error, double latitude, doubl } } +static int cleanup_default_handle() +{ + int ret = LOCATIONS_ERROR_NONE; + if (manager) { + ret = location_manager_destroy(manager); + manager = NULL; + } + return ret; +} /** * @function utc_location_manager_startup @@ -108,6 +117,9 @@ int utc_location_manager_create_p(void) { location_manager_h manager2 = NULL; + ret = cleanup_default_handle(); + assert_eq(ret, LOCATIONS_ERROR_NONE); + ret = location_manager_create(LOCATIONS_METHOD_GPS, &manager2); if (is_gps_supported) { assert_eq(ret, LOCATIONS_ERROR_NONE); @@ -115,12 +127,6 @@ int utc_location_manager_create_p(void) ret = location_manager_destroy(manager2); assert_eq(ret, LOCATIONS_ERROR_NONE); manager2 = NULL; - - if (manager) { - ret = location_manager_destroy(manager); - assert_eq(ret, LOCATIONS_ERROR_NONE); - manager = NULL; - } } else { assert_eq(ret, LOCATIONS_ERROR_NOT_SUPPORTED); } @@ -226,6 +232,9 @@ int utc_location_manager_get_method_p2(void) if (is_location_supported) { if (is_gps_supported) { + ret = cleanup_default_handle(); + assert_eq(ret, LOCATIONS_ERROR_NONE); + ret = location_manager_create(LOCATIONS_METHOD_GPS, &manager2); assert_eq(ret, LOCATIONS_ERROR_NONE); @@ -258,6 +267,9 @@ int utc_location_manager_get_method_p3(void) if (is_location_supported) { if (is_wps_supported) { + ret = cleanup_default_handle(); + assert_eq(ret, LOCATIONS_ERROR_NONE); + ret = location_manager_create(LOCATIONS_METHOD_WPS, &manager2); assert_eq(ret, LOCATIONS_ERROR_NONE); @@ -1073,6 +1085,9 @@ int utc_location_manager_request_single_location_p2(void) __location_updated = false; if (is_location_supported) { + ret = cleanup_default_handle(); + assert_eq(ret, LOCATIONS_ERROR_NONE); + if (is_gps_supported) { ret = location_manager_create(LOCATIONS_METHOD_GPS, &manager2); assert_eq(ret, LOCATIONS_ERROR_NONE); -- 2.7.4