So right now I'm building a simple app to emulate a smartcard using Android HCE (Host-based Card Emulation). The app only returns {90,00} byte array for every APDU command it receives. Here is the code:
public class MyHostApduService extends HostApduService {
@Override
public byte[] processCommandApdu(byte[] apdu, Bundle extras) {
byte[] response = new byte[2];
response[0] = (byte)0x90;
response[1] = 0x00;
return response;
}
//Rest of the code...
}
And then I tried to connect my smartphone (I'm using Sony Xperia M2) to a smartcard reader (ACR122U-A9) using CardTerminal.connect() method from javax.smartcardio.CardTerminal like this
Card card = terminal.connect("*");
It worked for a real smart card, but it doesn't want to connect my phone. There is a beep sound, but the LED turned off (it doesn't turned green like when it detects a real smartcard), and when I remove the smartphone, I got CardException, and the LED light goes back to red. Sometimes the reader looks like connected to the phone (the LED turned green), but the phone doesn't seem to receive the APDU. I also tried to connect using scScriptor.exe from springcard, with same result.
Is there something I miss on the code? Or probably a technical issue?
EDIT: I installed the apk file on my friend's galaxy s iii, and it's working, so I suspect that this is a phone problem