Hal backend changes 85/316185/3
authorAbhimanyu Swami <abhimanyu1.s@samsung.com>
Wed, 14 Aug 2024 10:30:00 +0000 (16:00 +0530)
committerAbhimanyu Swami <abhimanyu1.s@samsung.com>
Thu, 3 Oct 2024 12:47:21 +0000 (18:17 +0530)
Change-Id: Iac1972b085a7aa81be83c4e91f83f2d199844af7

CMakeLists.txt
gps-plugin/include/gps_plugin_debug.h
gps-plugin/include/setting.h
gps-plugin/src/gps_plugin_replay.c
gps-plugin/src/setting.c
packaging/lbs-server-plugin-replay.spec

index 2c05390cb32165e41faa28517d1999d5333e40de..327e7ee13b20b6f8b415899ae5038540c58b7ee4 100644 (file)
@@ -7,7 +7,7 @@ SET(PREFIX ${CMAKE_INSTALL_PREFIX})
 
 # Set required packages
 INCLUDE(FindPkgConfig)
-pkg_check_modules(pkgs REQUIRED glib-2.0 vconf dlog hal-api-common hal-api-location deviced libtzplatform-config capi-network-wifi-manager)
+pkg_check_modules(pkgs REQUIRED hal-rootstrap)
 
 FOREACH(flag ${pkgs_CFLAGS})
        SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
