Change service state behavior when GPS/WPS searching mode 56/72956/2 accepted/tizen/common/20160607.194814 accepted/tizen/ivi/20160607.235617 accepted/tizen/mobile/20160607.235630 accepted/tizen/tv/20160607.235540 accepted/tizen/wearable/20160607.235550 submit/tizen/20160607.100305
authorkj7.sung <kj7.sung@samsung.com>
Fri, 3 Jun 2016 08:29:23 +0000 (17:29 +0900)
committerkj7.sung <kj7.sung@samsung.com>
Fri, 3 Jun 2016 08:31:45 +0000 (17:31 +0900)
2. get_accessibility_state behavior changed

Change-Id: I8f225cfc3c11b13065cdcfa8abc3b046d17f41a9
Signed-off-by: kj7.sung <kj7.sung@samsung.com>
location/manager/location-batch.c
location/manager/location-common-util.h
location/manager/location-gps.c
location/manager/location-hybrid-mobile.c
location/manager/location-wps.c
location/manager/location.c
packaging/liblbs-location.changes
packaging/liblbs-location.spec

index 5c8cf90..66e86d1 100755 (executable)
@@ -128,7 +128,7 @@ location_get_batch_file(int num_of_location)
        return batch;
 }
 
-#ifdef TIZEN_DEVICE
+#if defined(TIZEN_DEVICE) && !defined(TIZEN_PROFILE_TV)
 EXPORT_API gboolean location_set_sensor_batch(LocationBatch *batch, sensor_event_s *event)
 {
        g_return_val_if_fail(batch, FALSE);
@@ -138,8 +138,8 @@ EXPORT_API gboolean location_set_sensor_batch(LocationBatch *batch, sensor_event
        float latitude  = event->values[0];
        float longitude = event->values[1];
        float altitude  = event->values[2];
-       float speed      = event->values[3];
-       int idx = (int)(event->values[4]);
+       float speed     = event->values[3];
+       int idx   = (int)(event->values[4]);
 
        batch->batch_data[idx].timestamp = batch->start_time - (time_t)((timestamp / 1001000) % 100000);
        batch->batch_data[idx].latitude = latitude;
index 333b2e2..09565f5 100644 (file)
@@ -65,6 +65,22 @@ int location_get_app_type(char *app_id);
 
 const char* err_msg(int err);
 
+#define LOCATION_IF_POS_FAIL(path) {\
+               int state = 0; \
+               vconf_get_int(path, &state); \
+               if (state != 2){\
+                       return LOCATION_ERROR_NOT_AVAILABLE;\
+               }\
+       }
+
+#define LOCATION_IF_HYBRID_FAIL(gpath, wpath) { \
+               int gps = 0; vconf_get_int(gpath, &gps); \
+               int wps = 0; vconf_get_int(wpath, &wps); \
+               if (gps != 2 && wps != 2) {\
+                       return LOCATION_ERROR_NOT_AVAILABLE;\
+               }\
+       }
+
 G_END_DECLS
 
 #endif
