madhanraj / seek-for-android

Automatically exported from code.google.com/p/seek-for-android
0 stars 0 forks source link

Reader.openSession() does not throw IOException when SE is not presented #22

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
According to 
http://seek-for-android.googlecode.com/svn/trunk/doc/org/simalliance/openmobilea
pi/Reader.html#openSession()

public Session openSession()
                    throws IOException

suppose to throw IOException if something went wrong with the communicating to 
the Secure Element or the reader.

However, when tested with UICC Reader, without a UICC (SIM) inserted, hence, no 
SE present, this API does not throw IOException as expected.

following is a tested propose solution to this issue.

public Session openSession() throws IOException {
        // should check whether SE presents before proceed to OpenSession
        // according to API doc, IOException should be raised if communication to SE went wrong
        // start of solution
        if (!mService.isSecureElementPresent(this))
            throw new IOException("Secure Element is not presented.");
        // end of solution

        synchronized (mSessions) {
            Session session = new Session(getName(), this);
            mSessions.add(session);
            return session;
        }
    }

Original issue reported on code.google.com by tommypo...@gmail.com on 29 May 2012 at 4:14

GoogleCodeExporter commented 9 years ago
Patch attached, maybe NoSuchElementException is more appropriate, similar like 
issue6?

Original comment by Daniel.A...@gi-de.com on 19 Jun 2012 at 12:41

Attachments:

GoogleCodeExporter commented 9 years ago
unless the API Doc is change, IOException is the only documented behavior (and 
acceptable one) under this situation.

Original comment by tommypo...@gmail.com on 19 Jun 2012 at 4:57

GoogleCodeExporter commented 9 years ago
setting old issues from fixed to done

Original comment by Daniel.A...@gi-de.com on 5 Jul 2013 at 2:33