Make copies of NetworkInfo to give out.

Otherwise we'll change it out from under those we've given it too.
bug:5233462

Change-Id: Iffc886849edfa6ced3da1133f9d363e11b2733f8
This commit is contained in:
Robert Greenwalt
2011-09-09 12:38:12 -07:00
parent 4f0de1e285
commit 3084999887

View File

@@ -138,6 +138,23 @@ public class NetworkInfo implements Parcelable {
mIsRoaming = false;
}
/** {@hide} */
public NetworkInfo(NetworkInfo source) {
if (source != null) {
mNetworkType = source.mNetworkType;
mSubtype = source.mSubtype;
mTypeName = source.mTypeName;
mSubtypeName = source.mSubtypeName;
mState = source.mState;
mDetailedState = source.mDetailedState;
mReason = source.mReason;
mExtraInfo = source.mExtraInfo;
mIsFailover = source.mIsFailover;
mIsRoaming = source.mIsRoaming;
mIsAvailable = source.mIsAvailable;
}
}
/**
* Reports the type of network (currently mobile or Wi-Fi) to which the
* info in this object pertains.