androidnfcsim-cardcontactless-smartcardsecure-element

How detect when the phone enters into a nfc field using card emulation


I'm using a card emulation with a uicc SE (no HCE). My min api sdk is 17 and my target is 19.

As I far i remember in Android 2.x was a intent that aware the app if the phone goes into a nfc field, something like FIELD_ON intent. ¿Is there anyhow nowadays?

The NDEF detection is, obviously, not valid for me as far I'm the passive one. My situation is: "hey you're being reading from a active element".

Thank you


Solution

  • Browsing through the current AOSP source and the NFC service on a GS4, there are a couple of intents/broadcasts that could do what you want:

    1. This seems to be sent when an external RF field activates a secure element:

      com.android.nfc_extras.action.RF_FIELD_ON_DETECTED
      
    2. This seems to be sent when an application on an SE is selected:

      com.android.nfc_extras.action.AID_SELECTED
      
    3. This seems to be sent when an APDU is received by an SE:

      com.android.nfc_extras.action.APDU_RECEIVED
      
    4. This seems to be sent when an SE is activated:

      com.android.nfc_extras.action.SE_LISTEN_ACTIVATED
      
    5. This seems to be sent when an SE's MIFARE functionality is accessed:

      com.android.nfc_extras.action.MIFARE_ACCESS_DETECTED
      

    Moreover, I found the following events (some seem to be device specific):

    android.nfc.action.TRANSACTION_DETECTED
    com.sony.nfc.action.TRANSACTION_DETECTED
    com.nxp.action.CONNECTIVITY_EVENT_DETECTED
    

    However, I'm not sure what permissions you need in order to receive any of those intents. Also, I'm not sure which of those events apply to the UICC and which are valid for embedded SEs only. Moreover, I'm not sure if all of them are broadcasts (i.e. receivable through broadcast receivers).