I have a programmable device (Galaxy Watch) that can act as a ISO7816 smart card and I have another programmable device (Android Smartphone) that can act as a card terminal. Without needing any of the smart card functionality as it is supposed to be used all I need to do is send and receive a few bytes from the phone to the watch.
I have a working implementation that registers an AID on the watch. The phone is sending an A4 (SELECT FILE) instruction with command P1=04 and P2=00 and that registered AID in the data field. The watch does then get a callback and can respond to it with arbitrary data. This is working fine.
My question is this: how can I extend this so that I'm able to send a few arbitrary bytes of custom information to the watch? I have too many different information objects in order to register a separate AID for every one of those. Can I somehow add some arbitrary bytes to that A4 or probably any other command?
I am basing my answer on the host-based card emulation overview.
You seem to already have extended the HostApduService and implemented the processCommandApdu() function that receives all APDUs sent in the scope of your "application" (i.e. what you want to access through your AID).
Now you have to decide how to model and encapsulate the "few arbitrary bytes of custom information" in terms of ISO7816 (see here for a nice entry point for reading up on ISO 7816; here you have the options of
Once you have decided upon data organization, you'd have to enable the above mentioned processCommandApdu() to decode the respective APDUs and read / write the "few arbitrary bytes of custom information".