use of nfc.sample.nfctransaction.nfc.CardEmulation in project Samples-for-Java by blackberry.
the class NfcSettingsScreen method applySettings.
private void applySettings() {
try {
if ((current_se == SecureElement.SIM) && (se_choices.getSelectedIndex() == 1)) {
ce.initCe(SecureElement.EMBEDDED);
settings.setSeEmbedded();
} else {
if ((current_se == SecureElement.EMBEDDED) && (se_choices.getSelectedIndex() == 0)) {
ce.initCe(SecureElement.SIM);
settings.setSeSIM();
}
}
} catch (NFCException e) {
Utilities.popupAlert("Error: could not change SE selection");
return;
}
int tech_types = TechnologyType.NONE;
if (cbx_iso1443a.getChecked() == true) {
tech_types = tech_types | TechnologyType.ISO14443A;
}
if (cbx_iso1443b.getChecked() == true) {
tech_types = tech_types | TechnologyType.ISO14443B;
}
if (cbx_iso1443b_prime.getChecked() == true) {
tech_types = tech_types | TechnologyType.ISO14443B_PRIME;
}
settings.setISO14443A(cbx_iso1443a.getChecked());
settings.setISO14443B(cbx_iso1443b.getChecked());
settings.setISO14443B_PRIME(cbx_iso1443b_prime.getChecked());
if (!settings.getRegisteredAIDAsString().equals(edt_aid.getText())) {
settings.setRegisteredAID(edt_aid.getText());
CardEmulation ce = CardEmulation.getInstance();
ce.removeTransactionListener();
CardEmulation.registerTransactionListener(NfcTransHandlerApp.getTransactionListener());
}
settings.setAPDU(edt_apdu.getText());
Utilities.log("XXXX " + Thread.currentThread().getName() + " Selected tech types=" + Utilities.getTechnologyTypesNames(tech_types));
if (current_tt != tech_types) {
try {
ce.setRoutingOn(tech_types);
} catch (NFCException e) {
Utilities.popupAlert("Error: could not change CE technology types");
return;
} catch (Exception e) {
Utilities.log("XXXX " + Thread.currentThread().getName() + " " + e.getClass().getName() + ":" + e.getMessage());
Utilities.popupAlert(e.getClass().getName() + ": could not change CE technology types");
return;
}
}
Utilities.log("XXXX " + Thread.currentThread().getName() + " applySettings 11");
setDirty(false);
Utilities.log("XXXX " + Thread.currentThread().getName() + " applySettings 12");
Utilities.popupMessage("New settings applied");
}
Aggregations