sync with latest 3.0 82/113082/3
authorkj7.sung <kj7.sung@samsung.com>
Mon, 6 Feb 2017 04:27:36 +0000 (13:27 +0900)
committerkj7.sung <kj7.sung@samsung.com>
Tue, 7 Feb 2017 10:32:55 +0000 (19:32 +0900)
Change-Id: I8712c136aa10bf612bf69dc339eae42abc311240
Signed-off-by: kj7.sung <kj7.sung@samsung.com>
location/manager/location-gps.c
location/manager/location-hybrid-mobile.c
location/manager/location-ielement.c
location/manager/location-ielement.h
location/manager/location-passive.c
location/manager/location-wps.c
location/manager/location.c
location/manager/location.h
location/module/location-module.h
packaging/liblbs-location.changes
packaging/liblbs-location.spec

index 3e53c9f..7e4542b 100755 (executable)
@@ -103,6 +103,7 @@ static GParamSpec *properties[PROP_MAX] = {NULL, };
 #define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), LOCATION_TYPE_GPS, LocationGpsPrivate))
 
 static void location_ielement_interface_init(LocationIElementInterface *iface);
+static int location_gps_cancel_single_location(LocationGps *self);
 
 G_DEFINE_TYPE_WITH_CODE(LocationGps, location_gps, G_TYPE_OBJECT,
                                                G_IMPLEMENT_INTERFACE(LOCATION_TYPE_IELEMENT, location_ielement_interface_init));
@@ -287,7 +288,7 @@ static int location_gps_start(LocationGps *self)
        g_return_val_if_fail(priv->mod->handler, LOCATION_ERROR_NOT_AVAILABLE);
        g_return_val_if_fail(priv->mod->ops.start, LOCATION_ERROR_NOT_AVAILABLE);
 
-       if (__get_started(self) == TRUE) return LOCATION_ERROR_NONE;
+       LOC_COND_RET(__get_started(self) == TRUE, LOCATION_ERROR_NONE, _E, "gps already started. Error[%s]", err_msg(LOCATION_ERROR_NONE));
 
        int ret = LOCATION_ERROR_NONE;
 
@@ -953,6 +954,32 @@ location_gps_request_single_location(LocationGps *self, int timeout)
        return ret;
 }
 
