diff options
author | Yerriswamy <yerriswamy.kurubathayanna@nxp.com> | 2020-04-14 09:01:15 +0530 |
---|---|---|
committer | nxf24591 <nanjesh.s_1@nxp.com> | 2020-05-01 00:48:12 +0530 |
commit | df19af2caf99f897464b678ae56f49901937389f (patch) | |
tree | 4877bed68e34c98946a8d6a45b723e632106732f | |
parent | 55ca1dd8684f0d136fcc9a8c4c0c39ce94b14887 (diff) |
{R-DP2} 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
-rwxr-xr-x | 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 92dcec3..0b5cc43 100755 --- a/src/com/android/se/Terminal.java +++ b/src/com/android/se/Terminal.java @@ -322,22 +322,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"); |