diff options
author | Ruchi Kandoi <kandoiruchi@google.com> | 2018-02-08 02:54:07 +0000 |
---|---|---|
committer | android-build-merger <android-build-merger@google.com> | 2018-02-08 02:54:07 +0000 |
commit | f453aba7f5a0057e785768a1277b95bc3069a208 (patch) | |
tree | 50d1a382532a4c51d10d5be5fa3471a335937d29 | |
parent | 2fc68caa3970a157f0052ba6f692aac8c61706f1 (diff) | |
parent | 4869ec7c4ba1f46028be00cc063cde0dfc06af9d (diff) | |
download | SecureElement-f453aba7f5a0057e785768a1277b95bc3069a208.tar.gz |
Fix return types and exceptions am: e6556339e7
am: 4869ec7c4b
Change-Id: I6006716bedcd6422cbf39cc3ab96635c82189bb2
-rw-r--r-- | src/com/android/se/Channel.java | 2 | ||||
-rwxr-xr-x | src/com/android/se/Terminal.java | 19 |
2 files changed, 15 insertions, 6 deletions
diff --git a/src/com/android/se/Channel.java b/src/com/android/se/Channel.java index 56d4f9d..9dff38a 100644 --- a/src/com/android/se/Channel.java +++ b/src/com/android/se/Channel.java @@ -269,7 +269,7 @@ public class Channel implements IBinder.DeathRecipient { * implementation. */ public byte[] getSelectResponse() { - return mSelectResponse; + return (mHasSelectedAid ? mSelectResponse : null); } public boolean isBasicChannel() { diff --git a/src/com/android/se/Terminal.java b/src/com/android/se/Terminal.java index c7348cd..2733a6e 100755 --- a/src/com/android/se/Terminal.java +++ b/src/com/android/se/Terminal.java @@ -82,6 +82,9 @@ public class Terminal { } } else { initializeAccessControl(); + synchronized (mLock) { + mDefaultApplicationSelectedOnBasicChannel = true; + } } } } @@ -202,9 +205,6 @@ public class Terminal { } } catch (RemoteException ignore) { } - synchronized (mLock) { - mDefaultApplicationSelectedOnBasicChannel = true; - } } private void select(byte[] aid) throws RemoteException { @@ -225,8 +225,8 @@ public class Terminal { selectResponse = null; throw new NoSuchElementException("Response length is too small"); } - int sw1 = selectResponse[selectResponse.length - 2]; - int sw2 = selectResponse[selectResponse.length - 1]; + int sw1 = selectResponse[selectResponse.length - 2] & 0xFF; + int sw2 = selectResponse[selectResponse.length - 1] & 0xFF; if (sw1 != 0x90 || sw2 != 0x00) { selectResponse = null; throw new NoSuchElementException("Status word is incorrect"); @@ -276,7 +276,11 @@ public class Terminal { throw new UnsupportedOperationException("OpenBasicChannel() failed"); } else if (status[0] == SecureElementStatus.IOERROR) { throw new ServiceSpecificException(SEService.IO_ERROR, "OpenBasicChannel() failed"); + } else if (status[0] == SecureElementStatus.NO_SUCH_ELEMENT_ERROR) { + throw new ServiceSpecificException(SEService.NO_SUCH_ELEMENT_ERROR, + "OpenBasicChannel() failed"); } + Channel basicChannel = new Channel(session, this, 0, selectResponse, listener); basicChannel.setChannelAccess(channelAccess); @@ -622,6 +626,11 @@ public class Terminal { throw new NullPointerException("session is null"); } mSessions.remove(session); + synchronized (mLock) { + if (mSessions.size() == 0) { + mDefaultApplicationSelectedOnBasicChannel = true; + } + } } @Override |