* - %http://tizen.org/feature/network.secure_element\n
* - %http://tizen.org/feature/network.secure_element.ese\n
* - %http://tizen.org/feature/network.secure_element.uicc\n
+ * - %http://tizen.org/feature/network.secure_element.usb\n
* It is recommended to design feature related codes in your application for reliability.\n
*
* You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
* - %http://tizen.org/feature/network.secure_element\n
* - %http://tizen.org/feature/network.secure_element.ese\n
* - %http://tizen.org/feature/network.secure_element.uicc\n
+ * - %http://tizen.org/feature/network.secure_element.usb\n
* It is recommended to design feature related codes in your application for reliability.\n
*
* You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
* - %http://tizen.org/feature/network.secure_element\n
* - %http://tizen.org/feature/network.secure_element.ese\n
* - %http://tizen.org/feature/network.secure_element.uicc\n
+ * - %http://tizen.org/feature/network.secure_element.usb\n
* It is recommended to design feature related codes in your application for reliability.\n
*
* You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
* - %http://tizen.org/feature/network.secure_element\n
* - %http://tizen.org/feature/network.secure_element.ese\n
* - %http://tizen.org/feature/network.secure_element.uicc\n
+ * - %http://tizen.org/feature/network.secure_element.usb\n
* It is recommended to design feature related codes in your application for reliability.\n
*
* You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
* - %http://tizen.org/feature/network.secure_element\n
* - %http://tizen.org/feature/network.secure_element.ese\n
* - %http://tizen.org/feature/network.secure_element.uicc\n
+ * - %http://tizen.org/feature/network.secure_element.usb\n
* It is recommended to design feature related codes in your application for reliability.\n
*
* You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
* - %http://tizen.org/feature/network.secure_element\n
* - %http://tizen.org/feature/network.secure_element.ese\n
* - %http://tizen.org/feature/network.secure_element.uicc\n
+ * - %http://tizen.org/feature/network.secure_element.usb\n
* It is recommended to design feature related codes in your application for reliability.\n
*
* You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
* - %http://tizen.org/feature/network.secure_element\n
* - %http://tizen.org/feature/network.secure_element.ese\n
* - %http://tizen.org/feature/network.secure_element.uicc\n
+ * - %http://tizen.org/feature/network.secure_element.usb\n
* It is recommended to design feature related codes in your application for reliability.\n
*
* You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
* - %http://tizen.org/feature/network.secure_element\n
* - %http://tizen.org/feature/network.secure_element.ese\n
* - %http://tizen.org/feature/network.secure_element.uicc\n
+ * - %http://tizen.org/feature/network.secure_element.usb\n
* It is recommended to design feature related codes in your application for reliability.\n
*
* You can check if a device supports the related features for this API by using @ref CAPI_SYSTEM_SYSTEM_INFO_MODULE, thereby controlling the procedure of your application.\n
static void reader_removed(GObject *source_object,
guint reader_id, gchar *reader_name,
gpointer user_data);
+ static void card_inserted(GObject *source_object,
+ guint reader_id, gchar *reader_name,
+ gpointer user_data);
+ static void card_removed(GObject *source_object,
+ guint reader_id, gchar *reader_name,
+ gpointer user_data);
static void se_service_shutdown_cb(GObject *source_object,
GAsyncResult *res, gpointer user_data);
static void se_service_cb(GObject *source_object,
SMARTCARD_READER_EVENT_TYPE_IO_ERROR = 0, /**< This event notifies the application that I/O error occurs on smartcard reader */
SMARTCARD_READER_EVENT_TYPE_INSERTED = 1, /**< This event notifies the application that smartcard reader is inserted */
SMARTCARD_READER_EVENT_TYPE_REMOVED = 2, /**< This event notifies the application that smartcard reader is removed */
+ SMARTCARD_READER_EVENT_TYPE_CARD_INSERTED = 3, /**< This event notifies the application that smartcard reader is inserted (Since 6.5) */
+ SMARTCARD_READER_EVENT_TYPE_CARD_REMOVED = 4, /**< This event notifies the application that smartcard reader is removed (Since 6.5) */
} smartcard_reader_event_type_e;
/**
#ifndef __TIZEN_CAPI_NETWORK_SMARTCARD_DEBUG_H__
#define __TIZEN_CAPI_NETWORK_SMARTCARD_DEBUG_H__
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#define LOG_TAG "SMARTCARD_API"
+#endif
+
#define COLOR_BLACK "\033[0;30m"
#define COLOR_RED "\033[0;31m"
#define COLOR_GREEN "\033[0;32m"
} \
} while (0)
-#endif /* __TIZEN_CAPI_NETWORK_SMARTCARD_DEBUG_H__ */
\ No newline at end of file
+#endif /* __TIZEN_CAPI_NETWORK_SMARTCARD_DEBUG_H__ */
/* SLP library header */
/* local header */
-#include "Debug.h"
+#include "smartcard_debug.h"
#include "ClientChannel.h"
#include "ReaderHelper.h"
#include "APDUHelper.h"
/* local header */
#include "smartcard-types.h"
-#include "Debug.h"
+#include "smartcard_debug.h"
#include "ByteArray.h"
#include "ClientGDBus.h"
/* SLP library header */
/* local header */
-#include "Debug.h"
+#include "smartcard_debug.h"
#include "Reader.h"
#include "Session.h"
#include "ClientGDBus.h"
#include <stdlib.h>
/* local header */
-#include "Debug.h"
+#include "smartcard_debug.h"
#include "SEService.h"
#include "ClientChannel.h"
#include "Reader.h"
_INFO("[MSG_NOTIFY_SE_INSERTED]");
/* add readers */
- reader = new (std::nothrow)Reader(service->context,
+ reader = new (std::nothrow)Reader(GUINT_TO_POINTER(service->handle),
reader_name, GUINT_TO_POINTER(reader_id));
if (reader != NULL) {
}
}
+ void SEService::card_inserted(GObject *source_object,
+ guint reader_id, gchar *reader_name, gpointer user_data)
+ {
+ SEService *service = (SEService *)user_data;
+ size_t i;
+
+ _INFO("[MSG_NOTIFY_CARD_INSERTED]");
+
+ for (i = 0; i < service->readers.size(); i++)
+ {
+ if (((Reader *)service->readers[i])->handle ==
+ GUINT_TO_POINTER(reader_id))
+ {
+ if (service->event_handler != NULL)
+ service->event_handler((long)service->readers[i], 3, service->context);
+ break;
+ }
+ }
+ }
+
+ void SEService::card_removed(GObject *source_object,
+ guint reader_id, gchar *reader_name, gpointer user_data)
+ {
+ SEService *service = (SEService *)user_data;
+ size_t i;
+
+ _INFO("[MSG_NOTIFY_CARD_REMOVED]");
+
+ for (i = 0; i < service->readers.size(); i++)
+ {
+ if (((Reader *)service->readers[i])->handle ==
+ GUINT_TO_POINTER(reader_id))
+ {
+ _INFO("Here it is.");
+
+ if (service->event_handler != NULL)
+ service->event_handler((long)service->readers[i], 4, service->context);
+ break;
+ }
+ }
+ }
+
void SEService::se_service_shutdown_cb(GObject *source_object,
GAsyncResult *res, gpointer user_data)
{
g_signal_connect(proxy, "reader-removed",
G_CALLBACK(&SEService::reader_removed), this);
+ g_signal_connect(proxy, "card-inserted",
+ G_CALLBACK(&SEService::card_inserted), this);
+
+ g_signal_connect(proxy, "card-removed",
+ G_CALLBACK(&SEService::card_removed), this);
+
/* request reader */
if(smartcard_service_se_service_call_se_service_sync(
(SmartcardServiceSeService *)proxy, &result, &handle, &readers, NULL, &error) == true) {
for (i = 0; i < temp_readers.size(); i++)
{
if (temp_readers[i]->isSecureElementPresent()) {
- (*readers)[i] = (long)temp_readers[i];
+ (*readers)[temp] = (long)temp_readers[i];
temp++;
}
}
/* SLP library header */
/* local header */
-#include "Debug.h"
+#include "smartcard_debug.h"
#include "Session.h"
#include "Reader.h"
#include "ClientChannel.h"
#define SE_FEATURE "http://tizen.org/feature/network.secure_element"
#define SE_UICC_FEATURE "http://tizen.org/feature/network.secure_element.uicc"
#define SE_ESE_FEATURE "http://tizen.org/feature/network.secure_element.ese"
+#define SE_USB_FEATURE "http://tizen.org/feature/network.secure_element.usb"
#define SMARTCARD_LOCK \
do { \
bool is_supported_se = false;
bool is_supported_se_uicc = false;
bool is_supported_se_ese = false;
+ bool is_supported_se_usb = false;
system_info_get_platform_bool(SE_FEATURE, &is_supported_se);
system_info_get_platform_bool(SE_UICC_FEATURE, &is_supported_se_uicc);
system_info_get_platform_bool(SE_ESE_FEATURE, &is_supported_se_ese);
+ system_info_get_platform_bool(SE_USB_FEATURE, &is_supported_se_usb);
- if (is_supported_se && (is_supported_se_uicc || is_supported_se_ese))
+ if (is_supported_se && (is_supported_se_uicc || is_supported_se_ese || is_supported_se_usb))
ret = true;
return ret;
}
}
+void __smartcard_reader_event_cb(int reader, smartcard_reader_event_type_e event_type, void *user_data)
+{
+ int ret;
+ int session;
+ int channel;
+ int pLength;
+ int *phReaders = NULL;
+
+ unsigned char command[] = { 0xFF, 0xCA, 0x00, 0x00, 0x00 };
+ unsigned char *response = NULL;
+ int resp_len = 50;
+
+ if (event_type == SMARTCARD_READER_EVENT_TYPE_CARD_INSERTED) {
+ TC_PRT("smartcard inserted");
+
+ ret = smartcard_get_readers(&phReaders, &pLength);
+ if (ret != SMARTCARD_ERROR_NONE || pLength <= 0) {
+ TC_PRT("smartcard_get_readers failed : %d, %d", ret, pLength);
+ return;
+ }
+
+ for (int i = 0; i < pLength; i++) {
+ if (phReaders[i] == reader) {
+ ret = smartcard_reader_open_session(phReaders[i], &session);
+ if (ret != SMARTCARD_ERROR_NONE || session <= 0) {
+ TC_PRT("smartcard_reader_open_session failed");
+ return;
+ }
+
+ ret = smartcard_session_open_basic_channel(session, NULL, 0, 0x00, &channel);
+ if (ret != SMARTCARD_ERROR_NONE || channel <= 0) {
+ TC_PRT("smartcard_session_open_basic_channel failed");
+ return;
+ }
+
+ ret = smartcard_channel_transmit(channel, command, 5, &response, &resp_len);
+ if (ret != SMARTCARD_ERROR_NONE) {
+ TC_PRT("smartcard_channel_transmit failed");
+ return;
+ }
+
+ TC_PRT("response length %d", resp_len);
+ printf("\nAPDU : { ");
+ for (int i = 0; i < resp_len; i++) {
+ printf("0x%02X ", (int)response[i]);
+ }
+ printf("} \n\n");
+ }
+ }
+ } else if (event_type == SMARTCARD_READER_EVENT_TYPE_CARD_REMOVED) {
+ TC_PRT("smartcard removed");
+ } else if (event_type == SMARTCARD_READER_EVENT_TYPE_INSERTED) {
+ TC_PRT("reader inserted");
+ } else if (event_type == SMARTCARD_READER_EVENT_TYPE_REMOVED) {
+ TC_PRT("reader removed");
+ }
+}
+
int test_input_callback(void *data)
{
int ret = 0;
TC_PRT("smartcard initialize success");
else
TC_PRT("smartcard initialize failed");
+
+ smartcard_reader_set_event_cb(__smartcard_reader_event_cb, NULL);
+
+ TC_PRT("smartcard_reader_set_event_cb success");
}
break;
case 2:
if (ret == SMARTCARD_ERROR_NONE) {
TC_PRT("smartcard_get_readers is success");
- TC_PRT("reader handle : %d", phReaders[0]);
TC_PRT("readers length : %d", pLength);
+
+ if (pLength > 0)
+ TC_PRT("reader handle : %d", phReaders[0]);
+
} else {
TC_PRT("smartcard_get_readers is failed : %d", ret);
}
#define SE_FEATURE "http://tizen.org/feature/network.secure_element"
#define SE_UICC_FEATURE "http://tizen.org/feature/network.secure_element.uicc"
#define SE_ESE_FEATURE "http://tizen.org/feature/network.secure_element.ese"
+#define SE_ESE_FEATURE "http://tizen.org/feature/network.secure_element.usb"
bool _is_support_smartcard()
{
bool is_supported_se = false;
bool is_supported_se_uicc = false;
bool is_supported_se_ese = false;
+ bool is_supported_se_usb = false;
system_info_get_platform_bool(SE_FEATURE, &is_supported_se);
system_info_get_platform_bool(SE_UICC_FEATURE, &is_supported_se_uicc);
system_info_get_platform_bool(SE_ESE_FEATURE, &is_supported_se_ese);
+ system_info_get_platform_bool(SE_USB_FEATURE, &is_supported_se_usb);
- if(is_supported_se && (is_supported_se_uicc || is_supported_se_ese))
+ if(is_supported_se && (is_supported_se_uicc || is_supported_se_ese || is_supported_se_usb))
ret = true;
return ret;