diff options
| author | Robert Greenwalt <rgreenwalt@google.com> | 2011-06-16 12:42:15 -0700 |
|---|---|---|
| committer | Android Git Automerger <android-git-automerger@android.com> | 2011-06-16 12:42:15 -0700 |
| commit | 241b65aca93e263f0869c5bec4ad1dbda0dec6db (patch) | |
| tree | a2fd6e08f7167ce8fe140ece946ed3700a906bd9 /services/java/com/android/server/ConnectivityService.java | |
| parent | 03cbb58e2418dc22ae18a8648404382da4ee46e8 (diff) | |
| parent | 5f3505121b761dbd3bba62d1603fbab49de139b9 (diff) | |
am 5f350512: Merge "Reset connections AFTER we take down the network." into honeycomb-LTE
* commit '5f3505121b761dbd3bba62d1603fbab49de139b9':
Reset connections AFTER we take down the network.
Diffstat (limited to 'services/java/com/android/server/ConnectivityService.java')
| -rw-r--r-- | services/java/com/android/server/ConnectivityService.java | 41 |
1 files changed, 37 insertions, 4 deletions
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java index 55ce80b851bb..fe31a91c5219 100644 --- a/services/java/com/android/server/ConnectivityService.java +++ b/services/java/com/android/server/ConnectivityService.java @@ -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); /* @@ -1355,7 +1377,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { } thisNet.setTeardownRequested(false); updateNetworkSettings(thisNet); - handleConnectivityChange(type); + handleConnectivityChange(type, false); sendConnectedBroadcast(info); } @@ -1365,7 +1387,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. @@ -1405,6 +1427,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) { @@ -1847,7 +1880,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; |
