diff options
author | Jeff Brown <jeffbrown@google.com> | 2012-09-09 13:56:17 -0700 |
---|---|---|
committer | Jeff Brown <jeffbrown@google.com> | 2012-09-09 14:08:52 -0700 |
commit | d8544a51482c86b12da3ac82ea77b83045f689b7 (patch) | |
tree | ab1c3abf59b2db7429afbe16956a301368d09f63 /wifi/java/android/net/wifi/p2p/WifiP2pGroupList.java | |
parent | 21c7153d30071dcbeb92daa1fd48ed181e42aef3 (diff) | |
download | frameworks_base-d8544a51482c86b12da3ac82ea77b83045f689b7.zip frameworks_base-d8544a51482c86b12da3ac82ea77b83045f689b7.tar.gz frameworks_base-d8544a51482c86b12da3ac82ea77b83045f689b7.tar.bz2 |
Copy all mutable state before sending to clients.
This resolves an issue with ConcurrentModificationException
or inconsistent data being perceived by clients.
Fixed an NPE in the WifiP2pDeviceList copy constructor.
Bug: 7133752
Change-Id: I37a4d004f7b1ca21d490f131039d81695db2ba42
Diffstat (limited to 'wifi/java/android/net/wifi/p2p/WifiP2pGroupList.java')
-rw-r--r-- | wifi/java/android/net/wifi/p2p/WifiP2pGroupList.java | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/wifi/java/android/net/wifi/p2p/WifiP2pGroupList.java b/wifi/java/android/net/wifi/p2p/WifiP2pGroupList.java index 3459a5a..98f0972 100644 --- a/wifi/java/android/net/wifi/p2p/WifiP2pGroupList.java +++ b/wifi/java/android/net/wifi/p2p/WifiP2pGroupList.java @@ -16,6 +16,7 @@ package android.net.wifi.p2p; import java.util.Collection; +import java.util.Map; import android.os.Parcel; import android.os.Parcelable; @@ -32,8 +33,9 @@ public class WifiP2pGroupList implements Parcelable { private static final int CREDENTIAL_MAX_NUM = 32; - private LruCache<Integer, WifiP2pGroup> mGroups; - private GroupDeleteListener mListener; + private final LruCache<Integer, WifiP2pGroup> mGroups; + private final GroupDeleteListener mListener; + private boolean isClearCalled = false; public interface GroupDeleteListener { @@ -41,10 +43,10 @@ public class WifiP2pGroupList implements Parcelable { } WifiP2pGroupList() { - this(null); + this(null, null); } - WifiP2pGroupList(GroupDeleteListener listener) { + WifiP2pGroupList(WifiP2pGroupList source, GroupDeleteListener listener) { mListener = listener; mGroups = new LruCache<Integer, WifiP2pGroup>(CREDENTIAL_MAX_NUM) { @Override @@ -55,6 +57,12 @@ public class WifiP2pGroupList implements Parcelable { } } }; + + if (source != null) { + for (Map.Entry<Integer, WifiP2pGroup> item : source.mGroups.snapshot().entrySet()) { + mGroups.put(item.getKey(), item.getValue()); + } + } } /** |