diff options
author | Jack Yu <jackcwyu@google.com> | 2020-02-06 17:53:36 +0800 |
---|---|---|
committer | Jack Yu <jackcwyu@google.com> | 2020-02-06 19:40:07 +0800 |
commit | c3f935b630910cb90e96da1484f02ef49f9e1013 (patch) | |
tree | b5f1104729419d0841e74f56c04f42cea8fd67b6 | |
parent | bf7f92fea23ff6bc3772c5a8d3db592194cee11d (diff) | |
download | SecureElement-c3f935b630910cb90e96da1484f02ef49f9e1013.tar.gz |
Include channel operation in synchronized area
When application try to stress OMAPI by continuously open/close channels
with multi-thread, there is possibility channel management is incorrect
and result to no response.
Bug: 148892905
Test: OMAPI works normal after multi-thread stress tests
Change-Id: I530015ff20ed143a129024d6385fae9392a00a99
-rw-r--r-- | src/com/android/se/Terminal.java | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/src/com/android/se/Terminal.java b/src/com/android/se/Terminal.java index d21c323..521d696 100644 --- a/src/com/android/se/Terminal.java +++ b/src/com/android/se/Terminal.java @@ -247,22 +247,22 @@ public class Terminal { if (channel == null) { return; } - if (mIsConnected) { - try { - byte status = mSEHal.closeChannel((byte) channel.getChannelNumber()); - /* For Basic Channels, errors are expected. - * Underlying implementations use this call as an indication when there - * aren't any users actively using the channel, and the chip can go - * into low power state. - */ - if (!channel.isBasicChannel() && status != SecureElementStatus.SUCCESS) { - Log.e(mTag, "Error closing channel " + channel.getChannelNumber()); + synchronized (mLock) { + if (mIsConnected) { + try { + byte status = mSEHal.closeChannel((byte) channel.getChannelNumber()); + /* For Basic Channels, errors are expected. + * Underlying implementations use this call as an indication when there + * aren't any users actively using the channel, and the chip can go + * into low power state. + */ + if (!channel.isBasicChannel() && status != SecureElementStatus.SUCCESS) { + Log.e(mTag, "Error closing channel " + channel.getChannelNumber()); + } + } catch (RemoteException e) { + Log.e(mTag, "Exception in closeChannel() " + e); } - } catch (RemoteException e) { - Log.e(mTag, "Exception in closeChannel() " + e); } - } - synchronized (mLock) { mChannels.remove(channel.getChannelNumber(), channel); if (mChannels.get(channel.getChannelNumber()) != null) { Log.e(mTag, "Removing channel failed"); |