index 790b08b6e213e99f28ddeb517c90482061d6a909..e9190175ee645ed709dcdff3cfd54b297dbe696c 100644 (file)
@@ -30,18 +30,20 @@ extern "C" {
 #include <dlog.h>
 #define TAG_GPS_PLUGIN         "LBS_REPLAY"
 
-#define DBG_LOW                LOG_DEBUG
-#define DBG_INFO       LOG_INFO
-#define DBG_WARN       LOG_WARN
-#define DBG_ERR                LOG_ERROR
+#define DBG_LOW                DLOG_DEBUG
+#define DBG_INFO       DLOG_INFO
+#define DBG_WARN       DLOG_WARN
+#define DBG_ERR                DLOG_ERROR
 
 #ifdef GPS_DLOG_DEBUG          /* Debug mode */
-#define LOG_PLUGIN(dbg_lvl, fmt, args...)              SLOG(dbg_lvl, TAG_GPS_PLUGIN, fmt, ##args)
-#define SECLOG_PLUGIN(dbg_lvl, fmt, args...)   SECURE_SLOG(dbg_lvl, TAG_GPS_PLUGIN, "[%-40s: %-4d] "fmt, __FILE__, __LINE__, ##args)
+#define LOG_PLUGIN(dbg_lvl, fmt, args...)              dlog_print(dbg_lvl, TAG_GPS_PLUGIN, fmt, ##args)
+#define SECLOG_PLUGIN(dbg_lvl, fmt, args...)   dlog_print(dbg_lvl, TAG_GPS_PLUGIN, "[%-40s: %-4d %s] "fmt, __FILE__, __LINE__, __func__, ##args)
 #else                          /* Release(commercial) mode */
-#define LOG_PLUGIN(dbg_lvl, fmt, args...)              SLOG(dbg_lvl, TAG_GPS_PLUGIN, fmt, ##args)
-#define SECLOG_PLUGIN(dbg_lvl, fmt, args...)   SECURE_SLOG(dbg_lvl, TAG_GPS_PLUGIN, fmt, ##args)
+#define LOG_PLUGIN(dbg_lvl, fmt, args...)              dlog_print(dbg_lvl, TAG_GPS_PLUGIN, fmt, ##args)
+#define SECLOG_PLUGIN(dbg_lvl, fmt, args...)   dlog_print(dbg_lvl, TAG_GPS_PLUGIN, fmt, ##args)
 #endif
+#else
+#define LOG_PLUGIN(dbg_lvl, fmt, args)
 #endif
 
 #ifdef __cplusplus
index a0727e696b6e6a1d12b2e14abfefaa167ddd4c60..26af58847c3b8b0014f619246f4d83b6fc789048 100644 (file)
@@ -19,8 +19,8 @@
 #ifndef _SETTING_H_
 #define _SETTING_H_
 
-#include <vconf.h>
-#include <vconf-internal-location-keys.h>
+// #include <vconf.h>
+// #include <vconf-internal-location-keys.h>
 
 
 typedef enum {
@@ -41,11 +41,11 @@ typedef enum {
        READ_NOT_FIXED  = 1,
 } read_error_t;
 
-int setting_get_int(const char *path, int *val);
-int setting_get_double(const char *path, double *val);
-char *setting_get_string(const char *path);
+// int setting_get_int(const char *path, int *val);
+// int setting_get_double(const char *path, double *val);
+// char *setting_get_string(const char *path);
 
-typedef void (*key_changed_cb)(keynode_t *key, void *data);
+typedef void (*key_changed_cb)();
 
 int setting_notify_key_changed(const char *path, void *key_changed_cb);
 int setting_ignore_key_changed(const char *path, void *key_changed_cb);
index f4482a3ea59c8830e9422ee477265841eed79cb7..8b5506b555c001a9c5fdebdd2cfe714f215f07a1 100755 (executable)
@@ -27,8 +27,9 @@
 
 #include <hal/hal-location-interface.h>
 #include <hal/hal-common-interface.h>
-#include <dd-display.h>
-#include <tzplatform_config.h>
+
+//#include <tzplatform_config.h>
+#include <tzplatform_config_public.h>
 
 #include "gps_plugin_debug.h"
 #include "nmea_parser.h"
@@ -69,6 +70,8 @@ typedef struct {
 
 replay_timeout *g_replay_timer = NULL;
 
+const char* nmea_file_name;
+
 void gps_plugin_replay_pos_event(pos_data_t *data)
 {
        gps_event_info_t gps_event;
@@ -127,7 +130,7 @@ void gps_plugin_replay_batch_event(pos_data_t *data, replay_timeout *timer)
                timer->batch_buf_size = size;
        }
 
-       if (timer->lcd_mode == VCONFKEY_PM_STATE_NORMAL) {
+       if (timer->lcd_mode == 0) { //DISPLAY_STATE_NORMAL
 
                if (timer->num_of_batch < timer->batch_buf_size) {
                        add_batch_data(data, timer, timer->num_of_batch, timestamp);
@@ -329,18 +332,22 @@ gboolean gps_plugin_replay_read_manual(pos_data_t *pos_data)
 {
        gboolean ret = TRUE;
 
-       if (setting_get_double(VCONFKEY_LOCATION_MANUAL_LATITUDE, &pos_data->latitude) == FALSE) {
-               LOG_PLUGIN(DBG_ERR, "Fail to get latitude");
-               ret = FALSE;
-       }
-       if (setting_get_double(VCONFKEY_LOCATION_MANUAL_LONGITUDE, &pos_data->longitude) == FALSE) {
-               LOG_PLUGIN(DBG_ERR, "Fail to get longitude");
-               ret = FALSE;
-       }
-       if (setting_get_double(VCONFKEY_LOCATION_MANUAL_ALTITUDE, &pos_data->altitude) == FALSE) {
-               LOG_PLUGIN(DBG_ERR, "Fail to get altitude");
-               ret = FALSE;
-       }
+       //set as 0
+       // if (setting_get_double(VCONFKEY_LOCATION_MANUAL_LATITUDE, &pos_data->latitude) == FALSE) {
+       //      LOG_PLUGIN(DBG_ERR, "Fail to get latitude");
+       //      ret = FALSE;
+       // }
+       // if (setting_get_double(VCONFKEY_LOCATION_MANUAL_LONGITUDE, &pos_data->longitude) == FALSE) {
+       //      LOG_PLUGIN(DBG_ERR, "Fail to get longitude");
+       //      ret = FALSE;
+       // }
+       // if (setting_get_double(VCONFKEY_LOCATION_MANUAL_ALTITUDE, &pos_data->altitude) == FALSE) {
+       //      LOG_PLUGIN(DBG_ERR, "Fail to get altitude");
+       //      ret = FALSE;
+       // }
+       pos_data->latitude = 0;
+       pos_data->longitude = 0;
+       pos_data->altitude = 0;
 
        return ret;
 }
@@ -427,24 +434,29 @@ void gps_plugin_stop_replay_mode(replay_timeout *timer)
        }
        gps_plugin_respond_stop_session();
 
-       display_unlock_state(LCD_OFF, PM_RESET_TIMER);
-       LOG_PLUGIN(DBG_LOW, "display_unlock_state(LCD_OFF, PM_RESET_TIMER);");
+       // moved to lbs-server
+       // display_unlock_state(LCD_OFF, PM_RESET_TIMER);
+       // LOG_PLUGIN(DBG_LOW, "display_unlock_state(LCD_OFF, PM_RESET_TIMER);");
 }
 
 gboolean gps_plugin_get_nmea_fd(replay_timeout *timer)
 {
        char replay_file_path[256];
        char nmea_log_path[256];
-       char *str;
 
-       str = setting_get_string(VCONFKEY_LOCATION_NMEA_FILE_NAME);
-       if (str == NULL)
+       // sent to lbs-server
+       // str = setting_get_string(VCONFKEY_LOCATION_NMEA_FILE_NAME);
+       // if (str == NULL)
+       //      return FALSE;
+
+       if (nmea_file_name == NULL)
                return FALSE;
 
        const char *nmea_file_path = tzplatform_mkpath(TZ_SYS_SHARE, "location/replay/");
-       snprintf(replay_file_path, sizeof(replay_file_path), "%s%s", nmea_file_path, str);
+       snprintf(replay_file_path, sizeof(replay_file_path), "%s%s", nmea_file_path, nmea_file_name);
        SECLOG_PLUGIN(DBG_ERR, "check custom replay : %s", replay_file_path);
-       free(str);
+       if(nmea_file_name)
+               free(nmea_file_name);
 
        timer->fd = fopen(replay_file_path, "r");
        if (timer->fd == NULL) {
@@ -488,14 +500,15 @@ gboolean gps_plugin_start_replay_mode(replay_timeout *timer)
                                LOG_PLUGIN(DBG_LOW, "timeout_src(%p) is created & attatched to %p", (void*)timer->timeout_src, (void*)timer->default_context);
                                ret = TRUE;
                        } else {
-                               gps_plugin_stop_replay_mode(timer);
+                               gps_plugin_stop_replay_mode(timer); //display_unlock_state in gps_plugin_stop_replay_mode moved to lbs-server
                                ret = FALSE;
                        }
                }
        }
 
-       display_lock_state(LCD_OFF, STAY_CUR_STATE, 0);
-       LOG_PLUGIN(DBG_LOW, "display_lock_state(LCD_OFF, STAY_CUR_STATE, 0);");
+       // moved to lbs-server
+       // display_lock_state(LCD_OFF, STAY_CUR_STATE, 0);
+       // LOG_PLUGIN(DBG_LOW, "display_lock_state(LCD_OFF, STAY_CUR_STATE, 0);");
 
        gps_plugin_respond_start_session(ret);
 
@@ -549,11 +562,8 @@ void gps_plugin_stop_batch_mode(replay_timeout *timer, int batch_interval, int b
        }
 }
 
-static void replay_mode_changed_cb(keynode_t *key, void *data)
+static void replay_mode_changed()
 {
-       if (setting_get_int(VCONFKEY_LOCATION_REPLAY_MODE, &g_replay_timer->replay_mode) == FALSE)
-               g_replay_timer->replay_mode = REPLAY_OFF;
-
        if (g_replay_timer->replay_mode == REPLAY_NMEA) {
                if (gps_plugin_get_nmea_fd(g_replay_timer) == FALSE)
                        LOG_PLUGIN(DBG_ERR, "Fail to get nmea fd.");
@@ -567,14 +577,9 @@ static void replay_mode_changed_cb(keynode_t *key, void *data)
        return;
 }
 
-static void display_mode_changed_cb(keynode_t * key, void *data)
+static void display_mode_changed()
 {
-       if (setting_get_int(VCONFKEY_PM_STATE, &g_replay_timer->lcd_mode) == FALSE) {
-               LOG_PLUGIN(DBG_ERR, "Fail to get lcd state");
-               g_replay_timer->lcd_mode = VCONFKEY_PM_STATE_LCDOFF;
-       }
-
-       if (g_replay_timer->lcd_mode == VCONFKEY_PM_STATE_NORMAL)
+       if (g_replay_timer->lcd_mode == 0) //DISPLAY_STATE_NORMAL
                g_replay_timer->is_flush = TRUE;
 
        return;
@@ -601,15 +606,14 @@ replay_timeout *gps_plugin_replay_timer_init()
        timer->batch_buf_size = 0;
        timer->is_flush = FALSE;
 
-       if (setting_get_int(VCONFKEY_LOCATION_REPLAY_MODE, &timer->replay_mode) == FALSE)
-               timer->replay_mode = REPLAY_OFF;
+       //moved to lbs-server
+       // if (setting_get_int(VCONFKEY_LOCATION_REPLAY_MODE, &timer->replay_mode) == FALSE)
+       //      timer->replay_mode = REPLAY_OFF;
 
-       setting_notify_key_changed(VCONFKEY_LOCATION_REPLAY_MODE, replay_mode_changed_cb);
+       //moved to lbs-server
+       //setting_notify_key_changed(VCONFKEY_LOCATION_REPLAY_MODE, replay_mode_changed_cb);
 
-       if (setting_get_int(VCONFKEY_PM_STATE, &timer->lcd_mode) == FALSE)
-               timer->lcd_mode = VCONFKEY_PM_STATE_LCDOFF;
-
-       setting_notify_key_changed(VCONFKEY_PM_STATE, display_mode_changed_cb);
+       //setting_notify_key_changed(VCONFKEY_PM_STATE, display_mode_changed_cb); moved to lbs-server module
 
        timer->pos_data = (pos_data_t *) malloc(sizeof(pos_data_t));
        if (timer->pos_data == NULL) {
@@ -670,7 +674,8 @@ void gps_plugin_replay_timer_deinit(replay_timeout *timer)
                timer->nmea_data = NULL;
        }
 
-       setting_ignore_key_changed(VCONFKEY_LOCATION_REPLAY_MODE, replay_mode_changed_cb);
+       //moved to lbs-server
+       //setting_ignore_key_changed(VCONFKEY_LOCATION_REPLAY_MODE, replay_mode_changed_cb);
 
        free(timer);
        timer = NULL;
@@ -700,6 +705,7 @@ static int gps_plugin_replay_gps_request(gps_action_t gps_action, void *gps_acti
 
        switch (gps_action) {
        case GPS_ACTION_SEND_PARAMS:
+               g_replay_timer->lcd_mode = *(int*)(gps_action_data);
                break;
        case GPS_ACTION_START_SESSION:
                gps_plugin_start_replay_mode(g_replay_timer);
@@ -719,10 +725,19 @@ static int gps_plugin_replay_gps_request(gps_action_t gps_action, void *gps_acti
 
                gps_plugin_stop_batch_mode(g_replay_timer, gps_start_data->interval, gps_start_data->period);
                break;
+//error when adding new options, cannot build. so adding calling functions in existing cases for now which were unused
        case GPS_INDI_SUPL_VERIFICATION:
+               display_mode_changed();
+               break;
        case GPS_INDI_SUPL_DNSQUERY:
+               nmea_file_name = *(const char**)(gps_action_data);
+               break;
        case GPS_ACTION_START_FACTTEST:
+               g_replay_timer->replay_mode = *(int*)(gps_action_data);
+               break;
        case GPS_ACTION_STOP_FACTTEST:
+               replay_mode_changed();
+               break;
        case GPS_ACTION_REQUEST_SUPL_NI:
                LOG_PLUGIN(DBG_LOW, "Don't use action type : [ %d ]", gps_action);
                break;
@@ -737,25 +752,23 @@ static int location_init(void **data)
 {
        hal_backend_location_funcs *location_funcs;
 
-       location_funcs = calloc(1, sizeof(hal_backend_location_funcs));
+       if(!data)
+               return -EINVAL;
+
+       location_funcs = *(hal_backend_location_funcs **)data;
+
        if (!location_funcs)
-               return -ENOMEM;
+               return -EINVAL;
 
        location_funcs->init = gps_plugin_replay_gps_init;
        location_funcs->deinit = gps_plugin_replay_gps_deinit;
        location_funcs->request = gps_plugin_replay_gps_request;
 
-       *data = (void *)location_funcs;
-
        return 0;
 }
 
 static int location_exit(void *data)
 {
-       if (!data)
-               return -EINVAL;
-       free(data);
-
        return 0;
 }
 
index 7726a036741ba35b4d2533062b52f5a8f70d1cbb..2d0059a0cf8489ce6ef07395c50591ddab796ac6 100644 (file)
 #include "setting.h"
 #include "gps_plugin_debug.h"
 
-int setting_get_int(const char *path, int *val)
-{
-       int ret = vconf_get_int(path, val);
-       if (ret == 0) {
-               ret = TRUE;
-       } else {
-               LOG_PLUGIN(DBG_ERR, "vconf_get_int failed, [%s]", path);
-               ret = FALSE;
-       }
-       return ret;
-}
+// int setting_get_int(const char *path, int *val)
+// {
+//     int ret = vconf_get_int(path, val);
+//     if (ret == 0) {
+//             ret = TRUE;
+//     } else {
+//             LOG_PLUGIN(DBG_ERR, "vconf_get_int failed, [%s]", path);
+//             ret = FALSE;
+//     }
+//     return ret;
+// }
 
-int setting_get_double(const char *path, double *val)
-{
-       int ret = vconf_get_dbl(path, val);
-       if (ret == 0) {
-               ret = TRUE;
-       } else {
-               LOG_PLUGIN(DBG_ERR, "vconf_get_int failed, [%s]", path);
-               ret = FALSE;
-       }
-       return ret;
-}
+// int setting_get_double(const char *path, double *val)
+// {
+//     int ret = vconf_get_dbl(path, val);
+//     if (ret == 0) {
+//             ret = TRUE;
+//     } else {
+//             LOG_PLUGIN(DBG_ERR, "vconf_get_int failed, [%s]", path);
+//             ret = FALSE;
+//     }
+//     return ret;
+// }
 
-char *setting_get_string(const char *path)
-{
-       return vconf_get_str(path);
-}
+// char *setting_get_string(const char *path)
+// {
+//     return vconf_get_str(path);
+// }
 
-int setting_notify_key_changed(const char *path, void *key_changed_cb)
-{
-       int ret = TRUE;
-       if (vconf_notify_key_changed(path, key_changed_cb, NULL) != 0) {
-               LOG_PLUGIN(DBG_ERR, "Fail to vconf_notify_key_changed [%s]", path);
-               ret = FALSE;
-       }
-       return ret;
-}
+// int setting_notify_key_changed(const char *path, void *key_changed_cb)
+// {
+//     int ret = TRUE;
+//     if (vconf_notify_key_changed(path, key_changed_cb, NULL) != 0) {
+//             LOG_PLUGIN(DBG_ERR, "Fail to vconf_notify_key_changed [%s]", path);
+//             ret = FALSE;
+//     }
+//     return ret;
+// }
 
-int setting_ignore_key_changed(const char *path, void *key_changed_cb)
-{
-       int ret = TRUE;
-       if (vconf_ignore_key_changed(path, key_changed_cb) != 0) {
-               LOG_PLUGIN(DBG_ERR, "Fail to vconf_ignore_key_changed [%s]", path);
-               ret = FALSE;
-       }
-       return ret;
-}
+// int setting_ignore_key_changed(const char *path, void *key_changed_cb)
+// {
+//     int ret = TRUE;
+//     if (vconf_ignore_key_changed(path, key_changed_cb) != 0) {
+//             LOG_PLUGIN(DBG_ERR, "Fail to vconf_ignore_key_changed [%s]", path);
+//             ret = FALSE;
+//     }
+//     return ret;
+// }
index 334a4982b58a563041e23054914c0da9d81798f9..d48386302b83c97acb68118798eeb603537e198e 100755 (executable)
@@ -1,21 +1,13 @@
 Name:       lbs-server-plugin-replay
 Summary:    LBS Server plugin library for replay mode
-Version:    0.2.9
+Version:    0.2.10
 Release:    1
 Group:      Location/Libraries
 License:    Apache-2.0
 Source0:    %{name}-%{version}.tar.gz
 Source1:    lbs-server-plugin-replay.manifest
 BuildRequires:  cmake
-BuildRequires:  pkgconfig(glib-2.0)
-BuildRequires:  pkgconfig(vconf)
-BuildRequires:  pkgconfig(dlog)
-BuildRequires:  pkgconfig(lbs-server-plugin)
-BuildRequires:  pkgconfig(deviced)
-BuildRequires:  pkgconfig(libtzplatform-config)
-BuildRequires:  pkgconfig(capi-network-wifi-manager)
-BuildRequires:  pkgconfig(hal-api-common)
-BuildRequires:  pkgconfig(hal-api-location)
+BuildRequires:  pkgconfig(hal-rootstrap)
 Requires(post): /sbin/ldconfig
 Requires(postun): /sbin/ldconfig
 
@@ -45,8 +37,8 @@ make %{?jobs:-j%jobs}
 rm -rf %{buildroot}
 %make_install
 
-mkdir -p  %{buildroot}/hal%{TZ_SYS_RO_ETC}/location
-cp -a nmea-log/*.log %{buildroot}/hal%{TZ_SYS_RO_ETC}/location
+mkdir -p  %{buildroot}/hal/etc/location
+cp -a nmea-log/*.log %{buildroot}/hal/etc/location
 
 %post
 rm -rf %{_libdir}/liblbs-server-plugin.so
@@ -63,4 +55,4 @@ ln -sf %{_hal_libdir}/libhal-backend-location.so %{_libdir}/liblbs-server-plugin
 %{_hal_licensedir}/%{name}/LICENSE
 %defattr(-,root,root,-)
 %{_hal_libdir}/*.so*
-/hal%{TZ_SYS_RO_ETC}/location/*
+/hal/etc/location/*