CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(nfc-manager C CXX)
MESSAGE("build nfc-common-lib and nfc-manager")
SET(PREFIX ${CMAKE_INSTALL_PREFIX})
SET(LIBDIR "${PREFIX}/lib")
SET(MODULEDIR "${LIBDIR}/nfc")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror -fprofile-arcs -ftest-coverage")
ADD_DEFINITIONS("-D_GNU_SOURCE")
+IF(BUILD_GTESTS)
+ADD_DEFINITIONS(-DBUILD_GCOV)
+ENDIF(BUILD_GTESTS)
+
+IF(BUILD_GCOV)
+ ADD_DEFINITIONS("-DTIZEN_TEST_GCOV")
+ENDIF(BUILD_GCOV)
+
ADD_SUBDIRECTORY(src/commonlib)
ADD_SUBDIRECTORY(src/manager)
ADD_SUBDIRECTORY(haltests)
+
+IF(BUILD_GTESTS)
+ADD_SUBDIRECTORY(unittest)
+ENDIF(BUIILD_GTESTS)
+
Name: nfc-manager
Summary: NFC framework manager
-Version: 0.1.176
+Version: 0.1.177
Release: 0
Group: Network & Connectivity/NFC
License: Flora-1.1
BuildRequires: python
BuildRequires: python-xml
+%if 0%{?gtests:1}
+BuildRequires: pkgconfig(gmock)
+%endif
+
Requires(post): /sbin/ldconfig
Requires(postun): /sbin/ldconfig
export FFLAGS="$FFLAGS -DTIZEN_DEBUG_ENABLE"
export CFLAGS="$CFLAGS -DTIZEN_TELEPHONY_ENABLED"
-export LDFLAGS+="-Wl,--rpath=%{_prefix}/lib -Wl,--as-needed"
+%if 0%{?gcov:1}
+export CFLAGS+=" -fprofile-arcs -ftest-coverage"
+export CXXFLAGS+=" -fprofile-arcs -ftest-coverage"
+export LDFLAGS+=" -lgcov"
+%endif
+
+export LDFLAGS+=" -Wl,--rpath=%{_prefix}/lib -Wl,--as-needed"
LDFLAGS="$LDFLAGS" cmake . \
-DTIZEN_ENGINEER_MODE=1 \
-DCMAKE_INSTALL_PREFIX=%{_prefix} \
-DTIZEN_TELEPHONY_ENABLED=1 \
-DBIN_DIR=%{_bindir} \
+ -DBUILD_GTESTS=%{?gtests:1}%{!?gtests:0} \
+ -DBUILD_GCOV=%{?gcov:1}%{!?gcov:0} \
%ifarch aarch64 x86_64
-DTIZEN_ARCH_64=1 \
%endif
/usr/lib/systemd/system/multi-user.target.wants/%{name}.service
%{_datadir}/dbus-1/system-services/org.tizen.NetNfcService.service
/etc/dbus-1/system.d/org.tizen.NetNfcService.conf
+%if 0%{?gtests:1}
+%{_bindir}/gtest*
+%endif
%files -n nfc-common-lib
${CMAKE_CURRENT_SOURCE_DIR}/net_nfc.xml \\
")
+#SET_SOURCE_FILES_PROPERTIES(${CMAKE_CURRENT_SOURCE_DIR}/net_nfc_gdbus.c PROPERTIES GENERATED TRUE)
+
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/include)
AUX_SOURCE_DIRECTORY(${CMAKE_CURRENT_SOURCE_DIR} COMMON_LIB_SRCS)
}
}
+/* LCOV_EXCL_START */
NET_NFC_EXPORT_API void __net_nfc_util_free_mem(void **mem, char *filename, unsigned int line)
{
if (mem == NULL) {
return true;
}
+/* LCOV_EXCL_STOP */
int net_nfc_util_get_fd_from_systemd()
{
#include "net_nfc_util_gdbus_internal.h"
#include "net_nfc_util_ndef_message.h"
+/* LCOV_EXCL_START */
void net_nfc_util_gdbus_variant_to_buffer(GVariant * variant, uint8_t ** buffer, size_t * length)
{
GVariantIter *iter;
return variant;
}
+/* LCOV_EXCL_STOP */
(__x.length == __y##_LEN) && \
(memcmp(__x.buffer, __y, __y##_LEN) == 0))
+/* LCOV_EXCL_START */
static gboolean _find_by_attribute_cb(GNode * node, gpointer data)
{
net_nfc_carrier_property_s *prop = node->data;
return error;
}
+/* LCOV_EXCL_STOP */
#define CH_BT_MIME "application/vnd.bluetooth.ep.oob"
#define CH_BT_MIME_LEN 32
+/* LCOV_EXCL_START */
bool net_nfc_util_handover_bt_check_carrier_record(ndef_record_s * record)
{
bool result;
return result;
}
+/* LCOV_EXCL_STOP */
#include "net_nfc_util_ndef_message.h"
#include "net_nfc_util_handover.h"
+/* LCOV_EXCL_START */
bool net_nfc_util_handover_wfd_check_carrier_record(ndef_record_s * record)
{
bool result;
return result;
}
+/* LCOV_EXCL_STOP */
#include "net_nfc_util_ndef_message.h"
#include "net_nfc_util_handover.h"
+/* LCOV_EXCL_START */
bool net_nfc_util_handover_wps_check_carrier_record(ndef_record_s * record)
{
bool result;
return result;
}
+/* LCOV_EXCL_STOP */
uint8_t data[0];
} __attribute__ ((packed)) apdu_header_t;
+/* LCOV_EXCL_START */
net_nfc_apdu_data_t *net_nfc_util_hce_create_apdu_data()
{
net_nfc_apdu_data_t *apdu_data;
{
return NET_NFC_NOT_SUPPORTED;
}
+/* LCOV_EXCL_STOP */
static net_nfc_error_e __net_nfc_repair_record_flags(ndef_message_s * ndef_message);
+/* LCOV_EXCL_START */
net_nfc_error_e net_nfc_util_check_ndef_message_rawdata(data_s * rawdata)
{
uint32_t offset = 0, records = 0;
}
}
+/* LCOV_EXCL_STOP */
#include "net_nfc_util_ndef_message.h"
#include "net_nfc_util_ndef_record.h"
+/* LCOV_EXCL_START */
net_nfc_error_e net_nfc_util_free_record(ndef_record_s * record)
{
if (record == NULL)
return result;
}
+/* LCOV_EXCL_STOP */
// return x509;
//}
+/* LCOV_EXCL_START */
static X509 *_load_certificate_from_mem(int format, uint8_t * buffer, uint32_t length, char *password)
{
X509 *x509 = NULL;
return ret;
}
+/* LCOV_EXCL_STOP */
#define __NEXT_SUB_FIELD(__dst) ((__dst)->value + (__dst)->length)
+/* LCOV_EXCL_START */
bool _get_records_data_buffer(ndef_record_s * begin_record, ndef_record_s * end_record, uint8_t ** buffer, uint32_t * length)
{
bool result = false;
return result;
}
+/* LCOV_EXCL_STOP */
static net_nfc_addon_hce_ops_t *selected_ops;
+/* LCOV_EXCL_START */
static void __process_command(net_nfc_target_handle_s * handle, data_s * data)
{
net_nfc_apdu_data_t *apdu_data;
break;
}
}
+/* LCOV_EXCL_STOP */
static void _nfc_addon_hce_init(void)
{
net_nfc_server_hce_start_hce_handler("nfc-manager", NULL, __hce_listener, NULL, NULL);
for (i = 0; i < hce_addons_count; i++)
- hce_addons[i]->init();
+ hce_addons[i]->init(); // LCOV_EXCL_LINE
}
+/* LCOV_EXCL_START */
static void _nfc_addon_hce_pause(void)
{
int i;
for (i = 0; i < hce_addons_count; i++)
hce_addons[i]->resume();
}
+/* LCOV_EXCL_STOP */
static void _nfc_addon_hce_deinit(void)
{
DEBUG_ADDON_MSG(">>>>");
- for (i = 0; i < hce_addons_count; i++)
- hce_addons[i]->deinit();
+ for (i = 0; i < hce_addons_count; i++) // LCOV_EXCL_LINE
+ hce_addons[i]->deinit(); // LCOV_EXCL_LINE
net_nfc_server_hce_stop_hce_handler("nfc-manager");
}
static bool enabled;
+/* LCOV_EXCL_START */
static void __send_response(net_nfc_target_handle_s * handle, uint16_t sw, uint8_t * resp, size_t len)
{
size_t total_len = sizeof(sw);
g_free(ndef_data);
}
+/* LCOV_EXCL_STOP */
net_nfc_addon_hce_ops_t net_nfc_addon_hce_ndef_ops = {
.name = "HCE NDEF EMUL",
.listener = __nfc_addon_hce_ndef_listener,
};
+/* LCOV_EXCL_START */
void net_nfc_addon_hce_ndef_enable(void)
{
net_nfc_error_e result = NET_NFC_OK;
enabled = false;
}
}
+/* LCOV_EXCL_STOP */
static bool selected;
+/* LCOV_EXCL_START */
static size_t __put_tlv(uint8_t * out, size_t len, uint16_t t, uint16_t l, uint8_t * v)
{
size_t offset = 0;
DEBUG_ERR_MSG("net_nfc_server_route_table_del_aid failed, [%d]", result);
}
}
+/* LCOV_EXCL_STOP */
net_nfc_addon_hce_ops_t net_nfc_addon_hce_ppse_ops = {
.name = "HCE PPSE EMUL",
static bool selected;
static bool enabled;
+/* LCOV_EXCL_START */
static void __send_response(net_nfc_target_handle_s * handle, uint16_t sw, uint8_t * resp, size_t len)
{
size_t total_len = sizeof(sw);
_plugin_hce_tmoney_disable();
}
+/* LCOV_EXCL_STOP */
net_nfc_addon_hce_ops_t net_nfc_addon_hce_tmoney_ops = {
.name = "HCE T-MONEY EMUL",
return NET_NFC_OK;
}
+/* LCOV_EXCL_START */
net_nfc_error_e net_nfc_addons_pause(void)
{
int i;
return NET_NFC_OK;
}
+/* LCOV_EXCL_STOP */
net_nfc_error_e net_nfc_addons_deinit(void)
{
typedef net_nfc_error_e(*process_message_cb) (ndef_message_s * msg);
/* TEMP : process handover message */
+
+/* LCOV_EXCL_START */
static void _process_carrier_record_cb(net_nfc_error_e result, net_nfc_conn_handover_carrier_type_e type, data_s * data, void *user_param)
{
data_s *message = (data_s *) user_param;
else
return false;
}
+/* LCOV_EXCL_STOP */
void net_nfc_app_util_clean_storage(char *src_path)
{
if ((dir = opendir(src_path)) == NULL)
return;
+ /* LCOV_EXCL_START */
while ((ent = readdir(dir)) != NULL) {
if (strncmp(ent->d_name, ".", 1) == 0 || strncmp(ent->d_name, "..", 2) == 0) {
continue;
closedir(dir);
rmdir(src_path);
+ /* LCOV_EXCL_STOP */
}
+/* LCOV_EXCL_START */
static void _to_lower_utf_8(char *str)
{
while (*str != 0) {
notification_status_message_post(msg);
}
}
+/* LCOV_EXCL_STOP */
SECURE_MSG("path : %s", path);
if (stat(path, &st) == -1) {
- DEBUG_ERR_MSG("stat failed : file not found");
+ DEBUG_ERR_MSG("stat failed : file not found"); // LCOV_EXCL_LINE
goto ERROR;
}
if (S_ISREG(st.st_mode) == 0) {
- DEBUG_ERR_MSG("S_ISREG(st.st_mode) == 0");
+ DEBUG_ERR_MSG("S_ISREG(st.st_mode) == 0"); // LCOV_EXCL_LINE
goto ERROR;
}
handle = dlopen(path, RTLD_LAZY);
if (handle == NULL) {
- DEBUG_ERR_MSG("dlopen failed, [%d] : %s", errno, dlerror());
+ DEBUG_ERR_MSG("dlopen failed, [%d] : %s", errno, dlerror()); // LCOV_EXCL_LINE
goto ERROR;
}
onload = dlsym(handle, "onload");
if (onload == NULL) {
- DEBUG_ERR_MSG("dlsym failed, [%d] : %s", errno, dlerror());
+ DEBUG_ERR_MSG("dlsym failed, [%d] : %s", errno, dlerror()); // LCOV_EXCL_LINE
goto ERROR;
}
memset(&g_interface, 0, sizeof(g_interface));
if (onload(&g_interface) == false) {
- DEBUG_ERR_MSG("onload failed");
+ DEBUG_ERR_MSG("onload failed"); // LCOV_EXCL_LINE
goto ERROR;
}
if (net_nfc_controller_support_nfc(&result) == false) {
- DEBUG_ERR_MSG("net_nfc_controller_support_nfc failed, [%d]", result);
+ DEBUG_ERR_MSG("net_nfc_controller_support_nfc failed, [%d]", result); // LCOV_EXCL_LINE
goto ERROR;
}
return handle;
ERROR:
- if (handle != NULL)
- dlclose(handle);
+ if (handle != NULL) // LCOV_EXCL_LINE
+ dlclose(handle); // LCOV_EXCL_LINE
return NULL;
}
}
}
- closedir(dirp);
+ closedir(dirp); // LCOV_EXCL_LINE
/* load default plugin */
- handle = net_nfc_controller_load_file(NFC_MANAGER_MODULEDIR, NET_NFC_DEFAULT_PLUGIN);
+ handle = net_nfc_controller_load_file(NFC_MANAGER_MODULEDIR, NET_NFC_DEFAULT_PLUGIN); // LCOV_EXCL_LINE
- if (handle) {
- SECURE_MSG("loaded default plugin : %s", NET_NFC_DEFAULT_PLUGIN);
+ if (handle) { // LCOV_EXCL_LINE
+ SECURE_MSG("loaded default plugin : %s", NET_NFC_DEFAULT_PLUGIN); // LCOV_EXCL_LINE
return handle;
} else {
- SECURE_MSG("can not load default plugin : %s", NET_NFC_DEFAULT_PLUGIN);
+ SECURE_MSG("can not load default plugin : %s", NET_NFC_DEFAULT_PLUGIN); // LCOV_EXCL_LINE
return NULL;
}
}
if (g_interface.init != NULL) {
return g_interface.init(result);
} else {
- *result = NET_NFC_DEVICE_DOES_NOT_SUPPORT_NFC;
- DEBUG_SERVER_MSG("interface is null");
+ *result = NET_NFC_DEVICE_DOES_NOT_SUPPORT_NFC; // LCOV_EXCL_LINE
+ DEBUG_SERVER_MSG("interface is null"); // LCOV_EXCL_LINE
return false;
}
}
if (g_interface.register_listener != NULL) {
return g_interface.register_listener(target_detection_listener, se_transaction_listener, llcp_event_listener, hce_apdu_listener, result);
} else {
- *result = NET_NFC_DEVICE_DOES_NOT_SUPPORT_NFC;
- DEBUG_SERVER_MSG("interface is null");
+ *result = NET_NFC_DEVICE_DOES_NOT_SUPPORT_NFC; // LCOV_EXCL_LINE
+ DEBUG_SERVER_MSG("interface is null"); // LCOV_EXCL_LINE
return false;
}
}
+/* LCOV_EXCL_START */
bool net_nfc_controller_unregister_listener()
{
if (g_interface.unregister_listener != NULL) {
return false;
}
}
+/* LCOV_EXCL_STOP */
bool net_nfc_controller_configure_discovery(net_nfc_discovery_mode_e mode, net_nfc_event_filter_e config, net_nfc_error_e * result)
{
if (g_interface.configure_discovery != NULL) {
return g_interface.configure_discovery(mode, config, result);
} else {
- *result = NET_NFC_DEVICE_DOES_NOT_SUPPORT_NFC;
- DEBUG_SERVER_MSG("interface is null");
+ *result = NET_NFC_DEVICE_DOES_NOT_SUPPORT_NFC; // LCOV_EXCL_LINE
+ DEBUG_SERVER_MSG("interface is null"); // LCOV_EXCL_LINE
return false;
}
}
+/* LCOV_EXCL_START */
bool net_nfc_controller_get_secure_element_list(net_nfc_secure_element_info_s * list, int *count, net_nfc_error_e * result)
{
if (g_interface.get_secure_element_list != NULL) {
return g_interface.get_secure_element_list(list, count, result);
} else {
- *result = NET_NFC_DEVICE_DOES_NOT_SUPPORT_NFC;
- DEBUG_SERVER_MSG("interface is null");
+ *result = NET_NFC_DEVICE_DOES_NOT_SUPPORT_NFC; // LCOV_EXCL_LINE
+ DEBUG_SERVER_MSG("interface is null"); // LCOV_EXCL_LINE
return false;
}
}
+/* LCOV_EXCL_STOP */
bool net_nfc_controller_set_secure_element_mode(net_nfc_secure_element_type_e element_type, net_nfc_secure_element_mode_e mode, net_nfc_error_e * result)
{
}
}
+/* LCOV_EXCL_START */
bool net_nfc_controller_secure_element_open(net_nfc_secure_element_type_e element_type, net_nfc_target_handle_s ** handle, net_nfc_error_e * result)
{
if (g_interface.secure_element_open != NULL) {
return false;
}
}
+/* LCOV_EXCL_STOP */
bool net_nfc_controller_is_ready(net_nfc_error_e * result)
{
if (g_interface.is_ready != NULL) {
return g_interface.is_ready(result);
} else {
- *result = NET_NFC_DEVICE_DOES_NOT_SUPPORT_NFC;
- DEBUG_SERVER_MSG("interface is null");
+ *result = NET_NFC_DEVICE_DOES_NOT_SUPPORT_NFC; // LCOV_EXCL_LINE
+ DEBUG_SERVER_MSG("interface is null"); // LCOV_EXCL_LINE
return false;
}
}
if (g_interface.config_llcp != NULL) {
return g_interface.config_llcp(config, result);
} else {
- *result = NET_NFC_DEVICE_DOES_NOT_SUPPORT_NFC;
- DEBUG_SERVER_MSG("interface is null");
+ *result = NET_NFC_DEVICE_DOES_NOT_SUPPORT_NFC; // LCOV_EXCL_LINE
+ DEBUG_SERVER_MSG("interface is null"); // LCOV_EXCL_LINE
return false;
}
}
+/* LCOV_EXCL_START */
bool net_nfc_controller_llcp_check_llcp(net_nfc_target_handle_s * handle, net_nfc_error_e * result)
{
if (g_interface.check_llcp_status != NULL) {
return false;
}
}
+/* LCOV_EXCL_STOP */
bool net_nfc_controller_support_nfc(net_nfc_error_e * result)
{
}
}
+/* LCOV_EXCL_START */
bool net_nfc_controller_eedata_register_set(net_nfc_error_e * result, uint32_t mode, uint32_t reg_id, data_s * data)
{
if (g_interface.eedata_register_set != NULL) {
return false;
}
}
+/* LCOV_EXCL_STOP */
bool net_nfc_controller_secure_element_commit_routing(net_nfc_error_e * result)
{
}
}
+/* LCOV_EXCL_START */
bool net_nfc_controller_secure_element_set_default_route(net_nfc_se_type_e switch_on, net_nfc_se_type_e switch_off, net_nfc_se_type_e battery_off, net_nfc_error_e * result)
{
if (g_interface.set_default_route != NULL) {
return false;
}
}
+/* LCOV_EXCL_STOP */
bool net_nfc_controller_secure_element_set_route_entry(net_nfc_se_entry_type_e type, net_nfc_se_tech_protocol_type_e value, net_nfc_se_type_e route, int power, net_nfc_error_e * result)
{
}
}
+/* LCOV_EXCL_START*/
bool net_nfc_controller_secure_element_set_listen_tech_mask(net_nfc_se_tech_protocol_type_e value, net_nfc_error_e * result)
{
if (g_interface.set_listen_tech_mask != NULL) {
return false;
}
}
+/* LCOV_EXCL_STOP */
bool net_nfc_controller_set_screen_state(net_nfc_screen_state_type_e screen_state, net_nfc_error_e * result)
{
return;
if (value == true) {
- DEBUG_SERVER_MSG("Set the se_type , wallet mode HCE");
+ DEBUG_SERVER_MSG("Set the se_type , wallet mode HCE"); // LCOV_EXCL_LINE
- vconf_set_int(VCONFKEY_NFC_SE_TYPE, VCONFKEY_NFC_SE_POLICY_HCE_ON);
+ vconf_set_int(VCONFKEY_NFC_SE_TYPE, VCONFKEY_NFC_SE_POLICY_HCE_ON); // LCOV_EXCL_LINE
- vconf_set_int(VCONFKEY_NFC_WALLET_MODE, VCONFKEY_NFC_WALLET_MODE_HCE);
+ vconf_set_int(VCONFKEY_NFC_WALLET_MODE, VCONFKEY_NFC_WALLET_MODE_HCE); // LCOV_EXCL_LINE
}
}
if (state == 1)
net_nfc_server_manager_set_active(TRUE);
- else if (net_nfc_check_mode_conditions())
- net_nfc_server_manager_set_active(FALSE);
+ else if (net_nfc_check_mode_conditions()) // LCOV_EXCL_LINE
+ net_nfc_server_manager_set_active(FALSE); // LCOV_EXCL_LINE
#ifndef ESE_ALWAYS_ON
- else if (use_daemon == TRUE) {
- DEBUG_SERVER_MSG("exit process...");
- net_nfc_server_controller_deinit();
+ else if (use_daemon == TRUE) { // LCOV_EXCL_LINE
+ DEBUG_SERVER_MSG("exit process..."); // LCOV_EXCL_LINE
+ net_nfc_server_controller_deinit(); // LCOV_EXCL_LINE
}
#endif
}
SECURE_MSG("name : %s", name);
}
+/* LCOV_EXCL_START */
static void on_name_lost(GDBusConnection * connnection, const gchar * name, gpointer user_data)
{
SECURE_MSG("name : %s", name);
net_nfc_manager_quit();
}
+/* LCOV_EXCL_STOP */
int main(int argc, char *argv[])
{
+#ifdef TIZEN_TEST_GCOV
+ setenv("GCOV_PREFIX", "/tmp/daemon", 1);
+#endif
+
+#ifdef TIZEN_TEST_GCOV
+ void __gcov_flush(void); // if you use C++, you should declare extern "C" at out of the function.
+ __gcov_flush();
+#endif
+
void *handle = NULL;
guint id = 0;
gboolean use_daemon = FALSE;
g_option_context_add_main_entries(option_context, option_entries, NULL);
if (g_option_context_parse(option_context, &argc, &argv, &error) == FALSE) {
- DEBUG_ERR_MSG("can not parse option: %s", error->message);
- g_error_free(error);
+ DEBUG_ERR_MSG("can not parse option: %s", error->message); // LCOV_EXCL_LINE
+ g_error_free(error); // LCOV_EXCL_LINE
- g_option_context_free(option_context);
+ g_option_context_free(option_context); // LCOV_EXCL_LINE
return 0;
}
handle = net_nfc_controller_onload();
if (handle == NULL) {
- DEBUG_ERR_MSG("load plugin library is failed");
+ DEBUG_ERR_MSG("load plugin library is failed"); // LCOV_EXCL_LINE
- if (vconf_set_bool(VCONFKEY_NFC_FEATURE, VCONFKEY_NFC_FEATURE_OFF) != 0)
- DEBUG_ERR_MSG("VCONFKEY_NFC_FEATURE set to %d failed", VCONFKEY_NFC_FEATURE_OFF);
+ if (vconf_set_bool(VCONFKEY_NFC_FEATURE, VCONFKEY_NFC_FEATURE_OFF) != 0) // LCOV_EXCL_LINE
+ DEBUG_ERR_MSG("VCONFKEY_NFC_FEATURE set to %d failed", VCONFKEY_NFC_FEATURE_OFF); // LCOV_EXCL_LINE
- if (vconf_set_bool(VCONFKEY_NFC_STATE, 0) != 0)
- DEBUG_ERR_MSG("VCONFKEY_NFC_STATE set to %d failed", 0);
+ if (vconf_set_bool(VCONFKEY_NFC_STATE, 0) != 0) // LCOV_EXCL_LINE
+ DEBUG_ERR_MSG("VCONFKEY_NFC_STATE set to %d failed", 0); // LCOV_EXCL_LINE
goto EXIT;
}
return 0;
}
+/* LCOV_EXCL_START */
static bool net_nfc_check_mode_conditions()
{
#ifdef ENABLE_TELEPHONY
#endif
}
+/* LCOV_EXCL_STOP */
#include "net_nfc_util_internal.h"
#include "net_nfc_manager_util_internal.h"
+/* LCOV_EXCL_START */
static void __focus_changed_cb(sound_stream_info_h stream_info, sound_stream_focus_mask_e focus_mask, sound_stream_focus_state_e focus_state, sound_stream_focus_change_reason_e reason_for_change, int sound_behavior, const char *additional_info, void *user_data)
{
}
}
}
+/* LCOV_EXCL_STOP */
net_nfc_server_gdbus_init_client_context();
if (net_nfc_server_controller_thread_init() == FALSE) {
- DEBUG_ERR_MSG("Can not init controller thread");
+ DEBUG_ERR_MSG("Can not init controller thread"); // LCOV_EXCL_LINE
return;
}
_subscribe_name_owner_changed_event();
if (net_nfc_server_manager_init(connection) == FALSE) {
- DEBUG_ERR_MSG("Can not init manager");
+ DEBUG_ERR_MSG("Can not init manager"); // LCOV_EXCL_LINE
return;
}
if (net_nfc_server_tag_init(connection) == FALSE) {
- DEBUG_ERR_MSG("Can not init tag");
+ DEBUG_ERR_MSG("Can not init tag"); // LCOV_EXCL_LINE
return;
}
if (net_nfc_server_ndef_init(connection) == FALSE) {
- DEBUG_ERR_MSG("Can not init ndef");
+ DEBUG_ERR_MSG("Can not init ndef"); // LCOV_EXCL_LINE
return;
}
if (net_nfc_server_llcp_init(connection) == FALSE) {
- DEBUG_ERR_MSG("Can not init llcp");
+ DEBUG_ERR_MSG("Can not init llcp"); // LCOV_EXCL_LINE
return;
}
if (net_nfc_server_p2p_init(connection) == FALSE) {
- DEBUG_ERR_MSG("Can not init tag");
+ DEBUG_ERR_MSG("Can not init tag"); // LCOV_EXCL_LINE
return;
}
if (net_nfc_server_transceive_init(connection) == FALSE) {
- DEBUG_ERR_MSG("Can not initialize transceive");
+ DEBUG_ERR_MSG("Can not initialize transceive"); // LCOV_EXCL_LINE
return;
}
if (net_nfc_server_test_init(connection) == FALSE) {
- DEBUG_ERR_MSG("Can not init Test");
+ DEBUG_ERR_MSG("Can not init Test"); // LCOV_EXCL_LINE
return;
}
if (net_nfc_server_handover_init(connection) == FALSE) {
- DEBUG_ERR_MSG("Can not initialize transceive");
+ DEBUG_ERR_MSG("Can not initialize transceive"); // LCOV_EXCL_LINE
return;
}
if (net_nfc_server_se_init(connection) == FALSE) {
- DEBUG_ERR_MSG("Can not init Test");
+ DEBUG_ERR_MSG("Can not init Test"); // LCOV_EXCL_LINE
return;
}
if (net_nfc_server_snep_init(connection) == FALSE) {
- DEBUG_ERR_MSG("Can not init controller thread");
+ DEBUG_ERR_MSG("Can not init controller thread"); // LCOV_EXCL_LINE
return;
}
if (net_nfc_server_system_handler_init(connection) == FALSE) {
- DEBUG_ERR_MSG("Can not init controller thread");
+ DEBUG_ERR_MSG("Can not init controller thread"); // LCOV_EXCL_LINE
return;
}
if (net_nfc_server_hce_init(connection) == FALSE) {
- DEBUG_ERR_MSG("Can not init Test");
+ DEBUG_ERR_MSG("Can not init Test"); // LCOV_EXCL_LINE
return;
}
}
controller_is_running = FALSE;
}
+/* LCOV_EXCL_START */
static net_nfc_current_target_info_s *_create_target_info(net_nfc_request_target_detected_t * msg)
{
net_nfc_current_target_info_s *info;
DEBUG_SERVER_MSG("net_nfc_server_llcp_set_config success");
}
+/* LCOV_EXCL_STOP */
#ifndef ESE_ALWAYS_ON
static void controller_deinit_thread_func(gpointer user_data)
net_nfc_manager_quit();
}
#endif
+
+/* LCOV_EXCL_START */
static void restart_polling_loop_thread_func(gpointer user_data)
{
gint state = 0;
DEBUG_SERVER_MSG("NFC is ON!! No kill daemon!!");
}
}
+/* LCOV_EXCL_STOP */
gboolean net_nfc_server_controller_thread_init(void)
{
controller_thread = g_thread_try_new("controller_thread", controller_thread_func, NULL, &error);
if (controller_thread == NULL) {
- DEBUG_ERR_MSG("can not create controller thread");
- if (error != NULL) {
- DEBUG_ERR_MSG("error msg : %s", error->message);
- g_error_free(error);
+ DEBUG_ERR_MSG("can not create controller thread"); // LCOV_EXCL_LINE
+ if (error != NULL) { // LCOV_EXCL_LINE
+ DEBUG_ERR_MSG("error msg : %s", error->message); // LCOV_EXCL_LINE
+ g_error_free(error); // LCOV_EXCL_LINE
}
return FALSE;
}
controller_async_queue = NULL;
}
+/* LCOV_EXCL_START */
void net_nfc_server_controller_init(void)
{
if (net_nfc_server_controller_async_queue_push_force(controller_init_thread_func, NULL) == FALSE)
return false;
}
+/* LCOV_EXCL_STOP */
static inline void _push_to_queue(guint msec, bool blocking, net_nfc_server_controller_func func, gpointer user_data)
{
if (__builtin_expect(msec == 0, true))
g_async_queue_push(controller_async_queue, func_data);
else
- g_timeout_add(msec, _timeout_cb, func_data);
+ g_timeout_add(msec, _timeout_cb, func_data); //LCOV_EXCL_LINE
}
#ifndef ESE_ALWAYS_ON
void net_nfc_server_controller_deinit(void)
{
if (controller_async_queue == NULL) {
- DEBUG_ERR_MSG("controller_async_queue is not initialized");
+ DEBUG_ERR_MSG("controller_async_queue is not initialized"); //LCOV_EXCL_LINE
return;
}
gboolean net_nfc_server_controller_async_queue_delayed_push_force(guint msec, net_nfc_server_controller_func func, gpointer user_data)
{
if (controller_async_queue == NULL) {
- DEBUG_ERR_MSG("controller_async_queue is not initialized");
+ DEBUG_ERR_MSG("controller_async_queue is not initialized"); //LCOV_EXCL_LINE
return FALSE;
}
return TRUE;
}
+/* LCOV_EXCL_START */
void net_nfc_server_controller_run_dispatch_loop()
{
if (controller_async_queue == NULL)
{
return server_state;
}
+/* LCOV_EXCL_STOP */
bool net_nfc_server_controller_init_sync(void)
{
net_nfc_error_e result;
if (net_nfc_controller_init(&result) == false) {
- DEBUG_ERR_MSG("net_nfc_controller_init failed, [%d]", result);
+ DEBUG_ERR_MSG("net_nfc_controller_init failed, [%d]", result); //LCOV_EXCL_LINE
- net_nfc_manager_quit();
+ net_nfc_manager_quit(); //LCOV_EXCL_LINE
return false;
}
DEBUG_SERVER_MSG("net_nfc_controller_init success, [%d]", result);
if (net_nfc_controller_register_listener(controller_target_detected_cb, controller_se_transaction_cb, controller_llcp_event_cb, controller_hce_apdu_cb, &result) == false) {
- DEBUG_ERR_MSG("net_nfc_contorller_register_listener failed [%d]", result);
+ DEBUG_ERR_MSG("net_nfc_contorller_register_listener failed [%d]", result); //LCOV_EXCL_LINE
- net_nfc_manager_quit();
+ net_nfc_manager_quit(); //LCOV_EXCL_LINE
return false;
}
result = net_nfc_server_llcp_set_config(NULL);
if (result != NET_NFC_OK) {
- DEBUG_ERR_MSG("net_nfc_server_llcp_set config failed, [%d]", result);
+ DEBUG_ERR_MSG("net_nfc_server_llcp_set config failed, [%d]", result); //LCOV_EXCL_LINE
- net_nfc_manager_quit();
+ net_nfc_manager_quit(); //LCOV_EXCL_LINE
return false;
}
ret = cynara_initialize(&p_cynara, NULL);
if (ret != CYNARA_API_SUCCESS) {
- DEBUG_SERVER_MSG("cynara_initialize() failed");
+ DEBUG_SERVER_MSG("cynara_initialize() failed"); // LCOV_EXCL_LINE
return false;
}
ret = cynara_creds_gdbus_get_pid(connection, sender_unique_name, &pid);
if (ret != CYNARA_API_SUCCESS) {
- DEBUG_SERVER_MSG("cynara_creds_gdbus_get_pid() failed");
+ DEBUG_SERVER_MSG("cynara_creds_gdbus_get_pid() failed"); // LCOV_EXCL_LINE
return false;
}
ret = cynara_creds_gdbus_get_user(connection, sender_unique_name, USER_METHOD_DEFAULT, &user);
if (ret != CYNARA_API_SUCCESS) {
- DEBUG_SERVER_MSG("cynara_creds_gdbus_get_user() failed");
+ DEBUG_SERVER_MSG("cynara_creds_gdbus_get_user() failed"); // LCOV_EXCL_LINE
return false;
}
ret = cynara_creds_gdbus_get_client(connection, sender_unique_name, CLIENT_METHOD_DEFAULT, &client);
if (ret != CYNARA_API_SUCCESS) {
- DEBUG_SERVER_MSG("cynara_creds_gdbus_get_client() failed");
- g_free(user);
+ DEBUG_SERVER_MSG("cynara_creds_gdbus_get_client() failed"); // LCOV_EXCL_LINE
+ g_free(user); // LCOV_EXCL_LINE
return false;
}
break;
case NET_NFC_PRIVILEGE_NFC_CARD_EMUL:
- privilege = "http://tizen.org/privilege/nfc.cardemulation";
- break;
+ privilege = "http://tizen.org/privilege/nfc.cardemulation"; // LCOV_EXCL_LINE
+ break; // LCOV_EXCL_LINE
default:
- DEBUG_SERVER_MSG("Undifined privilege");
+ DEBUG_SERVER_MSG("Undifined privilege"); // LCOV_EXCL_LINE
return false;
break;
}
client_session = cynara_session_from_pid(pid);
if (!client_session) {
- DEBUG_SERVER_MSG("cynara_session_from_pid() failed");
- g_free(client);
- g_free(user);
+ DEBUG_SERVER_MSG("cynara_session_from_pid() failed"); // LCOV_EXCL_LINE
+ g_free(client); // LCOV_EXCL_LINE
+ g_free(user); // LCOV_EXCL_LINE
return false;
}
return g_hash_table_size(client_contexts);
}
+/* LCOV_EXCL_START */
size_t net_nfc_server_gdbus_get_client_count()
{
size_t result;
return result;
}
+/* LCOV_EXCL_STOP */
net_nfc_client_context_info_t *net_nfc_server_gdbus_get_client_context_no_lock(const char *id)
{
return result;
}
+/* LCOV_EXCL_START */
net_nfc_client_context_info_t *net_nfc_server_gdbus_get_client_context_by_pid(pid_t pid)
{
net_nfc_client_context_info_t *result = NULL;
return result;
}
+/* LCOV_EXCL_STOP */
void net_nfc_server_gdbus_add_client_context(const char *id, client_state_e state)
{
pthread_mutex_unlock(&context_lock);
}
+/* LCOV_EXCL_START */
void net_nfc_server_gdbus_for_each_client_context(net_nfc_server_gdbus_for_each_client_cb cb, void *user_param)
{
GHashTableIter iter;
pthread_mutex_unlock(&context_lock);
}
+/* LCOV_EXCL_STOP */
bool net_nfc_server_gdbus_check_client_is_running(const char *id)
{
return (net_nfc_server_gdbus_get_client_context(id) != NULL);
}
+/* LCOV_EXCL_START */
client_state_e net_nfc_server_gdbus_get_client_state(const char *id)
{
net_nfc_client_context_info_t *info;
pthread_mutex_unlock(&context_lock);
}
+/* LCOV_EXCL_STOP */
bool net_nfc_server_gdbus_is_server_busy_no_lock()
{
static gboolean handover_handle_request(NetNfcGDbusHandover * hdover, GDBusMethodInvocation * invocation, guint32 arg_handle, gint32 arg_type, GVariant * smack_privilege, gpointer user_data);
+/* LCOV_EXCL_START */
static void handover_request_thread_func(gpointer user_data)
{
HandoverRequestData *handover_data = (HandoverRequestData *) user_data;
return NET_NFC_OK;
}
+/* LCOV_EXCL_STOP */
gboolean net_nfc_server_handover_init(GDBusConnection * connection)
{
GError *error = NULL;
if (handover_skeleton)
- g_object_unref(handover_skeleton);
+ g_object_unref(handover_skeleton); // LCOV_EXCL_LINE
handover_skeleton = net_nfc_gdbus_handover_skeleton_new();
g_signal_connect(handover_skeleton, "handle-request", G_CALLBACK(handover_handle_request), NULL);
if (g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(handover_skeleton), connection, "/org/tizen/NetNfcService/Handover", &error) == FALSE) {
- g_error_free(error);
+ g_error_free(error); // LCOV_EXCL_LINE
- g_object_unref(handover_skeleton);
- handover_skeleton = NULL;
+ g_object_unref(handover_skeleton); // LCOV_EXCL_LINE
+ handover_skeleton = NULL; // LCOV_EXCL_LINE
- return FALSE;
+ return FALSE; // LCOV_EXCL_LINE
}
return TRUE;
static int _bt_prepare_pairing(net_nfc_handover_bt_process_context_t * context);
static int _bt_do_pairing(net_nfc_handover_bt_process_context_t * context);
+/* LCOV_EXCL_START */
net_nfc_conn_handover_carrier_state_e net_nfc_server_handover_bt_get_cps()
{
net_nfc_conn_handover_carrier_state_e cps = NET_NFC_CONN_HANDOVER_CARRIER_INACTIVATE;
return result;
}
+/* LCOV_EXCL_STOP */
device_type_t secondary_devices[0];
} __attribute__ ((packed)) device_info_attr_t;
+/* LCOV_EXCL_START */
static void set_mac_address(char *data, uint8_t * origin_data)
{
int i, len = 0;
return result;
}
+/* LCOV_EXCL_STOP */
void *user_param;
} wps_process_context_t;
+/* LCOV_EXCL_START */
net_nfc_conn_handover_carrier_state_e net_nfc_server_handover_wps_get_cps()
{
int wifi_manager_state = 0;
return result;
}
+/* LCOV_EXCL_STOP */
static wifi_manager_security_type_e _wps_get_security_type(net_nfc_carrier_config_s * config)
{
wifi_manager_security_type_e result;
uint16_t ret;
- ret = _wps_get_short_property(config, NET_NFC_WIFI_ATTRIBUTE_AUTH_TYPE);
+ ret = _wps_get_short_property(config, NET_NFC_WIFI_ATTRIBUTE_AUTH_TYPE); // LCOV_EXCL_LINE
switch (ret) {
case 1: /* open */
wifi_manager_encryption_type_e result;
uint16_t ret;
- ret = _wps_get_short_property(config, NET_NFC_WIFI_ATTRIBUTE_ENC_TYPE);
+ ret = _wps_get_short_property(config, NET_NFC_WIFI_ATTRIBUTE_ENC_TYPE); // LCOV_EXCL_LINE
switch (ret) {
case 1: /* None */
return result;
}
+/* LCOV_EXCL_START */
net_nfc_error_e net_nfc_server_handover_wps_get_selector_carrier(net_nfc_server_handover_get_carrier_cb cb, void *user_param)
{
net_nfc_error_e result = NET_NFC_NOT_SUPPORTED;
return result;
}
+/* LCOV_EXCL_STOP */
}
}
+/* LCOV_EXCL_START */
static bool _del_by_id_cb(hce_listener_t * data, void *user_data)
{
const char *id = user_data;
return result;
}
+/* LCOV_EXCL_STOP */
static void _routing_table_del_by_id(const char *id)
{
return NET_NFC_OK;
}
+/* LCOV_EXCL_START */
net_nfc_error_e net_nfc_server_hce_stop_hce_handler_by_id(const char *id)
{
if (id == NULL || strlen(id) == 0)
return result;
}
+/* LCOV_EXCL_STOP */
////////////////////////////////////////////////////////////////////////////////
#if 0
}
}
#else
+
+/* LCOV_EXCL_START */
static void _hce_default_listener_cb(net_nfc_target_handle_s * handle, int event, data_s * data, void *user_data)
{
hce_client_context_s *context = (hce_client_context_s *) user_data;
g_free(data);
}
}
+/* LCOV_EXCL_STOP */
/******************************************************************************/
uint8_t data[0];
} __attribute__ ((packed)) apdu_header_t;
+/* LCOV_EXCL_START */
static bool __extract_parameter(apdu_header_t * apdu, size_t len, uint16_t * lc, uint16_t * le, uint8_t ** data)
{
size_t l = sizeof(*apdu);
_net_nfc_util_free_mem(hce_event);
}
+/* LCOV_EXCL_STOP */
static void _hce_on_client_detached_cb(net_nfc_client_context_info_t * info)
{
DEBUG_ERR_MSG("fcntl, executing nonblock error");
}
+/* LCOV_EXCL_START */
static pid_t __get_pid_by_socket(int socket)
{
struct ucred uc;
DEBUG_SERVER_MSG("client removed, [%d]", g_hash_table_size(hce_clients));
}
+/* LCOV_EXCL_STOP */
static void __hce_client_init()
{
hce_clients = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, __on_client_value_destroy);
}
+/* LCOV_EXCL_START */
static void __hce_client_add(int socket, GIOChannel * channel, guint source_id)
{
net_nfc_hce_client_t *client;
{
g_hash_table_remove(hce_clients, (gconstpointer) channel);
}
+/* LCOV_EXCL_STOP */
static void __hce_client_clear()
{
return (net_nfc_hce_client_t *) g_hash_table_lookup(hce_clients, (gconstpointer) channel);
}
+/* LCOV_EXCL_START */
static net_nfc_hce_client_t *__hce_client_find_by_id(const char *id)
{
net_nfc_hce_client_t *result = NULL;
return TRUE;
}
+/* LCOV_EXCL_STOP */
bool net_nfc_server_hce_ipc_init()
{
return true;
ERROR:
+/* LCOV_EXCL_START */
if (hce_server_src_id > 0) {
g_source_remove(hce_server_src_id);
hce_server_src_id = 0;
hce_server_socket = -1;
}
+/* LCOV_EXCL_STOP */
return false;
}
}
}
+/* LCOV_EXCL_START */
static bool __send_data_to_client(int socket, data_s * data)
{
ssize_t ret;
return ret;
}
+/* LCOV_EXCL_STOP */
static void llcp_simple_receive_cb(net_nfc_llcp_socket_t socket, net_nfc_error_e result, data_s * data, void *extra, void *user_param);
+/* LCOV_EXCL_START */
static void llcp_socket_error_cb(net_nfc_llcp_socket_t socket, net_nfc_error_e result, data_s * data, void *extra, void *user_param)
{
llcp_client_data *client_data = (llcp_client_data *) user_param;
g_free(simple_data);
}
+/* LCOV_EXCL_STOP */
-static void _llcp_on_client_detached_cb(net_nfc_client_context_info_t * client)
+static void _llcp_on_client_detached_cb(net_nfc_client_context_info_t * client) // LCOV_EXCL_LINE
{
- net_nfc_server_llcp_unregister_services(client->id);
+ net_nfc_server_llcp_unregister_services(client->id); // LCOV_EXCL_LINE
}
/* Public Function */
if (result == TRUE) {
net_nfc_server_gdbus_register_on_client_detached_cb(_llcp_on_client_detached_cb);
} else {
- g_error_free(error);
+ g_error_free(error); // LCOV_EXCL_LINE
- net_nfc_server_llcp_deinit();
+ net_nfc_server_llcp_deinit(); // LCOV_EXCL_LINE
}
return result;
return result;
}
- net_nfc_controller_llcp_config(config, &result);
- memcpy(&llcp_config, config, sizeof(llcp_config));
+ net_nfc_controller_llcp_config(config, &result); // LCOV_EXCL_LINE
+ memcpy(&llcp_config, config, sizeof(llcp_config)); // LCOV_EXCL_LINE
- return result;
+ return result; // LCOV_EXCL_LINE
}
+/* LCOV_EXCL_START */
guint16 net_nfc_server_llcp_get_miu(void)
{
return llcp_config.miu;
return result;
}
+/* LCOV_EXCL_STOP */
typedef struct _service_t {
uint32_t sap;
result = NET_NFC_OK;
} else {
- DEBUG_ERR_MSG("alloc failed");
+ DEBUG_ERR_MSG("alloc failed"); // LCOV_EXCL_LINE
result = NET_NFC_ALLOC_FAIL;
}
} else {
- DEBUG_ERR_MSG("already registered");
+ DEBUG_ERR_MSG("already registered"); // LCOV_EXCL_LINE
result = NET_NFC_ALREADY_REGISTERED;
}
return result;
}
+/* LCOV_EXCL_START */
static void _llcp_remove_service(uint32_t sap)
{
service_t *service = NULL;
g_hash_table_iter_init(&iter, service_table);
while (g_hash_table_iter_next(&iter, &key, (gpointer) & service)) {
- if (id == NULL || strcmp(service->id, id) == 0) {
- g_free(service->san);
- g_free(service->id);
- g_free(service);
+ if (id == NULL || strcmp(service->id, id) == 0) { // LCOV_EXCL_LINE
+ g_free(service->san); // LCOV_EXCL_LINE
+ g_free(service->id); // LCOV_EXCL_LINE
+ g_free(service); // LCOV_EXCL_LINE
g_hash_table_iter_remove(&iter);
}
{
g_hash_table_foreach(service_table, _llcp_start_services_cb, handle);
}
+/* LCOV_EXCL_STOP */
net_nfc_error_e net_nfc_server_llcp_register_service(const char *id, sap_t sap, const char *san, net_nfc_server_llcp_activate_cb cb, void *user_param)
{
return _llcp_add_service(id, sap, san, cb, user_param);
}
+/* LCOV_EXCL_START */
net_nfc_error_e net_nfc_server_llcp_unregister_service(const char *id, sap_t sap, const char *san)
{
net_nfc_error_e result;
return NET_NFC_OK;
}
+/* LCOV_EXCL_STOP */
net_nfc_error_e net_nfc_server_llcp_unregister_all()
{
return NET_NFC_OK;
}
+/* LCOV_EXCL_START */
net_nfc_error_e net_nfc_server_llcp_start_registered_services(net_nfc_target_handle_s * handle)
{
_llcp_start_services(handle);
return true;
}
+/* LCOV_EXCL_STOP */
if (net_nfc_controller_configure_discovery(NET_NFC_DISCOVERY_MODE_START, NET_NFC_ALL_ENABLE, &result) == true) {
/* vconf on */
if (vconf_set_bool(VCONFKEY_NFC_STATE, TRUE) != 0) {
- DEBUG_ERR_MSG("vconf_set_bool is failed");
+ DEBUG_ERR_MSG("vconf_set_bool is failed"); // LCOV_EXCL_LINE
- result = NET_NFC_OPERATION_FAIL;
+ result = NET_NFC_OPERATION_FAIL; // LCOV_EXCL_LINE
}
} else {
+/* LCOV_EXCL_START */
DEBUG_ERR_MSG("net_nfc_controller_configure_discovery is failed, [%d]", result);
net_nfc_server_controller_init();
/* ADD TEMPORARY ABORT FOR DEBUG */
//abort();
+/* LCOV_EXCL_STOP */
}
return result;
data->is_active = arg_is_active;
if (data->is_active == true) {
+/* LCOV_EXCL_START */
net_nfc_error_e check_result;
INFO_MSG("Daemon alive, But check the nfc device state.");
net_nfc_server_controller_init();
} else
INFO_MSG("nfc is already active!!!!!!");
+/* LCOV_EXCL_STOP */
}
if (net_nfc_server_controller_async_queue_push_and_block(manager_handle_active_thread_func, data) == FALSE) {
return TRUE;
+/* LCOV_EXCL_START */
ERROR:
if (data != NULL) {
g_object_unref(data->invocation);
return TRUE;
}
+/* LCOV_EXCL_STOP */
/* server side */
static void manager_active_thread_func(gpointer user_data)
net_nfc_error_e result;
if (manager_skeleton == NULL) {
- DEBUG_ERR_MSG("net_nfc_server_manager is not initialized");
+ DEBUG_ERR_MSG("net_nfc_server_manager is not initialized"); // LCOV_EXCL_LINE
- return;
+ return; // LCOV_EXCL_LINE
}
DEBUG_SERVER_MSG("is_active %d", is_active);
data = g_try_new0(ManagerActivationData, 1);
if (data == NULL) {
- DEBUG_ERR_MSG("Memory allocation failed");
+ DEBUG_ERR_MSG("Memory allocation failed"); // LCOV_EXCL_LINE
return;
}
net_nfc_controller_is_ready(&result);
if (result != NET_NFC_OK) {
- INFO_MSG("nfc is not active. so call net_nfc_server_controller_init");
- net_nfc_server_controller_init();
+ INFO_MSG("nfc is not active. so call net_nfc_server_controller_init"); // LCOV_EXCL_LINE
+ net_nfc_server_controller_init(); // LCOV_EXCL_LINE
} else
INFO_MSG("nfc is already active!!!!!!");
}
if (net_nfc_server_controller_async_queue_push(manager_active_thread_func, data) == FALSE) {
- DEBUG_ERR_MSG("can not push to controller thread");
+ DEBUG_ERR_MSG("can not push to controller thread"); // LCOV_EXCL_LINE
- g_object_unref(data->manager);
- g_free(data);
+ g_object_unref(data->manager); // LCOV_EXCL_LINE
+ g_free(data); // LCOV_EXCL_LINE
}
}
+/* LCOV_EXCL_START */
bool net_nfc_server_manager_get_active()
{
int value;
return (!!value);
}
+/* LCOV_EXCL_STOP */
static gboolean ndef_handle_format(NetNfcGDbusNdef * ndef, GDBusMethodInvocation * invocation, guint32 arg_handle, GVariant * arg_key, GVariant * smack_privilege, gpointer user_data);
+/* LCOV_EXCL_START */
static void ndef_read_thread_func(gpointer user_data)
{
ReadData *data = user_data;
return TRUE;
}
+/* LCOV_EXCL_STOP */
gboolean net_nfc_server_ndef_init(GDBusConnection * connection)
{
static NetNfcGDbusP2p *p2p_skeleton = NULL;
+/* LCOV_EXCL_START */
static void p2p_send_data_thread_func(gpointer user_data)
{
P2pSendData *p2p_data = (P2pSendData *) user_data;
return TRUE;
}
+/* LCOV_EXCL_STOP */
gboolean net_nfc_server_p2p_init(GDBusConnection * connection)
{
return result;
}
+/* LCOV_EXCL_START */
void net_nfc_server_p2p_deinit(void)
{
if (p2p_skeleton) {
g_free(data);
}
+/* LCOV_EXCL_STOP */
#endif
////////////////////////////////////////////////////////////////////////////
+/* LCOV_EXCL_START */
static void _send_response(net_nfc_error_e result, net_nfc_conn_handover_carrier_type_e carrier, data_h ac_data, void *user_param)
{
HandoverRequestData *handover_data = (HandoverRequestData *) user_param;
return result;
}
+/* LCOV_EXCL_STOP */
#if 0
static net_nfc_error_e _net_nfc_server_handover_snep_client_cb(net_nfc_snep_handle_h handle, net_nfc_error_e result, uint32_t type, data_s * data, void *user_param)
}
#else
+/* LCOV_EXCL_START */
static net_nfc_error_e _select_carrier_record(net_nfc_ch_message_s * request, net_nfc_ch_carrier_s ** carrier)
{
net_nfc_error_e result;
return result;
}
+/* LCOV_EXCL_STOP */
static void _handover_default_activate_cb(int event, net_nfc_target_handle_s * handle, uint32_t sap, const char *san, void *user_param)
{
DEBUG_SERVER_MSG("event [%d], handle [%p], sap [%d], san [%s]", event, handle, sap, san);
if (event == NET_NFC_LLCP_START) {
+ /* LCOV_EXCL_START */
/* start default handover server using snep */
result = net_nfc_server_snep_default_server_register_get_response_cb(_get_response_cb, NULL);
DEBUG_SERVER_MSG("start handover server, san [%s], sap [%d]", CH_SAN, CH_SAP);
else
DEBUG_ERR_MSG("net_nfc_service_llcp_server failed, [%d]", result);
+ /* LCOV_EXCL_STOP */
} else if (event == NET_NFC_LLCP_UNREGISTERED) {
/* unregister server, do nothing */
}
return net_nfc_server_llcp_register_service(id, CH_SAP, CH_SAN, _handover_default_activate_cb, NULL);
}
+/* LCOV_EXCL_START */
net_nfc_error_e net_nfc_server_handover_default_server_unregister()
{
char id[20];
return result;
}
+/* LCOV_EXCL_STOP */
static void npp_default_client_cb(net_nfc_error_e result, data_s * data, gpointer user_data);
+/* LCOV_EXCL_START */
static net_nfc_error_e npp_create_message(data_s * data, data_s * message)
{
size_t length = NPP_HEADER_LEN;
/* start default npp server */
return net_nfc_server_npp_server(handle, NPP_SAN, NPP_SAP, npp_default_server_cb, (gpointer) 1234);
}
+/* LCOV_EXCL_STOP */
static void _npp_default_activate_cb(int event, net_nfc_target_handle_s * handle, uint32_t sap, const char *san, void *user_param)
{
if (event == NET_NFC_LLCP_START) {
/* start default npp server */
- result = net_nfc_server_npp_server(handle, (char *)san, sap, npp_default_server_cb, user_param);
- if (result != NET_NFC_OK)
- DEBUG_ERR_MSG("net_nfc_server_npp_server failed, [%d]", result);
+ result = net_nfc_server_npp_server(handle, (char *)san, sap, npp_default_server_cb, user_param); //LCOV_EXCL_LINE
+ if (result != NET_NFC_OK) //LCOV_EXCL_LINE
+ DEBUG_ERR_MSG("net_nfc_server_npp_server failed, [%d]", result); //LCOV_EXCL_LINE
} else if (event == NET_NFC_LLCP_UNREGISTERED) {
/* unregister server, do nothing */
}
return net_nfc_server_llcp_register_service(id, NPP_SAP, NPP_SAN, _npp_default_activate_cb, NULL);
}
+/* LCOV_EXCL_START */
net_nfc_error_e net_nfc_server_npp_default_server_unregister()
{
char id[20];
return result;
}
+/* LCOV_EXCL_STOP */
static void _net_nfc_server_snep_server_process(net_nfc_server_snep_context_t * context);
/**********************************************************************/
+/* LCOV_EXCL_START */
static bool _net_nfc_server_snep_add_get_response_cb(net_nfc_server_snep_listen_cb cb, void *user_param)
{
net_nfc_server_cb_data_t *data = NULL;
return result;
}
+/* LCOV_EXCL_STOP */
static void _snep_default_activate_cb(int event, net_nfc_target_handle_s * handle, uint32_t sap, const char *san, void *user_param)
{
if (event == NET_NFC_LLCP_START) {
/* start snep server */
- result = net_nfc_server_snep_server(handle, (char *)san, sap, _net_nfc_server_default_server_cb_, user_param);
- if (result != NET_NFC_OK)
- DEBUG_ERR_MSG("net_nfc_service_snep_server failed, [%d]", result);
+ result = net_nfc_server_snep_server(handle, (char *)san, sap, _net_nfc_server_default_server_cb_, user_param); //LCOV_EXCL_LINE
+ if (result != NET_NFC_OK) //LCOV_EXCL_LINE
+ DEBUG_ERR_MSG("net_nfc_service_snep_server failed, [%d]", result); //LCOV_EXCL_LINE
} else if (event == NET_NFC_LLCP_UNREGISTERED) {
/* unregister server, do nothing */
}
return net_nfc_server_llcp_register_service(id, SNEP_SAP, SNEP_SAN, _snep_default_activate_cb, NULL);
}
+/* LCOV_EXCL_START */
net_nfc_error_e net_nfc_server_snep_default_server_unregister()
{
char id[20];
return NET_NFC_OK;
}
+/* LCOV_EXCL_STOP */
if (count > 0)
result = true;
else
- result = false;
+ result = false; //LCOV_EXCL_LINE
} else {
- DEBUG_ERR_MSG("sqlite3_step failed, [%d:%s]", ret, sqlite3_errmsg(db));
+ DEBUG_ERR_MSG("sqlite3_step failed, [%d:%s]", ret, sqlite3_errmsg(db)); //LCOV_EXCL_LINE
result = false;
}
sqlite3_finalize(stmt);
} else {
- DEBUG_ERR_MSG("sqlite3_prepare_v2 failed, [%d:%s]", ret, sqlite3_errmsg(db));
+ DEBUG_ERR_MSG("sqlite3_prepare_v2 failed, [%d:%s]", ret, sqlite3_errmsg(db)); //LCOV_EXCL_LINE
result = false;
}
sqlite3_free(sql);
} else {
- DEBUG_ERR_MSG("sqlite3_mprintf failed");
+ DEBUG_ERR_MSG("sqlite3_mprintf failed"); //LCOV_EXCL_LINE
result = false;
}
return result;
}
+/* LCOV_EXCL_START */
static void __create_table()
{
int ret;
DEBUG_ERR_MSG("sqlite3_mprintf failed");
}
}
+/* LCOV_EXCL_STOP */
static int __check_integrity()
{
static void __prepare_table()
{
if (__is_table_existing(NFC_ROUTE_TABLE_DB_TABLE) == false)
- __create_table();
+ __create_table(); //LCOV_EXCL_LINE
}
static void __initialize_db()
if (db == NULL) {
result = sqlite3_open_v2(NFC_ROUTE_TABLE_DB_FILE, &db, SQLITE_OPEN_NOMUTEX | SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, NULL);
if (result != SQLITE_OK) {
- DEBUG_ERR_MSG("sqlite3_open_v2 failed, [%d]", result);
+ DEBUG_ERR_MSG("sqlite3_open_v2 failed, [%d]", result); //LCOV_EXCL_LINE
goto ERR;
}
if (__check_integrity() < 0) {
+ /* LCOV_EXCL_START */
DEBUG_ERR_MSG("Failed to check integrity");
unlink(NFC_ROUTE_TABLE_DB_FILE);
db = NULL;
goto ERR;
}
+ /* LCOV_EXCL_STOP */
}
/* Enable persist journal mode */
result = sqlite3_exec(db, "PRAGMA journal_mode = PERSIST", NULL, NULL, &error);
if (result != SQLITE_OK) {
- DEBUG_ERR_MSG("Fail to change journal mode: %s", error);
- sqlite3_free(error);
+ DEBUG_ERR_MSG("Fail to change journal mode: %s", error); //LCOV_EXCL_LINE
+ sqlite3_free(error); //LCOV_EXCL_LINE
goto ERR;
}
return;
ERR:
+/* LCOV_EXCL_START */
if (db != NULL) {
result = sqlite3_close(db);
if (result == SQLITE_OK)
DEBUG_ERR_MSG("sqlite3_close failed, [%d]", result);
}
}
+/* LCOV_EXCL_STOP */
static void __iterate_db(_iterate_db_cb cb, void *user_data)
{
bool manifest;
while ((ret = sqlite3_step(stmt)) == SQLITE_ROW) {
+/* LCOV_EXCL_START */
package = (const char *)sqlite3_column_text(stmt, 1);
se_type = (net_nfc_se_type_e) sqlite3_column_int(stmt, 2);
category = (net_nfc_card_emulation_category_t) sqlite3_column_int(stmt, 3);
manifest = (bool) sqlite3_column_int(stmt, 7);
cb(package, se_type, category, aid, unlock, power, manifest, user_data);
+/* LCOV_EXCL_STOP */
}
sqlite3_finalize(stmt);
}
}
+/* LCOV_EXCL_START */
static net_nfc_error_e __insert_into_db(const char *package, net_nfc_se_type_e se_type, net_nfc_card_emulation_category_t category, const char *aid, bool unlock, int power, bool manifest)
{
net_nfc_error_e result;
return result;
}
+/* LCOV_EXCL_STOP */
#if 0
static net_nfc_error_e __delete_aids_from_db(const char *package)
activated_payment = g_strdup(package);
}
+/* LCOV_EXCL_START */
static bool __is_preferred_payment_handler(const char *package)
{
return (preferred_payment != NULL && g_strcmp0(package, preferred_payment) == 0);
{
g_free(data);
}
+/* LCOV_EXCL_STOP */
static void __update_other_handler(const char *packages)
{
}
}
+/* LCOV_EXCL_START */
void net_nfc_server_route_table_update_other_handler(const char *packages)
{
__update_other_handler(packages);
break;
}
}
+/* LCOV_EXCL_STOP */
////////////////////////////////////////////////////////////////////////////////
route_table_handler_t *preferred_handler;
static GHashTable *routing_handlers;
+/* LCOV_EXCL_START */
static bool __get_package_name(const char *id, char *package, size_t len)
{
pid_t pid;
__route_table_add_aid(NULL, package, se_type, category, aid, unlock, power, manifest, false);
}
+/* LCOV_EXCL_STOP */
void net_nfc_server_route_table_init()
{
__iterate_db(__on_iterate_db_aid_cb, NULL);
}
+/* LCOV_EXCL_START */
void net_nfc_server_route_table_deinit()
{
if (routing_handlers != NULL) {
}
}
+/* LCOV_EXCL_STOP */
route_table_handler_t *net_nfc_server_route_table_find_handler(const char *package)
{
return (route_table_handler_t *) g_hash_table_lookup(routing_handlers, (gconstpointer) package);
}
+/* LCOV_EXCL_START */
net_nfc_error_e net_nfc_server_route_table_add_handler(const char *id, const char *package)
{
route_table_handler_t *data;
return result;
}
+/* LCOV_EXCL_STOP */
+
#endif
net_nfc_error_e net_nfc_server_route_table_update_handler_id(const char *package, const char *id)
{
data = net_nfc_server_route_table_find_handler(package);
if (data != NULL) {
+/* LCOV_EXCL_START */
if (data->id != NULL) {
SECURE_MSG("remove client id, [%s]", id);
g_free(data->id);
data->id = NULL;
}
+/* LCOV_EXCL_STOP */
}
return result;
}
+/* LCOV_EXCL_START */
route_table_handler_t *net_nfc_server_route_table_get_preferred_handler()
{
return preferred_handler;
}
DEBUG_SERVER_MSG("------------------------------");
}
+/* LCOV_EXCL_STOP */
+
#endif
void net_nfc_server_route_table_iterate_handler(net_nfc_server_route_table_handler_iter_cb cb, void *user_data)
g_hash_table_iter_init(&iter, routing_handlers);
while (g_hash_table_iter_next(&iter, &key, (gpointer) & data)) {
- if (!__is_preferred_payment_handler((const char *)key)
- && !__is_preferred_other_handler((const char *)key)
- && !__is_payment_handler((const char *)key)
- && !__is_other_handler((const char *)key)) {
- if (cb((const char *)key, data, user_data) == false)
+ if (!__is_preferred_payment_handler((const char *)key) // LCOV_EXCL_LINE
+ && !__is_preferred_other_handler((const char *)key) // LCOV_EXCL_LINE
+ && !__is_payment_handler((const char *)key) // LCOV_EXCL_LINE
+ && !__is_other_handler((const char *)key)) { // LCOV_EXCL_LINE
+ if (cb((const char *)key, data, user_data) == false) // LCOV_EXCL_LINE
break;
}
}
g_hash_table_iter_init(&iter, routing_handlers);
while (g_hash_table_iter_next(&iter, &key, (gpointer) & data)) {
- if (__is_preferred_payment_handler((const char *)key) == false && __is_preferred_other_handler((const char *)key) == false && (__is_payment_handler((const char *)key) || __is_other_handler((const char *)key))) {
- if (cb((const char *)key, data, user_data) == false)
+ if (__is_preferred_payment_handler((const char *)key) == false && __is_preferred_other_handler((const char *)key) == false && (__is_payment_handler((const char *)key) || __is_other_handler((const char *)key))) { // LCOV_EXCL_LINE
+ if (cb((const char *)key, data, user_data) == false) // LCOV_EXCL_LINE
break;
}
}
if (preferred_handler != NULL)
- cb((const char *)preferred_handler->package, preferred_handler, user_data);
+ cb((const char *)preferred_handler->package, preferred_handler, user_data); // LCOV_EXCL_LINE
}
#ifdef PRINT_TABLE
static const char *__get_se_name(net_nfc_se_type_e se_type)
{
- switch (se_type) {
+ switch (se_type) { // LCOV_EXCL_LINE
case NET_NFC_SE_TYPE_ESE:
return "eSE";
case NET_NFC_SE_TYPE_UICC:
}
}
+/* LCOV_EXCL_START */
static bool _display_route_table_cb(const char *package, route_table_handler_t * handler, void *user_data)
{
int i;
return true;
}
+/* LCOV_EXCL_STOP */
static void __display_route_table()
{
DEBUG_SERVER_MSG(" +------------------------------------------------+");
}
#endif
+/* LCOV_EXCL_START */
static bool __activation_iter_cb(const char *package, route_table_handler_t * handler, void *user_data)
{
int i;
return true;
}
+/* LCOV_EXCL_STOP */
net_nfc_error_e net_nfc_server_route_table_do_update(bool routing)
{
result = NET_NFC_OK;
} else if (ret > 1) {
+ /* LCOV_EXCL_START */
DEBUG_ERR_MSG("some packages are not updated, [%d]", ret);
result = NET_NFC_OPERATION_FAIL;
DEBUG_ERR_MSG("wrong result, [%d]", ret);
result = NET_NFC_OPERATION_FAIL;
+ /* LCOV_EXCL_STOP */
}
if (routing == true)
return result;
}
+/* LCOV_EXCL_START */
net_nfc_error_e net_nfc_server_route_table_get_storage_info(net_nfc_card_emulation_category_t category, int *used, int *max)
{
if (used == NULL || max == NULL)
return NET_NFC_OK;
}
+/* LCOV_EXCL_STOP */
break;
case SECURE_ELEMENT_POLICY_UICC_ON:
- if (gdbus_uicc_ready == SE_UICC_READY)
+ if (gdbus_uicc_ready == SE_UICC_READY) //LCOV_EXCL_LINE
state = NET_NFC_CARD_EMELATION_ENABLE;
else
- state = NET_NFC_CARD_EMULATION_DISABLE;
+ state = NET_NFC_CARD_EMULATION_DISABLE; //LCOV_EXCL_LINE
break;
case SECURE_ELEMENT_POLICY_HCE_ON:
break;
default:
- state = NET_NFC_CARD_EMULATION_DISABLE;
+ state = NET_NFC_CARD_EMULATION_DISABLE; //LCOV_EXCL_LINE
break;
}
return state;
}
+/* LCOV_EXCL_START */
net_nfc_card_emulation_mode_t net_nfc_server_se_get_se_state()
{
net_nfc_card_emulation_mode_t state;
return result;
}
+/* LCOV_EXCL_STOP */
static inline const char *__se_get_se_name(net_nfc_se_type_e type)
{
break;
case NET_NFC_SE_TYPE_HCE:
- name = "HCE";
+ name = "HCE"; //LCOV_EXCL_LINE
break;
default:
- name = "unknown";
+ name = "unknown"; //LCOV_EXCL_LINE
break;
}
return name;
}
+/* LCOV_EXCL_START */
static net_nfc_se_type_e __se_get_se_type(net_nfc_secure_element_policy_e policy)
{
net_nfc_se_type_e type;
break;
default:
- type = NET_NFC_SE_TYPE_NONE;
+ type = NET_NFC_SE_TYPE_NONE; //LCOV_EXCL_LINE
break;
}
return type;
}
+/* LCOV_EXCL_STOP */
net_nfc_se_type_e net_nfc_server_se_get_se_type()
{
return se_type;
}
+/* LCOV_EXCL_START */
net_nfc_error_e net_nfc_server_se_set_se_type(net_nfc_se_type_e type)
{
net_nfc_error_e result;
return result;
}
+/* LCOV_EXCL_STOP */
static net_nfc_secure_element_policy_e __se_get_se_policy()
{
int wallet_mode = 0;
if (vconf_get_int(VCONFKEY_NFC_WALLET_MODE, &wallet_mode) != 0)
- DEBUG_ERR_MSG("vconf_get_int failed");
+ DEBUG_ERR_MSG("vconf_get_int failed"); //LCOV_EXCL_LINE
if (vconf_get_int(VCONFKEY_NFC_SE_TYPE, &se_policy) != 0)
- DEBUG_ERR_MSG("vconf_get_int failed");
+ DEBUG_ERR_MSG("vconf_get_int failed"); //LCOV_EXCL_LINE
if (wallet_mode == NET_NFC_WALLET_MODE_UICC) {
+ /* LCOV_EXCL_START */
if (__se_get_se_state(se_policy) == NET_NFC_CARD_EMELATION_ENABLE)
se_policy = SECURE_ELEMENT_POLICY_UICC_ON;
else
se_policy = SECURE_ELEMENT_POLICY_UICC_OFF;
+ /* LCOV_EXCL_STOP */
} else if (wallet_mode == NET_NFC_WALLET_MODE_ESE) {
if (__se_get_se_state(se_policy) == NET_NFC_CARD_EMELATION_ENABLE)
se_policy = SECURE_ELEMENT_POLICY_ESE_ON;
+ /* LCOV_EXCL_START */
else
se_policy = SECURE_ELEMENT_POLICY_ESE_OFF;
} else if (wallet_mode == NET_NFC_WALLET_MODE_HCE) {
else
se_policy = SECURE_ELEMENT_POLICY_HCE_OFF;
}
+ /* LCOV_EXCL_STOP */
return se_policy;
}
+/* LCOV_EXCL_START */
#if 0
net_nfc_error_e net_nfc_server_se_set_se_policy(net_nfc_secure_element_policy_e policy)
{
{
return (gdbus_uicc_ready == SE_UICC_READY && gdbus_uicc_handle != NULL && (TapiHandle *) handle == gdbus_uicc_handle);
}
+/* LCOV_EXCL_STOP */
static void _se_uicc_close(net_nfc_target_handle_s * handle)
{
switch (policy) {
case SECURE_ELEMENT_POLICY_UICC_ON:
+ /* LCOV_EXCL_START */
if (gdbus_uicc_ready == SE_UICC_READY) {
net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_ESE, SECURE_ELEMENT_OFF_MODE, &result);
} else {
current_policy = SECURE_ELEMENT_POLICY_UICC_OFF;
}
+ /* LCOV_EXCL_STOP */
break;
case SECURE_ELEMENT_POLICY_ESE_ON:
break;
case SECURE_ELEMENT_POLICY_HCE_ON:
+ /* LCOV_EXCL_START */
net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_UICC, SECURE_ELEMENT_OFF_MODE, &result);
net_nfc_controller_set_secure_element_mode(SECURE_ELEMENT_TYPE_ESE, SECURE_ELEMENT_OFF_MODE, &result);
#endif
current_policy = policy;
break;
+ /* LCOV_EXCL_STOP */
case SECURE_ELEMENT_POLICY_UICC_OFF:
case SECURE_ELEMENT_POLICY_ESE_OFF:
return net_nfc_server_se_apply_se_policy(policy);
}
+/* LCOV_EXCL_START */
net_nfc_error_e net_nfc_server_se_change_wallet_mode(net_nfc_wallet_mode_e wallet_mode)
{
net_nfc_error_e result = NET_NFC_OK;
return result;
}
+/* LCOV_EXCL_STOP */
static void __llcp_on_client_detached_cb(net_nfc_client_context_info_t * client)
{
if (client->ref_se > 0) {
- DEBUG_SERVER_MSG("close opened secure element");
+ DEBUG_SERVER_MSG("close opened secure element"); //LCOV_EXCL_LINE
- client->ref_se = 0;
+ client->ref_se = 0; //LCOV_EXCL_LINE
- __se_close_ese_no_lock();
+ __se_close_ese_no_lock(); //LCOV_EXCL_LINE
}
}
+/* LCOV_EXCL_START */
static void se_set_preferred_handler_thread_func(gpointer user_data)
{
SeSetPreferred *data = (SeSetPreferred *) user_data;
return TRUE;
}
+/* LCOV_EXCL_STOP */
gboolean net_nfc_server_se_init(GDBusConnection * connection)
{
if (result == true) {
net_nfc_server_gdbus_register_on_client_detached_cb(__llcp_on_client_detached_cb);
} else {
- DEBUG_ERR_MSG("can not skeleton_export %s", error->message);
+ DEBUG_ERR_MSG("can not skeleton_export %s", error->message); //LCOV_EXCL_LINE
- g_error_free(error);
+ g_error_free(error); //LCOV_EXCL_LINE
- net_nfc_server_se_deinit();
+ net_nfc_server_se_deinit(); //LCOV_EXCL_LINE
}
return result;
}
}
+/* LCOV_EXCL_START */
static void se_detected_thread_func(gpointer user_data)
{
net_nfc_target_handle_s *handle = NULL;
/* FIXME : should be removed when plugins would be fixed */
_net_nfc_util_free_mem(info);
}
+/* LCOV_EXCL_STOP */
static guint __timer_handle;
static gint __set_guard_time;
static net_nfc_screen_state_type_e __lcd_state;
static pthread_mutex_t __state_mutex = PTHREAD_MUTEX_INITIALIZER;
+/* LCOV_EXCL_START */
static void ____delayed_change_screen_state_thread_func(gpointer user_data)
{
net_nfc_error_e result = NET_NFC_OK;
return FALSE;
}
+/* LCOV_EXCL_STOP */
static void __stop_lcd_on_timer()
{
DEBUG_SERVER_MSG("timer stopped");
if (__timer_handle > 0) {
- g_source_remove(__timer_handle);
- __timer_handle = 0;
+ g_source_remove(__timer_handle); //LCOV_EXCL_LINE
+ __timer_handle = 0; //LCOV_EXCL_LINE
}
pthread_mutex_unlock(&__state_mutex);
}
+/* LCOV_EXCL_START */
static void __start_lcd_on_timer()
{
__stop_lcd_on_timer();
void net_nfc_server_se_create_deactivate_apdu_command(uint8_t * orig, uint8_t ** dest, size_t * destLen)
{
}
+/* LCOV_EXCL_STOP */
#define USEESE_FILE_PATH "/opt/usr/data/nfc-manager-daemon/aid.dat"
#define FIRST_BOOT_USEESE_FILE_PATH "/opt/usr/share/nfc_debug/is_first_boot.dat"
DEBUG_SERVER_MSG("first boot NO");
return;
} else if (result == -1) {
+ /* LCOV_EXCL_START */
DEBUG_SERVER_MSG("first boot YES");
fp = fopen(FIRST_BOOT_USEESE_FILE_PATH, "w+");
if (fp) {
if (cmd != NULL)
g_free(cmd);
+ /* LCOV_EXCL_STOP */
}
void net_nfc_server_se_deactivate_card(void)
/* definition */
static NetNfcGDbusSnep *snep_skeleton = NULL;
+/* LCOV_EXCL_START */
static void _emit_snep_event_signal(GVariant * parameter, net_nfc_snep_handle_h handle, net_nfc_error_e result, uint32_t type, data_s * data)
{
GDBusConnection *connection;
return TRUE;
}
+/* LCOV_EXCL_STOP */
gboolean net_nfc_server_snep_init(GDBusConnection * connection)
{
gboolean result;
if (snep_skeleton)
- g_object_unref(snep_skeleton);
+ g_object_unref(snep_skeleton); //LCOV_EXCL_LINE
snep_skeleton = net_nfc_gdbus_snep_skeleton_new();
result = g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(snep_skeleton), connection, "/org/tizen/NetNfcService/Snep", &error);
if (result == FALSE) {
- g_error_free(error);
+ g_error_free(error); //LCOV_EXCL_LINE
net_nfc_server_snep_deinit();
}
static gboolean popup_handle_get(NetNfcGDbusPopup * popup_manager, GDBusMethodInvocation * invocation, GVariant * smack_privilege, gpointer user_data);
+/* LCOV_EXCL_START */
static gboolean popup_handle_set(NetNfcGDbusPopup * popup_manager, GDBusMethodInvocation * invocation, gint state, gint focus_state, GVariant * smack_privilege, gpointer user_data)
{
int result = NET_NFC_OK;
return TRUE;
}
+/* LCOV_EXCL_STOP */
gboolean net_nfc_server_system_handler_init(GDBusConnection * connection)
{
gboolean result;
if (popup_skeleton)
- g_object_unref(popup_skeleton);
+ g_object_unref(popup_skeleton); //LCOV_EXCL_LINE
popup_skeleton = net_nfc_gdbus_popup_skeleton_new();
if (popup_skeleton == NULL) {
- DEBUG_ERR_MSG("Failed to allocate popup skeleton");
+ DEBUG_ERR_MSG("Failed to allocate popup skeleton"); //LCOV_EXCL_LINE
return FALSE;
}
result = g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(popup_skeleton), connection, "/org/tizen/NetNfcService/Popup", &error);
if (result == FALSE) {
- DEBUG_ERR_MSG("Can not skeleton_export %s", error->message);
+ DEBUG_ERR_MSG("Can not skeleton_export %s", error->message); //LCOV_EXCL_LINE
- g_error_free(error);
+ g_error_free(error); //LCOV_EXCL_LINE
net_nfc_server_system_handler_deinit();
}
return result;
}
#endif
+/* LCOV_EXCL_START */
static gboolean tag_read_ndef_message(net_nfc_target_handle_s * handle, int dev_type, data_s ** read_ndef)
{
net_nfc_error_e result = NET_NFC_OK;
return TRUE;
}
+/* LCOV_EXCL_STOP */
gboolean net_nfc_server_tag_init(GDBusConnection * connection)
{
result = g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(tag_skeleton), connection, "/org/tizen/NetNfcService/Tag", &error);
if (result == FALSE) {
- DEBUG_ERR_MSG("can not skeleton_export %s", error->message);
+ DEBUG_ERR_MSG("can not skeleton_export %s", error->message); //LCOV_EXCL_LINE
- g_error_free(error);
+ g_error_free(error); //LCOV_EXCL_LINE
net_nfc_server_tag_deinit();
}
}
}
+/* LCOV_EXCL_START */
void net_nfc_server_set_target_info(net_nfc_current_target_info_s * info)
{
if (current_target_info)
return TRUE;
}
+/* LCOV_EXCL_STOP */
void net_nfc_server_free_target_info(void)
{
current_target_info = NULL;
}
+/* LCOV_EXCL_START */
bool net_nfc_server_tag_target_detected(void *info)
{
if (net_nfc_server_controller_async_queue_push_force(tag_slave_target_detected_thread_func, info) == FALSE) {
return true;
}
+/* LCOV_EXCL_STOP */
static NetNfcGDbusTest *test_skeleton = NULL;
+/* LCOV_EXCL_START */
static void test_handle_sim_test_thread_func(gpointer user_data)
{
TestData *data = (TestData *) user_data;
return TRUE;
}
+/* LCOV_EXCL_STOP */
gboolean net_nfc_server_test_init(GDBusConnection * connection)
{
result = g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(test_skeleton), connection, "/org/tizen/NetNfcService/Test", &error);
if (result == FALSE) {
+ /* LCOV_EXCL_START */
DEBUG_ERR_MSG("Can not skeleton_export %s", error->message);
g_error_free(error);
g_object_unref(test_skeleton);
test_skeleton = NULL;
+ /* LCOV_EXCL_STOP */
}
return result;
net_nfc_transceive_info_s transceive_info;
};
+/* LCOV_EXCL_START */
static void transceive_data_thread_func(gpointer user_data)
{
TransceiveSendData *transceive_data = (TransceiveSendData *) user_data;
return TRUE;
}
+/* LCOV_EXCL_STOP */
gboolean net_nfc_server_transceive_init(GDBusConnection * connection)
{
result = g_dbus_interface_skeleton_export(G_DBUS_INTERFACE_SKELETON(transceive_skeleton), connection, "/org/tizen/NetNfcService/Transceive", &error);
if (result == FALSE) {
+ /* LCOV_EXCL_START */
g_error_free(error);
g_object_unref(transceive_skeleton);
transceive_skeleton = NULL;
+ /* LCOV_EXCL_STOP */
}
return result;
static void net_nfc_server_vconf_pm_state_changed(keynode_t * key, void *user_data);
+/* LCOV_EXCL_START */
static void net_nfc_server_vconf_lock_state_changed(keynode_t * key, void *user_data)
{
net_nfc_server_restart_polling_loop();
}
+/* LCOV_EXCL_STOP */
static void net_nfc_server_vconf_pm_state_changed(keynode_t * key, void *user_data)
{
}
}
+/* LCOV_EXCL_START */
static void net_nfc_server_vconf_se_type_changed(keynode_t * key, void *user_data)
{
net_nfc_server_se_apply_se_current_policy();
if (net_nfc_server_controller_async_queue_push(__on_other_handlers_changed_func, g_strdup(key->value.s)) == false)
DEBUG_ERR_MSG("net_nfc_server_controller_async_queue_push failed");
}
+/* LCOV_EXCL_STOP */
void net_nfc_server_vconf_init(void)
{
vconf_ignore_key_changed(VCONFKEY_NFC_OTHER_HANDLERS, net_nfc_server_vconf_other_handlers_changed);
}
+/* LCOV_EXCL_START */
bool net_nfc_check_start_polling_vconf(void)
{
gint lock_state = 0;
{
is_screen_state_on = flag;
}
+/* LCOV_EXCL_STOP */
--- /dev/null
+CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
+PROJECT(gtest-nfc-manager C CXX)
+
+SET(TARGET_GTEST_TESTS "gtest-nfc-manager")
+ADD_DEFINITIONS("-DUSE_DLOG")
+
+SET(REQUIRES_LIST ${REQUIRES_LIST}
+ glib-2.0
+ gio-2.0
+ gmock
+ dlog
+ capi-system-info
+)
+
+INCLUDE(FindPkgConfig)
+PKG_CHECK_MODULES(TARGET_GTEST_TESTS_PKG REQUIRED ${REQUIRES_LIST})
+
+FOREACH(flag ${TARGET_GTEST_TESTS_PKG_CFLAGS})
+ SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}")
+ENDFOREACH(flag)
+
+SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} -Wall -fPIE")
+SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_CFLAGS}")
+SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -pie")
+
+FILE(GLOB TARGET_GTEST_TESTS_SRCS *.cpp)
+SET(TARGET_GTEST_TESTS_SRCS ${TARGET_GTEST_TESTS_SRCS})
+
+ADD_EXECUTABLE(${TARGET_GTEST_TESTS} ${TARGET_GTEST_TESTS_SRCS})
+TARGET_LINK_LIBRARIES(${TARGET_GTEST_TESTS} ${TARGET_GTEST_TESTS_LDFLAGS} ${TARGET_GTEST_TESTS_PKG_LDFLAGS} -ldl -lgcov)
+
+INSTALL(TARGETS ${TARGET_GTEST_TESTS} RUNTIME DESTINATION ${BIN_DIR})
--- /dev/null
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <iostream>
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+#include "gdbus.h"
+
+GDbus::GDbus()
+{
+ this->m_pConnection = NULL;
+ this->m_pCancellable = NULL;
+}
+
+GDbus::~GDbus()
+{
+ GDBusConnection *conn = this->m_pConnection;
+ GCancellable *cancel = this->m_pCancellable;
+
+ if (cancel) {
+ g_cancellable_cancel(cancel); // LCOV_EXCL_LINE
+ g_object_unref(cancel); // LCOV_EXCL_LINE
+ cancel = NULL; // LCOV_EXCL_LINE
+ }
+
+ if (conn) {
+ g_object_unref(conn);
+ conn = NULL;
+ }
+}
+
+error_e GDbus::Create(void)
+{
+ GError *err = NULL;
+
+#if !GLIB_CHECK_VERSION(2, 36, 0)
+ g_type_init();
+#endif
+
+ this->m_pConnection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &err);
+ if (this->m_pConnection == NULL) {
+ if (err != NULL) {
+ GLOGD("Failed to connect to the D-BUS daemon [%s]", err->message);
+ g_error_free(err);
+ }
+
+ return ERROR_OPERATION_FAILED;
+ }
+
+ this->m_pCancellable = g_cancellable_new();
+
+ return ERROR_NONE;
+}
+
+error_e GDbus::Destroy(void)
+{
+ g_cancellable_cancel(this->m_pCancellable);
+ g_object_unref(this->m_pCancellable);
+ this->m_pCancellable = NULL;
+
+ g_object_unref(this->m_pConnection);
+ this->m_pConnection = NULL;
+
+ return ERROR_NONE;
+}
+
+/* LCOV_EXCL_START */
+GDBusConnection *GDbus::GetConnection(void)
+{
+ return this->m_pConnection;
+}
+
+GCancellable *GDbus::GetCancellable(void)
+{
+ return this->m_pCancellable;
+}
+/* LCOV_EXCL_STOP*/
+
+/* LCOV_EXCL_START */
+error_e GDbus::ConvertErrorStringToEnum(const char *error)
+{
+ if (NULL != strstr(error, "NoReply"))
+ return ERROR_INVALID_OPERATION;
+ else if (NULL != strstr(error, "Failed"))
+ return ERROR_OPERATION_FAILED;
+ else if (NULL != strstr(error, "UnknownMethod"))
+ return ERROR_INVALID_OPERATION;
+ else if (NULL != strstr(error, "InvalidArguments"))
+ return ERROR_INVALID_PARAMETER;
+ else if (NULL != strstr(error, "AccessDenied"))
+ return ERROR_PERMISSION_DENIED;
+ else if (NULL != strstr(error, "PermissionDenied"))
+ return ERROR_PERMISSION_DENIED;
+ else if (NULL != strstr(error, "NotSupported"))
+ return ERROR_NOT_SUPPORTED;
+ else if (NULL != strstr(error, "InProgress"))
+ return ERROR_IN_PROGRESS;
+
+ return ERROR_OPERATION_FAILED;
+}
+/* LCOV_EXCL_STOP */
+
+GVariant *GDbus::InvokeMethod(const char *dest, const char *path,
+ const char *iface_name, const char *method, GVariant *params, int *dbus_error)
+{
+ GError *error = NULL;
+ GVariant *reply = NULL;
+ GDBusConnection *connection = NULL;
+ *dbus_error = ERROR_NONE;
+
+ connection = GetConnection();
+ if (connection == NULL) {
+ /* LCOV_EXCL_START */
+ GLOGD("GDBusconnection is NULL");
+ *dbus_error = ERROR_NOT_INITIALIZED;
+ return reply;
+ /* LCOV_EXCL_STOP */
+ }
+
+ reply = g_dbus_connection_call_sync(connection,
+ dest,
+ path,
+ iface_name,
+ method,
+ params,
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ DBUS_REPLY_TIMEOUT,
+ GetCancellable(),
+ &error);
+
+ if (reply == NULL) {
+ /* LCOV_EXCL_START */
+ if (error != NULL) {
+ GLOGD("g_dbus_connection_call_sync() failed "
+ "error [%d: %s]", error->code, error->message);
+ *dbus_error = ConvertErrorStringToEnum(error->message);
+ g_error_free(error);
+ } else {
+ GLOGD("g_dbus_connection_call_sync() failed");
+ *dbus_error = ERROR_OPERATION_FAILED;
+ }
+
+ return NULL;
+ /* LCOV_EXCL_STOP */
+ }
+
+ return reply;
+}
+
+/* LCOV_EXCL_START */
+error_e GDbus::InvokeMethodNonblock(const char *dest, const char *path,
+ const char *iface_name, const char *method, GVariant *params, int timeout,
+ GAsyncReadyCallback notify_func, void *user_data)
+{
+ GDBusConnection *connection = NULL;
+
+ connection = GetConnection();
+ if (connection == NULL) {
+ GLOGD("GDBusconnection is NULL");
+ return ERROR_NOT_INITIALIZED;
+ }
+
+ g_dbus_connection_call(connection,
+ dest,
+ path,
+ iface_name,
+ method,
+ params,
+ NULL,
+ G_DBUS_CALL_FLAGS_NONE,
+ timeout,
+ GetCancellable(),
+ (GAsyncReadyCallback) notify_func,
+ (gpointer)user_data);
+
+ return ERROR_NONE;
+}
+/* LCOV_EXCL_STOP */
--- /dev/null
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef __NFC_MGR_GDBUS_H__
+#define __NFC_MGR_GDBUS_H__
+
+#include <glib.h>
+#include <gio/gio.h>
+
+#include "nfcmgr.h"
+
+#define GMAINTIMEOUT 10000
+#define DBUS_REPLY_TIMEOUT (120 * 1000)
+
+#define NFC_MGR_SERVICE "org.tizen.NetNfcService"
+
+#define NFC_MANAGER_PATH "/org/tizen/NetNfcService/Manager"
+#define NFC_TAG_PATH "/org/tizen/NetNfcService/Tag"
+#define NFC_NDEF_PATH "/org/tizen/NetNfcService/Ndef"
+#define NFC_LLCP_PATH "/org/tizen/NetNfcService/Llcp"
+#define NFC_P2P_PATH "/org/tizen/NetNfcService/P2p"
+#define NFC_POPUP_PATH "/org/tizen/NetNfcService/Popup"
+#define NFC_SECURE_ELEMENT_PATH "/org/tizen/NetNfcService/SecureElement"
+#define NFC_TRANSCEIVE_PATH "/org/tizen/NetNfcService/Transceive"
+#define NFC_HANDOVER_PATH "/org/tizen/NetNfcService/Handover"
+#define NFC_TEST_PATH "/org/tizen/NetNfcService/Test"
+#define NFC_SNEP_PATH "/org/tizen/NetNfcService/Snep"
+#define NFC_HCE_PATH "/org/tizen/NetNfcService/Hce"
+
+#define NFC_MANAGER_INTERFACE "org.tizen.NetNfcService.Manager"
+#define NFC_TAG_INTERFACE "org.tizen.NetNfcService.Tag"
+#define NFC_NDEF_INTERFACE "org.tizen.NetNfcService.Ndef"
+#define NFC_LLCP_INTERFACE "org.tizen.NetNfcService.Llcp"
+#define NFC_P2P_INTERFACE "org.tizen.NetNfcService.P2p"
+#define NFC_POPUP_INTERFACE "org.tizen.NetNfcService.Popup"
+#define NFC_SECURE_ELEMENT_INTERFACE "org.tizen.NetNfcService.SecureElement"
+#define NFC_TRANSCEIVE_INTERFACE "org.tizen.NetNfcService.Transceive"
+#define NFC_HANDOVER_INTERFACE "org.tizen.NetNfcService.Handover"
+#define NFC_TEST_INTERFACE "org.tizen.NetNfcService.Test"
+#define NFC_SNEP_INTERFACE "org.tizen.NetNfcService.Snep"
+#define NFC_HCE_INTERFACE "org.tizen.NetNfcService.Hce"
+
+
+class GDbus {
+private:
+ GDBusConnection *m_pConnection;
+ GCancellable *m_pCancellable;
+public:
+ GDbus();
+ ~GDbus();
+ error_e Create(void);
+ error_e Destroy(void);
+ GDBusConnection *GetConnection(void);
+ GCancellable *GetCancellable(void);
+ error_e ConvertErrorStringToEnum(const char *error);
+ GVariant *InvokeMethod(const char *dest, const char *path,
+ const char *iface_name, const char *method, GVariant *params, int *dbus_error);
+ error_e InvokeMethodNonblock(const char *dest, const char *path,
+ const char *iface_name, const char *method, GVariant *params, int timeout,
+ GAsyncReadyCallback notify_func, void *user_data);
+};
+
+#endif /* __NFC_MGR_GDBUS_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <iostream>
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+
+#include "manager.h"
+
+Manager::Manager()
+{
+ Create();
+}
+
+Manager::~Manager()
+{
+ Destroy();
+}
+
+//===================== Manager ======================
+
+int Manager::SetActive(bool is_active)
+{
+ sleep(1); // needed in case when setactive(false) is called too quickly. This issue handled and resolved in another commit.
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("SetActive()");
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_MANAGER_PATH,
+ NFC_MANAGER_INTERFACE,
+ "SetActive",
+ g_variant_new("(b)", is_active),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(i)", &error);
+ GLOGD("ret = [%d]", error);
+ g_variant_unref(message);
+
+ return error;
+}
+
+int Manager::GetServerState(unsigned int *state)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("GetServerState()");
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_MANAGER_PATH,
+ NFC_MANAGER_INTERFACE,
+ "GetServerState",
+ NULL,
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(iu)", &error, state);
+ GLOGD("ret = [%d: %u]", error, *state);
+ g_variant_unref(message);
+
+ return error;
+}
+
+//===================== Tag ======================
+
+int Manager::IsTagConnected(bool *is_connected, int *dev_type)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("IsTagConnected()");
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_TAG_PATH,
+ NFC_TAG_INTERFACE,
+ "IsTagConnected",
+ NULL,
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(ibi)", &error, is_connected, dev_type);
+ GLOGD("ret = [%d: %d: %d]", error, (int)*is_connected, *dev_type);
+ g_variant_unref(message);
+
+ return error;
+}
+
+int Manager::GetCurrentTagInfo(bool *is_connected, unsigned int *handle, int *dev_type, bool *is_ndef_supported, unsigned char *ndef_card_state,
+ unsigned int *max_data_size, unsigned int *actual_data_size, unsigned int *number_of_keys, GVariant **target_info_values, GVariant **raw_data)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("GetCurrentTagInfo()");
+
+ int pre_error = this->IsTagConnected(is_connected, dev_type);
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_TAG_PATH,
+ NFC_TAG_INTERFACE,
+ "GetCurrentTagInfo",
+ NULL,
+ &error);
+
+ if (message == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ }
+
+ GVariantIter *value_iter = NULL;
+ GVariantIter *raw_data_iter = NULL;
+ unsigned char endpoint = 0;
+ GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)"));
+
+ g_variant_get(message, "(ibuibyuuua(y)a(y))", &error, is_connected, handle, dev_type, is_ndef_supported,
+ ndef_card_state, max_data_size, actual_data_size, number_of_keys, &value_iter, &raw_data_iter);
+
+ GLOGD("ret = [%d: %d: %u: %d: %d: %u: %u: %u: %u: ...]", error, (int)*is_connected, *handle, *dev_type, (int)*is_ndef_supported, *ndef_card_state,
+ *max_data_size, *actual_data_size, *number_of_keys);
+
+ while (g_variant_iter_loop(value_iter, "(y)", &endpoint))
+ g_variant_builder_add(builder, "(y)", endpoint);
+
+ *target_info_values = g_variant_builder_end(builder);
+ g_variant_builder_unref(builder);
+
+ builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)"));
+ while (g_variant_iter_loop(raw_data_iter, "(y)", &endpoint))
+ g_variant_builder_add(builder, "(y)", endpoint);
+
+ *raw_data = g_variant_builder_end(builder);
+ g_variant_builder_unref(builder);
+
+ g_variant_iter_free(value_iter);
+ g_variant_iter_free(raw_data_iter);
+ g_variant_unref(message);
+
+ if (pre_error != ERROR_NONE || *is_connected == 0)
+ return ERROR_NONE;
+
+ return error;
+}
+
+int Manager::GetBarcode(GVariant **barcode)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("GetBarcode()");
+
+ bool is_connected = 0;
+ int dev_type = 0;
+ int pre_error = this->IsTagConnected(&is_connected, &dev_type);
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_TAG_PATH,
+ NFC_TAG_INTERFACE,
+ "GetBarcode",
+ NULL,
+ &error);
+
+ if (message == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ }
+
+ GVariantIter *iter = NULL;
+ unsigned char endpoint = 0;
+ GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)"));
+
+ g_variant_get(message, "(ia(y))", &error, &iter);
+ GLOGD("ret = [%d: ...]", error);
+
+ while (g_variant_iter_loop(iter, "(y)", &endpoint))
+ g_variant_builder_add(builder, "(y)", endpoint);
+
+ *barcode = g_variant_builder_end(builder);
+ g_variant_builder_unref(builder);
+
+ g_variant_iter_free(iter);
+ g_variant_unref(message);
+
+ if (pre_error != ERROR_NONE)
+ return pre_error;
+ if (is_connected == 0)
+ return ERROR_INVALID_OPERATION;
+
+ return error;
+}
+
+int Manager::GetCurrentTargetHandle(bool *is_connected, unsigned int *handle, int *dev_type)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("GetCurrentTargetHandle()");
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_TAG_PATH,
+ NFC_TAG_INTERFACE,
+ "GetCurrentTargetHandle",
+ NULL,
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(ibui)", &error, is_connected, handle, dev_type);
+ GLOGD("ret = [%d: %d: %u: %d]", error, (int)*is_connected, *handle, *dev_type);
+ g_variant_unref(message);
+
+ return error;
+}
+
+//===================== Ndef ======================
+
+int Manager::Read(unsigned int *handle, GVariant **data)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("Read()");
+
+ bool is_connected = 0;
+ int dev_type = 0;
+ int pre_error = this->GetCurrentTargetHandle(&is_connected, handle, &dev_type);
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_NDEF_PATH,
+ NFC_NDEF_INTERFACE,
+ "Read",
+ g_variant_new("(u)", *handle),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ GVariantIter *iter = NULL;
+ unsigned char endpoint = 0;
+ GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)"));
+
+ g_variant_get(message, "(ia(y))", &error, &iter);
+ GLOGD("ret = [%d: ...]", error);
+
+ while (g_variant_iter_loop(iter, "(y)", &endpoint))
+ g_variant_builder_add(builder, "(y)", endpoint);
+
+ *data = g_variant_builder_end(builder);
+ g_variant_builder_unref(builder);
+ g_variant_iter_free(iter);
+ g_variant_unref(message);
+
+ if (pre_error != ERROR_NONE || is_connected == 0)
+ return ERROR_INVALID_OPERATION;
+
+ return error;
+}
+
+int Manager::Write(unsigned int *handle, GVariant **data)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("Write()");
+
+ bool is_connected = 0;
+ int dev_type = 0;
+ int pre_error = this->GetCurrentTargetHandle(&is_connected, handle, &dev_type);
+
+ unsigned int data_length = 10;
+ unsigned char data_array[data_length] = {'a', 'a', '\0'};
+ GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)"));
+ unsigned int i = 0;
+ while (i++ < data_length)
+ g_variant_builder_add(builder, "(y)", data_array[i]);
+
+ *data = g_variant_builder_end(builder);
+ g_variant_builder_unref(builder);
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_NDEF_PATH,
+ NFC_NDEF_INTERFACE,
+ "Write",
+ g_variant_new("(u@a(y))", *handle, *data),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(i)", &error);
+ GLOGD("ret = [%d]", error);
+ g_variant_unref(message);
+
+ if (pre_error != ERROR_NONE || is_connected == 0)
+ return ERROR_INVALID_OPERATION;
+
+ return error;
+}
+
+int Manager::MakeReadOnly(unsigned int *handle)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("MakeReadOnly()");
+
+ bool is_connected = 0;
+ int dev_type = 0;
+ int pre_error = this->GetCurrentTargetHandle(&is_connected, handle, &dev_type);
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_NDEF_PATH,
+ NFC_NDEF_INTERFACE,
+ "MakeReadOnly",
+ g_variant_new("(u)", *handle),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(i)", &error);
+ GLOGD("ret = [%d]", error);
+ g_variant_unref(message);
+
+ if (pre_error != ERROR_NONE)
+ return pre_error;
+ if (is_connected == 0)
+ return ERROR_INVALID_OPERATION;
+
+ return error;
+}
+
+int Manager::Format(unsigned int *handle, unsigned char *key, unsigned int key_length)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("Format()");
+
+ bool is_connected = 0;
+ int dev_type = 0;
+ int pre_error = this->GetCurrentTargetHandle(&is_connected, handle, &dev_type);
+
+ GVariant *key_var = NULL;
+ GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)"));
+ unsigned int i = 0;
+ while (i++ < key_length)
+ g_variant_builder_add(builder, "(y)", key[i]);
+
+ key_var = g_variant_builder_end(builder);
+ g_variant_builder_unref(builder);
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_NDEF_PATH,
+ NFC_NDEF_INTERFACE,
+ "Format",
+ g_variant_new("(u@a(y))", *handle, key_var),
+ &error);
+
+ if (message == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ }
+
+ g_variant_get(message, "(i)", &error);
+ GLOGD("ret = [%d]", error);
+ g_variant_unref(message);
+
+ if (pre_error != ERROR_NONE)
+ return pre_error;
+ if (is_connected == 0)
+ return ERROR_INVALID_OPERATION;
+
+ return error;
+}
+
+//===================== Llcp ======================
+
+int Manager::Config(unsigned short *c1, unsigned short *c2, unsigned char *c3, unsigned char *c4)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("Config()");
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_LLCP_PATH,
+ NFC_LLCP_INTERFACE,
+ "Config",
+ g_variant_new("((qqyy))", *c1, *c2, *c3, *c4),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(i)", &error);
+ GLOGD("ret = [%d]", error);
+ g_variant_unref(message);
+
+ return error;
+}
+
+int Manager::Listen(unsigned int *handle, unsigned int *client_socket, unsigned short *miu, unsigned char *rw, int *type, unsigned char *sap, char **service_name)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("Listen()");
+
+ char service_name_arr[] = "org.tizen.NetNfcService";
+ *service_name = service_name_arr;
+// bool is_connected = 0;
+// int dev_type = 0;
+// int pre_error = this->GetCurrentTargetHandle(&is_connected, handle, &dev_type);
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_LLCP_PATH,
+ NFC_LLCP_INTERFACE,
+ "Listen",
+ g_variant_new("(uuqyiys)", *handle, *client_socket, *miu, *rw, *type, *sap, *service_name),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(iu)", &error, client_socket);
+ GLOGD("ret = [%d: %u]", error, *client_socket);
+ g_variant_unref(message);
+
+// if (pre_error != ERROR_NONE || is_connected == 0)
+// return ERROR_INVALID_OPERATION;
+
+ return error;
+}
+
+int Manager::Accept(unsigned int *handle, unsigned int *client_socket)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("Accept()");
+
+// bool is_connected = 0;
+// int dev_type = 0;
+// int pre_error = this->GetCurrentTargetHandle(&is_connected, handle, &dev_type);
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_LLCP_PATH,
+ NFC_LLCP_INTERFACE,
+ "Accept",
+ g_variant_new("(uu)", *handle, *client_socket),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(i)", &error);
+ GLOGD("ret = [%d]", error);
+ g_variant_unref(message);
+
+// if (pre_error != ERROR_NONE || is_connected == 0)
+// return ERROR_INVALID_OPERATION;
+
+ return error;
+}
+
+/* LCOV_EXCL_START */
+int Manager::Reject(unsigned int *handle, unsigned int *client_socket)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("Reject()");
+
+// bool is_connected = 0;
+// int dev_type = 0;
+// int pre_error = this->GetCurrentTargetHandle(&is_connected, handle, &dev_type);
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_LLCP_PATH,
+ NFC_LLCP_INTERFACE,
+ "Reject",
+ g_variant_new("(uu)", *handle, *client_socket),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(i)", &error);
+ GLOGD("ret = [%d]", error);
+ g_variant_unref(message);
+
+// if (pre_error != ERROR_NONE || is_connected == 0)
+// return ERROR_INVALID_OPERATION;
+
+ return error;
+}
+
+int Manager::Connect(unsigned int *handle, unsigned int *client_socket, unsigned short *miu, unsigned char *rw, int *type, char **service_name)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("Connect()");
+
+ char service_name_arr[] = "org.tizen.NetNfcService";
+ *service_name = service_name_arr;
+// bool is_connected = 0;
+// int dev_type = 0;
+// int pre_error = this->GetCurrentTargetHandle(&is_connected, handle, &dev_type);
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_LLCP_PATH,
+ NFC_LLCP_INTERFACE,
+ "Connect",
+ g_variant_new("(uuqyis)", *handle, *client_socket, *miu, *rw, *type, *service_name),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(iu)", &error, client_socket);
+ GLOGD("ret = [%d: %u]", error, *client_socket);
+ g_variant_unref(message);
+
+// if (pre_error != ERROR_NONE || is_connected == 0)
+// return ERROR_INVALID_OPERATION;
+
+ return error;
+}
+
+int Manager::ConnectSap(unsigned int *handle, unsigned int *client_socket, unsigned short *miu, unsigned char *rw, int *type, unsigned char *sap)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("ConnectSap()");
+
+// bool is_connected = 0;
+// int dev_type = 0;
+// int pre_error = this->GetCurrentTargetHandle(&is_connected, handle, &dev_type);
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_LLCP_PATH,
+ NFC_LLCP_INTERFACE,
+ "ConnectSap",
+ g_variant_new("(uuqyiy)", *handle, *client_socket, *miu, *rw, *type, *sap),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(iu)", &error, client_socket);
+ GLOGD("ret = [%d: %u]", error, *client_socket);
+ g_variant_unref(message);
+
+// if (pre_error != ERROR_NONE || is_connected == 0)
+// return ERROR_INVALID_OPERATION;
+
+ return error;
+}
+
+int Manager::Send(unsigned int *handle, unsigned int *client_socket, GVariant **data)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("Send()");
+
+// bool is_connected = 0;
+// int dev_type = 0;
+// int pre_error = this->GetCurrentTargetHandle(&is_connected, handle, &dev_type);
+
+ unsigned int data_length = 10;
+ unsigned char data_array[data_length] = {'a', 'a', '\0'};
+ GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)"));
+ unsigned int i = 0;
+ while (i++ < data_length)
+ g_variant_builder_add(builder, "(y)", data_array[i]);
+
+ *data = g_variant_builder_end(builder);
+ g_variant_builder_unref(builder);
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_LLCP_PATH,
+ NFC_LLCP_INTERFACE,
+ "Send",
+ g_variant_new("(uu@a(y))", *handle, *client_socket, *data),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(iu)", &error, client_socket);
+ GLOGD("ret = [%d: %u]", error, *client_socket);
+ g_variant_unref(message);
+
+// if (pre_error != ERROR_NONE || is_connected == 0)
+// return ERROR_INVALID_OPERATION;
+
+ return error;
+}
+
+int Manager::SendTo(unsigned int *handle, unsigned int *client_socket, unsigned char *sap, GVariant **data)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("SendTo()");
+
+// bool is_connected = 0;
+// int dev_type = 0;
+// int pre_error = this->GetCurrentTargetHandle(&is_connected, handle, &dev_type);
+
+ unsigned int data_length = 10;
+ unsigned char data_array[data_length] = {'a', 'a', '\0'};
+ GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)"));
+ unsigned int i = 0;
+ while (i++ < data_length)
+ g_variant_builder_add(builder, "(y)", data_array[i]);
+
+ *data = g_variant_builder_end(builder);
+ g_variant_builder_unref(builder);
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_LLCP_PATH,
+ NFC_LLCP_INTERFACE,
+ "SendTo",
+ g_variant_new("(uuy@a(y))", *handle, *client_socket, *sap, *data),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(iu)", &error, client_socket);
+ GLOGD("ret = [%d: %u: ...]", error, *client_socket);
+ g_variant_unref(message);
+
+// if (pre_error != ERROR_NONE || is_connected == 0)
+// return ERROR_INVALID_OPERATION;
+
+ return error;
+}
+
+int Manager::Receive(unsigned int *handle, unsigned int *client_socket, unsigned int *request_length, GVariant **data)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("Receive()");
+
+// bool is_connected = 0;
+// int dev_type = 0;
+// int pre_error = this->GetCurrentTargetHandle(&is_connected, handle, &dev_type);
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_LLCP_PATH,
+ NFC_LLCP_INTERFACE,
+ "Receive",
+ g_variant_new("(uuu)", *handle, *client_socket, *request_length),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ GVariantIter *iter = NULL;
+ unsigned char endpoint = 0;
+ GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)"));
+
+ g_variant_get(message, "(ia(y))", &error, &iter);
+ GLOGD("ret = [%d: ...]", error);
+
+ while (g_variant_iter_loop(iter, "(y)", &endpoint))
+ g_variant_builder_add(builder, "(y)", endpoint);
+
+ *data = g_variant_builder_end(builder);
+ g_variant_builder_unref(builder);
+ g_variant_iter_free(iter);
+ g_variant_unref(message);
+
+// if (pre_error != ERROR_NONE || is_connected == 0)
+// return ERROR_INVALID_OPERATION;
+
+ return error;
+}
+
+int Manager::ReceiveFrom(unsigned int *handle, unsigned int *client_socket, unsigned int *request_length, unsigned char *sap, GVariant **data)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("ReceiveFrom()");
+
+ bool is_connected = 0;
+ int dev_type = 0;
+ int pre_error = this->GetCurrentTargetHandle(&is_connected, handle, &dev_type);
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_LLCP_PATH,
+ NFC_LLCP_INTERFACE,
+ "ReceiveFrom",
+ g_variant_new("(uuu)", *handle, *client_socket, *request_length),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ GVariantIter *iter = NULL;
+ unsigned char endpoint = 0;
+ GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)"));
+
+ g_variant_get(message, "(iya(y))", &error, sap, &iter);
+ GLOGD("ret = [%d: %c: ...]", error, *sap);
+
+ while (g_variant_iter_loop(iter, "(y)", &endpoint))
+ g_variant_builder_add(builder, "(y)", endpoint);
+
+ *data = g_variant_builder_end(builder);
+ g_variant_builder_unref(builder);
+ g_variant_iter_free(iter);
+ g_variant_unref(message);
+
+ if (pre_error != ERROR_NONE || is_connected == 0)
+ return ERROR_INVALID_OPERATION;
+
+ return error;
+}
+/* LCOV_EXCL_STOP */
+
+int Manager::Close(unsigned int *handle, unsigned int *client_socket)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("Close()");
+
+// bool is_connected = 0;
+// int dev_type = 0;
+// int pre_error = this->GetCurrentTargetHandle(&is_connected, handle, &dev_type);
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_LLCP_PATH,
+ NFC_LLCP_INTERFACE,
+ "Close",
+ g_variant_new("(uu)", *handle, *client_socket),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(iu)", &error, client_socket);
+ GLOGD("ret = [%d: %u]", error, *client_socket);
+ g_variant_unref(message);
+
+// if (pre_error != ERROR_NONE || is_connected == 0)
+// return ERROR_INVALID_OPERATION;
+
+ return error;
+}
+
+/* LCOV_EXCL_START */
+int Manager::Disconnect(unsigned int *handle, unsigned int *client_socket)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("Disconnect()");
+
+// bool is_connected = 0;
+// int dev_type = 0;
+// int pre_error = this->GetCurrentTargetHandle(&is_connected, handle, &dev_type);
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_LLCP_PATH,
+ NFC_LLCP_INTERFACE,
+ "Disconnect",
+ g_variant_new("(uu)", *handle, *client_socket),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(iu)", &error, client_socket);
+ GLOGD("ret = [%d: %u]", error, *client_socket);
+ g_variant_unref(message);
+
+// if (pre_error != ERROR_NONE || is_connected == 0)
+// return ERROR_INVALID_OPERATION;
+
+ return error;
+}
+/* LCOV_EXCL_STOP */
+
+//===================== P2p ======================
+
+int Manager::SendPtop(int *type, GVariant **data, unsigned int *handle)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("SendPtop()");
+
+ bool is_connected = 0;
+ int dev_type = 0;
+ int pre_error = this->GetCurrentTargetHandle(&is_connected, handle, &dev_type);
+
+ unsigned int data_length = 10;
+ unsigned char data_array[data_length] = {'a', 'a', '\0'};
+ GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)"));
+ unsigned int i = 0;
+ while (i++ < data_length)
+ g_variant_builder_add(builder, "(y)", data_array[i]);
+
+ *data = g_variant_builder_end(builder);
+ g_variant_builder_unref(builder);
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_P2P_PATH,
+ NFC_P2P_INTERFACE,
+ "Send",
+ g_variant_new("(i@a(y)u)", *type, *data, *handle),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(i)", &error);
+ GLOGD("ret = [%d]", error);
+ g_variant_unref(message);
+
+ if (pre_error != ERROR_NONE || is_connected == 0)
+ return ERROR_INVALID_OPERATION;
+
+ return error;
+}
+
+//===================== Popup ======================
+
+int Manager::SetPopup(int *state, int *focus_state)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("SetPopup()");
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_POPUP_PATH,
+ NFC_POPUP_INTERFACE,
+ "Set",
+ g_variant_new("(ii)", *state, *focus_state),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(i)", &error);
+ GLOGD("ret = [%d]", error);
+ g_variant_unref(message);
+
+ return error;
+}
+
+int Manager::GetPopup(int *state)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("GetPopup()");
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_POPUP_PATH,
+ NFC_POPUP_INTERFACE,
+ "Get",
+ NULL,
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(ii)", &error, state);
+ GLOGD("ret = [%d: %d]", error, *state);
+ g_variant_unref(message);
+
+ return error;
+}
+
+//===================== SecureElement ======================
+
+int Manager::Set(int *type)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("Set()");
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_SECURE_ELEMENT_PATH,
+ NFC_SECURE_ELEMENT_INTERFACE,
+ "Set",
+ g_variant_new("(i)", *type),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(i)", &error);
+ GLOGD("ret = [%d]", error);
+ g_variant_unref(message);
+
+ return error;
+}
+
+int Manager::Get(int *type)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("Get()");
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_SECURE_ELEMENT_PATH,
+ NFC_SECURE_ELEMENT_INTERFACE,
+ "Get",
+ NULL,
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(ii)", &error, type);
+ GLOGD("ret = [%d: %d]", error, *type);
+ g_variant_unref(message);
+
+ return error;
+}
+
+int Manager::SetCardEmulation(int *mode)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("SetCardEmulation()");
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_SECURE_ELEMENT_PATH,
+ NFC_SECURE_ELEMENT_INTERFACE,
+ "SetCardEmulation",
+ g_variant_new("(i)", *mode),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(i)", &error);
+ GLOGD("ret = [%d]", error);
+ g_variant_unref(message);
+
+ return error;
+}
+
+int Manager::GetCardEmulation(int *type)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("GetCardEmulation()");
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_SECURE_ELEMENT_PATH,
+ NFC_SECURE_ELEMENT_INTERFACE,
+ "GetCardEmulation",
+ NULL,
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(ii)", &error, type);
+ GLOGD("ret = [%d: %d]", error, *type);
+ g_variant_unref(message);
+
+ return error;
+}
+
+int Manager::OpenSecureElement(int *type, unsigned int *handle)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("OpenSecureElement()");
+
+// int mode = 1;
+// int pre_error = SetCardEmulation(&mode);
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_SECURE_ELEMENT_PATH,
+ NFC_SECURE_ELEMENT_INTERFACE,
+ "OpenSecureElement",
+ g_variant_new("(i)", *type),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(iu)", &error, handle);
+ GLOGD("ret = [%d: %u]", error, *handle);
+ g_variant_unref(message);
+
+// if(pre_error != ERROR_NONE)
+// return ERROR_INVALID_OPERATION;
+
+ return error;
+}
+
+int Manager::CloseSecureElement(unsigned int *handle)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("CloseSecureElement()");
+
+ int type = 1;
+ int pre_error = this->OpenSecureElement(&type, handle);
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_SECURE_ELEMENT_PATH,
+ NFC_SECURE_ELEMENT_INTERFACE,
+ "CloseSecureElement",
+ g_variant_new("(u)", *handle),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(i)", &error);
+ GLOGD("ret = [%d]", error);
+ g_variant_unref(message);
+
+ if(pre_error != ERROR_NONE)
+ return ERROR_INVALID_OPERATION;
+
+ return error;
+}
+
+int Manager::GetAtr(unsigned int *handle, GVariant **atr)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("GetAtr()");
+
+ int type = 1;
+ int pre_error = this->OpenSecureElement(&type, handle);
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_SECURE_ELEMENT_PATH,
+ NFC_SECURE_ELEMENT_INTERFACE,
+ "GetAtr",
+ g_variant_new("(u)", *handle),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ GVariantIter *iter = NULL;
+ unsigned char endpoint = 0;
+ GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)"));
+
+ g_variant_get(message, "(ia(y))", &error, &iter);
+ GLOGD("ret = [%d: ...]", error);
+
+ while (g_variant_iter_loop(iter, "(y)", &endpoint))
+ g_variant_builder_add(builder, "(y)", endpoint);
+
+ *atr = g_variant_builder_end(builder);
+ g_variant_builder_unref(builder);
+ g_variant_iter_free(iter);
+ g_variant_unref(message);
+
+ if(pre_error != ERROR_NONE)
+ return ERROR_INVALID_OPERATION;
+
+ return error;
+}
+
+int Manager::SendAPDU(unsigned int *handle, GVariant **data, GVariant **response)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("SendAPDU()");
+
+ int type = 1;
+ int pre_error = this->OpenSecureElement(&type, handle);
+
+ unsigned int data_length = 10;
+ unsigned char data_array[data_length] = {'a', 'a', '\0'};
+ GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)"));
+ unsigned int i = 0;
+ while (i++ < data_length)
+ g_variant_builder_add(builder, "(y)", data_array[i]);
+
+ *data = g_variant_builder_end(builder);
+ g_variant_builder_unref(builder);
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_SECURE_ELEMENT_PATH,
+ NFC_SECURE_ELEMENT_INTERFACE,
+ "SendAPDU",
+ g_variant_new("(u@a(y))", *handle, *data),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ GVariantIter *iter = NULL;
+ unsigned char endpoint = 0;
+ builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)"));
+
+ g_variant_get(message, "(ia(y))", &error, &iter);
+ GLOGD("ret = [%d: ...]", error);
+
+ while (g_variant_iter_loop(iter, "(y)", &endpoint))
+ g_variant_builder_add(builder, "(y)", endpoint);
+
+ *response = g_variant_builder_end(builder);
+ g_variant_builder_unref(builder);
+ g_variant_iter_free(iter);
+ g_variant_unref(message);
+
+ if(pre_error != ERROR_NONE)
+ return ERROR_INVALID_OPERATION;
+
+ return error;
+}
+
+int Manager::SetTransactionFgDispatch(int *mode)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("SetTransactionFgDispatch()");
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_SECURE_ELEMENT_PATH,
+ NFC_SECURE_ELEMENT_INTERFACE,
+ "SetTransactionFgDispatch",
+ g_variant_new("(i)", *mode),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(i)", &error);
+ GLOGD("ret = [%d]", error);
+ g_variant_unref(message);
+
+ return error;
+}
+
+int Manager::SetDefaultRoute(unsigned int *switch_on, unsigned int *switch_off, unsigned int *battery_off)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("SetDefaultRoute()");
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_SECURE_ELEMENT_PATH,
+ NFC_SECURE_ELEMENT_INTERFACE,
+ "SetDefaultRoute",
+ g_variant_new("(uuu)", *switch_on, *switch_off, *battery_off),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(i)", &error);
+ GLOGD("ret = [%d]", error);
+ g_variant_unref(message);
+
+ return error;
+}
+
+int Manager::SetPreferredHandler(bool *state)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("SetPreferredHandler()");
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_SECURE_ELEMENT_PATH,
+ NFC_SECURE_ELEMENT_INTERFACE,
+ "SetPreferredHandler",
+ g_variant_new("(b)", *state),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(i)", &error);
+ GLOGD("ret = [%d]", error);
+ g_variant_unref(message);
+
+ return error;
+}
+
+int Manager::CheckTransactionPermission(GVariant **aid)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("CheckTransactionPermission()");
+
+ unsigned int data_length = 10;
+ unsigned char data_array[data_length] = {'a', 'a', '\0'};
+ GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)"));
+ unsigned int i = 0;
+ while (i++ < data_length)
+ g_variant_builder_add(builder, "(y)", data_array[i]);
+
+ *aid = g_variant_builder_end(builder);
+ g_variant_builder_unref(builder);
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_SECURE_ELEMENT_PATH,
+ NFC_SECURE_ELEMENT_INTERFACE,
+ "CheckTransactionPermission",
+ g_variant_new("(@a(y))", *aid),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(i)", &error);
+ GLOGD("ret = [%d]", error);
+ g_variant_unref(message);
+
+ return error;
+}
+
+int Manager::IsActivatedAidHandler(unsigned int *type, char **aid, bool *activated)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("IsActivatedAidHandler()");
+
+ unsigned int data_length = 10;
+ char data_array[data_length] = {'a', 'a', '\0'};
+ *aid = &data_array[0];
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_SECURE_ELEMENT_PATH,
+ NFC_SECURE_ELEMENT_INTERFACE,
+ "IsActivatedAidHandler",
+ g_variant_new("(us)", *type, *aid),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(ib)", &error, activated);
+ GLOGD("ret = [%d: %d]", error, (int)*activated);
+ g_variant_unref(message);
+
+ return error;
+}
+
+int Manager::IsActivatedCategoryHandler(unsigned int *type, unsigned int *category, bool *activated)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("IsActivatedCategoryHandler()");
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_SECURE_ELEMENT_PATH,
+ NFC_SECURE_ELEMENT_INTERFACE,
+ "IsActivatedCategoryHandler",
+ g_variant_new("(uu)", *type, *category),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(ib)", &error, activated);
+ GLOGD("ret = [%d: %d]", error, (int)*activated);
+ g_variant_unref(message);
+
+ return error;
+}
+
+int Manager::GetRegisteredAids(unsigned int *type, unsigned int *category, GVariant **aids)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("GetRegisteredAids()");
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_SECURE_ELEMENT_PATH,
+ NFC_SECURE_ELEMENT_INTERFACE,
+ "GetRegisteredAids",
+ g_variant_new("(uu)", *type, *category),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ GVariantIter *iter = NULL;
+ char *aid_ptr = NULL;
+ bool bool_data = 0;
+ GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a(sb)"));
+
+ g_variant_get(message, "(ia(sb))", &error, &iter);
+ GLOGD("ret = [%d: ...]", error);
+
+ while (g_variant_iter_loop(iter, "(sb)", &aid_ptr, &bool_data))
+ g_variant_builder_add(builder, "(sb)", aid_ptr, bool_data);
+
+ *aids = g_variant_builder_end(builder);
+ g_variant_builder_unref(builder);
+ g_variant_iter_free(iter);
+ g_variant_unref(message);
+
+ return error;
+}
+
+int Manager::RegisterAid(unsigned int *type, unsigned int *category, char **aid)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("RegisterAid()");
+
+ unsigned int data_length = 10;
+ char data_array[data_length] = {'a', 'a', '\0'};
+ *aid = &data_array[0];
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_SECURE_ELEMENT_PATH,
+ NFC_SECURE_ELEMENT_INTERFACE,
+ "RegisterAid",
+ g_variant_new("(uus)", *type, *category, *aid),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(i)", &error);
+ GLOGD("ret = [%d]", error);
+ g_variant_unref(message);
+
+ return error;
+}
+
+int Manager::UnregisterAid(unsigned int *type, unsigned int *category, char **aid)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("UnregisterAid()");
+
+ unsigned int data_length = 10;
+ char data_array[data_length] = {'a', 'a', '\0'};
+ *aid = &data_array[0];
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_SECURE_ELEMENT_PATH,
+ NFC_SECURE_ELEMENT_INTERFACE,
+ "UnregisterAid",
+ g_variant_new("(uus)", *type, *category, *aid),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(i)", &error);
+ GLOGD("ret = [%d]", error);
+ g_variant_unref(message);
+
+ return error;
+}
+
+int Manager::UnregisterAids(unsigned int *type, unsigned int *category)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("UnregisterAids()");
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_SECURE_ELEMENT_PATH,
+ NFC_SECURE_ELEMENT_INTERFACE,
+ "UnregisterAids",
+ g_variant_new("(uu)", *type, *category),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(i)", &error);
+ GLOGD("ret = [%d]", error);
+ g_variant_unref(message);
+
+ return error;
+}
+
+
+int Manager::AddRouteAid(char **package, char **aid, unsigned int *se_type, unsigned int *category, bool *unlock, unsigned int *power)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("AddRouteAid()");
+
+ unsigned int data_length = 10;
+ char data_array[data_length] = {'a', 'a', '\0'};
+ *package = &data_array[0];
+ *aid = &data_array[0];
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_SECURE_ELEMENT_PATH,
+ NFC_SECURE_ELEMENT_INTERFACE,
+ "AddRouteAid",
+ g_variant_new("(ssuubu)", *package, *aid, *se_type, *category, *unlock, *power),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(i)", &error);
+ GLOGD("ret = [%d]", error);
+ g_variant_unref(message);
+
+ return error;
+}
+
+int Manager::RemoveRouteAid(char **package, char **aid)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("RemoveRouteAid()");
+
+ unsigned int data_length = 10;
+ char data_array[data_length] = {'a', 'a', '\0'};
+ *package = &data_array[0];
+ *aid = &data_array[0];
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_SECURE_ELEMENT_PATH,
+ NFC_SECURE_ELEMENT_INTERFACE,
+ "RemoveRouteAid",
+ g_variant_new("(ss)", *package, *aid),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(i)", &error);
+ GLOGD("ret = [%d]", error);
+ g_variant_unref(message);
+
+ return error;
+}
+
+int Manager::RemovePackageAids(char **package)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("RemovePackageAids()");
+
+ unsigned int data_length = 10;
+ char data_array[data_length] = {'a', 'a', '\0'};
+ *package = &data_array[0];
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_SECURE_ELEMENT_PATH,
+ NFC_SECURE_ELEMENT_INTERFACE,
+ "RemovePackageAids",
+ g_variant_new("(s)", *package),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(i)", &error);
+ GLOGD("ret = [%d]", error);
+ g_variant_unref(message);
+
+ return error;
+}
+
+int Manager::GetRegisteredHandlers(unsigned int *category, GVariant **packages)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("GetRegisteredHandlers()");
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_SECURE_ELEMENT_PATH,
+ NFC_SECURE_ELEMENT_INTERFACE,
+ "GetRegisteredHandlers",
+ g_variant_new("(u)", *category),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ GVariantIter *iter = NULL;
+ int int_data = 0;
+ char *str_ptr = NULL;
+ GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a(is)"));
+
+ g_variant_get(message, "(ia(is))", &error, &iter);
+ GLOGD("ret = [%d: ...]", error);
+
+ while (g_variant_iter_loop(iter, "(is)", &int_data, &str_ptr))
+ g_variant_builder_add(builder, "(is)", int_data, str_ptr);
+
+ *packages = g_variant_builder_end(builder);
+ g_variant_builder_unref(builder);
+ g_variant_iter_free(iter);
+ g_variant_unref(message);
+
+ return error;
+}
+
+int Manager::GetHandlerStorageInfo(unsigned int *category, int *used, int *maximum)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("GetHandlerStorageInfo()");
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_SECURE_ELEMENT_PATH,
+ NFC_SECURE_ELEMENT_INTERFACE,
+ "GetHandlerStorageInfo",
+ g_variant_new("(u)", *category),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(iii)", &error, used, maximum);
+ GLOGD("ret = [%d: %d: %d]", error, *used, *maximum);
+ g_variant_unref(message);
+
+ return error;
+}
+
+int Manager::GetConflictHandlers(char **package, unsigned int *category, char **aid, GVariant **packages)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("GetConflictHandlers()");
+
+ unsigned int data_length = 10;
+ char data_array[data_length] = {'a', 'a', '\0'};
+ *package = &data_array[0];
+ *aid = &data_array[0];
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_SECURE_ELEMENT_PATH,
+ NFC_SECURE_ELEMENT_INTERFACE,
+ "GetConflictHandlers",
+ g_variant_new("(sus)", *package, *category, *aid),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ GVariantIter *iter = NULL;
+ char *str_ptr = NULL;
+ GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a(s)"));
+
+ g_variant_get(message, "(ia(s))", &error, &iter);
+ GLOGD("ret = [%d: ...]", error);
+
+ while (g_variant_iter_loop(iter, "(s)", &str_ptr))
+ g_variant_builder_add(builder, "(s)", str_ptr);
+
+ *packages = g_variant_builder_end(builder);
+ g_variant_builder_unref(builder);
+ g_variant_iter_free(iter);
+ g_variant_unref(message);
+
+ return error;
+}
+
+//===================== Transceive ======================
+
+int Manager::TransceiveData(unsigned int *handle, unsigned int *dev_type, GVariant **data, GVariant **resp_data)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("TransceiveData()");
+
+ unsigned int data_length = 10;
+ unsigned char data_array[data_length] = {'a', 'a', '\0'};
+ GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)"));
+ unsigned int i = 0;
+ while (i++ < data_length)
+ g_variant_builder_add(builder, "(y)", data_array[i]);
+
+ *data = g_variant_builder_end(builder);
+ g_variant_builder_unref(builder);
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_TRANSCEIVE_PATH,
+ NFC_TRANSCEIVE_INTERFACE,
+ "TransceiveData",
+ g_variant_new("(uu@a(y))", *handle, *dev_type, *data),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ GVariantIter *iter = NULL;
+ unsigned char endpoint = 0;
+ builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)"));
+
+ g_variant_get(message, "(ia(y))", &error, &iter);
+ GLOGD("ret = [%d: ...]", error);
+
+ while (g_variant_iter_loop(iter, "(y)", &endpoint))
+ g_variant_builder_add(builder, "(y)", endpoint);
+
+ *resp_data = g_variant_builder_end(builder);
+ g_variant_builder_unref(builder);
+ g_variant_iter_free(iter);
+ g_variant_unref(message);
+
+ return error;
+}
+
+int Manager::Transceive(unsigned int *handle, unsigned int *dev_type, GVariant **data)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("Transceive()");
+
+ unsigned int data_length = 10;
+ unsigned char data_array[data_length] = {'a', 'a', '\0'};
+ GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)"));
+ unsigned int i = 0;
+ while (i++ < data_length)
+ g_variant_builder_add(builder, "(y)", data_array[i]);
+
+ *data = g_variant_builder_end(builder);
+ g_variant_builder_unref(builder);
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_TRANSCEIVE_PATH,
+ NFC_TRANSCEIVE_INTERFACE,
+ "Transceive",
+ g_variant_new("(uu@a(y))", *handle, *dev_type, *data),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(i)", &error);
+ GLOGD("ret = [%d]", error);
+ g_variant_unref(message);
+
+ return error;
+}
+
+//===================== Handover ======================
+
+int Manager::Request(unsigned int *handle, int *type, int *carrier_type, GVariant **handover_data)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("Request()");
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_HANDOVER_PATH,
+ NFC_HANDOVER_INTERFACE,
+ "Request",
+ g_variant_new("(ui)", *handle, *type),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ GVariantIter *iter = NULL;
+ unsigned char endpoint = 0;
+ GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)"));
+
+ g_variant_get(message, "(iia(y))", &error, carrier_type, &iter);
+ GLOGD("ret = [%d: %d: ...]", error, *carrier_type);
+
+ while (g_variant_iter_loop(iter, "(y)", &endpoint))
+ g_variant_builder_add(builder, "(y)", endpoint);
+
+ *handover_data = g_variant_builder_end(builder);
+ g_variant_builder_unref(builder);
+ g_variant_iter_free(iter);
+ g_variant_unref(message);
+
+ return error;
+}
+
+//===================== Test ======================
+
+int Manager::SimTest()
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("SimTest()");
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_TEST_PATH,
+ NFC_TEST_INTERFACE,
+ "SimTest",
+ NULL,
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(i)", &error);
+ GLOGD("ret = [%d]", error);
+ g_variant_unref(message);
+
+ return error;
+}
+
+int Manager::PrbsTest(unsigned int *tech, unsigned int *rate)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("PrbsTest()");
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_TEST_PATH,
+ NFC_TEST_INTERFACE,
+ "PrbsTest",
+ g_variant_new("(uu)", *tech, *rate),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(i)", &error);
+ GLOGD("ret = [%d]", error);
+ g_variant_unref(message);
+
+ return error;
+}
+
+int Manager::GetFirmwareVersion(GVariant **version)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("GetFirmwareVersion()");
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_TEST_PATH,
+ NFC_TEST_INTERFACE,
+ "GetFirmwareVersion",
+ NULL,
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ char *ptr = NULL;
+
+ g_variant_get(message, "(is)", &error, &ptr);
+ GLOGD("ret = [%d: %s]", error, ptr);
+
+ *version = g_variant_new("(s)", ptr);
+ g_variant_unref(message);
+
+ return error;
+}
+
+int Manager::SetEeData(unsigned int *mode, unsigned int *reg_id, GVariant **data)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("SetEeData()");
+
+ unsigned int data_length = 10;
+ unsigned char data_array[data_length] = {'a', 'a', '\0'};
+ GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)"));
+ unsigned int i = 0;
+ while (i++ < data_length)
+ g_variant_builder_add(builder, "(y)", data_array[i]);
+
+ *data = g_variant_builder_end(builder);
+ g_variant_builder_unref(builder);
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_TEST_PATH,
+ NFC_TEST_INTERFACE,
+ "SetEeData",
+ g_variant_new("(uu@a(y))", *mode, *reg_id, *data),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(i)", &error);
+ GLOGD("ret = [%d]", error);
+ g_variant_unref(message);
+
+ return error;
+}
+
+int Manager::EseTest()
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("EseTest()");
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_TEST_PATH,
+ NFC_TEST_INTERFACE,
+ "EseTest",
+ NULL,
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(i)", &error);
+ GLOGD("ret = [%d]", error);
+ g_variant_unref(message);
+
+ return error;
+}
+
+int Manager::SetSeTechType(unsigned int *type, unsigned int *tech)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("SetSeTechType()");
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_TEST_PATH,
+ NFC_TEST_INTERFACE,
+ "SetSeTechType",
+ g_variant_new("(uu)", *type, *tech),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(i)", &error);
+ GLOGD("ret = [%d]", error);
+ g_variant_unref(message);
+
+ return error;
+}
+
+int Manager::SetListenTechMask(unsigned int *tech)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("SetListenTechMask()");
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_TEST_PATH,
+ NFC_TEST_INTERFACE,
+ "SetListenTechMask",
+ g_variant_new("(u)", *tech),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(i)", &error);
+ GLOGD("ret = [%d]", error);
+ g_variant_unref(message);
+
+ return error;
+}
+
+//===================== Snep ======================
+
+int Manager::ServerRegister(unsigned int *sap, char **san, unsigned int *user_data)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("ServerRegister()");
+
+ unsigned int data_length = 10;
+ char data_array[data_length] = {'a', 'a', '\0'};
+ *san = &data_array[0];
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_SNEP_PATH,
+ NFC_SNEP_INTERFACE,
+ "ServerRegister",
+ g_variant_new("(usu)", *sap, *san, *user_data),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(i)", &error);
+ GLOGD("ret = [%d]", error);
+ g_variant_unref(message);
+
+ return error;
+}
+
+int Manager::ServerUnregister(unsigned int *sap, char **san)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("ServerUnregister()");
+
+ unsigned int data_length = 10;
+ char data_array[data_length] = {'a', 'a', '\0'};
+ *san = &data_array[0];
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_SNEP_PATH,
+ NFC_SNEP_INTERFACE,
+ "ServerUnregister",
+ g_variant_new("(us)", *sap, *san),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(i)", &error);
+ GLOGD("ret = [%d]", error);
+ g_variant_unref(message);
+
+ return error;
+}
+
+int Manager::ServerStart(unsigned int *handle, unsigned int *sap, char **san, unsigned int *user_data)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("ServerStart()");
+
+ unsigned int data_length = 10;
+ char data_array[data_length] = {'a', 'a', '\0'};
+ *san = &data_array[0];
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_SNEP_PATH,
+ NFC_SNEP_INTERFACE,
+ "ServerStart",
+ g_variant_new("(uusu)", *handle, *sap, *san, *user_data),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(i)", &error);
+ GLOGD("ret = [%d]", error);
+ g_variant_unref(message);
+
+ return error;
+}
+
+int Manager::ClientStart(unsigned int *handle, unsigned int *sap, char **san, unsigned int *user_data)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("ClientStart()");
+
+ unsigned int data_length = 10;
+ char data_array[data_length] = {'a', 'a', '\0'};
+ *san = &data_array[0];
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_SNEP_PATH,
+ NFC_SNEP_INTERFACE,
+ "ClientStart",
+ g_variant_new("(uusu)", *handle, *sap, *san, *user_data),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(i)", &error);
+ GLOGD("ret = [%d]", error);
+ g_variant_unref(message);
+
+ return error;
+}
+
+int Manager::ClientRequest(unsigned int *snep_handle, unsigned int *type, GVariant **ndef_msg, GVariant **data)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("ClientRequest()");
+
+ unsigned int data_length = 10;
+ unsigned char data_array[data_length] = {'a', 'a', '\0'};
+ GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)"));
+ unsigned int i = 0;
+ while (i++ < data_length)
+ g_variant_builder_add(builder, "(y)", data_array[i]);
+
+ *ndef_msg = g_variant_builder_end(builder);
+ g_variant_builder_unref(builder);
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_SNEP_PATH,
+ NFC_SNEP_INTERFACE,
+ "ClientRequest",
+ g_variant_new("(uu@a(y))", *snep_handle, *type, *ndef_msg),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ GVariantIter *iter = NULL;
+ unsigned char endpoint = 0;
+ builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)"));
+
+ g_variant_get(message, "(iua(y))", &error, type, &iter);
+ GLOGD("ret = [%d: %d: ...]", error, *type);
+
+ while (g_variant_iter_loop(iter, "(y)", &endpoint))
+ g_variant_builder_add(builder, "(y)", endpoint);
+
+ *data = g_variant_builder_end(builder);
+ g_variant_builder_unref(builder);
+ g_variant_iter_free(iter);
+ g_variant_unref(message);
+
+ return error;
+}
+
+int Manager::StopSnep(unsigned int *handle, unsigned int *snep_handle)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("StopSnep()");
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_SNEP_PATH,
+ NFC_SNEP_INTERFACE,
+ "StopSnep",
+ g_variant_new("(uu)", *handle, *snep_handle),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(i)", &error);
+ GLOGD("ret = [%d]", error);
+ g_variant_unref(message);
+
+ return error;
+}
+
+//===================== Hce ======================
+
+int Manager::StartHceHandler()
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("StartHceHandler()");
+
+ int pre_error = this->SetActive(true);
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_HCE_PATH,
+ NFC_HCE_INTERFACE,
+ "StartHceHandler",
+ NULL,
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(i)", &error);
+ GLOGD("ret = [%d]", error);
+ g_variant_unref(message);
+
+ if (pre_error != ERROR_NONE)
+ return pre_error;
+
+ return error;
+}
+
+int Manager::StopHceHandler()
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("StopHceHandler()");
+
+ int pre_error = this->SetActive(true);
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_HCE_PATH,
+ NFC_HCE_INTERFACE,
+ "StopHceHandler",
+ NULL,
+ &error);
+
+ if (message == NULL) {
+ GLOGD("Failed to invoke dbus method");
+ return error;
+ }
+
+ g_variant_get(message, "(i)", &error);
+ GLOGD("ret = [%d]", error);
+ g_variant_unref(message);
+
+ if (pre_error != ERROR_NONE)
+ return pre_error;
+
+ return error;
+}
+
+int Manager::ResponseApdu(unsigned int *handle, GVariant **data)
+{
+ GVariant *message = NULL;
+ int error = ERROR_NONE;
+
+ GLOGD("ResponseApdu()");
+
+ bool is_connected = 0;
+ int dev_type = 0;
+ int pre_error = this->GetCurrentTargetHandle(&is_connected, handle, &dev_type);
+
+ unsigned int data_length = 10;
+ unsigned char data_array[data_length] = {'a', 'a', '\0'};
+ GVariantBuilder *builder = g_variant_builder_new(G_VARIANT_TYPE("a(y)"));
+ unsigned int i = 0;
+ while (i++ < data_length)
+ g_variant_builder_add(builder, "(y)", data_array[i]);
+
+ *data = g_variant_builder_end(builder);
+ g_variant_builder_unref(builder);
+
+ message = InvokeMethod(NFC_MGR_SERVICE,
+ NFC_HCE_PATH,
+ NFC_HCE_INTERFACE,
+ "ResponseApdu",
+ g_variant_new("(u@a(y))", *handle, *data),
+ &error);
+
+ if (message == NULL)
+ return error;
+
+ g_variant_get(message, "(i)", &error);
+ GLOGD("ret = [%d]", error);
+ g_variant_unref(message);
+
+ if (pre_error != ERROR_NONE || is_connected == 0)
+ return ERROR_INVALID_OPERATION;
+
+ return error;
+}
--- /dev/null
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef __NFC_MGR_MANAGER_H__
+#define __NFC_MGR_MANAGER_H__
+
+#include "nfcmgr.h"
+#include "gdbus.h"
+
+#define WMESHD_STATION_TYPE_MESH_POINT 0
+
+class Manager:public GDbus {
+private:
+public:
+ Manager();
+ ~Manager();
+
+//===================== Manager ======================
+
+ int SetActive(bool is_active);
+ int GetServerState(unsigned int *state);
+
+//===================== Tag ======================
+
+ int IsTagConnected(bool *is_connected, int *dev_type);
+ int GetCurrentTagInfo(bool *is_connected, unsigned int *handle, int *dev_type, bool *is_ndef_supported, unsigned char *ndef_card_state,
+ unsigned int *max_data_size, unsigned int *actual_data_size, unsigned int *number_of_keys, GVariant **target_info_values, GVariant **raw_data);
+ int GetBarcode(GVariant **barcode);
+ int GetCurrentTargetHandle(bool *is_connected, unsigned int *handle, int *dev_type); //remove sleep and check it's effect
+
+//===================== Ndef ======================
+
+ int Read(unsigned int *handle, GVariant **data);
+ int Write(unsigned int *handle, GVariant **data);
+ int MakeReadOnly(unsigned int *handle);
+ int Format(unsigned int *handle, unsigned char *key, unsigned int key_length);
+
+
+//===================== Llcp ======================
+
+ int Config(unsigned short *c1, unsigned short *c2, unsigned char *c3, unsigned char *c4);
+ int Listen(unsigned int *handle, unsigned int *client_socket, unsigned short *miu, unsigned char *rw, int *type, unsigned char *sap, char **service_name);
+ int Accept(unsigned int *handle, unsigned int *client_socket);
+ int Reject(unsigned int *handle, unsigned int *client_socket);
+ int Connect(unsigned int *handle, unsigned int *client_socket, unsigned short *miu, unsigned char *rw, int *type, char **service_name);
+ int ConnectSap(unsigned int *handle, unsigned int *client_socket, unsigned short *miu, unsigned char *rw, int *type, unsigned char *sap);
+ int Send(unsigned int *handle, unsigned int *client_socket, GVariant **data);
+ int SendTo(unsigned int *handle, unsigned int *client_socket, unsigned char *sap, GVariant **data);
+ int Receive(unsigned int *handle, unsigned int *client_socket, unsigned int *request_length, GVariant **data);
+ int ReceiveFrom(unsigned int *handle, unsigned int *client_socket, unsigned int *request_length, unsigned char *sap, GVariant **data);
+ int Close(unsigned int *handle, unsigned int *client_socket);
+ int Disconnect(unsigned int *handle, unsigned int *client_socket);
+
+
+
+
+//===================== P2p ======================
+
+ int SendPtop(int *type, GVariant **data, unsigned int *handle);
+
+//===================== Popup ======================
+
+ int SetPopup(int *state, int *focus_state);
+ int GetPopup(int *state);
+
+//===================== SecureElement ======================
+
+ int Set(int *type);
+ int Get(int *type);
+ int SetCardEmulation(int *mode);
+ int GetCardEmulation(int *type);
+ int OpenSecureElement(int *type, unsigned int *handle);
+ int CloseSecureElement(unsigned int *handle);
+ int GetAtr(unsigned int *handle, GVariant **atr);
+ int SendAPDU(unsigned int *handle, GVariant **data, GVariant **response);
+
+ int SetTransactionFgDispatch(int *mode);
+ int SetDefaultRoute(unsigned int *switch_on, unsigned int *switch_off, unsigned int *battery_off);
+ int SetPreferredHandler(bool *state);
+ int CheckTransactionPermission(GVariant **aid);
+ int IsActivatedAidHandler(unsigned int *type, char **aid, bool *activated);
+ int IsActivatedCategoryHandler(unsigned int *type, unsigned int *category, bool *activated);
+ int GetRegisteredAids(unsigned int *type, unsigned int *category, GVariant **aids);
+ int RegisterAid(unsigned int *type, unsigned int *category, char **aid);
+ int UnregisterAid(unsigned int *type, unsigned int *category, char **aid);
+ int UnregisterAids(unsigned int *type, unsigned int *category);
+ int AddRouteAid(char **package, char **aid, unsigned int *se_type, unsigned int *category, bool *unlock, unsigned int *power);
+ int RemoveRouteAid(char **package, char **aid);
+ int RemovePackageAids(char **package);
+ int GetRegisteredHandlers(unsigned int *category, GVariant **packages);
+ int GetHandlerStorageInfo(unsigned int *category, int *used, int *maximum);
+ int GetConflictHandlers(char **package, unsigned int *category, char **aid, GVariant **packages);
+
+//===================== Transceive ======================
+
+ int TransceiveData(unsigned int *handle, unsigned int *dev_type, GVariant **data, GVariant **resp_data);
+ int Transceive(unsigned int *handle, unsigned int *dev_type, GVariant **data);
+
+//===================== Handover ======================
+
+ int Request(unsigned int *handle, int *type, int *carrier_type, GVariant **handover_data);
+
+//===================== Test ======================
+
+ int SimTest();
+ int PrbsTest(unsigned int *tech, unsigned int *rate);
+ int GetFirmwareVersion(GVariant **version);
+ int SetEeData(unsigned int *mode, unsigned int *reg_id, GVariant **data);
+ int EseTest();
+ int SetSeTechType(unsigned int *type, unsigned int *tech);
+ int SetListenTechMask(unsigned int *tech);
+
+//===================== Snep ======================
+
+ int ServerRegister(unsigned int *sap, char **san, unsigned int *user_data);
+ int ServerUnregister(unsigned int *sap, char **san);
+ int ServerStart(unsigned int *handle, unsigned int *sap, char **san, unsigned int *user_data);
+ int ClientStart(unsigned int *handle, unsigned int *sap, char **san, unsigned int *user_data);
+ int ClientRequest(unsigned int *snep_handle, unsigned int *type, GVariant **ndef_msg, GVariant **data);
+ int StopSnep(unsigned int *handle, unsigned int *snep_handle);
+
+//===================== Hce ======================
+
+ int StartHceHandler();
+ int StopHceHandler();
+ int ResponseApdu(unsigned int *handle, GVariant **data);
+
+};
+#endif /* __NFC_MGR_MANAGER_H__ */
+
+
--- /dev/null
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+#ifndef __NFC_MGR_H__
+#define __NFC_MGR_H__
+
+#include <glib.h>
+
+#ifdef USE_DLOG
+#include <dlog.h>
+#undef LOG_TAG
+#define LOG_TAG "NFC_MGR_GTEST"
+#define GLOGD(format, args...) LOGD(format, ##args)
+#else
+#define GLOGD(format, args...)
+#endif
+
+typedef enum {
+ ERROR_NONE = 0,
+ ERROR_NOT_PERMITTED = -1,
+ ERROR_OUT_OF_MEMORY = -2,
+ ERROR_PERMISSION_DENIED = -3,
+ ERROR_RESOURCE_BUSY = -4,
+ ERROR_INVALID_OPERATION = -5,
+ ERROR_INVALID_PARAMETER = -6,
+ ERROR_NOT_SUPPORTED = -7,
+ ERROR_OPERATION_FAILED = -8,
+ ERROR_NOT_INITIALIZED = -9,
+ ERROR_ALREADY_INITIALIZED = -10,
+ ERROR_IN_PROGRESS = -11,
+} error_e;
+
+
+#endif /* __NFC_MGR_H__ */
--- /dev/null
+/*
+ * Copyright (c) 2018 Samsung Electronics Co., Ltd All Rights Reserved
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <iostream>
+#include <gmock/gmock.h>
+#include <gtest/gtest.h>
+#include <system_info.h>
+
+#include "manager.h"
+
+using ::testing::InitGoogleTest;
+using ::testing::Test;
+using ::testing::TestCase;
+
+char *feature_name = (char *)"http://tizen.org/feature/network.nfc";
+
+int CheckFeature()
+{
+ bool nfc_supported = FALSE;
+ if (!system_info_get_platform_bool(feature_name, &nfc_supported)) {
+ if (FALSE == nfc_supported) {
+ GLOGD("nfc feature is disabled"); // LCOV_EXCL_LINE
+ return ERROR_NOT_SUPPORTED;
+ }
+ return ERROR_NONE;
+ } else {
+ GLOGD("Error - Feature getting from System Info"); // LCOV_EXCL_LINE
+ return ERROR_INVALID_PARAMETER;
+ }
+}
+
+//===================== Manager ======================
+
+TEST(nfc_gtest, SetActive_n)
+{
+ int ret = ERROR_NONE;
+ Manager mgr;
+
+ ret = mgr.SetActive(false);
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, SetActive_p)
+{
+ int ret = ERROR_NONE;
+ Manager mgr;
+
+ ret = mgr.SetActive(true);
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, GetServerState_p)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ unsigned int state = 0;
+
+ ret = mgr.GetServerState(&state);
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+//===================== Tag ======================
+
+TEST(nfc_gtest, IsTagConnected_p)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ bool is_connected = 0;
+ int dev_type = 0;
+
+ ret = mgr.IsTagConnected(&is_connected, &dev_type);
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, GetCurrentTagInfo_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ bool is_connected = 0;
+ unsigned int handle = 0;
+ int dev_type = 0;
+ bool is_ndef_supported = 0;
+ unsigned char ndef_card_state = 0;
+ unsigned int max_data_size = 0;
+ unsigned int actual_data_size = 0;
+ unsigned int number_of_keys = 0;
+ GVariant *target_info_values = NULL;
+ GVariant *raw_data = NULL;
+
+ ret = mgr.GetCurrentTagInfo(&is_connected,
+ &handle, &dev_type, &is_ndef_supported,
+ &ndef_card_state, &max_data_size,
+ &actual_data_size, &number_of_keys,
+ &target_info_values, &raw_data);
+
+ if(target_info_values)
+ g_variant_unref(target_info_values);
+ if(raw_data)
+ g_variant_unref(raw_data);
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, GetBarcode_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ GVariant *barcode = NULL;
+
+ ret = mgr.GetBarcode(&barcode);
+
+ if(barcode)
+ g_variant_unref(barcode);
+
+ EXPECT_EQ(ERROR_INVALID_OPERATION, ret);
+}
+
+TEST(nfc_gtest, GetCurrentTargetHandle_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ bool is_connected = 0;
+ unsigned int handle = 0;
+ int dev_type = 0;
+
+ ret = mgr.GetCurrentTargetHandle(&is_connected, &handle, &dev_type);
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+//===================== Ndef ======================
+
+TEST(nfc_gtest, Read_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ unsigned int handle = 0;
+ GVariant *data = NULL;
+
+ ret = mgr.Read(&handle, &data);
+
+ if (data)
+ g_variant_unref(data);
+
+ EXPECT_EQ(ERROR_INVALID_OPERATION, ret);
+}
+
+TEST(nfc_gtest, Write_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ unsigned int handle = 0;
+ GVariant *data = NULL;
+
+ ret = mgr.Write(&handle, &data);
+
+ EXPECT_EQ(ERROR_INVALID_OPERATION, ret);
+}
+
+TEST(nfc_gtest, MakeReadOnly_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ unsigned int handle = 0;
+
+ ret = mgr.MakeReadOnly(&handle);
+
+ EXPECT_EQ(ERROR_INVALID_OPERATION, ret);
+}
+
+TEST(nfc_gtest, Format_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ unsigned int handle = 0;
+ unsigned int key_length = 4;
+ unsigned char key[key_length] = { 'a', 'a', 'a', 'a' };
+
+ ret = mgr.Format(&handle, key, key_length);
+
+ EXPECT_EQ(ERROR_INVALID_OPERATION, ret);
+}
+
+//===================== Llcp ======================
+
+TEST(nfc_gtest, Config_p)
+{
+ Manager mgr; // file: "net_nfc_server_llcp.c +860":- g_variant_get(arg_config, "(qqyy)", &data->miu, &data->wks, &data->lto, &data->option)
+ int ret = ERROR_NONE;
+ unsigned short c1 = 128; // default values from file "net_nfc_server_llcp.h"
+ unsigned short c2 = 1;
+ unsigned char c3 = 10;
+ unsigned char c4 = 0;
+
+ ret = mgr.Config(&c1, &c2, &c3, &c4);
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+unsigned int client_socket_value = 0;
+
+TEST(nfc_gtest, Listen_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ unsigned int handle = 0;
+ unsigned int client_socket = 0; // this value get returned also
+ unsigned short miu = 128;
+ unsigned char rw = 0;
+ int type = 1; // socket_type
+ unsigned char sap = 1; // SDP_SAP 1, IP_SAP 2, OBEX_SAP 3 // 1 gives 982: invalid handle, bind failed
+ char *service_name = NULL; // these lines at two places
+
+ ret = mgr.Listen(&handle, &client_socket, &miu, &rw, &type, &sap, &service_name);
+
+ client_socket_value = client_socket;
+
+ EXPECT_NE(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, Accept_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ unsigned int handle = 0;
+ unsigned int client_socket = 0;
+
+ ret = mgr.Accept(&handle, &client_socket);
+
+ EXPECT_NE(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, Close_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ unsigned int handle = 0;
+ unsigned int client_socket = 0;
+
+ ret = mgr.Close(&handle, &client_socket);
+
+ EXPECT_NE(ERROR_NONE, ret);
+}
+
+
+//===================== P2p ======================
+
+TEST(nfc_gtest, SendPtop_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ int type = 0;
+ GVariant *data = NULL;
+ unsigned int handle = 0;
+
+ ret = mgr.SendPtop(&type, &data, &handle);
+
+ EXPECT_EQ(ERROR_INVALID_OPERATION, ret);
+}
+
+//===================== Popup ======================
+
+TEST(nfc_gtest, SetPopup_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ int state = 0;
+ int focus_state = 0;
+
+ ret = mgr.SetPopup(&state, &focus_state);
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, GetPopup_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ int state = 0;
+
+ ret = mgr.GetPopup(&state);
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+//===================== SecureElement ======================
+
+TEST(nfc_gtest, Set_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ int type = 0; // se_type
+
+ ret = mgr.Set(&type);
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, Set_p)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ int type = 1;
+
+ ret = mgr.Set(&type);
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, Get_p)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ int type = 0; // check value of type in output, to be fetched
+
+ ret = mgr.Get(&type);
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, SetCardEmulation_p)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ int mode = 1; // 1 means ON
+
+ ret = mgr.SetCardEmulation(&mode);
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, GetCardEmulation_p)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ int type = 0; // to be fetched
+
+ ret = mgr.GetCardEmulation(&type);
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, OpenSecureElement_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ int type = 1; // its "se_type", -- is 4(hce) a valid option?
+ unsigned int handle = 0; // to be fetched
+
+ ret = mgr.OpenSecureElement(&type, &handle);
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, CloseSecureElement_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ unsigned int handle = 0;
+
+ ret = mgr.CloseSecureElement(&handle);
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, GetAtr_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ unsigned int handle = 0;
+ GVariant *atr = NULL;
+
+ ret = mgr.GetAtr(&handle, &atr);
+
+ if(atr)
+ g_variant_unref(atr);
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, SendAPDU_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ unsigned int handle = 0;
+ GVariant *data = NULL;
+ GVariant *response = NULL;
+
+ ret = mgr.SendAPDU(&handle, &data, &response);
+
+ if(response)
+ g_variant_unref(response);
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, SetTransactionFgDispatch_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ int mode = 0;
+
+ ret = mgr.SetTransactionFgDispatch(&mode);
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, SetDefaultRoute_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ unsigned int switch_on = 1;
+ unsigned int switch_off = 0;
+ unsigned int battery_off = 0;
+
+ ret = mgr.SetDefaultRoute(&switch_on, &switch_off, &battery_off);
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, SetPreferredHandler_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ bool state = 0; //net_nfc_secure_element_state_e (0-inactive, active)
+
+ ret = mgr.SetPreferredHandler(&state);
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, CheckTransactionPermission_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ GVariant *aid = NULL;
+
+ ret = mgr.CheckTransactionPermission(&aid);
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, IsActivatedAidHandler_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ unsigned int type = 1;
+ char *aid = NULL;
+ bool activated = 0;
+
+ ret = mgr.IsActivatedAidHandler(&type, &aid, &activated);
+
+ EXPECT_NE(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, IsActivatedCategoryHandler_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ unsigned int type = 1;
+ unsigned int category = 1;
+ bool activated = 0;
+
+ ret = mgr.IsActivatedCategoryHandler(&type, &category, &activated);
+
+ EXPECT_NE(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, GetRegisteredAids_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ unsigned int type = 1;
+ unsigned int category = 1;
+ GVariant *aids = NULL;
+
+ ret = mgr.GetRegisteredAids(&type, &category, &aids);
+
+ if(aids)
+ g_variant_unref(aids);
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, RegisterAid_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ unsigned int type = 1;
+ unsigned int category = 1; //net_nfc_card_emulation_category_t(0-unknown, payment, other, 3-max)
+ char *aid = NULL;
+
+ ret = mgr.RegisterAid(&type, &category, &aid);
+
+ EXPECT_NE(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, UnregisterAid_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ unsigned int type = 1;
+ unsigned int category = 1;
+ char *aid = NULL;
+
+ ret = mgr.UnregisterAid(&type, &category, &aid);
+
+ EXPECT_NE(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, UnregisterAids_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ unsigned int type = 1;
+ unsigned int category = 1;
+
+ ret = mgr.UnregisterAids(&type, &category);
+
+ EXPECT_NE(ERROR_NONE, ret);
+}
+
+
+TEST(nfc_gtest, AddRouteAid_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ char *package = NULL;
+ char *aid = NULL;
+ unsigned int se_type = 1;
+ unsigned int category = 1; //net_nfc_card_emulation_category_t
+ bool unlock = 1; // its value???
+ unsigned int power = 1;
+
+ ret = mgr.AddRouteAid(&package, &aid, &se_type, &category, &unlock, &power);
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, RemoveRouteAid_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ char *package = NULL;
+ char *aid = NULL;
+
+ ret = mgr.RemoveRouteAid(&package, &aid);
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, RemovePackageAids_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ char *package = NULL;
+
+ ret = mgr.RemovePackageAids(&package);
+
+ EXPECT_NE(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, GetRegisteredHandlers_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ unsigned int category = 1;
+ GVariant *packages = NULL;
+
+ ret = mgr.GetRegisteredHandlers(&category, &packages);
+
+ if(packages)
+ g_variant_unref(packages);
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, GetHandlerStorageInfo_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ unsigned int category = 1;
+ int used = 0;
+ int maximum = 0;
+
+ ret = mgr.GetHandlerStorageInfo(&category, &used, &maximum);
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, GetConflictHandlers_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ char *package = NULL;
+ unsigned int category = 1;
+ char *aid = NULL;
+ GVariant *packages = NULL;
+
+ ret = mgr.GetConflictHandlers(&package, &category, &aid, &packages);
+
+ if(packages)
+ g_variant_unref(packages);
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+//===================== Transceive ======================
+
+TEST(nfc_gtest, TransceiveData_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ unsigned int handle = 0;
+ unsigned int dev_type = 0;
+ GVariant *data = NULL;
+ GVariant *resp_data = NULL;
+
+ ret = mgr.TransceiveData(&handle, &dev_type, &data, &resp_data);
+
+ if(resp_data)
+ g_variant_unref(resp_data);
+
+ EXPECT_NE(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, Transceive_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ unsigned int handle = 0;
+ unsigned int dev_type = 0;
+ GVariant *data = NULL;
+
+ ret = mgr.Transceive(&handle, &dev_type, &data);
+
+ EXPECT_NE(ERROR_NONE, ret);
+}
+
+//===================== Handover ======================
+
+TEST(nfc_gtest, Request_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ unsigned int handle = 0;
+ int type = 4;
+ int carrier_type = 0;
+ GVariant *handover_data = NULL;
+
+ ret = mgr.Request(&handle, &type, &carrier_type, &handover_data);
+
+ if(handover_data)
+ g_variant_unref(handover_data);
+
+ EXPECT_NE(ERROR_NONE, ret);
+}
+
+//===================== Test ======================
+
+TEST(nfc_gtest, SimTest_p)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+
+ ret = mgr.SimTest();
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, PrbsTest_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ unsigned int tech = 0;
+ unsigned int rate = 0;
+
+ ret = mgr.PrbsTest(&tech, &rate);
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, GetFirmwareVersion_p)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ GVariant *version = NULL;
+
+ ret = mgr.GetFirmwareVersion(&version);
+
+ if (version)
+ g_variant_unref(version);
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, SetEeData_p)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ unsigned int mode = 1;
+ unsigned int reg_id = 0;
+ GVariant *data = NULL;
+
+ ret = mgr.SetEeData(&mode, ®_id, &data);
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, EseTest_p)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+
+ ret = mgr.EseTest();
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, SetSeTechType_p)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ unsigned int type = 1;
+ unsigned int tech = 0;
+
+ ret = mgr.SetSeTechType(&type, &tech);
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, SetListenTechMask_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ unsigned int tech = 0;
+
+ ret = mgr.SetListenTechMask(&tech);
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+//===================== Snep ======================
+
+TEST(nfc_gtest, ServerRegister_p)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ unsigned int sap = 0;
+ char *san = NULL;
+ unsigned int user_data = 0;
+
+ ret = mgr.ServerRegister(&sap, &san, &user_data);
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, ServerUnregister_p)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ unsigned int sap = 0;
+ char *san = NULL;
+ unsigned int user_data = 0;
+
+ ret = mgr.ServerRegister(&sap, &san, &user_data);
+ if (ret == ERROR_NONE) {
+ ret = mgr.ServerUnregister(&sap, &san);
+ }
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, ServerStart_p)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ unsigned int handle = 0;
+ unsigned int sap = 0;
+ char *san = NULL;
+ unsigned int user_data = 0;
+
+ ret = mgr.ServerStart(&handle, &sap, &san, &user_data);
+
+ EXPECT_NE(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, ClientStart_p)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ unsigned int handle = 0;
+ unsigned int sap = 0;
+ char *san = NULL;
+ unsigned int user_data = 0;
+
+ ret = mgr.ClientStart(&handle, &sap, &san, &user_data);
+
+ EXPECT_NE(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, ClientRequest_p)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ unsigned int snep_handle = 0;
+ unsigned int type = 0;
+ GVariant *ndef_msg = NULL;
+ GVariant *data = NULL;
+
+ ret = mgr.ClientRequest(&snep_handle, &type, &ndef_msg, &data);
+
+ if(data)
+ g_variant_unref(data);
+
+ EXPECT_NE(ERROR_NONE, ret);
+}
+
+TEST(nfc_gtest, StopSnep_p)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ unsigned int handle = 0;
+ unsigned int snep_handle = 0;
+
+ ret = mgr.StopSnep(&handle, &snep_handle);
+
+ EXPECT_EQ(ERROR_NONE, ret);
+}
+
+//===================== Hce ======================
+
+
+TEST(nfc_gtest, StartHceHandler_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+
+ ret = mgr.StartHceHandler();
+
+ EXPECT_EQ(-975, ret);
+}
+
+TEST(nfc_gtest, StopHceHandler_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+
+ ret = mgr.StopHceHandler();
+
+ EXPECT_EQ(-975, ret);
+}
+
+TEST(nfc_gtest, ResponseApdu_n)
+{
+ Manager mgr;
+ int ret = ERROR_NONE;
+ unsigned int handle = 0;
+ GVariant *data = NULL;
+
+ ret = mgr.ResponseApdu(&handle, &data);
+
+ EXPECT_EQ(ERROR_INVALID_OPERATION, ret);
+}
+
+// ********************************************
+
+int main(int argc, char **argv)
+{
+ int ret = 0;
+ ret = CheckFeature();
+
+ if (ERROR_NONE != ret)
+ return ret;
+
+ testing::InitGoogleTest(&argc, argv);
+ ret = RUN_ALL_TESTS();
+
+ return ret;
+}