+ void NFCTerminal::onActivationChanged(bool activated, void *userData)
+ {
+ NFCTerminal *instance = (NFCTerminal *)userData;
+
+ _ERR("nfc state changed [%s]", activated ? "activated" : "deactivated");
+
+ if (activated == true) {
+ if (instance->present == false) {
+ if (instance->open() == true) {
+ instance->present = true;
+ instance->close();
+
+ if (instance->statusCallback != NULL) {
+ instance->statusCallback(
+ instance->getName(),
+ NOTIFY_SE_AVAILABLE,
+ SCARD_ERROR_OK,
+ NULL);
+ }
+ } else {
+ _ERR("ese open failed");
+ }
+ } else {
+ /* okay */
+ }
+ } else {
+ if (instance->present == true) {
+ instance->present = false;
+
+ if (instance->isClosed() == false) {
+ int ret;
+
+ /* close now */
+ ret = nfc_se_close_secure_element_internal(
+ instance->seHandle);
+ if (ret != NFC_ERROR_NONE) {
+ _ERR("nfc_se_close_secure_element failed [%d]", ret);
+ }
+
+ instance->seHandle = NULL;
+ instance->closed = true;
+ instance->referred = 0;
+ }
+
+ if (instance->statusCallback != NULL) {
+ instance->statusCallback(
+ instance->getName(),
+ NOTIFY_SE_NOT_AVAILABLE,
+ SCARD_ERROR_OK,
+ NULL);
+ }
+ } else {
+ /* okay */
+ }
+ }
+ }
+