Merge "Reset connections AFTER we take down the network." into honeycomb-LTE
This commit is contained in:
committed by
Android (Google) Code Review
commit
5f3505121b
@@ -69,10 +69,6 @@ public class MobileDataStateTracker implements NetworkStateTracker {
|
||||
private boolean mPrivateDnsRouteSet = false;
|
||||
private boolean mDefaultRouteSet = false;
|
||||
|
||||
// DEFAULT and HIPRI are the same connection. If we're one of these we need to check if
|
||||
// the other is also disconnected before we reset sockets
|
||||
private boolean mIsDefaultOrHipri = false;
|
||||
|
||||
private Handler mHandler;
|
||||
private AsyncChannel mDataConnectionTrackerAc;
|
||||
private Messenger mMessenger;
|
||||
@@ -87,12 +83,6 @@ public class MobileDataStateTracker implements NetworkStateTracker {
|
||||
TelephonyManager.getDefault().getNetworkType(), tag,
|
||||
TelephonyManager.getDefault().getNetworkTypeName());
|
||||
mApnType = networkTypeToApnType(netType);
|
||||
if (netType == ConnectivityManager.TYPE_MOBILE ||
|
||||
netType == ConnectivityManager.TYPE_MOBILE_HIPRI) {
|
||||
mIsDefaultOrHipri = true;
|
||||
}
|
||||
|
||||
mPhoneService = null;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -180,8 +170,6 @@ public class MobileDataStateTracker implements NetworkStateTracker {
|
||||
}
|
||||
|
||||
private class MobileDataStateReceiver extends BroadcastReceiver {
|
||||
IConnectivityManager mConnectivityManager;
|
||||
|
||||
@Override
|
||||
public void onReceive(Context context, Intent intent) {
|
||||
if (intent.getAction().equals(TelephonyIntents.
|
||||
@@ -218,35 +206,6 @@ public class MobileDataStateTracker implements NetworkStateTracker {
|
||||
}
|
||||
|
||||
setDetailedState(DetailedState.DISCONNECTED, reason, apnName);
|
||||
boolean doReset = true;
|
||||
if (mIsDefaultOrHipri == true) {
|
||||
// both default and hipri must go down before we reset
|
||||
int typeToCheck = (Phone.APN_TYPE_DEFAULT.equals(mApnType) ?
|
||||
ConnectivityManager.TYPE_MOBILE_HIPRI :
|
||||
ConnectivityManager.TYPE_MOBILE);
|
||||
if (mConnectivityManager == null) {
|
||||
IBinder b = ServiceManager.getService(
|
||||
Context.CONNECTIVITY_SERVICE);
|
||||
mConnectivityManager = IConnectivityManager.Stub.asInterface(b);
|
||||
}
|
||||
try {
|
||||
if (mConnectivityManager != null) {
|
||||
NetworkInfo info = mConnectivityManager.getNetworkInfo(
|
||||
typeToCheck);
|
||||
if (info.isConnected() == true) {
|
||||
doReset = false;
|
||||
}
|
||||
}
|
||||
} catch (RemoteException e) {
|
||||
// just go ahead with the reset
|
||||
loge("Exception trying to contact ConnService: " + e);
|
||||
}
|
||||
}
|
||||
if (doReset && mLinkProperties != null) {
|
||||
String iface = mLinkProperties.getInterfaceName();
|
||||
if (iface != null) NetworkUtils.resetConnections(iface);
|
||||
}
|
||||
// TODO - check this
|
||||
// can't do this here - ConnectivityService needs it to clear stuff
|
||||
// it's ok though - just leave it to be refreshed next time
|
||||
// we connect.
|
||||
|
||||
@@ -1129,8 +1129,30 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
||||
}
|
||||
}
|
||||
intent.putExtra(ConnectivityManager.EXTRA_INET_CONDITION, mDefaultInetConditionPublished);
|
||||
|
||||
// Reset interface if no other connections are using the same interface
|
||||
boolean doReset = true;
|
||||
LinkProperties linkProperties = mNetTrackers[prevNetType].getLinkProperties();
|
||||
if (linkProperties != null) {
|
||||
String oldIface = linkProperties.getInterfaceName();
|
||||
if (TextUtils.isEmpty(oldIface) == false) {
|
||||
for (NetworkStateTracker networkStateTracker : mNetTrackers) {
|
||||
if (networkStateTracker == null) continue;
|
||||
NetworkInfo networkInfo = networkStateTracker.getNetworkInfo();
|
||||
if (networkInfo.isConnected() && networkInfo.getType() != prevNetType) {
|
||||
LinkProperties l = networkStateTracker.getLinkProperties();
|
||||
if (l == null) continue;
|
||||
if (oldIface.equals(l.getInterfaceName())) {
|
||||
doReset = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// do this before we broadcast the change
|
||||
handleConnectivityChange(prevNetType);
|
||||
handleConnectivityChange(prevNetType, doReset);
|
||||
|
||||
sendStickyBroadcast(intent);
|
||||
/*
|
||||
@@ -1354,7 +1376,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
||||
}
|
||||
thisNet.setTeardownRequested(false);
|
||||
updateNetworkSettings(thisNet);
|
||||
handleConnectivityChange(type);
|
||||
handleConnectivityChange(type, false);
|
||||
sendConnectedBroadcast(info);
|
||||
}
|
||||
|
||||
@@ -1364,7 +1386,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
||||
* according to which networks are connected, and ensuring that the
|
||||
* right routing table entries exist.
|
||||
*/
|
||||
private void handleConnectivityChange(int netType) {
|
||||
private void handleConnectivityChange(int netType, boolean doReset) {
|
||||
/*
|
||||
* If a non-default network is enabled, add the host routes that
|
||||
* will allow it's DNS servers to be accessed.
|
||||
@@ -1391,6 +1413,17 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
||||
removePrivateDnsRoutes(mNetTrackers[netType]);
|
||||
}
|
||||
}
|
||||
|
||||
if (doReset) {
|
||||
LinkProperties linkProperties = mNetTrackers[netType].getLinkProperties();
|
||||
if (linkProperties != null) {
|
||||
String iface = linkProperties.getInterfaceName();
|
||||
if (TextUtils.isEmpty(iface) == false) {
|
||||
if (DBG) log("resetConnections(" + iface + ")");
|
||||
NetworkUtils.resetConnections(iface);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void addPrivateDnsRoutes(NetworkStateTracker nt) {
|
||||
@@ -1833,7 +1866,7 @@ public class ConnectivityService extends IConnectivityManager.Stub {
|
||||
break;
|
||||
case NetworkStateTracker.EVENT_CONFIGURATION_CHANGED:
|
||||
info = (NetworkInfo) msg.obj;
|
||||
handleConnectivityChange(info.getType());
|
||||
handleConnectivityChange(info.getType(), true);
|
||||
break;
|
||||
case EVENT_CLEAR_NET_TRANSITION_WAKELOCK:
|
||||
String causedBy = null;
|
||||
|
||||
@@ -1362,7 +1362,7 @@ public class WifiStateMachine extends StateMachine {
|
||||
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT
|
||||
| Intent.FLAG_RECEIVER_REPLACE_PENDING);
|
||||
intent.putExtra(WifiManager.EXTRA_NETWORK_INFO, mNetworkInfo);
|
||||
intent.putExtra(WifiManager.EXTRA_LINK_PROPERTIES, mLinkProperties);
|
||||
intent.putExtra(WifiManager.EXTRA_LINK_PROPERTIES, new LinkProperties (mLinkProperties));
|
||||
if (bssid != null)
|
||||
intent.putExtra(WifiManager.EXTRA_BSSID, bssid);
|
||||
mContext.sendStickyBroadcast(intent);
|
||||
@@ -1378,7 +1378,7 @@ public class WifiStateMachine extends StateMachine {
|
||||
private void sendLinkConfigurationChangedBroadcast() {
|
||||
Intent intent = new Intent(WifiManager.LINK_CONFIGURATION_CHANGED_ACTION);
|
||||
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
|
||||
intent.putExtra(WifiManager.EXTRA_LINK_PROPERTIES, mLinkProperties);
|
||||
intent.putExtra(WifiManager.EXTRA_LINK_PROPERTIES, new LinkProperties(mLinkProperties));
|
||||
mContext.sendBroadcast(intent);
|
||||
}
|
||||
|
||||
@@ -1413,10 +1413,8 @@ public class WifiStateMachine extends StateMachine {
|
||||
Log.d(TAG, "Reset connections and stopping DHCP");
|
||||
|
||||
/*
|
||||
* Reset connections & stop DHCP
|
||||
* stop DHCP
|
||||
*/
|
||||
NetworkUtils.resetConnections(mInterfaceName);
|
||||
|
||||
if (mDhcpStateMachine != null) {
|
||||
mDhcpStateMachine.sendMessage(DhcpStateMachine.CMD_STOP_DHCP);
|
||||
mDhcpStateMachine.quit();
|
||||
@@ -1509,7 +1507,6 @@ public class WifiStateMachine extends StateMachine {
|
||||
if (!linkProperties.equals(mLinkProperties)) {
|
||||
Log.d(TAG, "Link configuration changed for netId: " + mLastNetworkId
|
||||
+ " old: " + mLinkProperties + "new: " + linkProperties);
|
||||
NetworkUtils.resetConnections(mInterfaceName);
|
||||
mLinkProperties = linkProperties;
|
||||
sendLinkConfigurationChangedBroadcast();
|
||||
}
|
||||
@@ -2787,7 +2784,6 @@ public class WifiStateMachine extends StateMachine {
|
||||
if (mWifiInfo.getNetworkId() == result.getNetworkId()) {
|
||||
if (result.hasIpChanged()) {
|
||||
Log.d(TAG,"Reconfiguring IP on connection");
|
||||
NetworkUtils.resetConnections(mInterfaceName);
|
||||
transitionTo(mConnectingState);
|
||||
}
|
||||
if (result.hasProxyChanged()) {
|
||||
|
||||
Reference in New Issue
Block a user