From df3c5ec7d555cf4eeddfcf62ee2dce09f9a245c2 Mon Sep 17 00:00:00 2001 From: Sangdok Mo Date: Mon, 24 Jul 2017 11:05:31 +0900 Subject: [PATCH 01/16] changed AUTHORS Change-Id: Ifa9f3810da91b5be9f75ac94cccb1953d7a03595 Signed-off-by: Sangdok Mo --- AUTHORS | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/AUTHORS b/AUTHORS index ce0e4ee..3d8b966 100644 --- a/AUTHORS +++ b/AUTHORS @@ -1,5 +1,6 @@ Jongmun Woo -Young-Ae Kang Kyoungjun Sung +Seechan Kim +Young-Ae Kang Karthik Paulraj VENKATAKOTIVIJAYALAKSHMINARAYA -- 2.7.4 From 7f9fda3707c5d5f49a8d89541b251b7b0ad747bd Mon Sep 17 00:00:00 2001 From: jomui Date: Mon, 24 Jul 2017 13:54:43 +0900 Subject: [PATCH 02/16] fix for no AppId Signed-off-by: jomui Change-Id: I5edafd2e2e8a4f9d7c4d36eb24227c6f1a284801 --- geofence-server/CMakeLists.txt | 2 +- geofence-server/src/geofence_server.c | 10 +++++----- module/module_geofence_server.c | 3 ++- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/geofence-server/CMakeLists.txt b/geofence-server/CMakeLists.txt index 6d66d70..9f3786d 100644 --- a/geofence-server/CMakeLists.txt +++ b/geofence-server/CMakeLists.txt @@ -1,5 +1,5 @@ CMAKE_MINIMUM_REQUIRED(VERSION 2.0) -PROJECT(geofence-server) +PROJECT(geofence-server) SET(server_pkgs_LDFLAGS "${server_pkgs_LDFLAGS} -ldl") SET(SERVER_EXTRA_CFLAGS "${SERVER_EXTRA_CFLAGS} -D_GNU_SOURCE") diff --git a/geofence-server/src/geofence_server.c b/geofence-server/src/geofence_server.c index 2d17c64..2ecba0a 100644 --- a/geofence-server/src/geofence_server.c +++ b/geofence-server/src/geofence_server.c @@ -412,7 +412,7 @@ static void __check_inout_by_gps(double latitude, double longitude, int fence_id geofence_fence_state_e status = GEOFENCE_FENCE_STATE_OUT; geocoordinate_info_s *geocoordinate_info = (geocoordinate_info_s *)item_data->priv; /* get_current_position/ check_fence_in/out for geoPoint */ - location_manager_get_distance(latitude, longitude, geocoordinate_info->latitude, geocoordinate_info->longitude, &distance); + location_manager_get_distance(latitude, longitude, geocoordinate_info->latitude, geocoordinate_info->longitude, &distance); if (distance >= geocoordinate_info->radius) { LOGD_GEOFENCE("FENCE_OUT : based on distance. Distance[%f] for fence id: %d at (%f, %f)", distance, fence_id, latitude, longitude); @@ -2164,7 +2164,7 @@ static void dbus_start_geofence_cb(gint fence_id, const gchar *app_id, gpointer } else if (adapter_state == BT_ADAPTER_ENABLED) { bt_device_info_s *bt_device_info = NULL; if (bt_info != NULL) { - ret = bt_adapter_get_bonded_device_info(bt_info->bssid, &bt_device_info); + ret = bt_adapter_get_bonded_device_info(bt_info->bssid, &bt_device_info); if (ret != BT_ERROR_NONE) { LOGE_GEOFENCE("Fail to get the bonded device info/ Not bonded with any device. Error[%d]", ret); /*NEED TO BE DECIDED WHETHER TO REQUEST FOR A SCAN HERE OR JUST EMIT OUT AS STATUS*/ @@ -2172,7 +2172,7 @@ static void dbus_start_geofence_cb(gint fence_id, const gchar *app_id, gpointer status_to_be_emitted = GEOFENCE_FENCE_STATE_OUT; } else { if (bt_device_info == NULL) { - LOGI_GEOFENCE("bt_adapter_get_bonded_device_info [%s] failed.", bt_info->bssid); + LOGI_GEOFENCE("bt_adapter_get_bonded_device_info [%s] failed.", bt_info->bssid); status_to_be_emitted = GEOFENCE_FENCE_STATE_OUT; } else { if (bt_device_info->is_bonded == TRUE && bt_device_info->is_connected == TRUE) { @@ -2468,18 +2468,18 @@ static GVariant *dbus_get_geofences_cb(int place_id, const gchar *app_id, int *f if ((place_info != NULL) && (place_info->access_type == ACCESS_TYPE_PRIVATE)) { if (g_strcmp0(app_id, place_info->appid) != 0) { LOGI_GEOFENCE("Not authorized to access this private place[%d]", place_id); - g_free(place_info); /* Send ZERO data gvariant*/ *errorCode = GEOFENCE_SERVER_ERROR_PLACE_ACCESS_DENIED; *fenceCnt = fence_cnt; g_variant_builder_init(&b, G_VARIANT_TYPE("aa{sv}")); + g_free(place_info); return g_variant_builder_end(&b); } - g_free(place_info); } ret = geofence_manager_get_fence_list_from_db(&count, &fence_list, place_id); } LOGI_GEOFENCE("count = %d", count); + g_free(place_info); if (ret != FENCE_ERR_NONE) { LOGI_GEOFENCE("get list failed"); diff --git a/module/module_geofence_server.c b/module/module_geofence_server.c index 0a1cc92..ff80d10 100644 --- a/module/module_geofence_server.c +++ b/module/module_geofence_server.c @@ -491,7 +491,8 @@ static void __get_caller_app_id(void *handle) pid = getpid(); ret = app_manager_get_app_id(pid, &app_id); if (ret != APP_MANAGER_ERROR_NONE) { - MOD_LOGE("Fail to get app_id from module_geofence_server. Err[%d]", ret); + MOD_LOGE("No app_id. Set app_id to RequestbyFramework"); + geofence_manager->app_id = g_strdup("RequestbyFramework"); } else { MOD_LOGD("app_id: %s", app_id); geofence_manager->app_id = app_id; -- 2.7.4 From 865ec0d97dabca8dad27ce537abdc02b91d2fd84 Mon Sep 17 00:00:00 2001 From: jomui Date: Wed, 26 Jul 2017 17:29:40 +0900 Subject: [PATCH 03/16] remove unused code Signed-off-by: jomui Change-Id: Id89b89b27671e11f88a1f8ba5a90626af1571c32 --- geofence-server/src/geofence_server.c | 1 - 1 file changed, 1 deletion(-) diff --git a/geofence-server/src/geofence_server.c b/geofence-server/src/geofence_server.c index 2ecba0a..367b872 100644 --- a/geofence-server/src/geofence_server.c +++ b/geofence-server/src/geofence_server.c @@ -1122,7 +1122,6 @@ static int __gps_alarm_cb(alarm_id_t alarm_id, void *user_data) if (geofence_server->gps_alarm_id != -1) { /*LOGI_GEOFENCE("GPS interval timer removed. ID[%d]", geofence_server->gps_alarm_id);*/ geofence_server->gps_alarm_id = _geofence_remove_alarm(geofence_server->gps_alarm_id); - geofence_server->gps_alarm_id = -1; } if (geofence_server->loc_gps_started_by_wps == true) { ret = __start_gps_positioning(geofence_server, __geofence_gps_position_changed_cb); -- 2.7.4 From 80204ea329810010b54b81c66aa288897acb4f26 Mon Sep 17 00:00:00 2001 From: jomui Date: Thu, 24 Aug 2017 10:18:24 +0900 Subject: [PATCH 04/16] remove unused code about deprecated display APIs Signed-off-by: jomui Change-Id: Id4af70a4cda643579cdeb0c5232c91b997e5797a --- geofence-server/src/geofence_server.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/geofence-server/src/geofence_server.c b/geofence-server/src/geofence_server.c index 367b872..e9f60f6 100644 --- a/geofence-server/src/geofence_server.c +++ b/geofence-server/src/geofence_server.c @@ -20,7 +20,6 @@ #include #include #include -#include #include #include #include @@ -1149,7 +1148,6 @@ static int __wps_timeout_cb(alarm_id_t alarm_id, void *user_data) /*Stop the wps for sometime when there is no fix*/ __stop_wps_positioning(geofence_server); geofence_server->wps_alarm_id = _geofence_add_alarm(10, __wps_alarm_cb, geofence_server); - /*display_unlock_state(LCD_OFF, PM_RESET_TIMER);*/ return 0; } -- 2.7.4 From 5eac3a8c72205b0c1f9cced96559eeb3765a571c Mon Sep 17 00:00:00 2001 From: Susnata Date: Mon, 12 Mar 2018 05:13:11 -0400 Subject: [PATCH 05/16] Fixed svace issues of geofence-server db Change-Id: Ibbe226a6700c41d291b7e7d8195ca73c1e3e1137 Signed-off-by: Susnata --- geofence-server/src/geofence_server_db.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/geofence-server/src/geofence_server_db.c b/geofence-server/src/geofence_server_db.c index 8c85238..f4c4988 100755 --- a/geofence-server/src/geofence_server_db.c +++ b/geofence-server/src/geofence_server_db.c @@ -1147,6 +1147,7 @@ int geofence_manager_set_geocoordinate_info(int fence_id, geocoordinate_info_s * ret = snprintf(data_name_lon, MAX_DATA_NAME, "%lf", geocoordinate_info->longitude); if (ret < 0) { LOGD_GEOFENCE("ERROR: String will be truncated"); + sqlite3_finalize(state); return FENCE_ERR_STRING_TRUNCATED; } @@ -1157,6 +1158,7 @@ int geofence_manager_set_geocoordinate_info(int fence_id, geocoordinate_info_s * ret = snprintf(data_name_rad, MAX_DATA_NAME, "%lf", geocoordinate_info->radius); if (ret < 0) { LOGD_GEOFENCE("ERROR: String will be truncated"); + sqlite3_finalize(state); return FENCE_ERR_STRING_TRUNCATED; } @@ -1217,6 +1219,9 @@ int geofence_manager_get_geocoordinate_info(int fence_id, geocoordinate_info_s * } *geocoordinate_info = (geocoordinate_info_s *)g_malloc0(sizeof(geocoordinate_info_s)); + if (*geocoordinate_info == NULL) { + sqlite3_finalize(state); + } g_return_val_if_fail(*geocoordinate_info, FENCE_ERR_INVALID_PARAMETER); #ifdef SUPPORT_ENCRYPTION @@ -1314,6 +1319,9 @@ int geofence_manager_get_ap_info(const int fence_id, GList **ap_list) break; } wifi_info = g_slice_new0(wifi_info_s); + if (wifi_info == NULL) { + sqlite3_finalize(state); + } g_return_val_if_fail(wifi_info, -1); if (wifi_info) { bssid = (const char *) sqlite3_column_text(state, 1); @@ -1359,6 +1367,9 @@ int geofence_manager_get_place_info(int place_id, place_info_s **place_info) return FENCE_ERR_SQLITE_FAIL; } *place_info = (place_info_s *)g_malloc0(sizeof(place_info_s)); + if (*place_info == NULL) { + sqlite3_finalize(state); + } g_return_val_if_fail(*place_info, FENCE_ERR_INTERNAL); data_name = (char *)sqlite3_column_text(state, ++index); @@ -1471,6 +1482,9 @@ int geofence_manager_get_bssid_info(const int fence_id, bssid_info_s **bssid_inf break; } bssid_info_from_db = g_slice_new0(bssid_info_s); + if (bssid_info_from_db == NULL) { + sqlite3_finalize(state); + } g_return_val_if_fail(bssid_info_from_db, -1); if (bssid_info_from_db) { bssid = (const char *)sqlite3_column_text(state, 1); @@ -2411,6 +2425,7 @@ int geofence_manager_reset(void) return FENCE_ERR_SQLITE_FAIL; } sqlite3_reset(state); + sqlite3_finalize(state); sqlite3_free(query_two); char *query_three = sqlite3_mprintf("UPDATE sqlite_sequence SET seq = 0 where name = %Q;", menu_table[FENCE_MAIN_TABLE]); @@ -2527,6 +2542,7 @@ int geofence_manager_get_count_by_params(const char *app_id, geofence_type_e fen if (*count <= 0) { LOGI_GEOFENCE("ERROR: count = %d", *count); + sqlite3_finalize(state); return FENCE_ERR_COUNT; } else { LOGI_GEOFENCE("count[%d]", *count); @@ -2623,6 +2639,7 @@ int geofence_manager_get_count_of_fences(int *count) if (*count < 0) { LOGI_GEOFENCE("ERROR: count = %d", *count); + sqlite3_finalize(state); return FENCE_ERR_COUNT; } else { LOGI_GEOFENCE("count[%d]", *count); @@ -2661,6 +2678,7 @@ int geofence_manager_get_place_count_by_placeid(int place_id, int *count) if (*count < 0) { LOGI_GEOFENCE("ERROR: place count = %d", *count); + sqlite3_finalize(state); return FENCE_ERR_COUNT; } else { LOGI_GEOFENCE("place count[%d]", *count); -- 2.7.4 From b6c43069b07a763426b62d8f32e81eac807536da Mon Sep 17 00:00:00 2001 From: chanywa Date: Wed, 21 Mar 2018 15:32:12 +0900 Subject: [PATCH 06/16] Fix cmake upgrade issue Change-Id: Iacebdf1e1461e77428a7036b05bc13a46e8d8fc2 --- CMakeLists.txt | 2 +- geofence-server/CMakeLists.txt | 2 +- module/CMakeLists.txt | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6600afd..8e226f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -37,7 +37,7 @@ ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") ADD_DEFINITIONS(" -DEXPORT_API=\"__attribute__((visibility(\\\"default\\\")))\" ") MESSAGE(${CMAKE_C_FLAGS}) -MESSAGE(${CMAKE_EXE_LINKER_FLAGS}) +#MESSAGE(${CMAKE_EXE_LINKER_FLAGS}) ADD_SUBDIRECTORY(module) ADD_SUBDIRECTORY(geofence-server) diff --git a/geofence-server/CMakeLists.txt b/geofence-server/CMakeLists.txt index 9f3786d..a64c5f7 100644 --- a/geofence-server/CMakeLists.txt +++ b/geofence-server/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.0) +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(geofence-server) SET(server_pkgs_LDFLAGS "${server_pkgs_LDFLAGS} -ldl") diff --git a/module/CMakeLists.txt b/module/CMakeLists.txt index b13e779..9240749 100644 --- a/module/CMakeLists.txt +++ b/module/CMakeLists.txt @@ -1,4 +1,4 @@ -CMAKE_MINIMUM_REQUIRED(VERSION 2.0) +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) PROJECT(geofence) SET(geofence_module ${PROJECT_NAME}) -- 2.7.4 From 9ce9a5edf2aaaca76f83ad29cffb36f7d5c5ee6b Mon Sep 17 00:00:00 2001 From: Susnata Sovalin Date: Fri, 20 Apr 2018 15:19:04 +0530 Subject: [PATCH 07/16] Dbus/Cynara Policy Fix Change-Id: I907d7960a4f533a97f69cbf63ec8b0e652bf953e Signed-off-by: Susnata Sovalin --- geofence-server/config/geofence-server.conf | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/geofence-server/config/geofence-server.conf b/geofence-server/config/geofence-server.conf index 1effc5b..fb0e8ba 100644 --- a/geofence-server/config/geofence-server.conf +++ b/geofence-server/config/geofence-server.conf @@ -5,23 +5,25 @@ - - - - - + + + + + + + - + privilege="http://tizen.org/privilege/location"/> -- 2.7.4 From 05de360a602e22f231999346dd02b5d3441babc1 Mon Sep 17 00:00:00 2001 From: "Seechan, Kim" Date: Thu, 10 May 2018 17:57:13 +0900 Subject: [PATCH 08/16] Fixes dbus policy to receive alarm message Change-Id: I0e93914ee0a6d99c966f6a4f3b72ac0ac519e9b3 --- geofence-server/config/geofence-server.conf | 2 ++ 1 file changed, 2 insertions(+) diff --git a/geofence-server/config/geofence-server.conf b/geofence-server/config/geofence-server.conf index fb0e8ba..922ca23 100644 --- a/geofence-server/config/geofence-server.conf +++ b/geofence-server/config/geofence-server.conf @@ -22,6 +22,8 @@ + -- 2.7.4 From fff6ba50d1f40bbf02222eaa847ad386f0c2e95d Mon Sep 17 00:00:00 2001 From: "Seechan, Kim" Date: Thu, 21 Jun 2018 08:49:38 +0900 Subject: [PATCH 09/16] Fix mis-spelled dbus policy Change-Id: Ia05bd843ef1a4356dfff5fd9241c181e034b8258 --- geofence-server/config/geofence-server.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geofence-server/config/geofence-server.conf b/geofence-server/config/geofence-server.conf index 922ca23..d2ab32a 100644 --- a/geofence-server/config/geofence-server.conf +++ b/geofence-server/config/geofence-server.conf @@ -23,7 +23,7 @@ + send_interface="org.tizen.alarm.client" send_member="alarm_expired"/> -- 2.7.4 From 9a062ea1bb9b2ba90e164611fd2d8c19ae4017c7 Mon Sep 17 00:00:00 2001 From: "Seechan, Kim" Date: Thu, 21 Jun 2018 08:50:37 +0900 Subject: [PATCH 10/16] Revert "Fix mis-spelled dbus policy" This reverts commit fff6ba50d1f40bbf02222eaa847ad386f0c2e95d. --- geofence-server/config/geofence-server.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geofence-server/config/geofence-server.conf b/geofence-server/config/geofence-server.conf index d2ab32a..922ca23 100644 --- a/geofence-server/config/geofence-server.conf +++ b/geofence-server/config/geofence-server.conf @@ -23,7 +23,7 @@ + interface="org.tizen.alarm.client" member="alarm_expired"/> -- 2.7.4 From e062947cbf61888bca68951d31b670dbd0966ef8 Mon Sep 17 00:00:00 2001 From: "Seechan, Kim" Date: Thu, 21 Jun 2018 08:49:38 +0900 Subject: [PATCH 11/16] Fix mis-spelled dbus policy Change-Id: Ia05bd843ef1a4356dfff5fd9241c181e034b8258 --- geofence-server/config/geofence-server.conf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/geofence-server/config/geofence-server.conf b/geofence-server/config/geofence-server.conf index 922ca23..d2ab32a 100644 --- a/geofence-server/config/geofence-server.conf +++ b/geofence-server/config/geofence-server.conf @@ -23,7 +23,7 @@ + send_interface="org.tizen.alarm.client" send_member="alarm_expired"/> -- 2.7.4 From 557824777d6eeaf54bbba70b15d20f013a5e1f9b Mon Sep 17 00:00:00 2001 From: Susnata Sovalin Date: Tue, 18 Sep 2018 11:06:40 +0530 Subject: [PATCH 12/16] Fix Coverity issue 1026349 Change-Id: I5a5727c9ce176f233ef3c7cc0ace1d6514b61763 Signed-off-by: Susnata Sovalin --- geofence-server/src/geofence_server.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/geofence-server/src/geofence_server.c b/geofence-server/src/geofence_server.c index e9f60f6..179a497 100644 --- a/geofence-server/src/geofence_server.c +++ b/geofence-server/src/geofence_server.c @@ -238,6 +238,8 @@ void bt_le_scan_result_display_cb(int result, bt_adapter_le_device_scan_result_i } else if (ret == BT_ERROR_REMOTE_DEVICE_NOT_BONDED) { ble_proximity_mode = BLE_INFO_READ; /*Its not bonded*/ } + if (bt_device_info != NULL) + bt_adapter_free_device_info(bt_device_info); } } if (ble_proximity_mode == BLE_INFO_READ) { -- 2.7.4 From 79de70f960a280d7a2b995feb64ce8b5a19e61e4 Mon Sep 17 00:00:00 2001 From: Hyotaek Shim Date: Mon, 1 Oct 2018 11:57:15 +0900 Subject: [PATCH 13/16] Remove unnecessary dbus policy rules For the dbus session bus, default allow rule is applied, and only a certain uid is allowed to use. Thus, rules are only required. Change-Id: I62a2420ac9060634ad3f4390224abb6fad1fd1c2 Signed-off-by: Hyotaek Shim --- geofence-server/config/geofence-server.conf | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/geofence-server/config/geofence-server.conf b/geofence-server/config/geofence-server.conf index d2ab32a..991769e 100644 --- a/geofence-server/config/geofence-server.conf +++ b/geofence-server/config/geofence-server.conf @@ -1,29 +1,7 @@ - - - - - - - - - - - - - - - - - - - - -- 2.7.4 From 1c35a2839d2346544fe8d34efdedcd35a511a0f4 Mon Sep 17 00:00:00 2001 From: Susnata Sovalin Date: Fri, 5 Oct 2018 12:17:35 +0530 Subject: [PATCH 14/16] Resolved geofence ITC issue Change-Id: I03339743fb0980b4f1c57290b5b76892ec579cc9 Signed-off-by: Randeep Singh Signed-off-by: Susnata Sovalin --- geofence-server/src/server.c | 52 +++++++++++++++++++++----------------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/geofence-server/src/server.c b/geofence-server/src/server.c index 66dc4fc..a0c7aae 100644 --- a/geofence-server/src/server.c +++ b/geofence-server/src/server.c @@ -240,38 +240,36 @@ int _geofence_initialize_geofence_server(GeofenceServer *geofence_server) /*initialize to use bluetooth C-API*/ ret = bt_initialize(); if (BT_ERROR_NONE != ret) { - LOGD_GEOFENCE("bt_initialize() failed(%d).", ret); - return -1; - } - - /* register the bluetooth adapter state changed callback*/ - ret = bt_adapter_set_state_changed_cb(__geofence_bt_adapter_state_changed_cb, geofence_server); - if (BT_ERROR_NONE != ret) { - LOGD_GEOFENCE("bt_adapter_set_state_changed_cb() failed(%d).", ret); - bt_deinitialize(); - return -1; + LOGD_GEOFENCE("bt_initialize() failed(%d).Proceeding to wifi", ret); } else { - LOGD_GEOFENCE("bt_adapter_set_state_changed_cb() success.", ret); - } + /* register the bluetooth adapter state changed callback*/ + ret = bt_adapter_set_state_changed_cb(__geofence_bt_adapter_state_changed_cb, geofence_server); + if (BT_ERROR_NONE != ret) { + LOGE_GEOFENCE("bt_adapter_set_state_changed_cb() failed(%d).", ret); + bt_deinitialize(); + return -1; + } else { + LOGD_GEOFENCE("bt_adapter_set_state_changed_cb() success.", ret); + } - /* register the bluetooth device connection state changed callback*/ - ret = bt_device_set_connection_state_changed_cb(__geofence_bt_device_connection_state_changed_cb, geofence_server); - if (BT_ERROR_NONE != ret) { - LOGD_GEOFENCE("bt_device_set_connection_state_changed_cb() failed(%d).", ret); - bt_adapter_unset_state_changed_cb(); - bt_deinitialize(); - return -1; - } else { - LOGD_GEOFENCE("bt_device_set_connection_state_changed_cb() success.", ret); + /* register the bluetooth device connection state changed callback*/ + ret = bt_device_set_connection_state_changed_cb(__geofence_bt_device_connection_state_changed_cb, geofence_server); + if (BT_ERROR_NONE != ret) { + LOGE_GEOFENCE("bt_device_set_connection_state_changed_cb() failed(%d).", ret); + bt_adapter_unset_state_changed_cb(); + bt_deinitialize(); + return -1; + } else { + LOGD_GEOFENCE("bt_device_set_connection_state_changed_cb() success.", ret); + } + /*register for the discovery state change callback*/ + ret = bt_adapter_set_device_discovery_state_changed_cb(__geofence_bt_adapter_device_discovery_state_changed_cb, (void *)geofence_server); + if (BT_ERROR_NONE != ret) + LOGE_GEOFENCE("Failed to set the callback for discovery"); } - /*register for the discovery state change callback*/ - ret = bt_adapter_set_device_discovery_state_changed_cb(__geofence_bt_adapter_device_discovery_state_changed_cb, (void *)geofence_server); - if (BT_ERROR_NONE != ret) - LOGE_GEOFENCE("Failed to set the callback for discovery"); - ret = wifi_manager_initialize(&(geofence_server->wifi_h)); if (WIFI_MANAGER_ERROR_NONE != ret) { - LOGD_GEOFENCE("wifi_manager_initialize() failed(%d).", ret); + LOGE_GEOFENCE("wifi_manager_initialize() failed(%d).", ret); return -1; } -- 2.7.4 From f2bfe46537d02d5cb0c3c47845de5603fa62ee11 Mon Sep 17 00:00:00 2001 From: Susnata Sovalin Date: Wed, 12 Dec 2018 17:17:43 +0530 Subject: [PATCH 15/16] Updating debug logs for format check enforcement Change-Id: I1db1955191f0fb95eba2b0be06860874de1e30b2 Signed-off-by: Susnata Sovalin --- geofence-server/src/geofence_server.c | 2 +- geofence-server/src/geofence_server_db.c | 2 +- geofence-server/src/geofence_server_internal.c | 2 +- geofence-server/src/server.c | 10 +++++----- module/module_geofence_server.c | 4 ++-- 5 files changed, 10 insertions(+), 10 deletions(-) diff --git a/geofence-server/src/geofence_server.c b/geofence-server/src/geofence_server.c index 179a497..d8cff49 100644 --- a/geofence-server/src/geofence_server.c +++ b/geofence-server/src/geofence_server.c @@ -2222,7 +2222,7 @@ static void dbus_start_geofence_cb(gint fence_id, const gchar *app_id, gpointer } else { rv = wifi_manager_ap_get_bssid(ap_h, &ap_bssid); if (rv != WIFI_MANAGER_ERROR_NONE) { - LOGI_GEOFENCE("Fail to get the bssid: [%d]\n", __convert_wifi_error_to_string(rv)); + LOGI_GEOFENCE("Fail to get the bssid: [%s]\n", __convert_wifi_error_to_string(rv)); } else { bssidlen = strlen(ap_bssid); LOGI_GEOFENCE("Connected AP: %s, %d\n", ap_bssid, bssidlen); diff --git a/geofence-server/src/geofence_server_db.c b/geofence-server/src/geofence_server_db.c index f4c4988..3a6a340 100755 --- a/geofence-server/src/geofence_server_db.c +++ b/geofence-server/src/geofence_server_db.c @@ -820,7 +820,7 @@ int geofence_manager_set_common_info(fence_common_info_s *fence_info, int *fence return FENCE_ERR_PREPARE; } - LOGD_GEOFENCE("place_id[%d], enable[%d], appid[%s] geofence_type[%d] access_type[%d] running_status[%d]", fence_info->place_id, fence_info->enable, fence_info->appid, fence_info->running_status, fence_info->type, fence_info->access_type, fence_info->place_id); + LOGD_GEOFENCE("place_id[%d], enable[%d], appid[%s] geofence_type[%d] access_type[%d] running_status[%d]", fence_info->place_id, fence_info->enable, fence_info->appid, fence_info->type, fence_info->access_type, fence_info->running_status); ret = sqlite3_bind_int(state, ++index, fence_info->place_id); SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state); diff --git a/geofence-server/src/geofence_server_internal.c b/geofence-server/src/geofence_server_internal.c index 51a002e..4282f26 100644 --- a/geofence-server/src/geofence_server_internal.c +++ b/geofence-server/src/geofence_server_internal.c @@ -42,7 +42,7 @@ GeofenceItemData *__get_item_by_fence_id(gint fence_id, GeofenceServer *geofence GList *found_item = NULL; found_item = g_list_find_custom(geofence_server->geofence_list, &fence_id, __find_custom_item_by_fence_id); if (found_item == NULL || found_item->data == NULL) { - LOGD_GEOFENCE("item_data is not found. found_item[%d]", found_item); + LOGE_GEOFENCE("item_data is not found. found_item is NULL\n"); return NULL; } /*Get the item from the list and return it*/ diff --git a/geofence-server/src/server.c b/geofence-server/src/server.c index a0c7aae..b063be9 100644 --- a/geofence-server/src/server.c +++ b/geofence-server/src/server.c @@ -249,7 +249,7 @@ int _geofence_initialize_geofence_server(GeofenceServer *geofence_server) bt_deinitialize(); return -1; } else { - LOGD_GEOFENCE("bt_adapter_set_state_changed_cb() success.", ret); + LOGD_GEOFENCE("bt_adapter_set_state_changed_cb() success %d.", ret); } /* register the bluetooth device connection state changed callback*/ @@ -260,7 +260,7 @@ int _geofence_initialize_geofence_server(GeofenceServer *geofence_server) bt_deinitialize(); return -1; } else { - LOGD_GEOFENCE("bt_device_set_connection_state_changed_cb() success.", ret); + LOGD_GEOFENCE("bt_device_set_connection_state_changed_cb() success %d.", ret); } /*register for the discovery state change callback*/ ret = bt_adapter_set_device_discovery_state_changed_cb(__geofence_bt_adapter_device_discovery_state_changed_cb, (void *)geofence_server); @@ -289,7 +289,7 @@ int _geofence_initialize_geofence_server(GeofenceServer *geofence_server) geofence_server->wifi_h = NULL; return -1; } else { - LOGD_GEOFENCE("wifi_manager_set_connection_state_changed_cb() success.", ret); + LOGD_GEOFENCE("wifi_manager_set_connection_state_changed_cb() success(%d).", ret); } ret = wifi_manager_set_device_state_changed_cb(geofence_server->wifi_h, __geofence_wifi_device_state_changed_cb, geofence_server); @@ -301,7 +301,7 @@ int _geofence_initialize_geofence_server(GeofenceServer *geofence_server) geofence_server->wifi_h = NULL; return -1; } else { - LOGD_GEOFENCE("wifi_manager_set_device_state_changed_cb() success.", ret); + LOGD_GEOFENCE("wifi_manager_set_device_state_changed_cb() success %d.", ret); } ret = wifi_manager_set_rssi_level_changed_cb(geofence_server->wifi_h, __geofence_wifi_rssi_level_changed_cb, geofence_server); @@ -313,7 +313,7 @@ int _geofence_initialize_geofence_server(GeofenceServer *geofence_server) geofence_server->wifi_h = NULL; return -1; } else { - LOGD_GEOFENCE("wifi_manager_set_rssi_level_changed_cb() success.", ret); + LOGD_GEOFENCE("wifi_manager_set_rssi_level_changed_cb() success(%d).", ret); } /*Set the callback for location*/ diff --git a/module/module_geofence_server.c b/module/module_geofence_server.c index ff80d10..a4c9afb 100644 --- a/module/module_geofence_server.c +++ b/module/module_geofence_server.c @@ -381,7 +381,7 @@ EXPORT_API int start_geofence(void *handle, int fence_id) int ret = GEOFENCE_MANAGER_ERROR_NONE; - MOD_LOGD("geofence-server(%x)", geofence_manager); + MOD_LOGD("geofence-server(%p)", (void*)geofence_manager); ret = geo_client_start_geofence(geofence_manager->geofence_client, geofence_manager->app_id, fence_id); if (ret != GEOFENCE_MANAGER_ERROR_NONE) { @@ -395,7 +395,7 @@ EXPORT_API int start_geofence(void *handle, int fence_id) EXPORT_API int stop_geofence(void *handle, int fence_id) { GeofenceManagerData *geofence_manager = (GeofenceManagerData *)handle; - MOD_LOGD("geofence_manager->geofence_cb : %x", geofence_manager->geofence_cb); + MOD_LOGD("geofence_manager->geofence_cb : %p", geofence_manager->geofence_cb); g_return_val_if_fail(geofence_manager, GEOFENCE_MANAGER_ERROR_INVALID_PARAMETER); g_return_val_if_fail(geofence_manager->geofence_client, GEOFENCE_MANAGER_ERROR_INVALID_PARAMETER); -- 2.7.4 From a58db5553ca379480bb85de4cb455262daf6c5a0 Mon Sep 17 00:00:00 2001 From: Avichal Date: Tue, 12 Feb 2019 17:32:29 +0530 Subject: [PATCH 16/16] SVACE FIXS WGIDS: 370880,370928,370929,370931,370932,370933,370934,370936, 370938,370939,370940,370941,370942 Change-Id: I0c54ca2901747b5af8fbd4a25abd24cd847760e8 Signed-off-by: Avichal --- geofence-server/src/geofence_server_db.c | 56 ++++++++++++++++++++------------ 1 file changed, 36 insertions(+), 20 deletions(-) diff --git a/geofence-server/src/geofence_server_db.c b/geofence-server/src/geofence_server_db.c index 3a6a340..fd1e969 100755 --- a/geofence-server/src/geofence_server_db.c +++ b/geofence-server/src/geofence_server_db.c @@ -67,12 +67,13 @@ static struct { .handle = NULL, }; -#define SQLITE3_RETURN(ret, msg, state) \ +#define SQLITE3_RETURN(ret, msg, state, query) \ if (ret != SQLITE_OK) { \ LOGI_GEOFENCE("sqlite3 Error[%d] : %s", ret, msg); \ sqlite3_reset(state); \ sqlite3_clear_bindings(state); \ sqlite3_finalize(state); \ + sqlite3_free(query); \ return FENCE_ERR_SQLITE_FAIL; \ } @@ -351,6 +352,7 @@ static int __geofence_manager_db_insert_bssid_info(const int fence_id, char *bss } if (count > 0) { LOGI_GEOFENCE("count = %d", count); + sqlite3_free(query); return FENCE_ERR_NONE; } @@ -362,13 +364,13 @@ static int __geofence_manager_db_insert_bssid_info(const int fence_id, char *bss } ret = sqlite3_bind_int(state, ++index, fence_id); - SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state); + SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state, query); ret = sqlite3_bind_text(state, ++index, bssid_info, -1, SQLITE_STATIC); - SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state); + SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state, query); ret = sqlite3_bind_text(state, ++index, ssid, -1, SQLITE_STATIC); - SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state); + SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state, query); ret = sqlite3_step(state); if (ret != SQLITE_DONE) { @@ -420,10 +422,10 @@ static int __geofence_manager_db_insert_wifi_data_info(gpointer data, gpointer u } ret = sqlite3_bind_int(state, ++index, *fence_id); - SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state); + SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state, query); ret = sqlite3_bind_text(state, ++index, wifi_info->bssid, -1, SQLITE_STATIC); - SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state); + SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state, query); ret = sqlite3_step(state); if (ret != SQLITE_DONE) { @@ -772,13 +774,13 @@ int geofence_manager_set_place_info(place_info_s *place_info, int *place_id) LOGD_GEOFENCE("appid[%s] access_type[%d] place_name[%s]", place_info->appid, place_info->access_type, place_info->place_name); ret = sqlite3_bind_int(state, ++index, place_info->access_type); - SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state); + SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state, query); ret = sqlite3_bind_text(state, ++index, place_info->place_name, -1, SQLITE_STATIC); - SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state); + SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state, query); ret = sqlite3_bind_text(state, ++index, place_info->appid, -1, SQLITE_STATIC); - SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state); + SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state, query); ret = sqlite3_step(state); if (ret != SQLITE_DONE) { @@ -823,22 +825,22 @@ int geofence_manager_set_common_info(fence_common_info_s *fence_info, int *fence LOGD_GEOFENCE("place_id[%d], enable[%d], appid[%s] geofence_type[%d] access_type[%d] running_status[%d]", fence_info->place_id, fence_info->enable, fence_info->appid, fence_info->type, fence_info->access_type, fence_info->running_status); ret = sqlite3_bind_int(state, ++index, fence_info->place_id); - SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state); + SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state, query); ret = sqlite3_bind_int(state, ++index, fence_info->enable); - SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state); + SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state, query); ret = sqlite3_bind_text(state, ++index, fence_info->appid, -1, SQLITE_STATIC); - SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state); + SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state, query); ret = sqlite3_bind_int(state, ++index, fence_info->type); - SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state); + SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state, query); ret = sqlite3_bind_int(state, ++index, fence_info->access_type); - SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state); + SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state, query); ret = sqlite3_bind_int(state, ++index, fence_info->running_status); - SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state); + SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state, query); ret = sqlite3_step(state); if (ret != SQLITE_DONE) { @@ -1130,7 +1132,7 @@ int geofence_manager_set_geocoordinate_info(int fence_id, geocoordinate_info_s * } ret = sqlite3_bind_int(state, ++index, fence_id); - SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state); + SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state, query); #ifdef SUPPORT_ENCRYPTION if (password == NULL) @@ -1142,36 +1144,39 @@ int geofence_manager_set_geocoordinate_info(int fence_id, geocoordinate_info_s * ret = sqlite3_bind_text(state, ++index, data_name_lat, -1, SQLITE_STATIC); /*ret = sqlite3_bind_double (state, ++index, geocoordinate_info->latitude);*/ - SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state); + SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state, query); ret = snprintf(data_name_lon, MAX_DATA_NAME, "%lf", geocoordinate_info->longitude); if (ret < 0) { LOGD_GEOFENCE("ERROR: String will be truncated"); + sqlite3_free(query); sqlite3_finalize(state); return FENCE_ERR_STRING_TRUNCATED; } ret = sqlite3_bind_text(state, ++index, data_name_lon, -1, SQLITE_STATIC); /*ret = sqlite3_bind_double (state, ++index, geocoordinate_info->longitude);*/ - SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state); + SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state, query); ret = snprintf(data_name_rad, MAX_DATA_NAME, "%lf", geocoordinate_info->radius); if (ret < 0) { LOGD_GEOFENCE("ERROR: String will be truncated"); + sqlite3_free(query); sqlite3_finalize(state); return FENCE_ERR_STRING_TRUNCATED; } ret = sqlite3_bind_text(state, ++index, data_name_rad, -1, SQLITE_STATIC); /*ret = sqlite3_bind_double (state, ++index, geocoordinate_info->radius);*/ - SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state); + SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state, query); ret = sqlite3_bind_text(state, ++index, geocoordinate_info->address, -1, SQLITE_STATIC); - SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state); + SQLITE3_RETURN(ret, sqlite3_errmsg(db_info_s.handle), state, query); ret = sqlite3_step(state); if (ret != SQLITE_DONE) { LOGI_GEOFENCE("sqlite3_step Error[%d] : %s", ret, sqlite3_errmsg(db_info_s.handle)); + sqlite3_free(query); sqlite3_finalize(state); return FENCE_ERR_SQLITE_FAIL; } @@ -1221,6 +1226,7 @@ int geofence_manager_get_geocoordinate_info(int fence_id, geocoordinate_info_s * *geocoordinate_info = (geocoordinate_info_s *)g_malloc0(sizeof(geocoordinate_info_s)); if (*geocoordinate_info == NULL) { sqlite3_finalize(state); + sqlite3_free(query); } g_return_val_if_fail(*geocoordinate_info, FENCE_ERR_INVALID_PARAMETER); @@ -1320,6 +1326,7 @@ int geofence_manager_get_ap_info(const int fence_id, GList **ap_list) } wifi_info = g_slice_new0(wifi_info_s); if (wifi_info == NULL) { + sqlite3_free(query2); sqlite3_finalize(state); } g_return_val_if_fail(wifi_info, -1); @@ -1368,6 +1375,7 @@ int geofence_manager_get_place_info(int place_id, place_info_s **place_info) } *place_info = (place_info_s *)g_malloc0(sizeof(place_info_s)); if (*place_info == NULL) { + sqlite3_free(query); sqlite3_finalize(state); } g_return_val_if_fail(*place_info, FENCE_ERR_INTERNAL); @@ -1483,6 +1491,7 @@ int geofence_manager_get_bssid_info(const int fence_id, bssid_info_s **bssid_inf } bssid_info_from_db = g_slice_new0(bssid_info_s); if (bssid_info_from_db == NULL) { + sqlite3_free(query2); sqlite3_finalize(state); } g_return_val_if_fail(bssid_info_from_db, -1); @@ -2054,6 +2063,10 @@ int geofence_manager_get_access_type(int fence_id, int place_id, access_type_e * LOGD_GEOFENCE("current fence id is [%d]", fence_id); LOGD_GEOFENCE("current place id is [%d]", place_id); + + if (query == NULL) + return FENCE_ERR_INVALID_PARAMETER; + ret = sqlite3_prepare_v2(db_info_s.handle, query, -1, &state, &tail); if (ret != SQLITE_OK) { LOGI_GEOFENCE("Error: %s", sqlite3_errmsg(db_info_s.handle)); @@ -2543,6 +2556,7 @@ int geofence_manager_get_count_by_params(const char *app_id, geofence_type_e fen if (*count <= 0) { LOGI_GEOFENCE("ERROR: count = %d", *count); sqlite3_finalize(state); + sqlite3_free(query); return FENCE_ERR_COUNT; } else { LOGI_GEOFENCE("count[%d]", *count); @@ -2640,6 +2654,7 @@ int geofence_manager_get_count_of_fences(int *count) if (*count < 0) { LOGI_GEOFENCE("ERROR: count = %d", *count); sqlite3_finalize(state); + sqlite3_free(query); return FENCE_ERR_COUNT; } else { LOGI_GEOFENCE("count[%d]", *count); @@ -2679,6 +2694,7 @@ int geofence_manager_get_place_count_by_placeid(int place_id, int *count) if (*count < 0) { LOGI_GEOFENCE("ERROR: place count = %d", *count); sqlite3_finalize(state); + sqlite3_free(query); return FENCE_ERR_COUNT; } else { LOGI_GEOFENCE("place count[%d]", *count); -- 2.7.4