Grace B
Grace B

Reputation: 1406

Documentation for com.android.nfc_extras?

Apparently if you have a rooted phone, you can make use of com.android.nfc_extras to gain access to features such as card emulation ( Secure element Access Control on ICS 4.0.4 ).

I know that this is an unofficial API, but is there any documentation for it (official or unofficial)? Or on the other hand, is card emulation far more complicated than I've realised?

Upvotes: 4

Views: 2355

Answers (2)

NFC guy
NFC guy

Reputation: 10228

Keep in mind that accessing the secure element and doing card emulation are actually two different things. The secure element is essentially closed; you cannot modify it. Using com.android.nfc_extras you can turn card emulation through the secure element on or off. That's it.

You can send APDUs to the secure element from your app, like communicating with an IsoDep tag (in the lower level part of the NFC stack both use the same code path). See for example http://nelenkov.blogspot.nl/2012/08/accessing-embedded-secure-element-in.html for a good explanation how to do it.

Upvotes: 5

Nils Pipenbrinck
Nils Pipenbrinck

Reputation: 86393

There is no documentation. If you want to dig into this API I suggest that you look directly at the source-code. It is not much, just two files that implement and define the API. You can get a copy for example here:

http://source-android.frandroid.com/frameworks/base/nfc-extras/java/com/android/nfc_extras/

In the API you will find concepts like ExecutionEnvironment, Routes etc. Don't let these concepts confuse you. In the end all you can do with the NfcExtras interface is to:

  • Turn on card emulation by setting a route created with the ROUTE_ON_WHEN_SCREEN_ON.

  • Turn off card emulation by setting the 'off' route.

  • Exchange data with the embedded secure element.

That's it! All the rest is just API sugar to make things look bigger than it really is.

Some additional caveats:

  • If you want to call the functions you need your application to be white-listed in the nfcee_access.xml file locates in /etc. If you don't white-list yourself you'll get an access violation exception.

  • There is no way for you to distinguish between the embedded secure element or the NFC capable UICC present in the phone.

  • There is no way to talk to the NFC capable UICC in the phone. You can only talk to the embedded secure element (aka the SmartMX chip for phones with NXP chipset). Communication to the UICC itself is only possible through the RID interface via the ISO7816 interface, and this is - if possible at all - proprietary.

  • Last but not least: There is no guarantee that the NfcExtras interface does anything at all. The interface is used by Google Wallet, but the mobile payment market is segmented and everyone cooks his own soup. I know about at least one big mobile payment provider that completely ignores the NfcExtras interface, disabled it and uses his own, hidden mechanism to turn things on and off.

Upvotes: 2

Related Questions