diff options
| author | Wink Saville <wink@google.com> | 2011-07-13 14:19:12 -0700 |
|---|---|---|
| committer | Android Git Automerger <android-git-automerger@android.com> | 2011-07-13 14:19:12 -0700 |
| commit | 3810361e4a3e93d3c8a10aaeec54f65dfcc2d03d (patch) | |
| tree | e71d2736fae96eea7c99a0266760832b519ba481 /services/java/com/android/server/ConnectivityService.java | |
| parent | 6dd4531639157191e6224d3f8af5c9d099ca945f (diff) | |
| parent | 6d1d16c324a681dd966d47497a71a02eac512234 (diff) | |
am 6d1d16c3: Merge "Remove STOPSHIP but allow seamless Handoff when possible." into honeycomb-LTE
* commit '6d1d16c324a681dd966d47497a71a02eac512234':
Remove STOPSHIP but allow seamless Handoff when possible.
Diffstat (limited to 'services/java/com/android/server/ConnectivityService.java')
| -rw-r--r-- | services/java/com/android/server/ConnectivityService.java | 59 |
1 files changed, 54 insertions, 5 deletions
diff --git a/services/java/com/android/server/ConnectivityService.java b/services/java/com/android/server/ConnectivityService.java index aca603a6a433..5861505dc221 100644 --- a/services/java/com/android/server/ConnectivityService.java +++ b/services/java/com/android/server/ConnectivityService.java @@ -28,6 +28,7 @@ import android.net.EthernetDataTracker; import android.net.IConnectivityManager; import android.net.LinkAddress; import android.net.LinkProperties; +import android.net.LinkProperties.CompareAddressesResult; import android.net.MobileDataStateTracker; import android.net.NetworkConfig; import android.net.NetworkInfo; @@ -61,6 +62,7 @@ import java.io.FileDescriptor; import java.io.FileWriter; import java.io.IOException; import java.io.PrintWriter; +import java.net.Inet6Address; import java.net.InetAddress; import java.net.Inet4Address; import java.net.UnknownHostException; @@ -76,6 +78,7 @@ import java.util.List; public class ConnectivityService extends IConnectivityManager.Stub { private static final boolean DBG = true; + private static final boolean VDBG = true; private static final String TAG = "ConnectivityService"; // how long to wait before switching back to a radio's default network @@ -99,6 +102,11 @@ public class ConnectivityService extends IConnectivityManager.Stub { private NetworkStateTracker mNetTrackers[]; /** + * The link properties that define the current links + */ + private LinkProperties mCurrentLinkProperties[]; + + /** * A per Net list of the PID's that requested access to the net * used both as a refcount and for per-PID DNS selection */ @@ -302,6 +310,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { mNetTrackers = new NetworkStateTracker[ ConnectivityManager.MAX_NETWORK_TYPE+1]; + mCurrentLinkProperties = new LinkProperties[ConnectivityManager.MAX_NETWORK_TYPE+1]; mNetworkPreference = getPersistedNetworkPreference(); @@ -442,6 +451,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { mNetConfigs[netType].radio); continue; } + mCurrentLinkProperties[netType] = mNetTrackers[netType].getLinkProperties(); } mTethering = new Tethering(mContext, mHandler.getLooper()); @@ -1410,6 +1420,8 @@ public class ConnectivityService extends IConnectivityManager.Stub { * right routing table entries exist. */ private void handleConnectivityChange(int netType, boolean doReset) { + int resetMask = doReset ? NetworkUtils.RESET_ALL_ADDRESSES : 0; + /* * If a non-default network is enabled, add the host routes that * will allow it's DNS servers to be accessed. @@ -1417,6 +1429,45 @@ public class ConnectivityService extends IConnectivityManager.Stub { handleDnsConfigurationChange(netType); if (mNetTrackers[netType].getNetworkInfo().isConnected()) { + LinkProperties newLp = mNetTrackers[netType].getLinkProperties(); + LinkProperties curLp = mCurrentLinkProperties[netType]; + mCurrentLinkProperties[netType] = newLp; + if (VDBG) { + log("handleConnectivityChange: changed linkProperty[" + netType + "]:" + + " doReset=" + doReset + " resetMask=" + resetMask + + "\n curLp=" + curLp + + "\n newLp=" + newLp); + } + + if (curLp.isIdenticalInterfaceName(newLp)) { + CompareAddressesResult car = curLp.compareAddresses(newLp); + if ((car.removed.size() != 0) || (car.added.size() != 0)) { + for (LinkAddress linkAddr : car.removed) { + if (linkAddr.getAddress() instanceof Inet4Address) { + resetMask |= NetworkUtils.RESET_IPV4_ADDRESSES; + } + if (linkAddr.getAddress() instanceof Inet6Address) { + resetMask |= NetworkUtils.RESET_IPV6_ADDRESSES; + } + } + if (DBG) { + log("handleConnectivityChange: addresses changed" + + " linkProperty[" + netType + "]:" + " resetMask=" + resetMask + + "\n car=" + car); + } + } else { + if (DBG) { + log("handleConnectivityChange: address are the same reset per doReset" + + " linkProperty[" + netType + "]:" + + " resetMask=" + resetMask); + } + } + } else { + resetMask = NetworkUtils.RESET_ALL_ADDRESSES; + log("handleConnectivityChange: interface not not equivalent reset both" + + " linkProperty[" + netType + "]:" + + " resetMask=" + resetMask); + } if (mNetConfigs[netType].isDefault()) { handleApplyDefaultProxy(netType); addDefaultRoute(mNetTrackers[netType]); @@ -1444,15 +1495,13 @@ public class ConnectivityService extends IConnectivityManager.Stub { } } - if (doReset) { + if (doReset || resetMask != 0) { LinkProperties linkProperties = mNetTrackers[netType].getLinkProperties(); if (linkProperties != null) { String iface = linkProperties.getInterfaceName(); if (TextUtils.isEmpty(iface) == false) { - if (DBG) { - log("resetConnections(" + iface + ", NetworkUtils.RESET_ALL_ADDRESSES)"); - } - NetworkUtils.resetConnections(iface, NetworkUtils.RESET_ALL_ADDRESSES); + if (DBG) log("resetConnections(" + iface + ", " + resetMask + ")"); + NetworkUtils.resetConnections(iface, resetMask); } } } |
