Editing AOSP NFC/HCE to manually set UID

513 views
Skip to first unread message

James Allen

unread,
Feb 17, 2015, 8:11:18 PM2/17/15
to andro...@googlegroups.com

Greetings all,

I recently asked a question on stackoverflow about editing the functionality of the HCE feature of Android to manually set the UID that is generated when a device emulates an RFID tag, and got the following response:

Editing Functionality of Host Card Emulation in Android


I'm looking into how the various levels of the Android stack link from the top down to get some sort of idea as to where I should be making modifications to the AOSP, but am having trouble following what is going on at runtime.

Is there any in-depth documentation to how the various levels of the stack talk to each other, or any Android Kernel Trace/Debug/Verbose programs that are available to track what code is being called/run on each level of the stack so that I can follow the trail of executed code, so that I may be able to make out where I should be designing/implementing my modifications ?


Additionally, the objective of the project i'm working on is to manually set the UID of the device when emulating a device, by choosing an ID from a list in an application running on my device. The device I am currently using is a Nexus 7, but I was wondering if developing this functionality for other devices is the same as for the Nexus 7? i.e. is the code for setting the UID in the Android low-level interface (libnfc-nci) or is it stored elsewhere in the specific Broadcom driver code?

For instance, in the libnfc-nci file "nfc_main" (Located here) I have found the following code I think may set the UID of the connection at line 979.

 if (p_cb)
{
    p_cb->id = id;
    pp = param_tlvs;
    if (dest_type == NCI_DEST_TYPE_NFCEE)
    {
        num_tlv = 1;
        UINT8_TO_STREAM (pp, NCI_CON_CREATE_TAG_NFCEE_VAL);
        UINT8_TO_STREAM (pp, 2);
        UINT8_TO_STREAM (pp, id);
        UINT8_TO_STREAM (pp, protocol);
        tlv_size = 4;
    }
    else if (dest_type == NCI_DEST_TYPE_REMOTE)
    {
        num_tlv = 1;
        UINT8_TO_STREAM (pp, NCI_CON_CREATE_TAG_RF_DISC_ID);
        UINT8_TO_STREAM (pp, 1);
        UINT8_TO_STREAM (pp, id);
        tlv_size = 3;
    }

Finally, if I am to set the UID that the device will transmit during emulation in my application, presumably this ID will need to be passed down the various levels of the Android stack, from Application to libnfc-nci. Again, is there any documentation of the best way to implement adding a value/variable down the various levels of Android and how it would be converted from Java -> C -> Java -> C through the various levels?

Any help on any of the above topics is greatly appreciated

Reply all
Reply to author
Forward
0 new messages