Direct notification of network interface changes.

Connectivity broadcasts recently changed and are no longer sent for
certain types of network changes.  For example, when stacked network
interfaces change for a mobile network.  To ensure that we pick up
all these details, directly wire the two services together.

Also remove some unused code for split network types.

Bug: 18666753
Change-Id: I0467bd5b330c0e0cb51af2306d821b41ad16337a
This commit is contained in:
Jeff Sharkey
2014-12-08 14:50:12 -08:00
parent fffa983fe4
commit aa6ff6c7b0

View File

@@ -231,6 +231,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
private static ConnectivityService sServiceInstance; private static ConnectivityService sServiceInstance;
private INetworkManagementService mNetd; private INetworkManagementService mNetd;
private INetworkStatsService mStatsService;
private INetworkPolicyManager mPolicyManager; private INetworkPolicyManager mPolicyManager;
private String mCurrentTcpBufferSizes; private String mCurrentTcpBufferSizes;
@@ -630,6 +631,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
mContext = checkNotNull(context, "missing Context"); mContext = checkNotNull(context, "missing Context");
mNetd = checkNotNull(netManager, "missing INetworkManagementService"); mNetd = checkNotNull(netManager, "missing INetworkManagementService");
mStatsService = checkNotNull(statsService, "missing INetworkStatsService");
mPolicyManager = checkNotNull(policyManager, "missing INetworkPolicyManager"); mPolicyManager = checkNotNull(policyManager, "missing INetworkPolicyManager");
mKeyStore = KeyStore.getInstance(); mKeyStore = KeyStore.getInstance();
mTelephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE); mTelephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
@@ -2166,6 +2168,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
if (isDefaultNetwork(nai)) { if (isDefaultNetwork(nai)) {
mDefaultInetConditionPublished = 0; mDefaultInetConditionPublished = 0;
} }
notifyIfacesChanged();
notifyNetworkCallbacks(nai, ConnectivityManager.CALLBACK_LOST); notifyNetworkCallbacks(nai, ConnectivityManager.CALLBACK_LOST);
nai.networkMonitor.sendMessage(NetworkMonitor.CMD_NETWORK_DISCONNECTED); nai.networkMonitor.sendMessage(NetworkMonitor.CMD_NETWORK_DISCONNECTED);
mNetworkAgentInfos.remove(msg.replyTo); mNetworkAgentInfos.remove(msg.replyTo);
@@ -3660,6 +3663,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
if (isDefaultNetwork(networkAgent)) handleApplyDefaultProxy(newLp.getHttpProxy()); if (isDefaultNetwork(networkAgent)) handleApplyDefaultProxy(newLp.getHttpProxy());
// TODO - move this check to cover the whole function // TODO - move this check to cover the whole function
if (!Objects.equals(newLp, oldLp)) { if (!Objects.equals(newLp, oldLp)) {
notifyIfacesChanged();
notifyNetworkCallbacks(networkAgent, ConnectivityManager.CALLBACK_IP_CHANGED); notifyNetworkCallbacks(networkAgent, ConnectivityManager.CALLBACK_IP_CHANGED);
} }
} }
@@ -4250,6 +4254,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
} }
networkAgent.created = true; networkAgent.created = true;
updateLinkProperties(networkAgent, null); updateLinkProperties(networkAgent, null);
notifyIfacesChanged();
notifyNetworkCallbacks(networkAgent, ConnectivityManager.CALLBACK_PRECHECK); notifyNetworkCallbacks(networkAgent, ConnectivityManager.CALLBACK_PRECHECK);
networkAgent.networkMonitor.sendMessage(NetworkMonitor.CMD_NETWORK_CONNECTED); networkAgent.networkMonitor.sendMessage(NetworkMonitor.CMD_NETWORK_CONNECTED);
if (networkAgent.isVPN()) { if (networkAgent.isVPN()) {
@@ -4393,6 +4398,16 @@ public class ConnectivityService extends IConnectivityManager.Stub
return "UNKNOWN"; return "UNKNOWN";
} }
/**
* Notify other system services that set of active ifaces has changed.
*/
private void notifyIfacesChanged() {
try {
mStatsService.forceUpdateIfaces();
} catch (Exception ignored) {
}
}
@Override @Override
public boolean addVpnAddress(String address, int prefixLength) { public boolean addVpnAddress(String address, int prefixLength) {
throwIfLockdownEnabled(); throwIfLockdownEnabled();