Fix to abnormal plugin start 58/142958/3 accepted/tizen/4.0/unified/20170829.020218 accepted/tizen/unified/20170818.000059 submit/tizen/20170817.070255 submit/tizen_4.0/20170828.100004 submit/tizen_4.0/20170828.110004
authorkj7.sung <kj7.sung@samsung.com>
Tue, 8 Aug 2017 04:53:48 +0000 (13:53 +0900)
committerkj7.sung <kj7.sung@samsung.com>
Thu, 17 Aug 2017 06:26:45 +0000 (15:26 +0900)
Change-Id: I0cb224ecec0f99d3d7ec4d86b47ca2aeec42c163
Signed-off-by: kj7.sung <kj7.sung@samsung.com>
lbs-server/src/debug_util.h
lbs-server/src/lbs_server.c
module/nps_module.c
packaging/lbs-server.spec

index 275f3620f2c72ea66b5905577469babef37c4ad7..160e000c99ae5e6a80ec91edfc436732218dbbeb 100644 (file)
@@ -46,8 +46,6 @@ extern "C" {
 #define LOG_UNINDENT_PREFIX                 "< "
 #define INDENT(format)                                         LOG_INDENT_PREFIX   FUNCTION_PREFIX(format)
 #define UNINDENT(format)                                       LOG_UNINDENT_PREFIX FUNCTION_PREFIX(format)
-#define ENTER_FUNCTION_THIS_PREFIX(format)     LOG_INDENT_PREFIX   FUNCTION_THIS_PREFIX(format)
-#define LEAVE_FUNCTION_THIS_PREFIX(format)     LOG_UNINDENT_PREFIX FUNCTION_THIS_PREFIX(format)
 
 #define LOG_GPS(dbg_lvl, fmt, args...) SLOG(dbg_lvl, TAG_GPS_MANAGER, fmt, ##args)
 #define LOG_NPS(dbg_lvl, fmt, args...) SLOG(dbg_lvl, TAG_NPS_MANAGER, fmt, ##args)
index 91e8f4d44b7300e0ffeacae6d5f4a2a85bfb393a..a8eb904af00b201c72272b072c77f0787950fd4b 100644 (file)
@@ -63,7 +63,7 @@ typedef struct {
        /* nps variables */
        NpsManagerHandle nps_handle;
        unsigned long period;
-       NpsManagerPositionExt pos;
+       NpsManagerPositionExt wps;
        NpsManagerLastPositionExt last_pos;
        Plugin_LocationInfo location;
 
@@ -163,30 +163,30 @@ static void __setting_mock_cb(keynode_t *key, gpointer user_data)
        }
 }
 
-static void nps_set_last_position(NpsManagerPositionExt pos)
+static void nps_set_last_position(NpsManagerPositionExt wps)
 {
-       LOG_NPS(DBG_LOW, "nps_set_last_position[%d]", pos.timestamp);
+       LOG_NPS(DBG_LOW, "nps_set_last_position[%d]", wps.timestamp);
 
        char location[128] = {0,};
-       snprintf(location, sizeof(location), "%.6lf;%.6lf;%.2lf;%.2lf;%.2lf;%.2lf;", pos.latitude, pos.longitude, pos.altitude, pos.speed, pos.direction, pos.hor_accuracy);
+       snprintf(location, sizeof(location), "%.6lf;%.6lf;%.2lf;%.2lf;%.2lf;%.2lf;", wps.latitude, wps.longitude, wps.altitude, wps.speed, wps.direction, wps.hor_accuracy);
 
-       setting_set_int(VCONFKEY_LOCATION_NV_LAST_WPS_TIMESTAMP, pos.timestamp);
+       setting_set_int(VCONFKEY_LOCATION_NV_LAST_WPS_TIMESTAMP, wps.timestamp);
        setting_set_string(VCONFKEY_LOCATION_NV_LAST_WPS_LOCATION, location);
 }
 
