Merge "Make copies of NetworkInfo to give out." into honeycomb-LTE
This commit is contained in:
committed by
Android (Google) Code Review
commit
2f835a6193
@ -386,7 +386,7 @@ public class MobileDataStateTracker implements NetworkStateTracker {
|
||||
&& lastReason != null)
|
||||
reason = lastReason;
|
||||
mNetworkInfo.setDetailedState(state, reason, extraInfo);
|
||||
Message msg = mTarget.obtainMessage(EVENT_STATE_CHANGED, mNetworkInfo);
|
||||
Message msg = mTarget.obtainMessage(EVENT_STATE_CHANGED, new NetworkInfo(mNetworkInfo));
|
||||
msg.sendToTarget();
|
||||
}
|
||||
}
|
||||
|
@ -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.
|
||||
|
@ -160,7 +160,7 @@ public class WifiStateTracker implements NetworkStateTracker {
|
||||
* Fetch NetworkInfo for the network
|
||||
*/
|
||||
public NetworkInfo getNetworkInfo() {
|
||||
return mNetworkInfo;
|
||||
return new NetworkInfo(mNetworkInfo);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -226,7 +226,8 @@ public class WifiStateTracker implements NetworkStateTracker {
|
||||
} else {
|
||||
mLastState = state;
|
||||
}
|
||||
Message msg = mCsHandler.obtainMessage(EVENT_STATE_CHANGED, mNetworkInfo);
|
||||
Message msg = mCsHandler.obtainMessage(EVENT_STATE_CHANGED,
|
||||
new NetworkInfo(mNetworkInfo));
|
||||
msg.sendToTarget();
|
||||
} else if (intent.getAction().equals(WifiManager.LINK_CONFIGURATION_CHANGED_ACTION)) {
|
||||
mLinkProperties = (LinkProperties) intent.getParcelableExtra(
|
||||
|
Reference in New Issue
Block a user