Loading core/java/android/net/NetworkStateTracker.java +2 −6 Original line number Diff line number Diff line Loading @@ -45,7 +45,6 @@ public abstract class NetworkStateTracker extends Handler { protected String[] mDnsPropNames; private boolean mPrivateDnsRouteSet; protected int mDefaultGatewayAddr; private boolean mDefaultRouteSet; private boolean mTeardownRequested; private static boolean DBG = true; Loading Loading @@ -153,25 +152,22 @@ public abstract class NetworkStateTracker extends Handler { } public void addDefaultRoute() { if ((mInterfaceName != null) && (mDefaultGatewayAddr != 0) && mDefaultRouteSet == false) { if ((mInterfaceName != null) && (mDefaultGatewayAddr != 0)) { if (DBG) { Log.d(TAG, "addDefaultRoute for " + mNetworkInfo.getTypeName() + " (" + mInterfaceName + "), GatewayAddr=" + mDefaultGatewayAddr); } NetworkUtils.setDefaultRoute(mInterfaceName, mDefaultGatewayAddr); mDefaultRouteSet = true; } } public void removeDefaultRoute() { if (mInterfaceName != null && mDefaultRouteSet == true) { if (mInterfaceName != null) { if (DBG) { Log.d(TAG, "removeDefaultRoute for " + mNetworkInfo.getTypeName() + " (" + mInterfaceName + ")"); } NetworkUtils.removeDefaultRoute(mInterfaceName); mDefaultRouteSet = false; } } Loading services/java/com/android/server/ConnectivityService.java +48 −62 Original line number Diff line number Diff line Loading @@ -582,7 +582,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { !network.isTeardownRequested()) { if (ni.isConnected() == true) { // add the pid-specific dns handleDnsConfigurationChange(); handleDnsConfigurationChange(networkType); if (DBG) Slog.d(TAG, "special network already active"); return Phone.APN_ALREADY_ACTIVE; } Loading Loading @@ -914,7 +914,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { } } // do this before we broadcast the change handleConnectivityChange(); handleConnectivityChange(prevNetType); sendStickyBroadcast(intent); /* Loading Loading @@ -1070,9 +1070,6 @@ public class ConnectivityService extends IConnectivityManager.Stub { } } // do this before we broadcast the change handleConnectivityChange(); sendStickyBroadcast(intent); /* * If the failover network is already connected, then immediately send Loading Loading @@ -1143,7 +1140,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { } thisNet.setTeardownRequested(false); thisNet.updateNetworkSettings(); handleConnectivityChange(); handleConnectivityChange(type); sendConnectedBroadcast(info); } Loading @@ -1170,26 +1167,18 @@ public class ConnectivityService extends IConnectivityManager.Stub { } /** * After any kind of change in the connectivity state of any network, * make sure that anything that depends on the connectivity state of * more than one network is set up correctly. We're mainly concerned * with making sure that the list of DNS servers is set up according * to which networks are connected, and ensuring that the right routing * table entries exist. * After a change in the connectivity state of any network, We're mainly * concerned with making sure that the list of DNS servers is setupup * according to which networks are connected, and ensuring that the * right routing table entries exist. */ private void handleConnectivityChange() { private void handleConnectivityChange(int netType) { /* * If a non-default network is enabled, add the host routes that * will allow it's DNS servers to be accessed. Only * If both mobile and wifi are enabled, add the host routes that * will allow MMS traffic to pass on the mobile network. But * remove the default route for the mobile network, so that there * will be only one default route, to ensure that all traffic * except MMS will travel via Wi-Fi. * will allow it's DNS servers to be accessed. */ handleDnsConfigurationChange(); handleDnsConfigurationChange(netType); for (int netType : mPriorityList) { if (mNetTrackers[netType].getNetworkInfo().isConnected()) { if (mNetAttributes[netType].isDefault()) { mNetTrackers[netType].addDefaultRoute(); Loading @@ -1204,7 +1193,6 @@ public class ConnectivityService extends IConnectivityManager.Stub { } } } } /** * Adjust the per-process dns entries (net.dns<x>.<pid>) based Loading Loading @@ -1272,13 +1260,10 @@ public class ConnectivityService extends IConnectivityManager.Stub { SystemProperties.set("net.dnschange", "" + (n+1)); } private void handleDnsConfigurationChange() { private void handleDnsConfigurationChange(int netType) { // add default net's dns entries for (int x = mPriorityList.length-1; x>= 0; x--) { int netType = mPriorityList[x]; NetworkStateTracker nt = mNetTrackers[netType]; if (nt != null && nt.getNetworkInfo().isConnected() && !nt.isTeardownRequested()) { if (nt != null && nt.getNetworkInfo().isConnected() && !nt.isTeardownRequested()) { String[] dnsList = nt.getNameServers(); if (mNetAttributes[netType].isDefault()) { int j = 1; Loading @@ -1305,8 +1290,6 @@ public class ConnectivityService extends IConnectivityManager.Stub { } } } } bumpDns(); } Loading Loading @@ -1437,9 +1420,12 @@ public class ConnectivityService extends IConnectivityManager.Stub { case NetworkStateTracker.EVENT_NOTIFICATION_CHANGED: handleNotificationChange(msg.arg1 == 1, msg.arg2, (Notification) msg.obj); break; case NetworkStateTracker.EVENT_CONFIGURATION_CHANGED: handleDnsConfigurationChange(); info = (NetworkInfo) msg.obj; type = info.getType(); handleDnsConfigurationChange(type); break; case NetworkStateTracker.EVENT_ROAMING_CHANGED: Loading wifi/java/android/net/wifi/WifiStateTracker.java +4 −2 Original line number Diff line number Diff line Loading @@ -1132,7 +1132,8 @@ public class WifiStateTracker extends NetworkStateTracker { setDetailedState(DetailedState.CONNECTED); sendNetworkStateChangeBroadcast(mWifiInfo.getBSSID()); } else { mTarget.sendEmptyMessage(EVENT_CONFIGURATION_CHANGED); msg = mTarget.obtainMessage(EVENT_CONFIGURATION_CHANGED, mNetworkInfo); msg.sendToTarget(); } if (LOCAL_LOGD) Log.v(TAG, "IP configuration: " + mDhcpInfo); // Wi-Fi interface configuration state changed: Loading Loading @@ -2476,7 +2477,8 @@ public class WifiStateTracker extends NetworkStateTracker { resetConnections(true); configureInterface(); if (mUseStaticIp) { mTarget.sendEmptyMessage(EVENT_CONFIGURATION_CHANGED); Message msg = mTarget.obtainMessage(EVENT_CONFIGURATION_CHANGED, mNetworkInfo); msg.sendToTarget(); } } } Loading Loading
core/java/android/net/NetworkStateTracker.java +2 −6 Original line number Diff line number Diff line Loading @@ -45,7 +45,6 @@ public abstract class NetworkStateTracker extends Handler { protected String[] mDnsPropNames; private boolean mPrivateDnsRouteSet; protected int mDefaultGatewayAddr; private boolean mDefaultRouteSet; private boolean mTeardownRequested; private static boolean DBG = true; Loading Loading @@ -153,25 +152,22 @@ public abstract class NetworkStateTracker extends Handler { } public void addDefaultRoute() { if ((mInterfaceName != null) && (mDefaultGatewayAddr != 0) && mDefaultRouteSet == false) { if ((mInterfaceName != null) && (mDefaultGatewayAddr != 0)) { if (DBG) { Log.d(TAG, "addDefaultRoute for " + mNetworkInfo.getTypeName() + " (" + mInterfaceName + "), GatewayAddr=" + mDefaultGatewayAddr); } NetworkUtils.setDefaultRoute(mInterfaceName, mDefaultGatewayAddr); mDefaultRouteSet = true; } } public void removeDefaultRoute() { if (mInterfaceName != null && mDefaultRouteSet == true) { if (mInterfaceName != null) { if (DBG) { Log.d(TAG, "removeDefaultRoute for " + mNetworkInfo.getTypeName() + " (" + mInterfaceName + ")"); } NetworkUtils.removeDefaultRoute(mInterfaceName); mDefaultRouteSet = false; } } Loading
services/java/com/android/server/ConnectivityService.java +48 −62 Original line number Diff line number Diff line Loading @@ -582,7 +582,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { !network.isTeardownRequested()) { if (ni.isConnected() == true) { // add the pid-specific dns handleDnsConfigurationChange(); handleDnsConfigurationChange(networkType); if (DBG) Slog.d(TAG, "special network already active"); return Phone.APN_ALREADY_ACTIVE; } Loading Loading @@ -914,7 +914,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { } } // do this before we broadcast the change handleConnectivityChange(); handleConnectivityChange(prevNetType); sendStickyBroadcast(intent); /* Loading Loading @@ -1070,9 +1070,6 @@ public class ConnectivityService extends IConnectivityManager.Stub { } } // do this before we broadcast the change handleConnectivityChange(); sendStickyBroadcast(intent); /* * If the failover network is already connected, then immediately send Loading Loading @@ -1143,7 +1140,7 @@ public class ConnectivityService extends IConnectivityManager.Stub { } thisNet.setTeardownRequested(false); thisNet.updateNetworkSettings(); handleConnectivityChange(); handleConnectivityChange(type); sendConnectedBroadcast(info); } Loading @@ -1170,26 +1167,18 @@ public class ConnectivityService extends IConnectivityManager.Stub { } /** * After any kind of change in the connectivity state of any network, * make sure that anything that depends on the connectivity state of * more than one network is set up correctly. We're mainly concerned * with making sure that the list of DNS servers is set up according * to which networks are connected, and ensuring that the right routing * table entries exist. * After a change in the connectivity state of any network, We're mainly * concerned with making sure that the list of DNS servers is setupup * according to which networks are connected, and ensuring that the * right routing table entries exist. */ private void handleConnectivityChange() { private void handleConnectivityChange(int netType) { /* * If a non-default network is enabled, add the host routes that * will allow it's DNS servers to be accessed. Only * If both mobile and wifi are enabled, add the host routes that * will allow MMS traffic to pass on the mobile network. But * remove the default route for the mobile network, so that there * will be only one default route, to ensure that all traffic * except MMS will travel via Wi-Fi. * will allow it's DNS servers to be accessed. */ handleDnsConfigurationChange(); handleDnsConfigurationChange(netType); for (int netType : mPriorityList) { if (mNetTrackers[netType].getNetworkInfo().isConnected()) { if (mNetAttributes[netType].isDefault()) { mNetTrackers[netType].addDefaultRoute(); Loading @@ -1204,7 +1193,6 @@ public class ConnectivityService extends IConnectivityManager.Stub { } } } } /** * Adjust the per-process dns entries (net.dns<x>.<pid>) based Loading Loading @@ -1272,13 +1260,10 @@ public class ConnectivityService extends IConnectivityManager.Stub { SystemProperties.set("net.dnschange", "" + (n+1)); } private void handleDnsConfigurationChange() { private void handleDnsConfigurationChange(int netType) { // add default net's dns entries for (int x = mPriorityList.length-1; x>= 0; x--) { int netType = mPriorityList[x]; NetworkStateTracker nt = mNetTrackers[netType]; if (nt != null && nt.getNetworkInfo().isConnected() && !nt.isTeardownRequested()) { if (nt != null && nt.getNetworkInfo().isConnected() && !nt.isTeardownRequested()) { String[] dnsList = nt.getNameServers(); if (mNetAttributes[netType].isDefault()) { int j = 1; Loading @@ -1305,8 +1290,6 @@ public class ConnectivityService extends IConnectivityManager.Stub { } } } } bumpDns(); } Loading Loading @@ -1437,9 +1420,12 @@ public class ConnectivityService extends IConnectivityManager.Stub { case NetworkStateTracker.EVENT_NOTIFICATION_CHANGED: handleNotificationChange(msg.arg1 == 1, msg.arg2, (Notification) msg.obj); break; case NetworkStateTracker.EVENT_CONFIGURATION_CHANGED: handleDnsConfigurationChange(); info = (NetworkInfo) msg.obj; type = info.getType(); handleDnsConfigurationChange(type); break; case NetworkStateTracker.EVENT_ROAMING_CHANGED: Loading
wifi/java/android/net/wifi/WifiStateTracker.java +4 −2 Original line number Diff line number Diff line Loading @@ -1132,7 +1132,8 @@ public class WifiStateTracker extends NetworkStateTracker { setDetailedState(DetailedState.CONNECTED); sendNetworkStateChangeBroadcast(mWifiInfo.getBSSID()); } else { mTarget.sendEmptyMessage(EVENT_CONFIGURATION_CHANGED); msg = mTarget.obtainMessage(EVENT_CONFIGURATION_CHANGED, mNetworkInfo); msg.sendToTarget(); } if (LOCAL_LOGD) Log.v(TAG, "IP configuration: " + mDhcpInfo); // Wi-Fi interface configuration state changed: Loading Loading @@ -2476,7 +2477,8 @@ public class WifiStateTracker extends NetworkStateTracker { resetConnections(true); configureInterface(); if (mUseStaticIp) { mTarget.sendEmptyMessage(EVENT_CONFIGURATION_CHANGED); Message msg = mTarget.obtainMessage(EVENT_CONFIGURATION_CHANGED, mNetworkInfo); msg.sendToTarget(); } } } Loading