This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
byte[] response = isoCard.transceive(Apdu.select(APPLICATION_ID, APP_VERSION)); | |
if (Apdu.hasStatus(response, Apdu.OK_APDU)) { | |
/* ... */ | |
} else { | |
setMainMessage("Select not OK"); | |
setMainMessage(R.string.cardlet_not_installed); | |
installButton.setVisibility(View.VISIBLE); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* ... */ | |
byte[] response = isoCard.transceive(Apdu.select(APPLICATION_ID, APP_VERSION)); | |
if (Apdu.hasStatus(response, Apdu.OK_APDU)) { | |
setMainMessage("Select OK"); | |
byte[] payload = Apdu.responseData(response); | |
String printableResponse = new String(); | |
for (int i=0; i<payload.length; i++) printableResponse += (char)payload[i]; | |
setMainMessage(printableResponse); | |
} else { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void communicateWithCard(IsoCard isoCard) { | |
try { | |
isoCard.connect(); | |
byte[] response = isoCard.transceive(Apdu.select(APPLICATION_ID, APP_VERSION)); | |
if (Apdu.hasStatus(response, Apdu.OK_APDU)) { | |
setMainMessage("Select OK"); | |
} else { | |
setMainMessage("Select not OK"); | |
} | |
isoCard.close(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void tagDiscovered(Tag tag) { | |
setMainMessage("Reading card..."); | |
try { | |
IsoCard isoCard = AndroidCard.get(tag); | |
communicateWithCard(isoCard); | |
} catch(IOException e) { | |
e.printStackTrace(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void tagDiscovered(Tag tag) { | |
Log.v("MainActivity", "Card detected on the NFC interface!"); | |
try { | |
IsoCard isoCard = AndroidCard.get(tag); | |
} catch(IOException e) { | |
e.printStackTrace(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
protected void onResume() { | |
super.onResume(); | |
tagDispatcher = TagDispatcher.get(this, this); | |
tagDispatcher.enableExclusiveNfc(); | |
} | |
@Override | |
public void onPause() { | |
super.onPause(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void communicateWithCard(IsoCard isoCard) { | |
try { | |
isoCard.connect(); | |
Apdu.transceiveAndRequireOk(Apdu.select(OTP_AID), isoCard); | |
setMainMessage("Select OK"); | |
long timeStamp = getTimeStamp(); | |
byte[] totpCodeApdu = Otp.totpCodeApdu(TOTP_CODE_NAME, timeStamp); | |
byte[] rawTotpCode = Apdu.transceiveAndGetResponse(totpCodeApdu, isoCard, Otp.SEND_REMAINING_APDU); | |
if(Apdu.hasStatus(rawTotpCode, Apdu.OK_APDU)){ | |
String totpCode = Otp.decipherTotpCode(rawTotpCode); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void communicateWithCard(IsoCard isoCard) { | |
try { | |
isoCard.connect(); | |
Apdu.transceiveAndRequireOk(Apdu.select(OTP_AID), isoCard); | |
setMainMessage("Select OK"); | |
long timeStamp = getTimeStamp(); | |
byte[] totpCodeApdu = Otp.totpCodeApdu(TOTP_CODE_NAME, timeStamp); | |
byte[] rawTotpCode = Apdu.transceiveAndGetResponse(totpCodeApdu, isoCard, Otp.SEND_REMAINING_APDU); | |
isoCard.close(); | |
} catch (IOException e) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
protected void communicateWithCard(IsoCard isoCard) { | |
try { | |
isoCard.connect(); | |
Apdu.transceiveAndRequireOk(Apdu.select(OTP_AID), isoCard); | |
setMainMessage("Select OK"); | |
long timeStamp = getTimeStamp(); | |
byte[] totpCodeApdu = Otp.totpCodeApdu(TOTP_CODE_NAME, timeStamp); | |
isoCard.close(); | |
} catch (IOException e) { | |
e.printStackTrace(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Override | |
public void tagDiscovered(Tag tag) { | |
setMainMessage("Reading card..."); | |
try { | |
IsoCard isoCard = AndroidCard.get(tag); | |
communicateWithCard(isoCard); | |
} catch(IOException e) { | |
e.printStackTrace(); | |
} | |
} |
NewerOlder