Fix minor thread corectness issue in NetworkInfo

Hold the right lock while copying info from another
NetworkInfo object to prevent changes being made to it
while the copy is in progress.

Change-Id: I1aa2c29e81e045b0359f957352c438e79e692823
This commit is contained in:
Narayan Kamath
2013-10-11 13:43:30 +01:00
parent 2ce22dd500
commit b82bc07c9d

View File

@@ -156,6 +156,7 @@ public class NetworkInfo implements Parcelable {
/** {@hide} */ /** {@hide} */
public NetworkInfo(NetworkInfo source) { public NetworkInfo(NetworkInfo source) {
if (source != null) { if (source != null) {
synchronized (source) {
mNetworkType = source.mNetworkType; mNetworkType = source.mNetworkType;
mSubtype = source.mSubtype; mSubtype = source.mSubtype;
mTypeName = source.mTypeName; mTypeName = source.mTypeName;
@@ -170,6 +171,7 @@ public class NetworkInfo implements Parcelable {
mIsConnectedToProvisioningNetwork = source.mIsConnectedToProvisioningNetwork; mIsConnectedToProvisioningNetwork = source.mIsConnectedToProvisioningNetwork;
} }
} }
}
/** /**
* Reports the type of network to which the * Reports the type of network to which the