×

Discussion Board

Results 1 to 7 of 7
  1. #1
    Registered User
    Join Date
    Jul 2007
    Posts
    20

    Opening connection to the secure element fails when restarting the midlet.

    Hi,

    I have a midlet suite with two midlets. One of those midlets opens (and afterwards closes) a connection to the secure element. The midlet suite is signed.
    Access to the secure element works, but when the user exits the application and restarts it immediately from the midlet suite menu, Connector.open() blocks indefinately.

    The user has to fully exit the midlet suite before connections to the SE work again.

    Opening and closing the connection multiple times before exiting the application works perfect too.

    I have a little demo program with two midlets in a midlet suite to illustrate this issue:

    OpenCloseForm.java
    Code:
    import java.io.IOException;
    
    import javax.microedition.contactless.sc.ISO14443Connection;
    import javax.microedition.io.Connector;
    import javax.microedition.lcdui.Command;
    import javax.microedition.lcdui.CommandListener;
    import javax.microedition.lcdui.Displayable;
    import javax.microedition.lcdui.Form;
    import javax.microedition.lcdui.Item;
    import javax.microedition.lcdui.StringItem;
    
    public class OpenCloseSEForm extends Form implements CommandListener {
    
    	private static final Command EXITCOMMAND = new Command("quit", Command.EXIT,5);
    	private static final Command DOITCOMMAND = new Command("Open and Close SE",
    			Command.OK, 0);
    
    	public OpenCloseSEForm(String arg0) {
    		super(arg0);
    		this.addCommand(DOITCOMMAND);
    		this.addCommand(EXITCOMMAND);
    		this.setCommandListener(this);
    	}
    
    	public void commandAction(Command arg0, Displayable arg1) {
    		if (arg0.equals(DOITCOMMAND)) {
    			new Thread(){
    
    				public void run() {
    					tryOpenCloseSE();
    				}}.start();
    		} else if (arg0.equals(EXITCOMMAND))
    		{
    			TestConnectSecureElement.getMIDlet().notifyDestroyed();
    		}
    
    	}
    
    	private void log(String msg) {
    		StringItem item = new StringItem("", msg);
    		item.setLayout(Item.LAYOUT_2|Item.LAYOUT_NEWLINE_AFTER);
    		this.append(item);
    		System.out.println(msg);
    	}
    
    	private void tryOpenCloseSE() {
    		log("open SE");
    		
    		ISO14443Connection connection = null;
    		try {
    			connection = (ISO14443Connection) Connector.open(System.getProperty("internal.se.url"));
    		} catch (IOException e) {
    			// TODO Auto-generated catch block
    			e.printStackTrace();
    			log("Exception opening SE");
    		}
    		log("connection " + connection);
    		if (connection != null) {
    			try {
    				connection.close();
    			} catch (IOException e) {
    				// TODO Auto-generated catch block
    				e.printStackTrace();
    				log("Exception closing SE");
    			}
    		}
    		log("connection closed");
    	}
    
    }
    TestConnectSecureElement.java
    Code:
    import javax.microedition.lcdui.Display;
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.midlet.MIDletStateChangeException;
    
    public class TestConnectSecureElement extends MIDlet {
    
    	private static MIDlet theMIDlet = null;
    	
    	public TestConnectSecureElement()
    	{
    		TestConnectSecureElement.theMIDlet = this;
    	}
    
    
    	protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
    		System.out.println("Destroy");
    
    	}
    
    	protected void pauseApp() {
    		System.out.println("Pause");
    
    	}
    
    	protected void startApp() throws MIDletStateChangeException {
    		System.out.println("Start");
    		Display disp = Display.getDisplay(this);
    		disp.setCurrent(new OpenCloseSEForm("Test Open and Close SE"));
    		
    
    	}
    
    
    
    
    	public static MIDlet getMIDlet() {
    		return theMIDlet;
    	}
    
    }
    Dummy.java

    Code:
    import javax.microedition.midlet.MIDlet;
    import javax.microedition.midlet.MIDletStateChangeException;
    
    
    public class Dummy extends MIDlet {
    	
    	protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
    		System.out.println("Destroy");
    		
    	}
    
    	protected void pauseApp() {
    		System.out.println("Pause");
    		
    	}
    
    	protected void startApp() throws MIDletStateChangeException {
    		System.out.println("Start");
    		
    	}
    
    }
    If you create a midlet suite with these three source files, build and sign it, you can easily reproduce the issue:

    Start the midlet suite, start TestConnectSecureElement. Use the Open and close SE button a few times. You see it works nicely. Use quit. Immediately restart the midlet from the midlet suite menu. Opening the SE now blocks.

    Any suggestions, ideas workaround? Something I missed or a bug? I have this with the 3.12 firmware, I'd appreciate if someone could check if this is still the case with the 5.11 firmware.

    If you pm me an email address, I can send you the jad/jar and the eclipse project.

    thnx

    regards

    Tim

  2. #2
    Regular Contributor
    Join Date
    Dec 2004
    Posts
    53

    Re: Opening connection to the secure element fails when restarting the midlet.

    I was going to message you, but it said you don't want to recieve e-mails so I couldn't. Perhaps you need to update your profile to allow this?

  3. #3
    Registered User
    Join Date
    Apr 2007
    Location
    Beijing-China
    Posts
    11

    Re: Opening connection to the secure element fails when restarting the midlet.

    Hello,
    i've the same problem. Did you find a solution ?

  4. #4
    Registered User
    Join Date
    Jul 2007
    Posts
    20

    Re: Opening connection to the secure element fails when restarting the midlet.

    nope. I think its a bug.

  5. #5
    Registered User
    Join Date
    Jul 2007
    Posts
    20

    Re: Opening connection to the secure element fails when restarting the midlet.

    Phoenix,

    the message you sent through the forum still doesnt give me the possibility to attach files. Got access to a ftp site though, so here it goes:

    NokiaBugTest.jar
    NokiaBugTest.jad

  6. #6
    Regular Contributor
    Join Date
    Dec 2004
    Posts
    53

    Re: Opening connection to the secure element fails when restarting the midlet.

    I have tried this on a v5.11 firmware phone and can confirm it is doing what you described. I am able to open and close the connection as many times as I want when selecting TestConnectSecureElement, however if I return to the previous menu and then re-enter it fails to open a connection. Exiting the midlet completely and starting again works.

    -Jeff

  7. #7
    Registered User
    Join Date
    Jul 2007
    Posts
    20

    Re: Opening connection to the secure element fails when restarting the midlet.

    gr8, thnx for checking. At least I know I don't yet want to do the 5.11 upgrade.

Similar Threads

  1. opening a socket connection
    By bhatti81 in forum Mobile Java Networking & Messaging & Security
    Replies: 4
    Last Post: 2003-07-16, 10:08
  2. http midlet connection doesn't work with Nokia7650
    By epecis in forum Mobile Java General
    Replies: 1
    Last Post: 2002-10-17, 01:28
  3. 7650 http connection initiation from MIDlet
    By victordonselaar in forum Mobile Java General
    Replies: 0
    Last Post: 2002-09-24, 06:55
  4. Replies: 0
    Last Post: 2002-09-19, 11:45
  5. Can MIDLET Initialize Connection?
    By Nokia_Archive in forum Mobile Java General
    Replies: 1
    Last Post: 2002-05-27, 15:13

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×