Also log IPv4 and IPv6 connectivity of any previous default network

Change-Id: I07595c0a131fea21914f524949cd64af87403b88
This commit is contained in:
Erik Kline
2016-04-14 17:30:59 +09:00
parent dd55013f97
commit 2e815d38ac

View File

@@ -2208,9 +2208,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
rematchAllNetworksAndRequests(null, 0);
if (wasDefault && getDefaultNetwork() == null) {
// Log that we lost the default network and there is no replacement.
final int[] transportTypes = new int[0];
ConnectivityServiceChangeEvent.logEvent(NETID_UNSET, nai.network.netId,
transportTypes);
logConnectivityServiceChangeEvent(null, nai);
}
if (nai.created) {
// Tell netd to clean up the configuration for this network
@@ -4434,7 +4432,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
}
private void makeDefault(NetworkAgentInfo newNetwork, NetworkAgentInfo prevNetwork) {
int prevNetId = (prevNetwork == null) ? NETID_UNSET : prevNetwork.network.netId;
if (DBG) log("Switching to new default network: " + newNetwork);
setupDataActivityTracking(newNetwork);
try {
@@ -4446,8 +4443,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
handleApplyDefaultProxy(newNetwork.linkProperties.getHttpProxy());
updateTcpBufferSizes(newNetwork);
setDefaultDnsSystemProperties(newNetwork.linkProperties.getDnsServers());
ConnectivityServiceChangeEvent.logEvent(newNetwork.network.netId, prevNetId,
newNetwork.networkCapabilities.getTransportTypes());
logConnectivityServiceChangeEvent(newNetwork, prevNetwork);
}
// Handles a network appearing or improving its score.
@@ -5068,4 +5065,22 @@ public class ConnectivityService extends IConnectivityManager.Stub
NetworkAgentInfo nai, NetworkRequest defaultRequest) {
return new NetworkMonitor(context, handler, nai, defaultRequest);
}
private static void logConnectivityServiceChangeEvent(
NetworkAgentInfo next, NetworkAgentInfo prev) {
final int newNetId = (next == null) ? NETID_UNSET : next.network.netId;
final int[] newTransportTypes = (next == null)
? new int[0]
: next.networkCapabilities.getTransportTypes();
final int oldNetId = (prev == null) ? NETID_UNSET : prev.network.netId;
final boolean hadIPv4 = (prev != null) &&
prev.linkProperties.hasIPv4Address() &&
prev.linkProperties.hasIPv4DefaultRoute();
final boolean hadIPv6 = (prev != null) &&
prev.linkProperties.hasGlobalIPv6Address() &&
prev.linkProperties.hasIPv6DefaultRoute();
ConnectivityServiceChangeEvent.logEvent(newNetId, newTransportTypes,
oldNetId, hadIPv4, hadIPv6);
}
}