+static int
+location_gps_cancel_single_location(LocationGps *self)
+{
+       LOC_FUNC_LOG
+       LocationGpsPrivate* 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.stop, LOCATION_ERROR_NOT_AVAILABLE);
+
+       int ret = LOCATION_ERROR_NONE;
+
+       if (priv->loc_timeout)
+               g_source_remove(priv->loc_timeout);
+       priv->loc_timeout = 0;
+
+       if (__get_started(self) == TRUE) {
+               __set_started(self, FALSE);
+               __reset_pos_data_from_priv(priv);
+               ret = priv->mod->ops.stop(priv->mod->handler);
+               LOC_IF_FAIL_LOG(ret, _E, "Failed to stop [%s]", err_msg(ret));
+       }
+
+       return ret;
+}
+
 static int location_gps_get_nmea(LocationGps *self, char **nmea_data)
 {
        int ret = LOCATION_ERROR_NOT_AVAILABLE;
@@ -1037,6 +1064,8 @@ location_gps_set_mock_location(LocationGps *self, LocationPosition *position, Lo
 {
        LOC_FUNC_LOG
        LocationGpsPrivate *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);
 
@@ -1057,6 +1086,8 @@ location_gps_clear_mock_location(LocationGps *self)
 {
        LOC_FUNC_LOG
        LocationGpsPrivate *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);
 
@@ -1089,6 +1120,7 @@ static void location_ielement_interface_init(LocationIElementInterface *iface)
        iface->start_batch = (TYPE_START_BATCH)location_gps_start_batch;
        iface->stop_batch = (TYPE_STOP_BATCH)location_gps_stop_batch;
        iface->request_single_location = (TYPE_REQUEST_SINGLE_LOCATION)location_gps_request_single_location;
+       iface->cancel_single_location = (TYPE_CANCEL_SINGLE_LOCATION)location_gps_cancel_single_location;
        iface->get_nmea = (TYPE_GET_NMEA)location_gps_get_nmea;
        iface->set_mock_location = (TYPE_SET_MOCK_LOCATION) location_gps_set_mock_location;
        iface->clear_mock_location = (TYPE_CLEAR_MOCK_LOCATION) location_gps_clear_mock_location;
index b196be3..8878dd4 100755 (executable)
@@ -91,6 +91,15 @@ static void location_ielement_interface_init(LocationIElementInterface *iface);
 
 G_DEFINE_TYPE_WITH_CODE(LocationHybrid, location_hybrid, G_TYPE_OBJECT, G_IMPLEMENT_INTERFACE(LOCATION_TYPE_IELEMENT, location_ielement_interface_init));
 
+static int
+__get_availability_use_location(gpointer self)
+{
+       if (!location_setting_get_int(VCONFKEY_LOCATION_ENABLED) && !location_setting_get_int(VCONFKEY_LOCATION_NETWORK_ENABLED))
+               return LOCATION_ERROR_SETTING_OFF;
+
+       return LOCATION_ERROR_NONE;
+}
+
 static LocationMethod
 hybrid_get_current_method(LocationHybridPrivate *priv)
 {
@@ -259,6 +268,15 @@ hybrid_location_updated(GObject *obj, guint error, gpointer position, gpointer v
        LocationHybridPrivate *priv = GET_PRIVATE((LocationHybrid *)self);
        g_return_if_fail(priv);
 
+       GType g_type = G_TYPE_FROM_INSTANCE(obj);
+       if (g_type == LOCATION_TYPE_GPS) {
+               if (priv->wps)
+                       location_cancel_single_location(priv->wps);
+       } else if (g_type == LOCATION_TYPE_WPS) {
+               if (priv->gps)
+                       location_cancel_single_location(priv->gps);
+       }
+
        g_signal_emit(self, signals[LOCATION_UPDATED], 0, error, pos, vel, acc);
 }
 
@@ -1014,15 +1032,40 @@ location_hybrid_request_single_location(LocationHybrid *self, int timeout)
        g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
 
        int ret = LOCATION_ERROR_NOT_AVAILABLE;
+       int ret_gps = LOCATION_ERROR_NOT_AVAILABLE;
+       int ret_wps = LOCATION_ERROR_NOT_AVAILABLE;
 
-       if (priv->gps)
-               ret = location_request_single_location(priv->gps, timeout);
-       else
-               ret = location_request_single_location(priv->wps, timeout);
+       ret = __get_availability_use_location(self);
+       LOC_IF_FAIL(ret, _E, "setting off [%s]", err_msg(LOCATION_ERROR_SETTING_OFF));
+
+       if (priv->gps) {
+               LOCATION_LOGD("location_request_single_location : gps");
+               ret_gps = location_request_single_location(priv->gps, timeout);
+       }
+
+       if (priv->wps) {
+               LOCATION_LOGD("location_request_single_location : wps");
+               ret_wps = location_request_single_location(priv->wps, timeout);
+       }
+
+       if (ret_gps != LOCATION_ERROR_NONE && ret_wps != LOCATION_ERROR_NONE) {
+               if (ret_gps == LOCATION_ERROR_NOT_ALLOWED && ret_wps == LOCATION_ERROR_NOT_ALLOWED)
+                       return LOCATION_ERROR_NOT_ALLOWED;
+               else
+                       return LOCATION_ERROR_NOT_AVAILABLE;
+       }
 
        return ret;
 }
 
+int
+location_hybrid_cancel_single_location(LocationHybrid *self, int timeout)
+{
+       LOC_FUNC_LOG
+       return LOCATION_ERROR_NOT_SUPPORTED;
+}
+
+
 static int
 location_hybrid_get_nmea(LocationHybrid *self, char **nmea_data)
 {
@@ -1091,6 +1134,7 @@ location_ielement_interface_init(LocationIElementInterface *iface)
        iface->get_last_satellite = (TYPE_GET_SATELLITE)location_hybrid_get_last_satellite;
        iface->set_option = (TYPE_SET_OPTION)location_hybrid_set_option;
        iface->request_single_location = (TYPE_REQUEST_SINGLE_LOCATION)location_hybrid_request_single_location;
+       iface->cancel_single_location = (TYPE_CANCEL_SINGLE_LOCATION)location_hybrid_cancel_single_location;
        iface->get_nmea = (TYPE_GET_NMEA)location_hybrid_get_nmea;
 
        iface->set_mock_location = (TYPE_SET_MOCK_LOCATION) location_hybrid_set_mock_location;
index 2476fcc..a6d6617 100755 (executable)
@@ -103,6 +103,16 @@ location_ielement_request_single_location(LocationIElement *self, int timeout)
 }
 
 int
+location_ielement_cancel_single_location(LocationIElement *self)
+{
+       g_return_val_if_fail(LOCATION_IS_IELEMENT(self), LOCATION_ERROR_PARAMETER);
+       g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self), LOCATION_ERROR_NOT_AVAILABLE);
+       g_return_val_if_fail(LOCATION_IELEMENT_GET_INTERFACE(self)->cancel_single_location, LOCATION_ERROR_NOT_AVAILABLE);
+
+       return LOCATION_IELEMENT_GET_INTERFACE(self)->cancel_single_location(self);
+}
+
+int
 location_ielement_get_position(LocationIElement *self, LocationPosition **position, LocationAccuracy **accuracy)
 {
        g_return_val_if_fail(LOCATION_IS_IELEMENT(self), LOCATION_ERROR_PARAMETER);
index 58f0b4b..07a3be7 100644 (file)
@@ -66,6 +66,7 @@ typedef int (*TYPE_GET_VELOCITY)(LocationIElement *self, LocationVelocity **velo
 typedef int (*TYPE_GET_SATELLITE)(LocationIElement *self, LocationSatellite **satellite);
 typedef int (*TYPE_SET_OPTION)(LocationIElement *self, const char *option);
 typedef int (*TYPE_REQUEST_SINGLE_LOCATION)(LocationIElement *self, int timeout);
+typedef int (*TYPE_CANCEL_SINGLE_LOCATION)(LocationIElement *self);
 typedef int (*TYPE_GET_BATCH)(LocationIElement *self, LocationBatch **batch);
 typedef int (*TYPE_START_BATCH)(LocationIElement *self);
 typedef int (*TYPE_STOP_BATCH)(LocationIElement *self);
@@ -90,6 +91,7 @@ struct _LocationIElementInterface {
        TYPE_GET_SATELLITE get_last_satellite;
        TYPE_SET_OPTION set_option;
        TYPE_REQUEST_SINGLE_LOCATION request_single_location;
+       TYPE_CANCEL_SINGLE_LOCATION cancel_single_location;
        TYPE_GET_BATCH get_batch;
        TYPE_START_BATCH start_batch;
        TYPE_STOP_BATCH stop_batch;
@@ -114,6 +116,7 @@ int location_ielement_get_satellite(LocationIElement *self, LocationSatellite **
 int location_ielement_get_last_satellite(LocationIElement *self, LocationSatellite **satellite);
 int location_ielement_set_option(LocationIElement *self, const char *option);
 int location_ielement_request_single_location(LocationIElement *self, int timeout);
+int location_ielement_cancel_single_location(LocationIElement *self);
 int location_ielement_get_batch(LocationIElement *self, LocationBatch **batch);
 int location_ielement_start_batch(LocationIElement *self);
 int location_ielement_stop_batch(LocationIElement *self);
index f2400b8..eb70428 100755 (executable)
 
 #include <vconf-internal-location-keys.h>
 
-/*
- * forward definitions
- */
-
 typedef struct _LocationPassivePrivate {
-       LocationPassiveMod              *mod;
+       LocationPassiveMod      *mod;
        GMutex                          mutex;
        gboolean                        is_started;
        guint                           app_type;
@@ -50,10 +46,12 @@ typedef struct _LocationPassivePrivate {
        gboolean                        enabled;
        guint                           pos_updated_timestamp;
        guint                           vel_updated_timestamp;
+       guint                           sat_updated_timestamp;
        guint                           loc_updated_timestamp;
        guint                           dist_updated_timestamp;
        guint                           pos_interval;
        guint                           vel_interval;
+       guint                           sat_interval;
        guint                           loc_interval;
        guint                           loc_timeout;
        guint                           min_interval;
@@ -61,6 +59,7 @@ typedef struct _LocationPassivePrivate {
        LocationPosition        *pos;
        LocationVelocity        *vel;
        LocationAccuracy        *acc;
+       LocationSatellite       *sat;
        GList                           *boundary_list;
 } LocationPassivePrivate;
 
@@ -71,9 +70,11 @@ enum {
        PROP_LAST_POSITION,
        PROP_POS_INTERVAL,
        PROP_VEL_INTERVAL,
+       PROP_SAT_INTERVAL,
        PROP_LOC_INTERVAL,
        PROP_BOUNDARY,
        PROP_REMOVAL_BOUNDARY,
+       PROP_SATELLITE,
        PROP_MIN_INTERVAL,
        PROP_MIN_DISTANCE,
        PROP_SERVICE_STATUS,
@@ -103,12 +104,18 @@ static void __reset_pos_data_from_priv(LocationPassivePrivate *priv)
                location_velocity_free(priv->vel);
                priv->vel = NULL;
        }
+       if (priv->sat) {
+               location_satellite_free(priv->sat);
+               priv->sat = NULL;
+       }
        if (priv->acc) {
                location_accuracy_free(priv->acc);
                priv->acc = NULL;
        }
        priv->pos_updated_timestamp = 0;
        priv->vel_updated_timestamp = 0;
+       priv->sat_updated_timestamp = 0;
+       priv->loc_updated_timestamp = 0;
 }
 
 static gboolean __get_started(gpointer self)
@@ -133,63 +140,29 @@ static int __set_started(gpointer self, gboolean started)
        return 0;
 }
 
-static void passive_gps_cb(keynode_t * key, gpointer self)
+static void passive_location_cb(gboolean enabled, LocationPosition *pos, LocationVelocity *vel, LocationAccuracy *acc, gpointer self)
 {
-       LOC_FUNC_LOG
-       g_return_if_fail(key);
        g_return_if_fail(self);
+       g_return_if_fail(pos);
+       g_return_if_fail(vel);
+       g_return_if_fail(acc);
+
        LocationPassivePrivate *priv = GET_PRIVATE(self);
        g_return_if_fail(priv);
-       g_return_if_fail(priv->mod);
-       g_return_if_fail(priv->mod->handler);
-
-       LocationPosition *pos = NULL;
-       LocationVelocity *vel = NULL;
-       LocationAccuracy *acc = NULL;
-
-       LocModPassiveOps ops = priv->mod->ops;
-       int ret = ops.get_last_position(priv->mod->handler, &pos, &vel, &acc);
-       if (ret != LOCATION_ERROR_NONE) {
-               LOCATION_LOGE("Fail to get position[%d]", ret);
-               return ;
-       }
 
-       location_signaling(self, signals, TRUE, priv->boundary_list,
-                                       pos, vel, acc, priv->pos_interval, priv->vel_interval, priv->loc_interval,
-                                       &(priv->enabled), &(priv->pos_updated_timestamp),
-                                       &(priv->vel_updated_timestamp), &(priv->loc_updated_timestamp),
-                                       &(priv->pos), &(priv->vel), &(priv->acc));
+       location_signaling(self, signals, enabled, priv->boundary_list, pos, vel, acc,
+                                               priv->pos_interval, priv->vel_interval, priv->loc_interval, &(priv->enabled),
+                                               &(priv->pos_updated_timestamp), &(priv->vel_updated_timestamp),
+                                               &(priv->loc_updated_timestamp), &(priv->pos), &(priv->vel), &(priv->acc));
 }
 
-static void passive_wps_cb(keynode_t *key, gpointer self)
+static void passive_satellite_cb(gboolean enabled, LocationSatellite *sat, gpointer self)
 {
-       LOC_FUNC_LOG
-       g_return_if_fail(key);
        g_return_if_fail(self);
        LocationPassivePrivate *priv = GET_PRIVATE(self);
        g_return_if_fail(priv);
-       g_return_if_fail(priv->mod);
-       g_return_if_fail(priv->mod->handler);
-
-       LocationPosition *pos = NULL;
-       LocationVelocity *vel = NULL;
-       LocationAccuracy *acc = NULL;
 
-       LocModPassiveOps ops = priv->mod->ops;
-       int ret = ops.get_last_wps_position(priv->mod->handler, &pos, &vel, &acc);
-       if (ret != LOCATION_ERROR_NONE) {
-               LOCATION_LOGE("Fail to get position[%d]", ret);
-               return ;
-       }
-
-       if (location_setting_get_int(VCONFKEY_LOCATION_GPS_STATE) == VCONFKEY_LOCATION_GPS_CONNECTED)
-               return ;
-
-       location_signaling(self, signals, TRUE, priv->boundary_list,
-                                       pos, vel, acc, priv->pos_interval, priv->vel_interval, priv->loc_interval,
-                                       &(priv->enabled), &(priv->pos_updated_timestamp),
-                                       &(priv->vel_updated_timestamp), &(priv->loc_updated_timestamp),
-                                       &(priv->pos), &(priv->vel), &(priv->acc));
+       satellite_signaling(self, signals, &(priv->enabled), priv->sat_interval, TRUE, &(priv->sat_updated_timestamp), &(priv->sat), sat);
 }
 
 static int location_passive_start(LocationPassive *self)
@@ -199,8 +172,9 @@ static int location_passive_start(LocationPassive *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.start, LOCATION_ERROR_NOT_AVAILABLE);
 
-       LOC_COND_RET(__get_started(self) == TRUE, LOCATION_ERROR_NONE, _E, "__get_started. Error[%s]", err_msg(LOCATION_ERROR_NONE));
+       LOC_COND_RET(__get_started(self) == TRUE, LOCATION_ERROR_NONE, _E, "Passive already started. Error[%s]", err_msg(LOCATION_ERROR_NONE));
 
        int ret = LOCATION_ERROR_NONE;
 
@@ -209,11 +183,12 @@ static int location_passive_start(LocationPassive *self)
        } else {
                __set_started(self, TRUE);
 
-               ret = location_setting_add_notify(VCONFKEY_LOCATION_LAST_GPS_TIMESTAMP, passive_gps_cb, self);
-               LOC_COND_RET(ret != LOCATION_ERROR_NONE, ret, _E, "Add vconf notify. Error[%s]", err_msg(ret));
-
-               ret = location_setting_add_notify(VCONFKEY_LOCATION_LAST_WPS_TIMESTAMP, passive_wps_cb, self);
-               LOC_COND_RET(ret != LOCATION_ERROR_NONE, ret, _E, "Add vconf notify. Error[%s]", err_msg(ret));
+               ret = priv->mod->ops.start(priv->mod->handler, 1, NULL, passive_location_cb, passive_satellite_cb, self);
+               if (ret != LOCATION_ERROR_NONE) {
+                       LOCATION_LOGE("Fail to start gps. Error[%d]", ret);
+                       __set_started(self, FALSE);
+                       return ret;
+               }
        }
 
        if (priv->app_type != CPPAPP && priv->set_noti == FALSE)
@@ -229,11 +204,14 @@ static int location_passive_stop(LocationPassive *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.stop, LOCATION_ERROR_NOT_AVAILABLE);
 
        int ret = LOCATION_ERROR_NONE;
 
        if (__get_started(self) == TRUE) {
                __set_started(self, FALSE);
+               ret = priv->mod->ops.stop(priv->mod->handler);
+               LOC_IF_FAIL_LOG(ret, _E, "Failed to stop [%s]", err_msg(ret));
                g_signal_emit(self, signals[SERVICE_DISABLED], 0, LOCATION_STATUS_NO_FIX);
        }
 
@@ -287,6 +265,16 @@ static void location_passive_finalize(GObject *gobject)
        G_OBJECT_CLASS(location_passive_parent_class)->finalize(gobject);
 }
 
+static guint get_valid_interval(guint interval, int max_interval, int min_interval)
+{
+       if (interval > max_interval)
+               return (guint)max_interval;
+       else if (interval < min_interval)
+               return (guint)min_interval;
+       else
+               return interval;
+}
+
 static void location_passive_set_property(GObject *object, guint property_id, const GValue *value, GParamSpec *pspec)
 {
        LocationPassivePrivate *priv = GET_PRIVATE(object);
@@ -334,6 +322,12 @@ static void location_passive_set_property(GObject *object, guint property_id, co
                }
                break;
        }
+       case PROP_SAT_INTERVAL: {
+               guint interval = g_value_get_uint(value);
+               LOCATION_LOGD("Set prop>> PROP_SAT_INTERVAL: %u", interval);
+               priv->sat_interval = get_valid_interval(interval, LOCATION_UPDATE_INTERVAL_MAX, LOCATION_UPDATE_INTERVAL_MIN);
+               break;
+       }
        case PROP_LOC_INTERVAL: {
                guint interval = g_value_get_uint(value);
                LOCATION_LOGD("Set prop>> PROP_LOC_INTERVAL: %u", interval);
@@ -392,6 +386,9 @@ static void location_passive_get_property(GObject *object, guint property_id, GV
 {
        LocationPassivePrivate *priv = GET_PRIVATE(object);
        g_return_if_fail(priv);
+       g_return_if_fail(priv->mod);
+       g_return_if_fail(priv->mod->handler);
+       LocModPassiveOps ops = priv->mod->ops;
 
        switch (property_id) {
        case PROP_METHOD_TYPE:
@@ -412,6 +409,9 @@ static void location_passive_get_property(GObject *object, guint property_id, GV
        case PROP_VEL_INTERVAL:
                g_value_set_uint(value, priv->vel_interval);
                break;
+       case PROP_SAT_INTERVAL:
+               g_value_set_uint(value, priv->sat_interval);
+               break;
        case PROP_LOC_INTERVAL:
                g_value_set_uint(value, priv->loc_interval);
                break;
@@ -421,6 +421,18 @@ static void location_passive_get_property(GObject *object, guint property_id, GV
        case PROP_MIN_DISTANCE:
                g_value_set_double(value, priv->min_distance);
                break;
+       case PROP_SATELLITE: {
+               LocationSatellite *satellite = NULL;
+               if (ops.get_satellite && priv->mod->handler && LOCATION_ERROR_NONE == ops.get_satellite(priv->mod->handler, &satellite) && satellite) {
+                       LOCATION_LOGD("Get prop>> Last sat: num_used(%d) num_view(%d)", satellite->num_of_sat_used, satellite->num_of_sat_inview);
+                       g_value_set_boxed(value, satellite);
+                       location_satellite_free(satellite);
+               } else {
+                       LOCATION_LOGW("Get prop>> Last sat: failed");
+                       g_value_set_boxed(value, NULL);
+               }
+               break;
+       }
        case PROP_SERVICE_STATUS:
                g_value_set_int(value, priv->enabled);
                break;
@@ -432,6 +444,7 @@ static void location_passive_get_property(GObject *object, guint property_id, GV
 
 static int location_passive_get_position(LocationPassive *self, LocationPosition **position, LocationAccuracy **accuracy)
 {
+       LOC_FUNC_LOG
        int ret = LOCATION_ERROR_NOT_AVAILABLE;
 
        LocationPassivePrivate *priv = GET_PRIVATE(self);
@@ -456,6 +469,7 @@ static int location_passive_get_position(LocationPassive *self, LocationPosition
 
 static int location_passive_get_position_ext(LocationPassive *self, LocationPosition **position, LocationVelocity **velocity, LocationAccuracy **accuracy)
 {
+       LOC_FUNC_LOG
        int ret = LOCATION_ERROR_NOT_AVAILABLE;
 
        LocationPassivePrivate *priv = GET_PRIVATE(self);
@@ -482,6 +496,7 @@ static int location_passive_get_position_ext(LocationPassive *self, LocationPosi
 
 static int location_passive_get_last_position(LocationPassive *self, LocationPosition **position, LocationAccuracy **accuracy)
 {
+       LOC_FUNC_LOG
        LocationPassivePrivate *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);
@@ -502,6 +517,7 @@ static int location_passive_get_last_position(LocationPassive *self, LocationPos
 
 static int location_passive_get_last_position_ext(LocationPassive *self, LocationPosition **position, LocationVelocity **velocity, LocationAccuracy **accuracy)
 {
+       LOC_FUNC_LOG
        LocationPassivePrivate *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);
@@ -540,6 +556,7 @@ static int location_passive_get_velocity(LocationPassive *self, LocationVelocity
 
 static int location_passive_get_last_velocity(LocationPassive *self, LocationVelocity **velocity, LocationAccuracy **accuracy)
 {
+       LOC_FUNC_LOG
        LocationPassivePrivate *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);
@@ -556,31 +573,63 @@ static int location_passive_get_last_velocity(LocationPassive *self, LocationVel
        return ret;
 }
 
+static int location_passive_get_satellite(LocationPassive *self, LocationSatellite **satellite)
+{
+       LOC_FUNC_LOG
+       LocationPassivePrivate *priv = GET_PRIVATE(self);
+       g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
+       setting_retval_if_fail(VCONFKEY_LOCATION_ENABLED);
+
+       LOC_COND_RET(__get_started(self) != TRUE, LOCATION_ERROR_NOT_AVAILABLE, _E, "Passive is not started [%s]", err_msg(LOCATION_ERROR_NOT_AVAILABLE));
+
+       int ret = LOCATION_ERROR_NOT_AVAILABLE;
+       if (priv->sat) {
+               *satellite = location_satellite_copy(priv->sat);
+               ret = LOCATION_ERROR_NONE;
+       }
+
+       return ret;
+}
+
+static int location_passive_get_last_satellite(LocationPassive *self, LocationSatellite **satellite)
+{
+       LOC_FUNC_LOG
+       return location_passive_get_satellite(self, satellite);
+}
+
+static int location_passive_set_option(LocationPassive *self, const char *option)
+{
+       LOC_FUNC_LOG
+       return LOCATION_ERROR_NONE;
+}
+
 static int location_passive_request_single_location(LocationPassive *self, int timeout)
 {
+       LOC_FUNC_LOG
        return LOCATION_ERROR_NOT_SUPPORTED;
 }
 
-static int location_passive_get_satellite(LocationPassive *self, LocationSatellite **satellite)
+static int location_passive_cancel_single_location(LocationPassive *self, int timeout)
 {
+       LOC_FUNC_LOG
        return LOCATION_ERROR_NOT_SUPPORTED;
 }
 
-static int location_passive_get_last_satellite(LocationPassive *self, LocationSatellite **satellite)
+static int location_passive_get_nmea(LocationPassive *self, char **nmea_data)
 {
+       LOC_FUNC_LOG
        return LOCATION_ERROR_NOT_SUPPORTED;
 }
 
-static int location_passive_set_option(LocationPassive *self, const char *option)
+static int location_passive_set_mock_location(LocationPassive *self, LocationPosition *position, LocationVelocity *velocity, LocationAccuracy *accuracy)
 {
-       LocationPassivePrivate *priv = GET_PRIVATE(self);
-       g_return_val_if_fail(priv, LOCATION_ERROR_NOT_AVAILABLE);
-
-       return LOCATION_ERROR_NONE;
+       LOC_FUNC_LOG
+       return LOCATION_ERROR_NOT_SUPPORTED;
 }
 
-static int location_passive_get_nmea(LocationPassive *self, char **nmea_data)
+static int location_passive_clear_mock_location(LocationPassive *self)
 {
+       LOC_FUNC_LOG
        return LOCATION_ERROR_NOT_SUPPORTED;
 }
 
@@ -598,7 +647,10 @@ static void location_ielement_interface_init(LocationIElementInterface *iface)
        iface->get_last_satellite = (TYPE_GET_SATELLITE)location_passive_get_last_satellite;
        iface->set_option = (TYPE_SET_OPTION)location_passive_set_option;
        iface->request_single_location = (TYPE_REQUEST_SINGLE_LOCATION)location_passive_request_single_location;
+       iface->cancel_single_location = (TYPE_CANCEL_SINGLE_LOCATION)location_passive_cancel_single_location;
        iface->get_nmea = (TYPE_GET_NMEA)location_passive_get_nmea;
+       iface->set_mock_location = (TYPE_SET_MOCK_LOCATION) location_passive_set_mock_location;
+       iface->clear_mock_location = (TYPE_CLEAR_MOCK_LOCATION) location_passive_clear_mock_location;
 }
 
 static void location_passive_init(LocationPassive *self)
@@ -617,23 +669,25 @@ static void location_passive_init(LocationPassive *self)
 
        priv->pos_interval = LOCATION_UPDATE_INTERVAL_DEFAULT;
        priv->vel_interval = LOCATION_UPDATE_INTERVAL_DEFAULT;
+       priv->sat_interval = LOCATION_UPDATE_INTERVAL_DEFAULT;
        priv->loc_interval = LOCATION_UPDATE_INTERVAL_DEFAULT;
        priv->min_interval = LOCATION_UPDATE_INTERVAL_NONE;
 
        priv->pos_updated_timestamp = 0;
        priv->vel_updated_timestamp = 0;
+       priv->sat_updated_timestamp = 0;
        priv->loc_updated_timestamp = 0;
 
        priv->pos = NULL;
        priv->vel = NULL;
        priv->acc = NULL;
+       priv->sat = NULL;
        priv->boundary_list = NULL;
 
        priv->loc_timeout = 0;
 
        priv->app_type = location_get_app_type(NULL);
-       if (priv->app_type == 0)
-               LOCATION_LOGW("Fail to get app_type");
+       LOC_COND_LOG(priv->app_type == 0, _W, "[Info] Fail to get app_type");
 }
 
 static void location_passive_class_init(LocationPassiveClass *klass)
@@ -711,6 +765,11 @@ static void location_passive_class_init(LocationPassiveClass *klass)
                        "passive velocity interval data", LOCATION_UPDATE_INTERVAL_MIN,
                        LOCATION_UPDATE_INTERVAL_MAX, LOCATION_UPDATE_INTERVAL_DEFAULT, G_PARAM_READWRITE);
 
+       properties[PROP_SAT_INTERVAL] =
+                       g_param_spec_uint("sat-interval", "passive satellite interval prop",
+                       "passive satellite interval data", LOCATION_UPDATE_INTERVAL_MIN,
+                       LOCATION_UPDATE_INTERVAL_MAX, LOCATION_UPDATE_INTERVAL_DEFAULT, G_PARAM_READWRITE);
+
        properties[PROP_LOC_INTERVAL] =
                        g_param_spec_uint("loc-interval", "passive location interval prop",
                        "passive location interval data", LOCATION_UPDATE_INTERVAL_MIN,
@@ -734,7 +793,10 @@ static void location_passive_class_init(LocationPassiveClass *klass)
                        g_param_spec_boxed("removal-boundary", "passive removal boundary prop",
                        "passive removal boundary data", LOCATION_TYPE_BOUNDARY, G_PARAM_READWRITE);
 
-       /* Tizen 3.0 */
+       properties[PROP_SATELLITE] =
+                       g_param_spec_boxed("satellite", "passive satellite prop",
+                       "passive satellite data", LOCATION_TYPE_SATELLITE, G_PARAM_READABLE);
+
        properties[PROP_SERVICE_STATUS] =
                        g_param_spec_int("service-status", "location service status prop",
                        "location service status data", LOCATION_STATUS_NO_FIX,
index f96417f..21645ce 100755 (executable)
@@ -87,6 +87,7 @@ static GParamSpec *properties[PROP_MAX] = {NULL, };
 #define GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE((o), LOCATION_TYPE_WPS, LocationWpsPrivate))
 
 static void location_ielement_interface_init(LocationIElementInterface *iface);
+static int location_wps_cancel_single_location(LocationWps *self);
 
 G_DEFINE_TYPE_WITH_CODE(LocationWps, location_wps, G_TYPE_OBJECT,
                                                G_IMPLEMENT_INTERFACE(LOCATION_TYPE_IELEMENT, location_ielement_interface_init));
@@ -681,6 +682,32 @@ location_wps_request_single_location(LocationWps *self, int timeout)
 }
 
 static int
+location_wps_cancel_single_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.stop, LOCATION_ERROR_NOT_AVAILABLE);
+
+       int ret = LOCATION_ERROR_NONE;
+
+       if (priv->loc_timeout)
+               g_source_remove(priv->loc_timeout);
+       priv->loc_timeout = 0;
+
+       if (__get_started(self) == TRUE) {
+               __set_started(self, FALSE);
+               __reset_pos_data_from_priv(priv);
+               ret = priv->mod->ops.stop(priv->mod->handler);
+               LOC_IF_FAIL_LOG(ret, _E, "Failed to stop [%s]", err_msg(ret));
+       }
+
+       return ret;
+}
+
+static int
 location_wps_get_satellite(LocationWps *self, LocationSatellite **satellite)
 {
        return LOCATION_ERROR_NOT_SUPPORTED;
@@ -764,6 +791,7 @@ location_ielement_interface_init(LocationIElementInterface *iface)
        iface->get_last_satellite = (TYPE_GET_SATELLITE)location_wps_get_last_satellite;
        iface->set_option = (TYPE_SET_OPTION)location_wps_set_option;
        iface->request_single_location = (TYPE_REQUEST_SINGLE_LOCATION)location_wps_request_single_location;
+       iface->cancel_single_location = (TYPE_CANCEL_SINGLE_LOCATION)location_wps_cancel_single_location;
        iface->get_nmea = (TYPE_GET_NMEA)location_wps_get_nmea;
        iface->set_mock_location = (TYPE_SET_MOCK_LOCATION) location_wps_set_mock_location;
        iface->clear_mock_location = (TYPE_CLEAR_MOCK_LOCATION) location_wps_clear_mock_location;
index 1911083..5ec18ab 100755 (executable)
@@ -213,6 +213,10 @@ location_request_single_location(LocationObject *obj, int timeout)
        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_request_single_location(LOCATION_IELEMENT(obj), timeout);
        LOC_IF_FAIL(ret, _E, "Fail to request single location [%s]", err_msg(ret));
 
@@ -220,6 +224,24 @@ location_request_single_location(LocationObject *obj, int timeout)
 }
 
 EXPORT_API int
+location_cancel_single_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_cancel_single_location(LOCATION_IELEMENT(obj));
+       if (ret != LOCATION_ERROR_NONE)
+               LOCATION_LOGE("Fail to cancel single location. Error [%d]", ret);
+
+       return ret;
+}
+
+EXPORT_API int
 location_start(LocationObject *obj)
 {
        g_return_val_if_fail(obj, LOCATION_ERROR_PARAMETER);
index 022493f..82ca718 100755 (executable)
@@ -113,6 +113,8 @@ int location_stop(LocationObject *obj);
 
 int location_request_single_location(LocationObject *obj, int timeout);
 
+int location_cancel_single_location(LocationObject *obj);
+
 /**
  * @brief Check wheither a method is available.
  * @remarks
index 0ae4e52..d6e377e 100644 (file)
@@ -100,8 +100,11 @@ typedef struct {
 } LocModWpsOps;
 
 typedef struct {
+       int (*start)(gpointer handle, guint pos_update_interval, LocModStatusCB status_cb, LocModPositionExtCB pos_cb, LocModSatelliteCB sat_cb, gpointer userdata);
+       int (*stop)(gpointer handle);
        int (*get_last_position)(gpointer handle, LocationPosition **position, LocationVelocity **velocity, LocationAccuracy **accuracy);
        int (*get_last_wps_position)(gpointer handle, LocationPosition **position, LocationVelocity **velocity, LocationAccuracy **accuracy);
+       int (*get_satellite)(gpointer handle, LocationSatellite **satellite);
 } LocModPassiveOps;
 
 /**
index 80c7ae2..34cee30 100644 (file)
@@ -1,3 +1,15 @@
+[Version]      libslp-location_1.3.8
+[Date]         1 Feb 2017
+[Changes]      Support satellite for passive mode
+[Developer]    Kyoungjun Sung <kj7.sung@samsung.com>
+
+================================================================================
+[Version]      libslp-location_1.3.7
+[Date]         23 Jan 2017
+[Changes]      Fix single location behavior for hybrid mode
+[Developer]    Kyoungjun Sung <kj7.sung@samsung.com>
+
+================================================================================
 [Version]      libslp-location_1.3.6
 [Date]         22 Nov 2016
 [Changes]      Remove Profile Build Dependency
index c3543ae..054aa18 100755 (executable)
@@ -1,6 +1,6 @@
 Name: liblbs-location
 Summary: Location Based Service Library
-Version: 1.3.6
+Version: 1.3.8
 Release: 1
 Group: Location/Libraries
 License: Apache-2.0