diff options
author | Ganesh Deva <ganesh.deva_1@nxp.com> | 2020-07-22 19:22:47 +0530 |
---|---|---|
committer | nxf24591 <nanjesh.s_1@nxp.com> | 2020-09-08 17:44:08 +0530 |
commit | 6a55c23b8d4c3cf0a0115e8824f868e7f1d30e8e (patch) | |
tree | d76a682a2439663b7f3a02f28f43e52aebdaac5c | |
parent | 16b953a585b2e6f24565d40ba1dd88f3112f21a3 (diff) |
Fix potentially deadlcok issue
It need to break the deadlock between the objects of
Terminal.mLock and Channel to avoid the potentially ANR issue
-rw-r--r-- | src/com/android/se/Channel.java | 28 |
1 files changed, 15 insertions, 13 deletions
diff --git a/src/com/android/se/Channel.java b/src/com/android/se/Channel.java index 4fbb2a0..d6df415 100644 --- a/src/com/android/se/Channel.java +++ b/src/com/android/se/Channel.java @@ -89,21 +89,23 @@ public class Channel implements IBinder.DeathRecipient { /** * Closes the channel. */ - public synchronized void close() { + public void close() { synchronized (mLock) { - if (isBasicChannel()) { - Log.i(mTag, "Close basic channel - Select without AID ..."); - mTerminal.selectDefaultApplication(); - } - - mTerminal.closeChannel(this); + if (isClosed()) + return; mIsClosed = true; - if (mBinder != null) { - mBinder.unlinkToDeath(this, 0); - } - if (mSession != null) { - mSession.removeChannel(this); - } + } + if (isBasicChannel()) { + Log.i(mTag, "Close basic channel - Select without AID ..."); + mTerminal.selectDefaultApplication(); + } + + mTerminal.closeChannel(this); + if (mBinder != null) { + mBinder.unlinkToDeath(this, 0); + } + if (mSession != null) { + mSession.removeChannel(this); } } |