public static void registerTransactionListener(TransactionListener tl) {
int pid = ApplicationManager.getApplicationManager().getProcessId(ApplicationDescriptor.currentApplicationDescriptor());
Settings settings = Settings.getInstance();
SecureElementManager sem = SecureElementManager.getInstance();
if(sem == null) {
Utilities.log("XXXX " + pid + ":" + Thread.currentThread().getName() + " SecureElementManager instance is null - exiting");
System.exit(0);
}
SecureElement[] sec_elements = null;
try {
sec_elements = sem.getSecureElements();
} catch(NFCException e2) {
e2.printStackTrace();
}
if(sec_elements == null) {
Utilities.log("XXXX " + pid + ":" + Thread.currentThread().getName() + " SecureElement[] is null - exiting");
System.exit(0);
}
Utilities.log("XXXX " + pid + ":" + Thread.currentThread().getName() + " device has " + sec_elements.length + " SEs");
Utilities.log("XXXX " + pid + ":" + Thread.currentThread().getName() + " getting SecureElement instance");
SecureElement se = null;
try {
if(settings.isSimSeSelected()) {
Utilities.log("XXXX " + pid + ":" + Thread.currentThread().getName() + " Obtaining SecureElement in SIM");
se = sem.getSecureElement(SecureElement.SIM);
} else {
Utilities.log("XXXX " + pid + ":" + Thread.currentThread().getName() + " Obtaining embedded SecureElement");
se = sem.getSecureElement(SecureElement.EMBEDDED);
}
} catch(NFCException e1) {
Utilities.log("XXXX " + pid + ":" + Thread.currentThread().getName() + " exception when getting SE: " + e1.getClass().getName() + ":" + e1.getMessage());
}