From a21da3c95f05a9dbcfdad784594285a7d664483a Mon Sep 17 00:00:00 2001 From: "kj7.sung" Date: Thu, 30 Mar 2017 12:54:51 +0900 Subject: [PATCH] sync : multi handle, mock privilege, svace - Fix dynamic interval to support multi handle - Privilege check for mock location - svace single_request Change-Id: Ib6c032e37944c4a74bf3a3f7cbfc5cae1e9e31c4 Signed-off-by: kj7.sung --- location/manager/location-gps.c | 28 +++++++------- location/manager/location-wps.c | 30 +++++++++------ location/manager/location.c | 78 ++++++++------------------------------- location/manager/location.h | 4 +- packaging/liblbs-location.changes | 12 ++++++ packaging/liblbs-location.spec | 2 +- 6 files changed, 65 insertions(+), 89 deletions(-) diff --git a/location/manager/location-gps.c b/location/manager/location-gps.c index f08255d..bfdf34f 100755 --- a/location/manager/location-gps.c +++ b/location/manager/location-gps.c @@ -891,12 +891,11 @@ static gboolean __single_location_timeout_cb(void *data) LocationPosition *pos = location_position_new(0, 0.0, 0.0, 0.0, LOCATION_STATUS_NO_FIX); LocationVelocity *vel = location_velocity_new(0, 0.0, 0.0, 0.0); - LocationAccuracy *acc = location_accuracy_new(LOCATION_ACCURACY_LEVEL_NONE, 0.0, 0.0); if (priv->loc_timeout) g_source_remove(priv->loc_timeout); priv->loc_timeout = 0; - g_signal_emit(self, signals[LOCATION_UPDATED], 0, LOCATION_ERROR_NOT_AVAILABLE, pos, vel, acc); + g_signal_emit(self, signals[LOCATION_UPDATED], 0, LOCATION_ERROR_NOT_AVAILABLE, pos, vel, NULL); location_gps_stop(self); return FALSE; @@ -936,20 +935,23 @@ location_gps_request_single_location(LocationGps *self, int timeout) if (__get_started(self) == TRUE) return LOCATION_ERROR_NONE; int ret = LOCATION_ERROR_NONE; - - __set_started(self, TRUE); - ret = priv->mod->ops.start(priv->mod->handler, LOCATION_UPDATE_INTERVAL_DEFAULT, gps_status_cb, gps_single_location_cb, NULL, self); - if (ret != LOCATION_ERROR_NONE) { - LOCATION_LOGE("Fail to start request single. Error[%d]", ret); - __set_started(self, FALSE); - return ret; + if (!location_setting_get_int(VCONFKEY_LOCATION_ENABLED)) { + ret = LOCATION_ERROR_SETTING_OFF; } else { - if (priv->loc_timeout != 0) - g_source_remove(priv->loc_timeout); + __set_started(self, TRUE); + ret = priv->mod->ops.start(priv->mod->handler, LOCATION_UPDATE_INTERVAL_DEFAULT, gps_status_cb, gps_single_location_cb, NULL, self); + if (ret != LOCATION_ERROR_NONE) { + LOCATION_LOGE("Fail to start request single. Error[%d]", ret); + __set_started(self, FALSE); + return ret; + } else { + if (priv->loc_timeout != 0) + g_source_remove(priv->loc_timeout); - priv->loc_timeout = g_timeout_add_seconds(timeout, __single_location_timeout_cb, self); - } + priv->loc_timeout = g_timeout_add_seconds(timeout, __single_location_timeout_cb, self); + } + } return ret; } diff --git a/location/manager/location-wps.c b/location/manager/location-wps.c index 7dd4044..a268c4c 100755 --- a/location/manager/location-wps.c +++ b/location/manager/location-wps.c @@ -618,12 +618,11 @@ static gboolean __single_location_timeout_cb(void *data) LocationPosition *pos = location_position_new(0, 0.0, 0.0, 0.0, LOCATION_STATUS_NO_FIX); LocationVelocity *vel = location_velocity_new(0, 0.0, 0.0, 0.0); - LocationAccuracy *acc = location_accuracy_new(LOCATION_ACCURACY_LEVEL_NONE, 0.0, 0.0); if (priv->loc_timeout) g_source_remove(priv->loc_timeout); priv->loc_timeout = 0; - g_signal_emit(self, signals[LOCATION_UPDATED], 0, LOCATION_ERROR_NOT_AVAILABLE, pos, vel, acc); + g_signal_emit(self, signals[LOCATION_UPDATED], 0, LOCATION_ERROR_NOT_AVAILABLE, pos, vel, NULL); location_wps_stop(self); return FALSE; @@ -664,17 +663,22 @@ location_wps_request_single_location(LocationWps *self, int timeout) int ret = LOCATION_ERROR_NONE; - __set_started(self, TRUE); - ret = priv->mod->ops.start(priv->mod->handler, wps_status_cb, wps_single_location_cb, self); - if (ret != LOCATION_ERROR_NONE) { - LOCATION_LOGE("Fail to start request single. Error[%d]", ret); - __set_started(self, FALSE); - return ret; + if (!location_setting_get_int(VCONFKEY_LOCATION_NETWORK_ENABLED)) { + ret = LOCATION_ERROR_SETTING_OFF; } else { - if (priv->loc_timeout != 0) - g_source_remove(priv->loc_timeout); + __set_started(self, TRUE); + ret = priv->mod->ops.start(priv->mod->handler, wps_status_cb, wps_single_location_cb, self); + if (ret != LOCATION_ERROR_NONE) { + LOCATION_LOGE("Fail to start request single. Error[%d]", ret); + __set_started(self, FALSE); + return ret; + } else { + if (priv->loc_timeout != 0) + g_source_remove(priv->loc_timeout); + + priv->loc_timeout = g_timeout_add_seconds(timeout, __single_location_timeout_cb, self); + } - priv->loc_timeout = g_timeout_add_seconds(timeout, __single_location_timeout_cb, self); } return ret; @@ -740,6 +744,8 @@ location_wps_set_mock_location(LocationWps *self, LocationPosition *position, Lo { LOC_FUNC_LOG LocationWpsPrivate *priv = GET_PRIVATE(self); + g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE); + g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE); g_return_val_if_fail(priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE); g_return_val_if_fail(priv->mod->ops.set_mock_location, LOCATION_ERROR_NOT_AVAILABLE); @@ -760,6 +766,8 @@ location_wps_clear_mock_location(LocationWps *self) { LOC_FUNC_LOG LocationWpsPrivate *priv = GET_PRIVATE(self); + g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE); + g_return_val_if_fail(priv->mod, LOCATION_ERROR_NOT_AVAILABLE); g_return_val_if_fail(priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE); g_return_val_if_fail(priv->mod->ops.clear_mock_location, LOCATION_ERROR_NOT_AVAILABLE); diff --git a/location/manager/location.c b/location/manager/location.c index 5ec18ab..9a82d71 100755 --- a/location/manager/location.c +++ b/location/manager/location.c @@ -48,17 +48,7 @@ typedef struct _LocationSetting { void *user_data; } LocationSetting; -enum { - _METHOD_HYBRID = 0, - _METHOD_GPS_1, - _METHOD_GPS_2, - _METHOD_WPS_1, - _METHOD_WPS_2, - _METHOD_MAX -}; - static LocationSetting g_location_setting; -static bool is_method_created[_METHOD_MAX] = {false}; static char *__convert_setting_key(LocationMethod method) { @@ -127,53 +117,20 @@ int location_init(void) } EXPORT_API LocationObject * -location_new(LocationMethod method, gboolean is_internal_for_hybrid) +location_new(LocationMethod method, gboolean multi_handle) { LocationObject *self = NULL; - LOCATION_LOGD("method : %d, is_internal_for_hybrid[%d]", method, is_internal_for_hybrid); + LOCATION_LOGD("method : %d, multi_handle[%d]", method, multi_handle); switch (method) { case LOCATION_METHOD_HYBRID: - if (is_method_created[_METHOD_HYBRID]) { - LOCATION_LOGE("Hybrid handle already exist."); - } else { - self = g_object_new(LOCATION_TYPE_HYBRID, NULL); - is_method_created[_METHOD_HYBRID] = true; - } + self = g_object_new(LOCATION_TYPE_HYBRID, NULL); break; case LOCATION_METHOD_GPS: - if (is_internal_for_hybrid) { - if (is_method_created[_METHOD_GPS_2]) { - LOCATION_LOGD("Hybrid(GPS) handle already exist."); - } else { - is_method_created[_METHOD_GPS_2] = true; - self = g_object_new(LOCATION_TYPE_GPS, NULL); - } - } else { - if (is_method_created[_METHOD_GPS_1]) { - LOCATION_LOGE("GPS handle already exist."); - } else { - is_method_created[_METHOD_GPS_1] = true; - self = g_object_new(LOCATION_TYPE_GPS, NULL); - } - } + self = g_object_new(LOCATION_TYPE_GPS, NULL); break; case LOCATION_METHOD_WPS: - if (is_internal_for_hybrid) { - if (is_method_created[_METHOD_WPS_2]) { - LOCATION_LOGD("Hybrid(WPS) handle already exist."); - } else { - is_method_created[_METHOD_WPS_2] = true; - self = g_object_new(LOCATION_TYPE_WPS, NULL); - } - } else { - if (is_method_created[_METHOD_WPS_1]) { - LOCATION_LOGE("WPS handle already exist."); - } else { - is_method_created[_METHOD_WPS_1] = true; - self = g_object_new(LOCATION_TYPE_WPS, NULL); - } - } + self = g_object_new(LOCATION_TYPE_WPS, NULL); break; case LOCATION_METHOD_PASSIVE: self = g_object_new(LOCATION_TYPE_PASSIVE, NULL); @@ -187,22 +144,9 @@ location_new(LocationMethod method, gboolean is_internal_for_hybrid) } EXPORT_API int -location_free(LocationObject *obj, gboolean is_internal_for_hybrid) +location_free(LocationObject *obj, gboolean multi_handle) { g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER); - if (G_OBJECT_TYPE(obj) == LOCATION_TYPE_HYBRID) { - is_method_created[_METHOD_HYBRID] = false; - } else if (G_OBJECT_TYPE(obj) == LOCATION_TYPE_GPS) { - if (is_internal_for_hybrid) - is_method_created[_METHOD_GPS_2] = false; - else - is_method_created[_METHOD_GPS_1] = false; - } else if (G_OBJECT_TYPE(obj) == LOCATION_TYPE_WPS) { - if (is_internal_for_hybrid) - is_method_created[_METHOD_WPS_2] = false; - else - is_method_created[_METHOD_WPS_1] = false; - } g_object_unref(obj); return LOCATION_ERROR_NONE; } @@ -744,6 +688,11 @@ location_set_mock_location(LocationObject *obj, const LocationPosition *position g_return_val_if_fail(accuracy, LOCATION_ERROR_PARAMETER); int ret = LOCATION_ERROR_NONE; + if (_get_tizen_profile() != TIZEN_PROFILE_TV) { + ret = location_check_cynara(LOCATION_PRIVILEGE); + LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret)); + } + ret = location_ielement_set_mock_location(LOCATION_IELEMENT(obj), position, velocity, accuracy); LOC_IF_FAIL(ret, _E, "Fail to set_mock_location [%s]", err_msg(ret)); @@ -756,6 +705,11 @@ location_clear_mock_location(LocationObject *obj) g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER); int ret = LOCATION_ERROR_NONE; + if (_get_tizen_profile() != TIZEN_PROFILE_TV) { + ret = location_check_cynara(LOCATION_PRIVILEGE); + LOC_IF_FAIL(ret, _E, "Privilege not allowed [%s]", err_msg(ret)); + } + ret = location_ielement_clear_mock_location(LOCATION_IELEMENT(obj)); LOC_IF_FAIL(ret, _E, "Fail to clear_mock_location [%s]", err_msg(ret)); diff --git a/location/manager/location.h b/location/manager/location.h index 82ca718..bfc595e 100755 --- a/location/manager/location.h +++ b/location/manager/location.h @@ -72,7 +72,7 @@ int location_init(void); * @retval NULL if error occured * @see location_free */ -LocationObject *location_new(LocationMethod method, gboolean is_internal_for_hybrid); +LocationObject *location_new(LocationMethod method, gboolean multi_handle); /** * @brief Free memory of given #LocationObject. @@ -84,7 +84,7 @@ LocationObject *location_new(LocationMethod method, gboolean is_internal_for_hyb * @retval 0 Success. * Please refer #LocationError for more information. */ -int location_free(LocationObject *obj, gboolean is_internal_for_hybrid); +int location_free(LocationObject *obj, gboolean multi_handle); /** * @brief Start the location service by using given #LocationObject. diff --git a/packaging/liblbs-location.changes b/packaging/liblbs-location.changes index e581fd7..cb5ec7a 100644 --- a/packaging/liblbs-location.changes +++ b/packaging/liblbs-location.changes @@ -1,3 +1,15 @@ +[Version] libslp-location_1.3.11 +[Date] 29 Mar 2017 +[Changes] Fix dynamic interval to support multi handle +[Developer] Kyoungjun Sung + +================================================================================ +[Version] libslp-location_1.3.10 +[Date] 8 Mar 2017 +[Changes] Privilege check for mock location +[Developer] Kyoungjun Sung + +================================================================================ [Version] libslp-location_1.3.9 [Date] 7 Mar 2017 [Changes] Fix build error for tv profile diff --git a/packaging/liblbs-location.spec b/packaging/liblbs-location.spec index 7664201..7bc6b3f 100755 --- a/packaging/liblbs-location.spec +++ b/packaging/liblbs-location.spec @@ -1,6 +1,6 @@ Name: liblbs-location Summary: Location Based Service Library -Version: 1.3.9 +Version: 1.3.11 Release: 1 Group: Location/Libraries License: Apache-2.0 -- 2.7.4