Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #24 from mdwoolley/master

NfcTransactionHandler now delays JSR177 access until SIM is unlocked
  • Loading branch information...
commit 97d0bf29589048f6362b2d8529d799e519366a76 2 parents 53f6f8f + 2ff7fb0
@timwindsor timwindsor authored
View
2  NFC/NfcTransactionHandler/src/nfc/sample/nfctransaction/Constants.java
@@ -17,7 +17,7 @@
import net.rim.device.api.ui.Color;
public class Constants {
- public static String VERSION = "1.1.5";
+ public static String VERSION = "1.2.0";
public static final int SE_SIM=0;
public static final int SE_EMB=1;
View
21 NFC/NfcTransactionHandler/src/nfc/sample/nfctransaction/NfcTransHandlerApp.java
@@ -27,6 +27,7 @@
import net.rim.device.api.system.ApplicationManager;
import net.rim.device.api.system.ApplicationManagerException;
import net.rim.device.api.system.Backlight;
+import net.rim.device.api.system.GPRSInfo;
import net.rim.device.api.system.RuntimeStore;
import net.rim.device.api.ui.UiApplication;
import net.rim.device.api.util.ByteArrayUtilities;
@@ -67,6 +68,9 @@ public static void main(String[] args) {
Backlight.enable(true, 10);
+ // Essential that the SIM is unlocked (PIN) and initialised before we can proceed to use JSR177
+ waitForSimInitialisation();
+
CardEmulation.registerTransactionListener(app);
Utilities.log("XXXX " + pid + ":" + Thread.currentThread().getName() + " TransactionListener is exiting and will be restarted when a transaction occurs");
@@ -91,6 +95,23 @@ public static void main(String[] args) {
}
}
+ private static void waitForSimInitialisation() {
+
+ int mcc = GPRSInfo.getHomeMCC();
+ int mnc = GPRSInfo.getHomeMNC();
+ Utilities.log("XXXX MCC="+mcc+",MNC="+mnc);
+ while (mcc == -1) {
+ try {
+ Thread.sleep(3000);
+ } catch(InterruptedException e) {
+ }
+ mcc = GPRSInfo.getHomeMCC();
+ mnc = GPRSInfo.getHomeMNC();
+ Utilities.log("XXXX MCC="+mcc+",MNC="+mnc);
+ }
+ Utilities.log("XXXX SIM initialised.... proceeding");
+ }
+
private static void dumpArgs(String[] args) {
for(int i = 0; i < args.length; i++) {
Utilities.log("XXXX " + pid + ":" + Thread.currentThread().getName() + " args[" + i + "]=" + args[i]);
View
2  NFC/NfcTransactionHandler/src/nfc/sample/nfctransaction/commands/Iso7816Command.java
@@ -59,7 +59,7 @@ public void execute(ReadOnlyCommandMetadata metadata, Object context) {
// Open an APDUConnection to our applet. This results in an ISO 7816-4 SELECT command being sent by the JSR-177 API
String connection_string = Utilities.makeApduConnectionString(settings.getRegistered_aid());
Utilities.log("XXXX " + Thread.currentThread().getName() + " ISO 7816-4 command: opening APDUConnection to " + connection_string);
- apduConn = (APDUConnection) Connector.open(Constants.CONNECTION_STRING);
+ apduConn = (APDUConnection) Connector.open(connection_string);
Utilities.log("XXXX " + Thread.currentThread().getName() + " ISO 7816-4 command: APDUConnection opened");
screen.setUserMessage("Selected AID OK");
// Send the APDU and wait for a response - expect an error here unless your applet supports the command that was sent
Please sign in to comment.
Something went wrong with that request. Please try again.