index 3e78d03..fda3bf6 100755 (executable)
@@ -68,11 +68,7 @@ typedef struct _LocationGpsPrivate {
        LocationAccuracy        *acc;
        LocationSatellite       *sat;
        GList                           *boundary_list;
-#ifdef TIZEN_PROFILE_MOBILE
-       guint                           pos_searching_timer;
-       guint                           vel_searching_timer;
-#endif
-#ifdef TIZEN_DEVICE
+#if defined(TIZEN_DEVICE) && !defined(TIZEN_PROFILE_TV)
        sensor_h sensor;
        sensor_listener_h sensor_listener;
 #endif
@@ -107,76 +103,7 @@ static GParamSpec *properties[PROP_MAX] = {NULL, };
 static void location_ielement_interface_init(LocationIElementInterface *iface);
 
 G_DEFINE_TYPE_WITH_CODE(LocationGps, location_gps, G_TYPE_OBJECT,
-                                               G_IMPLEMENT_INTERFACE(LOCATION_TYPE_IELEMENT,
-                                                                                         location_ielement_interface_init));
-#ifdef TIZEN_PROFILE_MOBILE
-static gboolean _location_timeout_cb(gpointer data)
-{
-       GObject *object = (GObject *)data;
-       LocationGpsPrivate *priv = GET_PRIVATE(object);
-       g_return_val_if_fail(priv, FALSE);
-
-       LocationPosition *pos = NULL;
-       LocationVelocity *vel = NULL;
-       LocationAccuracy *acc = NULL;
-
-       if (priv->pos)
-               pos = location_position_copy(priv->pos);
-       else
-               pos = location_position_new(0, 0.0, 0.0, 0.0, LOCATION_STATUS_NO_FIX);
-
-       if (priv->vel)
-               vel = location_velocity_copy(priv->vel);
-       else
-               vel = location_velocity_new(0, 0.0, 0.0, 0.0);
-
-       if (priv->acc)
-               acc = location_accuracy_copy(priv->acc);
-       else
-               acc = location_accuracy_new(LOCATION_ACCURACY_LEVEL_NONE, 0.0, 0.0);
-
-       g_signal_emit(object, signals[SERVICE_UPDATED], 0, priv->signal_type, pos, vel, acc);
-       priv->signal_type = 0;
-
-       location_position_free(pos);
-       location_velocity_free(vel);
-       location_accuracy_free(acc);
-
-       return TRUE;
-}
-
-static gboolean _position_timeout_cb(gpointer data)
-{
-       GObject *object = (GObject *)data;
-       LocationGpsPrivate *priv = GET_PRIVATE(object);
-       g_return_val_if_fail(priv, FALSE);
-
-       if (priv->pos_interval == priv->vel_interval) {
-               priv->signal_type |= POSITION_UPDATED;
-               priv->signal_type |= VELOCITY_UPDATED;
-       } else {
-               priv->signal_type |= POSITION_UPDATED;
-       }
-       _location_timeout_cb(object);
-
-       return TRUE;
-}
-
-static gboolean _velocity_timeout_cb(gpointer data)
-{
-       GObject *object = (GObject *)data;
-       LocationGpsPrivate *priv = GET_PRIVATE(object);
-       g_return_val_if_fail(priv, FALSE);
-
-       if (priv->pos_interval != priv->vel_interval) {
-               priv->signal_type |= VELOCITY_UPDATED;
-               _location_timeout_cb(object);
-       }
-
-       return TRUE;
-}
-
-#endif
+                                               G_IMPLEMENT_INTERFACE(LOCATION_TYPE_IELEMENT, location_ielement_interface_init));
 
 static void __reset_pos_data_from_priv(LocationGpsPrivate *priv)
 {
@@ -248,12 +175,6 @@ static void gps_status_cb(gboolean enabled, LocationStatus status, gpointer self
        LocationGpsPrivate *priv = GET_PRIVATE(self);
        g_return_if_fail(priv);
        if (!priv->enabled && enabled) {        /* Update satellite at searching status. */
-#ifdef TIZEN_PROFILE_MOBILE
-               if (priv->pos_searching_timer) g_source_remove(priv->pos_searching_timer);
-               if (priv->vel_searching_timer) g_source_remove(priv->vel_searching_timer);
-               priv->pos_searching_timer = 0;
-               priv->vel_searching_timer = 0;
-#endif
                return; /* Ignored: Support to get position at enabled callback */
        } else if (priv->enabled == TRUE && enabled == FALSE) {
                __set_started(self, FALSE);
@@ -333,13 +254,8 @@ static void location_setting_search_cb(keynode_t *key, gpointer self)
        g_return_if_fail(priv);
 
        if (location_setting_get_key_val(key) == VCONFKEY_LOCATION_GPS_SEARCHING) {
-               if (!priv->pos_searching_timer) priv->pos_searching_timer = g_timeout_add(priv->pos_interval * 1000, _position_timeout_cb, self);
-               if (!priv->vel_searching_timer) priv->vel_searching_timer = g_timeout_add(priv->vel_interval * 1000, _velocity_timeout_cb, self);
-       } else {
-               if (priv->pos_searching_timer) g_source_remove(priv->pos_searching_timer);
-               if (priv->vel_searching_timer) g_source_remove(priv->vel_searching_timer);
-               priv->pos_searching_timer = 0;
-               priv->vel_searching_timer = 0;
+               LOCATION_LOGD("enable_signaling : SERVICE_DISABLED");
+               enable_signaling(self, signals, &(priv->enabled), FALSE, LOCATION_STATUS_NO_FIX);
        }
 }
 #endif
@@ -435,13 +351,6 @@ static int location_gps_stop(LocationGps *self)
                return LOCATION_ERROR_NONE;
        }
 
-#ifdef TIZEN_PROFILE_MOBILE
-       if (priv->pos_searching_timer) g_source_remove(priv->pos_searching_timer);
-       if (priv->vel_searching_timer) g_source_remove(priv->vel_searching_timer);
-       priv->pos_searching_timer = 0;
-       priv->vel_searching_timer = 0;
-#endif
-
        if (priv->app_type != CPPAPP && priv->set_noti == TRUE) {
                location_setting_ignore_notify(VCONFKEY_LOCATION_ENABLED, location_setting_gps_cb);
 #ifdef TIZEN_PROFILE_MOBILE
@@ -455,7 +364,7 @@ static int location_gps_stop(LocationGps *self)
        return ret;
 }
 
-#ifdef TIZEN_DEVICE
+#if defined(TIZEN_DEVICE) && !defined(TIZEN_PROFILE_TV)
 static void __sensor_event_cb(sensor_h s, sensor_event_s *event, void *data)
 {
        LocationGpsPrivate *priv = GET_PRIVATE(data);
@@ -553,9 +462,7 @@ static int location_gps_start_batch(LocationGps *self)
        if (!location_setting_get_int(VCONFKEY_LOCATION_ENABLED)) {
                ret = LOCATION_ERROR_SETTING_OFF;
        } else {
-#ifdef TIZEN_DEVICE
-               return __set_sensor_batch(self, priv->batch_interval);
-#else
+#ifndef TIZEN_DEVICE
                __set_started(self, TRUE);
                ret = priv->mod->ops.start_batch(priv->mod->handler, gps_batch_cb, priv->batch_interval, priv->batch_period, self);
                if (ret != LOCATION_ERROR_NONE) {
@@ -564,6 +471,10 @@ static int location_gps_start_batch(LocationGps *self)
                        return ret;
                }
 #endif
+
+#if defined(TIZEN_DEVICE) && !defined(TIZEN_PROFILE_TV)
+               return  __set_sensor_batch(self, priv->batch_interval);
+#endif
        }
 
        return ret;
@@ -580,7 +491,7 @@ static int location_gps_stop_batch(LocationGps *self)
 
        int ret = LOCATION_ERROR_NONE;
 
-#ifdef TIZEN_DEVICE
+#if defined(TIZEN_DEVICE) && !defined(TIZEN_PROFILE_TV)
        ret = sensor_listener_stop(priv->sensor_listener);
        LOC_IF_FAIL(ret, _E, "Fail to listener_stop [%s]", err_msg(LOCATION_ERROR_NOT_AVAILABLE));
 
@@ -612,12 +523,6 @@ static void location_gps_dispose(GObject *gobject)
        g_return_if_fail(priv);
        g_mutex_clear(&priv->mutex);
 
-#ifdef TIZEN_PROFILE_MOBILE
-       if (priv->pos_searching_timer) g_source_remove(priv->pos_searching_timer);
-       if (priv->vel_searching_timer) g_source_remove(priv->vel_searching_timer);
-       priv->pos_searching_timer = 0;
-       priv->vel_searching_timer = 0;
-#endif
        if (priv->loc_timeout) g_source_remove(priv->loc_timeout);
        priv->loc_timeout = 0;
 
@@ -710,13 +615,6 @@ static void location_gps_set_property(GObject *object, guint property_id, const
                                        priv->pos_interval = (guint)LOCATION_UPDATE_INTERVAL_DEFAULT;
                                }
 
-#ifdef TIZEN_PROFILE_MOBILE
-                               if (priv->pos_searching_timer) {
-                                       g_source_remove(priv->pos_searching_timer);
-                                       priv->pos_searching_timer = g_timeout_add(priv->pos_interval * 1000, _position_timeout_cb, object);
-                               }
-#endif
-
                                if (__get_started(object) == TRUE) {
                                        LOCATION_LOGD("[update_pos_interval]: update pos-interval while pos-tracking");
                                        g_return_if_fail(priv->mod->ops.set_position_update_interval);
@@ -738,12 +636,6 @@ static void location_gps_set_property(GObject *object, guint property_id, const
                                } else
                                        priv->vel_interval = (guint)LOCATION_UPDATE_INTERVAL_DEFAULT;
 
-#ifdef TIZEN_PROFILE_MOBILE
-                               if (priv->vel_searching_timer) {
-                                       g_source_remove(priv->vel_searching_timer);
-                                       priv->vel_searching_timer = g_timeout_add(priv->vel_interval * 1000, _velocity_timeout_cb, object);
-                               }
-#endif
                                break;
                        }
        case PROP_SAT_INTERVAL: {
@@ -926,6 +818,7 @@ static int location_gps_get_position(LocationGps *self, LocationPosition **posit
        setting_retval_if_fail(VCONFKEY_LOCATION_ENABLED);
 
        LOC_COND_RET(__get_started(self) != TRUE, LOCATION_ERROR_NOT_AVAILABLE, _E, "Location is not started [%s]", err_msg(LOCATION_ERROR_NOT_AVAILABLE));
+       LOCATION_IF_POS_FAIL(VCONFKEY_LOCATION_GPS_STATE);
 
        if (priv->pos) {
                *position = location_position_copy(priv->pos);
@@ -946,6 +839,7 @@ location_gps_get_position_ext(LocationGps *self, LocationPosition **position, Lo
        setting_retval_if_fail(VCONFKEY_LOCATION_ENABLED);
 
        LOC_COND_RET(__get_started(self) != TRUE, LOCATION_ERROR_NOT_AVAILABLE, _E, "Location is not started [%s]", err_msg(LOCATION_ERROR_NOT_AVAILABLE));
+       LOCATION_IF_POS_FAIL(VCONFKEY_LOCATION_GPS_STATE);
 
        if (priv->pos && priv->vel) {
                *position = location_position_copy(priv->pos);
@@ -1003,6 +897,7 @@ location_gps_get_velocity(LocationGps *self, LocationVelocity **velocity, Locati
        setting_retval_if_fail(VCONFKEY_LOCATION_ENABLED);
 
        LOC_COND_RET(__get_started(self) != TRUE, LOCATION_ERROR_NOT_AVAILABLE, _E, "Location is not started [%s]", err_msg(LOCATION_ERROR_NOT_AVAILABLE));
+       LOCATION_IF_POS_FAIL(VCONFKEY_LOCATION_GPS_STATE);
 
        if (priv->vel) {
                *velocity = location_velocity_copy(priv->vel);
@@ -1241,14 +1136,9 @@ static void location_gps_init(LocationGps *self)
        priv->acc = NULL;
        priv->sat = NULL;
        priv->boundary_list = NULL;
-
-#ifdef TIZEN_PROFILE_MOBILE
-       priv->pos_searching_timer = 0;
-       priv->vel_searching_timer = 0;
-#endif
        priv->loc_timeout = 0;
 
-#ifdef TIZEN_DEVICE
+#if defined(TIZEN_DEVICE) && !defined(TIZEN_PROFILE_TV)
        priv->sensor = NULL;
        priv->sensor_listener = NULL;
 #endif
index 93ba75f..7f1272e 100755 (executable)
@@ -909,6 +909,7 @@ location_hybrid_get_position(LocationHybrid *self, LocationPosition **position,
 
        LocationHybridPrivate *priv = GET_PRIVATE(self);
        g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
+       LOCATION_IF_HYBRID_FAIL(VCONFKEY_LOCATION_GPS_STATE, VCONFKEY_LOCATION_WPS_STATE);
 
        if (priv->pos) {
                *position = location_position_copy(priv->pos);
@@ -930,6 +931,7 @@ location_hybrid_get_position_ext(LocationHybrid *self, LocationPosition **positi
 
        LocationHybridPrivate *priv = GET_PRIVATE(self);
        g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
+       LOCATION_IF_HYBRID_FAIL(VCONFKEY_LOCATION_GPS_STATE, VCONFKEY_LOCATION_WPS_STATE);
 
        if (priv->pos && priv->vel) {
                *position = location_position_copy(priv->pos);
@@ -1051,6 +1053,7 @@ location_hybrid_get_velocity(LocationHybrid *self, LocationVelocity **velocity,
 
        LocationHybridPrivate *priv = GET_PRIVATE(self);
        g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
+       LOCATION_IF_HYBRID_FAIL(VCONFKEY_LOCATION_GPS_STATE, VCONFKEY_LOCATION_WPS_STATE);
 
        if (priv->vel) {
                *velocity = location_velocity_copy(priv->vel);
index bc6d086..a35afd3 100755 (executable)
@@ -194,6 +194,21 @@ wps_location_cb(gboolean enabled, LocationPosition *pos, LocationVelocity *vel,
 }
 
 static void
+location_setting_search_cb(keynode_t *key, gpointer self)
+{
+       LOC_FUNC_LOG
+       g_return_if_fail(key);
+       g_return_if_fail(self);
+       LocationWpsPrivate *priv = GET_PRIVATE(self);
+       g_return_if_fail(priv);
+
+       if (location_setting_get_key_val(key) == VCONFKEY_LOCATION_WPS_SEARCHING) {
+               LOCATION_LOGD("enable_signaling : SERVICE_DISABLED");
+               enable_signaling(self, signals, &(priv->enabled), FALSE, LOCATION_STATUS_NO_FIX);
+       }
+}
+
+static void
 location_setting_wps_cb(keynode_t *key, gpointer self)
 {
        LOC_FUNC_LOG
@@ -255,6 +270,7 @@ location_wps_start(LocationWps *self)
 
        if (priv->app_type != CPPAPP && priv->set_noti == FALSE) {
                location_setting_add_notify(VCONFKEY_LOCATION_NETWORK_ENABLED, location_setting_wps_cb, self);
+               location_state_add_notify(VCONFKEY_LOCATION_WPS_STATE, location_setting_search_cb, self);
                priv->set_noti = TRUE;
        }
 
@@ -281,6 +297,7 @@ location_wps_stop(LocationWps *self)
 
        if (priv->app_type != CPPAPP && priv->set_noti == TRUE) {
                location_setting_ignore_notify(VCONFKEY_LOCATION_NETWORK_ENABLED, location_setting_wps_cb);
+               location_state_ignore_notify(VCONFKEY_LOCATION_WPS_STATE, location_setting_search_cb);
                priv->set_noti = FALSE;
        }
 
@@ -299,6 +316,7 @@ location_wps_dispose(GObject *gobject)
        g_mutex_clear(&priv->mutex);
        if (priv->app_type != CPPAPP && priv->set_noti == TRUE) {
                location_setting_ignore_notify(VCONFKEY_LOCATION_NETWORK_ENABLED, location_setting_wps_cb);
+               location_state_ignore_notify(VCONFKEY_LOCATION_WPS_STATE, location_setting_search_cb);
                priv->set_noti = FALSE;
 
        }
@@ -490,6 +508,8 @@ location_wps_get_position(LocationWps *self, LocationPosition **position, Locati
                return LOCATION_ERROR_NOT_AVAILABLE;
        }
 
+       LOCATION_IF_POS_FAIL(VCONFKEY_LOCATION_WPS_STATE);
+
        if (priv->pos) {
                *position = location_position_copy(priv->pos);
                if (priv->acc) *accuracy = location_accuracy_copy(priv->acc);
@@ -511,6 +531,7 @@ location_wps_get_position_ext(LocationWps *self, LocationPosition **position, Lo
        setting_retval_if_fail(VCONFKEY_LOCATION_NETWORK_ENABLED);
 
        LOC_COND_RET(__get_started(self) != TRUE, LOCATION_ERROR_NOT_AVAILABLE, _E, "location is not started [%s]", err_msg(LOCATION_ERROR_NOT_AVAILABLE));
+       LOCATION_IF_POS_FAIL(VCONFKEY_LOCATION_WPS_STATE);
 
        if (priv->pos && priv->vel) {
                *position = location_position_copy(priv->pos);
@@ -571,6 +592,7 @@ location_wps_get_velocity(LocationWps *self, LocationVelocity **velocity, Locati
        setting_retval_if_fail(VCONFKEY_LOCATION_NETWORK_ENABLED);
 
        LOC_COND_RET(__get_started(self) != TRUE, LOCATION_ERROR_NOT_AVAILABLE, _E, "location is not started [%s]", err_msg(LOCATION_ERROR_NOT_AVAILABLE));
+       LOCATION_IF_POS_FAIL(VCONFKEY_LOCATION_WPS_STATE);
 
        if (priv->vel) {
                *velocity = location_velocity_copy(priv->vel);
index f36721e..33ac017 100755 (executable)
@@ -569,22 +569,19 @@ location_get_last_velocity(LocationObject *obj, LocationVelocity **velocity, Loc
 EXPORT_API int
 location_get_accessibility_state(LocationAccessState *state)
 {
-       int auth = location_application_get_authority();
-       switch (auth) {
-       case LOCATION_APP_OFF:
-               *state = LOCATION_ACCESS_DENIED;
-               break;
-       case LOCATION_APP_ON:
+       int ret = LOCATION_ERROR_NONE;
+
+#ifndef TIZEN_PROFILE_TV
+       ret = location_check_cynara(LOCATION_PRIVILEGE);
+#endif
+
+       if (ret == LOCATION_ERROR_NONE) {
                *state = LOCATION_ACCESS_ALLOWED;
-               break;
-       case LOCATION_APP_NOT_FOUND:
-               *state = LOCATION_ACCESS_NONE;
-               break;
-       default:
-               return LOCATION_ERROR_UNKNOWN;
+       } else {
+               *state = LOCATION_ACCESS_DENIED;
+               LOCATION_LOGE("Cannot use location service for privacy[%d]", ret);
        }
 
-       LOCATION_LOGD("get_accessibility_state [%d]", auth);
        return LOCATION_ERROR_NONE;
 }
 
index 978b2fc..950e9ee 100644 (file)
@@ -1,4 +1,11 @@
 [Version]      libslp-location_1.3.0
+[Date]         3 Jun 2016
+[Changes]      Change service state behavior when GPS/WPS searching mode
+[Developer]    Kyoungjun Sung <kj7.sung@samsung.com>
+
+================================================================================
+
+[Version]      libslp-location_1.3.0
 [Date]         12 May 2016
 [Changes]      Add location restriction to support DPM
 [Developer]    Kyoungjun Sung <kj7.sung@samsung.com>
index d0432a0..c2d6fe9 100755 (executable)
@@ -1,6 +1,6 @@
 Name: liblbs-location
 Summary: Location Based Service Library
-Version: 1.3.0
+Version: 1.3.1
 Release: 1
 Group: Location/Libraries
 License: Apache-2.0