Apply multi-hal interface 96/314396/1 accepted/tizen_unified accepted/tizen_unified_dev tizen accepted/tizen/unified/20240712.160122 accepted/tizen/unified/dev/20240715.080518
authorJihoon Jung <jh8801.jung@samsung.com>
Thu, 11 Jul 2024 07:40:44 +0000 (16:40 +0900)
committerJihoon Jung <jh8801.jung@samsung.com>
Thu, 11 Jul 2024 07:41:22 +0000 (16:41 +0900)
Change-Id: If4684ba42d74c0c7cc403177258314554a182c9f
Signed-off-by: Jihoon Jung <jh8801.jung@samsung.com>
CMakeLists.txt
packaging/nfc-plugin-emul.spec
src/nfc_debug_private.h
src/oem_emul.c [changed mode: 0755->0644]

index 2fb5fdc..32d1ab9 100644 (file)
@@ -1,12 +1,16 @@
 CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
 PROJECT(hal-backend-nfc C)
 
+IF(ENABLE_DLOG STREQUAL on)
+       ADD_DEFINITIONS("-DFEATURE_DLOG")
+ENDIF()
+
 INCLUDE(FindPkgConfig)
 
 SET(EXTRA_FLAGS "-Wall -Werror -fvisibility=hidden")
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_FLAGS}")
 
-pkg_check_modules(pkgs REQUIRED dlog vconf hal-api-nfc hal-api-common)
+pkg_check_modules(pkgs REQUIRED hal-rootstrap)
 INCLUDE_DIRECTORIES(${pkgs_INCLUDE_DIRS})
 LINK_DIRECTORIES(${pkgs_LIBRARY_DIRS})
 
index e60ef17..3541d16 100644 (file)
@@ -7,10 +7,7 @@ License: Apache-2.0
 Source0: %{name}-%{version}.tar.gz
 Source1001: %{name}.manifest
 BuildRequires: cmake
-BuildRequires: pkgconfig(dlog)
-BuildRequires: pkgconfig(vconf)
-BuildRequires: pkgconfig(hal-api-nfc)
-BuildRequires: pkgconfig(hal-api-common)
+BuildRequires: pkgconfig(hal-rootstrap)
 
 %description
 NFC Plugin Emul
index ade279f..49bc0c9 100644 (file)
 #include <sys/time.h>
 #include <libgen.h>
 
