From 3f5296b072da549c07a457bb0a38da6b7beff82b Mon Sep 17 00:00:00 2001 From: Jihoon Jung Date: Wed, 2 Mar 2016 19:27:48 +0900 Subject: [PATCH] NFC card emulation api ACR : preferred api Change-Id: If9f53bd8dd425da0b665f66bd79bead450cd2eec --- include/nfc.h | 57 +++++++++++++++++++++++++++++++++++++---- packaging/capi-network-nfc.spec | 2 +- src/nfc_card_emulation.c | 30 ++++++++++++++++++++++ 3 files changed, 83 insertions(+), 6 deletions(-) diff --git a/include/nfc.h b/include/nfc.h index 833a323..a9d78a8 100755 --- a/include/nfc.h +++ b/include/nfc.h @@ -843,7 +843,7 @@ bool nfc_manager_is_activated(void); * * @see nfc_manager_deinitialize() */ -int nfc_manager_initialize(); +int nfc_manager_initialize(void); /** * @brief Releases all the resource of the NFC Manager and disconnect the session between an application and NFC Manager. @@ -1117,7 +1117,7 @@ void nfc_manager_unset_hce_event_cb(void); * @see nfc_manager_disable_transaction_fg_dispatch() * @see nfc_manager_initialize() */ -int nfc_manager_enable_transaction_fg_dispatch(); +int nfc_manager_enable_transaction_fg_dispatch(void); /** * @brief disable foreground dispatch for "EVT_TRANSACTION" to the givin application. @@ -1145,7 +1145,7 @@ int nfc_manager_enable_transaction_fg_dispatch(); * @see nfc_manager_enable_transaction_fg_dispatch() * @see nfc_manager_initialize() */ -int nfc_manager_disable_transaction_fg_dispatch(); +int nfc_manager_disable_transaction_fg_dispatch(void); /** * @brief Gets NDEF message cached when the tag is detected or when data received from NFC peer-to-peer target. @@ -2827,7 +2827,7 @@ int nfc_snep_unregister_server(const char *san, int sap); * @see nfc_se_disable_card_emulation() * @see nfc_manager_initialize() */ -int nfc_se_enable_card_emulation(); +int nfc_se_enable_card_emulation(void); /** * @brief Disable card emulation mode. @@ -2855,7 +2855,7 @@ int nfc_se_enable_card_emulation(); * @see nfc_se_enable_card_emulation() * @see nfc_manager_initialize() */ -int nfc_se_disable_card_emulation(); +int nfc_se_disable_card_emulation(void); /** * @brief Get the current card emulation mode. @@ -3058,6 +3058,53 @@ int nfc_se_unregister_aid(nfc_se_type_e se_type, nfc_card_emulation_category_typ */ int nfc_se_foreach_registered_aids(nfc_se_type_e se_type, nfc_card_emulation_category_type_e category, nfc_se_registered_aid_cb callback, void *user_data); +/** + * @brief Sets the application as a preferred handler. + * @since_tizen 3.0 + * @details This api is possible to call when your application is in the foreground.\n + * We recommend that you call api when the app state is resume. + * @privlevel public + * @privilege %http://tizen.org/privilege/nfc.cardemulation + * @ingroup CAPI_NETWORK_NFC_SE_MODULE + * + * @retval #NFC_ERROR_NONE Successful + * @retval #NFC_ERROR_NOT_SUPPORTED Not supported NFC + * @retval #NFC_ERROR_NOT_INITIALIZED Not initialized NFC + * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated + * @retval #NFC_ERROR_OPERATION_FAILED Operation failed + * @retval #NFC_ERROR_PERMISSION_DENIED Permission denied + * + * @see nfc_manager_initialize() + * @see nfc_se_unset_preferred_handler() + * + */ +int nfc_se_set_preferred_handler(void); + + +/** + * @brief Unsets the application as a preferred handler. + * @since_tizen 3.0 + * @details We recommend that you call api when the app state is pause.\n + * If you do not call the api, Tizen will initialize the preferred app properly.\n + * But there may be a problem with the performance, we recommend your explicit call. + * + * @privlevel public + * @privilege %http://tizen.org/privilege/nfc.cardemulation + * @ingroup CAPI_NETWORK_NFC_SE_MODULE + * + * @retval #NFC_ERROR_NONE Successful + * @retval #NFC_ERROR_NOT_SUPPORTED Not supported NFC + * @retval #NFC_ERROR_NOT_INITIALIZED Not initialized NFC + * @retval #NFC_ERROR_NOT_ACTIVATED NFC is not activated + * @retval #NFC_ERROR_OPERATION_FAILED Operation failed + * @retval #NFC_ERROR_PERMISSION_DENIED Permission denied + * + * @see nfc_manager_initialize() + * @see nfc_se_set_preferred_handler() + * + */ +int nfc_se_unset_preferred_handler(void); + #ifdef __cplusplus } #endif diff --git a/packaging/capi-network-nfc.spec b/packaging/capi-network-nfc.spec index de0215e..8480362 100644 --- a/packaging/capi-network-nfc.spec +++ b/packaging/capi-network-nfc.spec @@ -1,6 +1,6 @@ Name: capi-network-nfc Summary: A NFC library in Native API -Version: 0.2.0 +Version: 0.2.1 Release: 0 Group: Network & Connectivity/NFC License: Apache-2.0 diff --git a/src/nfc_card_emulation.c b/src/nfc_card_emulation.c index 4681fdd..96d105a 100644 --- a/src/nfc_card_emulation.c +++ b/src/nfc_card_emulation.c @@ -412,3 +412,33 @@ int nfc_se_remove_route_for_aid_internal(const char* pkg_name, const char *aid) return nfc_common_convert_error_code(__func__, result); } + +int nfc_se_set_preferred_handler() +{ + net_nfc_error_e result; + + LOG_BEGIN(); + + CHECK_SUPPORTED(NFC_CE_HCE_FEATURE); + CHECK_INIT(); + CHECK_ACTIVATED(); + + result = net_nfc_client_se_set_preferred_handler_sync(true); + + return nfc_common_convert_error_code(__func__, result); +} + +int nfc_se_unset_preferred_handler() +{ + net_nfc_error_e result; + + LOG_BEGIN(); + + CHECK_SUPPORTED(NFC_CE_HCE_FEATURE); + CHECK_INIT(); + CHECK_ACTIVATED(); + + result = net_nfc_client_se_set_preferred_handler_sync(false); + + return nfc_common_convert_error_code(__func__, result); +} \ No newline at end of file -- 2.7.4