summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaoliang Tang <tangmaoliang@xiaomi.com>2020-06-05 19:52:23 +0800
committeralk3pInjection <webmaster@raspii.tech>2021-09-14 11:26:25 +0800
commite1ceb7431af5da478db19decb6057ed34f483dba (patch)
tree82ec61879571337e16d429c933349f2bff9b40b3
parent57ba8db9d456de7ce36303676d5238021c96be50 (diff)
SecureElement: Fix potential deadlock issue
It need to break the deadlock between the objects of Terminal.mLock and Channel to avoid the potentially ANR issue Bug: 158132553 Test: OMAPI works normal after multi-thread stress tests Signed-off-by: Maoliang Tang <tangmaoliang@xiaomi.com> Change-Id: I94676d45cabb65665d9336167d9814dfbca7a5bb (cherry picked from commit 8c52cf75b958f690457be330c52ba2487186f2d8)
-rw-r--r--src/com/android/se/Channel.java28
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);
}
}