-// below define should define before blog.h
-#define LOG_TAG "NFC_PLUGIN_EMUL"
-
-#include <dlog.h>
+#ifdef FEATURE_DLOG
+       #define LOG_TAG "HAL_BACKEND_NFC_PLUGIN_EMUL"
+       #include <dlog.h>
+       #define _D(fmt, args...)        dlog_print(DLOG_DEBUG, LOG_TAG, fmt, ##args)
+       #define _I(fmt, args...)        dlog_print(DLOG_INFO, LOG_TAG, fmt, ##args)
+       #define _W(fmt, args...)        dlog_print(DLOG_WARN, LOG_TAG, fmt, ##args)
+       #define _E(fmt, args...)        dlog_print(DLOG_ERROR, LOG_TAG, fmt, ##args)
+#else
+       #define _D(x, ...)
+       #define _I(x, ...)
+       #define _W(x, ...)
+       #define _E(x, ...)
+#endif
 
 #define LOG_COLOR_RED "\033[0;31m"
 #define LOG_COLOR_GREEN "\033[0;32m"
 #define DEBUG_MSG_PRINT_BUFFER(buffer, length) \
 do {\
        int i = 0;\
-       LOGE(LOG_COLOR_BLUE"BUFFER =>"LOG_COLOR_END);\
+       _D(LOG_COLOR_BLUE"BUFFER =>"LOG_COLOR_END);\
        for (; i < length; i++)\
-               LOGE(LOG_COLOR_BLUE" [0x%x] "LOG_COLOR_END, buffer[i]);\
-       LOGE(LOG_COLOR_BLUE""LOG_COLOR_END);\
+               _D(LOG_COLOR_BLUE" [0x%x] "LOG_COLOR_END, buffer[i]);\
+       _D(LOG_COLOR_BLUE""LOG_COLOR_END);\
 } while (0)
 
 #define DEBUG_MSG_PRINT_BUFFER_CHAR(buffer, length) \
 do {\
        int i = 0;\
-       LOGE(LOG_COLOR_BLUE"BUFFER =>"LOG_COLOR_END);\
+       _D(LOG_COLOR_BLUE"BUFFER =>"LOG_COLOR_END);\
        for (; i < length; i++)\
-               LOGE(LOG_COLOR_BLUE" [%c] "LOG_COLOR_END, buffer[i]);\
-       LOGE(LOG_COLOR_BLUE""LOG_COLOR_END);\
+               _D(LOG_COLOR_BLUE" [%c] "LOG_COLOR_END, buffer[i]);\
+       _D(LOG_COLOR_BLUE""LOG_COLOR_END);\
 } while (0)
 
 #define DEBUG_MSG(format, args...) \
 do {\
-       LOGE(LOG_COLOR_CYAN" "format""LOG_COLOR_END, ##args);\
+       _D(LOG_COLOR_CYAN" "format""LOG_COLOR_END, ##args);\
 } while (0)
 
 #define DEBUG_ERR_MSG(format, args...) \
 do {\
-       LOGE(LOG_COLOR_RED" "format""LOG_COLOR_END, ##args);\
+       _E(LOG_COLOR_RED" "format""LOG_COLOR_END, ##args);\
 } while (0)
 
 #define DEBUG_EMUL_BEGIN() \
 do {\
-       LOGE(LOG_COLOR_CYAN" BEGIN >>>>"LOG_COLOR_END);\
+       _D(LOG_COLOR_CYAN" BEGIN >>>>"LOG_COLOR_END);\
 } while (0)
 
 #define DEBUG_EMUL_END() \
 do {\
-       LOGE(LOG_COLOR_CYAN" END >>>>"LOG_COLOR_END);\
+       _D(LOG_COLOR_CYAN" END >>>>"LOG_COLOR_END);\
 } while (0)
 
 #define PROFILING(str) \
@@ -85,8 +94,8 @@ do {\
        gettimeofday(&mytime, NULL);\
        char time_string[128] = {0,};\
        sprintf(time_string, "%d.%4d", mytime.tv_sec, mytime.tv_usec);\
-       LOGE(str);\
-       LOGE("\t time = [%s]", time_string);\
+       _D(str);\
+       _D("\t time = [%s]", time_string);\
 } while (0)
 
 #endif
old mode 100755 (executable)
new mode 100644 (file)
index 8d55576..169dc61
@@ -24,7 +24,7 @@
 #include <stdbool.h>
 #include <sys/stat.h>
 #include <sys/epoll.h>
-#include <vconf.h>
+#include <string.h>
 
 #include <arpa/inet.h>
 #include <hal-nfc-interface.h>
@@ -220,7 +220,7 @@ static void __nfc_emul_util_alloc_mem(void **mem, int size, char *filename, unsi
 static void __nfc_emul_util_free_mem(void **mem, char *filename, unsigned int line)
 {
        if (mem == NULL || *mem == NULL) {
-               LOGE("FILE: %s, LINE:%d, Invalid parameter in mem free util (pinter is NULL)", filename, line);
+               DEBUG_ERR_MSG("FILE: %s, LINE:%d, Invalid parameter in mem free util (pinter is NULL)", filename, line);
                return;
        }
        free(*mem);
@@ -230,19 +230,19 @@ static void __nfc_emul_util_free_mem(void **mem, char *filename, unsigned int li
 static void __nfc_emul_util_alloc_mem(void **mem, int size, char *filename, unsigned int line)
 {
        if (mem == NULL || size <= 0) {
-               LOGE("FILE: %s, LINE:%d, Invalid parameter in mem alloc util", filename, line);
+               DEBUG_ERR_MSG("FILE: %s, LINE:%d, Invalid parameter in mem alloc util", filename, line);
                return;
        }
 
        DEBUG_MSG("size to malloc() = [%d]", size);
 
        if (*mem != NULL)
-               LOGE("FILE: %s, LINE:%d, WARNING: Pointer is already allocated or it was not initialized with NULL", filename, line);
+               DEBUG_ERR_MSG("FILE: %s, LINE:%d, WARNING: Pointer is already allocated or it was not initialized with NULL", filename, line);
 
        *mem = calloc(1, size);
 
        if (NULL == *mem)
-               LOGE("FILE: %s, LINE:%d, Allocation is failed", filename, line);
+               DEBUG_ERR_MSG("FILE: %s, LINE:%d, Allocation is failed", filename, line);
 }
 
 static bool _net_nfc_util_init_data(data_s * data, uint32_t length)
@@ -1054,12 +1054,12 @@ static int _net_nfc_create_records_from_emulMsg(emulMsg_s *emul_msg, ndef_messag
                memcpy(record.payload.buffer, record_payload, sizeof(record.payload.buffer) - 1);
 
 #ifndef __EMUL_DEBUG__
-               DEBUG_ERR_MSG("RECORD DATA START >>>>>>>>>>>>>>>>>>>>>>>>");
+               DEBUG_MSG("RECORD DATA START >>>>>>>>>>>>>>>>>>>>>>>>");
                DEBUG_MSG("TNF >>>>[%d]", record.tnf);
-               LOGE("type_name >>>>[%s]", type_name);
-               LOGE("record_id >>>>[%s]", record_id);
+               DEBUG_MSG("type_name >>>>[%s]", type_name);
+               DEBUG_MSG("record_id >>>>[%s]", record_id);
                DEBUG_MSG("record_payload >>>>[%s]", record_payload);
-               DEBUG_ERR_MSG("RECORD DATA END >>>>>>>>>>>>>>>>>>>>>>>>");
+               DEBUG_MSG("RECORD DATA END >>>>>>>>>>>>>>>>>>>>>>>>");
 #endif
 
                /* create record */
@@ -1784,7 +1784,7 @@ static void emul_ReaderThread(void *pArg)
 
        /* make file name */
        snprintf(file_name, sizeof(file_name), "%s/%s", NET_NFC_EMUL_DATA_PATH, NET_NFC_EMUL_MESSAGE_FILE_NAME);
-       LOGE("file path : %s", file_name);
+       DEBUG_MSG("file path : %s", file_name);
 
        /* open file for poll */
        emulMsg_file_fd = open(file_name, O_RDONLY | O_NONBLOCK);
@@ -1894,7 +1894,7 @@ static void emul_ReaderThread(void *pArg)
 
        /* make file name */
        snprintf(file_name, sizeof(file_name), "%s/%s", NET_NFC_EMUL_DATA_PATH, NET_NFC_EMUL_MESSAGE_FILE_NAME);
-       LOGE("file path : %s", file_name);
+       DEBUG_MSG("file path : %s", file_name);
 
        time(&curTime);
        DEBUG_MSG("Start Current Time [%ld]", (unsigned long)curTime);
@@ -3268,11 +3268,18 @@ static bool net_nfc_emul_controller_secure_element_close(net_nfc_target_handle_s
 
 static int nfc_backend_init(void **data)
 {
-        hal_backend_nfc_funcs *nfc_funcs;
+       hal_backend_nfc_funcs *nfc_funcs;
 
-        nfc_funcs = calloc(1, sizeof(hal_backend_nfc_funcs));
-        if (!nfc_funcs)
-                return -ENOMEM;
+       if (!data) {
+               _E("data is NULL");
+               return -EINVAL;
+       }
+
+       nfc_funcs = *(hal_backend_nfc_funcs **)data;
+       if (!nfc_funcs) {
+               _E("nfc_funcs is NULL");
+               return -EINVAL;
+       }
 
        nfc_funcs->start = net_nfc_emul_controller_init;
        nfc_funcs->stop = net_nfc_emul_controller_deinit;
@@ -3349,8 +3356,10 @@ static int nfc_backend_exit(void *data)
 
 EXPORT hal_backend hal_backend_nfc_data = {
         .name = "nfc-backend",
-        .vendor = "Emulator",
+        .vendor = "Samsung",
         .abi_version = HAL_ABI_VERSION_TIZEN_6_5,
         .init = nfc_backend_init,
         .exit = nfc_backend_exit,
+        .major_version = 1,
+        .minor_version = 0,
 };