-static void nps_set_position(lbs_server_s *lbs_server, NpsManagerPositionExt pos)
+static void nps_set_position(lbs_server_s *lbs_server, NpsManagerPositionExt wps)
 {
-       LOG_NPS(DBG_LOW, "set position timestamp : %d", pos.timestamp);
-       lbs_server->last_pos.timestamp = pos.timestamp;
+       LOG_NPS(DBG_LOW, "nps set position timestamp[%d]", wps.timestamp);
+       lbs_server->last_pos.timestamp = wps.timestamp;
        setting_set_int(VCONFKEY_LOCATION_LAST_WPS_TIMESTAMP, lbs_server->last_pos.timestamp);
 
-       if ((lbs_server->last_pos.latitude != pos.latitude) || (lbs_server->last_pos.longitude != pos.longitude)) {
-               lbs_server->last_pos.latitude = pos.latitude;
-               lbs_server->last_pos.longitude = pos.longitude;
-               lbs_server->last_pos.altitude = pos.altitude;
-               lbs_server->last_pos.hor_accuracy = pos.hor_accuracy;
-               lbs_server->last_pos.speed = pos.speed;
-               lbs_server->last_pos.direction = pos.direction;
+       if ((lbs_server->last_pos.latitude != wps.latitude) || (lbs_server->last_pos.longitude != wps.longitude)) {
+               lbs_server->last_pos.latitude = wps.latitude;
+               lbs_server->last_pos.longitude = wps.longitude;
+               lbs_server->last_pos.altitude = wps.altitude;
+               lbs_server->last_pos.hor_accuracy = wps.hor_accuracy;
+               lbs_server->last_pos.speed = wps.speed;
+               lbs_server->last_pos.direction = wps.direction;
 
                setting_set_double(VCONFKEY_LOCATION_LAST_WPS_LATITUDE, lbs_server->last_pos.latitude);
                setting_set_double(VCONFKEY_LOCATION_LAST_WPS_LONGITUDE, lbs_server->last_pos.longitude);
@@ -199,9 +199,9 @@ static void nps_set_position(lbs_server_s *lbs_server, NpsManagerPositionExt pos
        int last_timestamp = 0;
        setting_get_int(VCONFKEY_LOCATION_NV_LAST_WPS_TIMESTAMP, &last_timestamp);
 
-       LOG_NPS(DBG_LOW, "last_time stamp: %d, pos.timestamp: %d, UPDATE_INTERVAL: %d ", last_timestamp, pos.timestamp, UPDATE_INTERVAL);
-       if ((pos.timestamp - last_timestamp) > UPDATE_INTERVAL)
-               nps_set_last_position(pos);
+       LOG_NPS(DBG_LOW, "last_time stamp: %d, wps.timestamp: %d, UPDATE_INTERVAL: %d ", last_timestamp, wps.timestamp, UPDATE_INTERVAL);
+       if ((wps.timestamp - last_timestamp) > UPDATE_INTERVAL)
+               nps_set_last_position(wps);
 }
 
 static void nps_set_status(lbs_server_s *lbs_server, LbsStatus status)
@@ -210,7 +210,7 @@ static void nps_set_status(lbs_server_s *lbs_server, LbsStatus status)
                LOG_NPS(DBG_ERR, "lbs_server is NULL!!");
                return;
        }
-       LOG_NPS(DBG_LOW, "Previous status: %d, Current status: %d", lbs_server->status, status);
+       LOG_NPS(DBG_LOW, "status changed : %d --> [%d]", lbs_server->status, status);
        if (lbs_server->status == status) {
                LOG_NPS(DBG_WARN, "Don't update NPS status");
                return;
@@ -226,12 +226,12 @@ static void nps_set_status(lbs_server_s *lbs_server, LbsStatus status)
                setting_set_int(VCONFKEY_LOCATION_WPS_STATE, POSITION_OFF);
 
        if (status != LBS_STATUS_AVAILABLE)
-               lbs_server->pos.fields = LBS_POSITION_FIELDS_NONE;
+               lbs_server->wps.fields = LBS_POSITION_FIELDS_NONE;
 
        lbs_server_emit_status_changed(lbs_server->lbs_dbus_server, LBS_SERVER_METHOD_NPS, status);
 }
 
-static void nps_update_position(lbs_server_s *lbs_server, NpsManagerPositionExt pos)
+static void nps_update_position(lbs_server_s *lbs_server, NpsManagerPositionExt wps)
 {
        if (!lbs_server) {
                LOG_NPS(DBG_ERR, "lbs-server is NULL!!");
@@ -243,27 +243,27 @@ static void nps_update_position(lbs_server_s *lbs_server, NpsManagerPositionExt
 
        GVariant *accuracy = NULL;
 
-       lbs_server->pos.fields = pos.fields;
-       lbs_server->pos.timestamp = pos.timestamp;
-       lbs_server->pos.latitude = pos.latitude;
-       lbs_server->pos.longitude = pos.longitude;
-       lbs_server->pos.altitude = pos.altitude;
-       lbs_server->pos.hor_accuracy = pos.hor_accuracy;
-       lbs_server->pos.ver_accuracy = pos.ver_accuracy;
+       lbs_server->wps.fields = wps.fields;
+       lbs_server->wps.timestamp = wps.timestamp;
+       lbs_server->wps.latitude = wps.latitude;
+       lbs_server->wps.longitude = wps.longitude;
+       lbs_server->wps.altitude = wps.altitude;
+       lbs_server->wps.hor_accuracy = wps.hor_accuracy;
+       lbs_server->wps.ver_accuracy = wps.ver_accuracy;
 
-       accuracy = g_variant_ref_sink(g_variant_new("(idd)", lbs_server->pos.acc_level, lbs_server->pos.hor_accuracy, lbs_server->pos.ver_accuracy));
+       accuracy = g_variant_ref_sink(g_variant_new("(idd)", lbs_server->wps.acc_level, lbs_server->wps.hor_accuracy, lbs_server->wps.ver_accuracy));
 
-       LOG_NPS(DBG_LOW, "time:%d", lbs_server->pos.timestamp);
+       LOG_NPS(DBG_LOW, "[WPS] time: %d, latitude : %.6lf, longitude : %.6lf", lbs_server->wps.timestamp, lbs_server->wps.latitude, lbs_server->wps.longitude);
 
 #ifdef TIZEN_DEVICE
        if (lbs_server->is_fused_running)
-               send_wps_position_to_fused_engine(pos.timestamp, pos.latitude, pos.longitude, pos.hor_accuracy, pos.ver_accuracy);
+               send_wps_position_to_fused_engine(wps.timestamp, wps.latitude, wps.longitude, wps.hor_accuracy, wps.ver_accuracy);
 #endif
 
        lbs_server_emit_position_changed(lbs_server->lbs_dbus_server, LBS_SERVER_METHOD_NPS,
-                                       lbs_server->pos.fields, lbs_server->pos.timestamp, lbs_server->pos.latitude,
-                                       lbs_server->pos.longitude, lbs_server->pos.altitude, lbs_server->pos.speed,
-                                       lbs_server->pos.direction, 0.0, accuracy);
+                                       lbs_server->wps.fields, lbs_server->wps.timestamp, lbs_server->wps.latitude,
+                                       lbs_server->wps.longitude, lbs_server->wps.altitude, lbs_server->wps.speed,
+                                       lbs_server->wps.direction, 0.0, accuracy);
 
        g_variant_unref(accuracy);
 }
@@ -292,42 +292,42 @@ static gboolean nps_report_callback(gpointer user_data)
 
        nps_set_status(lbs_server, LBS_STATUS_AVAILABLE);
 
-       NpsManagerPositionExt pos;
-       memset(&pos, 0x00, sizeof(NpsManagerPositionExt));
+       NpsManagerPositionExt wps;
+       memset(&wps, 0x00, sizeof(NpsManagerPositionExt));
 
-       pos.timestamp = timestamp;
+       wps.timestamp = timestamp;
 
        if (location.latitude) {
-               pos.fields |= LBS_POSITION_EXT_FIELDS_LATITUDE;
-               pos.latitude = location.latitude;
+               wps.fields |= LBS_POSITION_EXT_FIELDS_LATITUDE;
+               wps.latitude = location.latitude;
        }
 
        if (location.longitude) {
-               pos.fields |= LBS_POSITION_EXT_FIELDS_LONGITUDE;
-               pos.longitude = location.longitude;
+               wps.fields |= LBS_POSITION_EXT_FIELDS_LONGITUDE;
+               wps.longitude = location.longitude;
        }
 
        if (location.altitude) {
-               pos.fields |= LBS_POSITION_EXT_FIELDS_ALTITUDE;
-               pos.altitude = location.altitude;
+               wps.fields |= LBS_POSITION_EXT_FIELDS_ALTITUDE;
+               wps.altitude = location.altitude;
        }
 
        if (location.speed >= 0) {
-               pos.fields |= LBS_POSITION_EXT_FIELDS_SPEED;
-               pos.speed = location.speed;
+               wps.fields |= LBS_POSITION_EXT_FIELDS_SPEED;
+               wps.speed = location.speed;
        }
        if (location.bearing >= 0) {
-               pos.fields |= LBS_POSITION_EXT_FIELDS_DIRECTION;
-               pos.direction = location.bearing;
+               wps.fields |= LBS_POSITION_EXT_FIELDS_DIRECTION;
+               wps.direction = location.bearing;
        }
 
-       pos.acc_level = LBS_ACCURACY_LEVEL_STREET;
-       pos.hor_accuracy = location.hpe;
-       pos.ver_accuracy = vertical_accuracy;
+       wps.acc_level = LBS_ACCURACY_LEVEL_STREET;
+       wps.hor_accuracy = location.hpe;
+       wps.ver_accuracy = vertical_accuracy;
 
-       nps_update_position(lbs_server, pos);
+       nps_update_position(lbs_server, wps);
 
-       nps_set_position(lbs_server, pos);
+       nps_set_position(lbs_server, wps);
 
        return FALSE;
 }
@@ -414,8 +414,8 @@ static gboolean nps_offline_location(lbs_server_s *lbs_server)
                if (lbs_server->token != NULL) {
                        LOG_NPS(DBG_LOW, "Token = %s", lbs_server->token);
                        int ret = get_nps_plugin_module()->offlineLocation((unsigned char *)key,
-                                       NPS_UNIQUE_ID_LEN, lbs_server->token, 0,
-                                       __nps_callback, lbs_server);
+                                       NPS_UNIQUE_ID_LEN, lbs_server->token, 0, __nps_callback, lbs_server);
+
                        if (ret) {
                                if (lbs_server->is_nps_running) {
                                        LOG_NPS(DBG_LOW, "offlineLocation() called nps_callback successfully.");
@@ -447,7 +447,7 @@ static void __nps_cancel_callback(void *arg)
 }
 
 static gboolean location_source_selector(lbs_server_s *lbs_server, gint fused_mode);
-static void plugin_status_controller(lbs_server_s *lbs_server);
+static gboolean plugin_status_controller(lbs_server_s *lbs_server);
 static void request_plugin_interval(lbs_server_s *lbs_server);
 
 static void start_tracking(lbs_server_s *lbs_server, lbs_server_method_e method, gint fused_mode)
@@ -472,8 +472,10 @@ static void start_tracking(lbs_server_s *lbs_server, lbs_server_method_e method,
                if (lbs_server->is_mock_running != MOCK_RUNNING_OFF && lbs_server->is_gps_running == FALSE && lbs_server->is_nps_running == FALSE)
                        mock_start_tracking(lbs_server);
 
-               if (location_source_selector(lbs_server, fused_mode))
-                       plugin_status_controller(lbs_server);
+               if (location_source_selector(lbs_server, fused_mode)) {
+                       if (plugin_status_controller(lbs_server))
+                               break;
+               }
 
                if (nps_is_dummy_plugin_module() != TRUE)
                        nps_offline_location(lbs_server);
@@ -735,13 +737,14 @@ static gboolean nps_plugin_start(lbs_server_s *lbs_server)
        return FALSE;
 }
 
-static void plugin_status_controller(lbs_server_s *lbs_server)
+static gboolean plugin_status_controller(lbs_server_s *lbs_server)
 {
        LOG_FUNC;
+       gboolean ret = FALSE;
        if (lbs_server->current_location_source == LOCATION_SOURCE_GPS) {
                LOG_FUSED(DBG_LOW, "-->> LOCATION_SOURCE_GPS");
                if (lbs_server->is_gps_running == FALSE)
-                       gps_plugin_start(lbs_server);
+                       ret = gps_plugin_start(lbs_server);
 
                if (lbs_server->is_nps_running)
                        nps_plugin_stop(lbs_server);
@@ -752,15 +755,15 @@ static void plugin_status_controller(lbs_server_s *lbs_server)
                        gps_plugin_stop(lbs_server);
 
                if (lbs_server->is_nps_running == FALSE)
-                       nps_plugin_start(lbs_server);
+                       ret = nps_plugin_start(lbs_server);
 
        } else if (lbs_server->current_location_source == LOCATION_SOURCE_BOTH) {
                LOG_FUSED(DBG_LOW, "-->> LOCATION_SOURCE_BOTH");
                if (lbs_server->is_gps_running == FALSE)
-                       gps_plugin_start(lbs_server);
+                       ret = gps_plugin_start(lbs_server);
 
                if (lbs_server->is_nps_running == FALSE)
-                       nps_plugin_start(lbs_server);
+                       ret = nps_plugin_start(lbs_server);
 
        } else if (lbs_server->current_location_source == LOCATION_SOURCE_NONE) {
                LOG_FUSED(DBG_LOW, "-->> LOCATION_SOURCE_NONE");
@@ -770,6 +773,8 @@ static void plugin_status_controller(lbs_server_s *lbs_server)
                if (lbs_server->is_nps_running)
                        nps_plugin_stop(lbs_server);
        }
+
+       return ret;
 }
 
 static void find_min_interval_foreach_cb(gpointer key, gpointer value, gpointer userdata)
@@ -1614,14 +1619,14 @@ static void nps_init(lbs_server_s *lbs_server)
        lbs_server->period = 5000;
        nps_set_status(lbs_server, LBS_STATUS_UNAVAILABLE);
 
-       lbs_server->pos.fields = LBS_POSITION_EXT_FIELDS_NONE;
-       lbs_server->pos.timestamp = 0;
-       lbs_server->pos.latitude = 0.0;
-       lbs_server->pos.longitude = 0.0;
-       lbs_server->pos.altitude = 0.0;
-       lbs_server->pos.acc_level = LBS_POSITION_EXT_FIELDS_NONE;
-       lbs_server->pos.hor_accuracy = -1.0;
-       lbs_server->pos.ver_accuracy = -1.0;
+       lbs_server->wps.fields = LBS_POSITION_EXT_FIELDS_NONE;
+       lbs_server->wps.timestamp = 0;
+       lbs_server->wps.latitude = 0.0;
+       lbs_server->wps.longitude = 0.0;
+       lbs_server->wps.altitude = 0.0;
+       lbs_server->wps.acc_level = LBS_POSITION_EXT_FIELDS_NONE;
+       lbs_server->wps.hor_accuracy = -1.0;
+       lbs_server->wps.ver_accuracy = -1.0;
 
        lbs_server->last_pos.timestamp = 0;
        lbs_server->last_pos.latitude = 0.0;
index b13f58d5cb2e132800efeff0672a4858b8baacf9..66fafb97c5cf2cf44c402a503fc18deb82e8549a 100644 (file)
@@ -82,10 +82,8 @@ static void position_callback(GVariant *param, void *user_data)
        g_variant_get(param, "(iiidddddd@(idd))", &method, &fields, &timestamp, &latitude, &longitude, &altitude, &speed, &direction, &climb, &accuracy);
 
        if (method != LBS_CLIENT_METHOD_NPS) {
-               if (method != LBS_CLIENT_METHOD_MOCK) {
-                       MOD_NPS_LOGD("Method is not LBS_CLIENT_METHOD_NPS: %d", method);
+               if (method != LBS_CLIENT_METHOD_MOCK)
                        return;
-               }
        }
 
        g_variant_get(accuracy, "(idd)", &level, &horizontal, &vertical);
index 5e5cc0adebb6fe649d029843712f337348c26dac..31853ba95d1a32b18aed8971cd8c9e84c05081aa 100644 (file)
@@ -1,6 +1,6 @@
 Name:    lbs-server
 Summary: LBS Server for Tizen
-Version: 1.2.5
+Version: 1.2.6
 Release: 1
 Group:   Location/Service
 License: Apache-2.0
@@ -9,7 +9,6 @@ Source1: lbs-server.service
 Source2: lbs-server.manifest
 Source3: location-lbs-server.manifest
 BuildRequires: cmake
-#BuildRequires: model-build-features
 BuildRequires: pkgconfig(glib-2.0)
 BuildRequires: pkgconfig(network)
 BuildRequires: pkgconfig(tapi)
@@ -58,10 +57,6 @@ cp %{SOURCE3} .
 %build
 %define _prefix /usr
 
-export CFLAGS="$CFLAGS -DTIZEN_DEBUG_ENABLE"
-export CXXFLAGS="$CXXFLAGS -DTIZEN_DEBUG_ENABLE"
-export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
-
 %ifarch %arm aarch64
 export CFLAGS="$CFLAGS -DTIZEN_DEVICE"
 export CXXFLAGS="$CXXFLAGS -DTIZEN_DEVICE"
@@ -100,9 +95,6 @@ rm -rf %{buildroot}
 
 
 %post -n location-lbs-server
-#%ifnarch %arm
-#      cp -f /usr/lib/location/module/libgps.so /usr/lib/location/module/libwps0.so
-#%endif
 
 
 %postun -p /sbin/ldconfig