I know HCE capability was introduced only in KitKat, but since the entire concept is only at a software level, shouldn't it be possible to explore into the AOSP code and pull out the changes related to HCE and create that as some kind of library so that every Android phone that supports NFC but is lesser than 4.4 can potentially be HCE compatible?
1 Answers
I would assume that it's not that easy. On Android all interaction with the NFC contactless front-end is handled by the NFC system service (which interacts with the NFC interface library (libnfc-nxp or libnfc-nci). The overall NFC stack looks about like this:
+----------------------------------------------------------------+
| App using NFC functionality (reader/writer, peer-to-peer, HCE) |
+----------------------------------------------------------------+
|
|
+----------------------------------------------------------------+
| Android NFC API (Framework/Java) |
+----------------------------------------------------------------+
| NFC system service (Java + native components) |
+----------------------------------------------------------------+
| NFC interface library (libnfc-n__, native code) |
+----------------------------------------------------------------+
| NFC interface driver (Kernel) |
+----------------------------------------------------------------+
|
|
+----------------------------------------------------------------+
| NFC contactless frontend chip (Broadcom, NXP) |
+----------------------------------------------------------------+
In order to add HCE, parts of the NFC interface library (?), the NFC system service and the Android NFC API need to be changed. While it should be possible to integrate the relevant code from the API layer to the application and directly interface to the NFC system service, you cannot change the NFC system service (and the libnfc-n__) without modifying the Android operating system itself.
You could, however try to root the device and modify all these components. (The relevant components are all in user-space, so this should not be a problem.) But then you could also directly install Android 4.4+ on that device.

- 39,663
- 10
- 99
- 206
-
For [at least some devices](http://stackoverflow.com/a/20595722/241211) currently running KitKat, the "NFC controller" (box 3 in your diagram?) still doesn't support HCE. Is this an issue that could be fixed with a custom ROM, or is it permanently stuck? – Michael Mar 11 '14 at 20:24
-
2Even for those devices the NFC controller (box "NFC contactless frontend chip") *does* support some form of HCE. It just does not support the mechanism that is used with Android's HCE implementation. E.g. the HCE implementation in CyanogenMod 9.1 specifically required a PN544 and would therefore work on the Nexus 7 (2012). Even building Android's HCE based on the PN544 should be possible (either by changing the PN544 firmware -- only the chip manufacturer could provide such an update -- or by adapting the Android's HCE mechanism to fit the PN544. – Michael Roland Mar 12 '14 at 06:52