Merge "Fix default network transition event recording" into nyc-dev
This commit is contained in:
@@ -68,8 +68,28 @@ public final class DefaultNetworkEvent extends IpConnectivityEvent implements Pa
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("DefaultNetworkEvent(%d -> %d, %s, IPv4: %b, IPv6: %b)", prevNetId,
|
String prevNetwork = String.valueOf(prevNetId);
|
||||||
netId, NetworkCapabilities.transportNamesOf(transportTypes), prevIPv4, prevIPv6);
|
String newNetwork = String.valueOf(netId);
|
||||||
|
if (prevNetId != 0) {
|
||||||
|
prevNetwork += ":" + ipSupport();
|
||||||
|
}
|
||||||
|
if (netId != 0) {
|
||||||
|
newNetwork += ":" + NetworkCapabilities.transportNamesOf(transportTypes);
|
||||||
|
}
|
||||||
|
return String.format("DefaultNetworkEvent(%s -> %s)", prevNetwork, newNetwork);
|
||||||
|
}
|
||||||
|
|
||||||
|
private String ipSupport() {
|
||||||
|
if (prevIPv4 && prevIPv6) {
|
||||||
|
return "DUAL";
|
||||||
|
}
|
||||||
|
if (prevIPv6) {
|
||||||
|
return "IPv6";
|
||||||
|
}
|
||||||
|
if (prevIPv4) {
|
||||||
|
return "IPv4";
|
||||||
|
}
|
||||||
|
return "NONE";
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final Parcelable.Creator<DefaultNetworkEvent> CREATOR
|
public static final Parcelable.Creator<DefaultNetworkEvent> CREATOR
|
||||||
|
|||||||
@@ -2245,6 +2245,11 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
final boolean wasDefault = isDefaultNetwork(nai);
|
final boolean wasDefault = isDefaultNetwork(nai);
|
||||||
if (wasDefault) {
|
if (wasDefault) {
|
||||||
mDefaultInetConditionPublished = 0;
|
mDefaultInetConditionPublished = 0;
|
||||||
|
// Log default network disconnection before required book-keeping.
|
||||||
|
// Let rematchAllNetworksAndRequests() below record a new default network event
|
||||||
|
// if there is a fallback. Taken together, the two form a X -> 0, 0 -> Y sequence
|
||||||
|
// whose timestamps tell how long it takes to recover a default network.
|
||||||
|
logDefaultNetworkEvent(null, nai);
|
||||||
}
|
}
|
||||||
notifyIfacesChangedForNetworkStats();
|
notifyIfacesChangedForNetworkStats();
|
||||||
// TODO - we shouldn't send CALLBACK_LOST to requests that can be satisfied
|
// TODO - we shouldn't send CALLBACK_LOST to requests that can be satisfied
|
||||||
@@ -2278,10 +2283,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
mLegacyTypeTracker.remove(nai, wasDefault);
|
mLegacyTypeTracker.remove(nai, wasDefault);
|
||||||
rematchAllNetworksAndRequests(null, 0);
|
rematchAllNetworksAndRequests(null, 0);
|
||||||
if (wasDefault && getDefaultNetwork() == null) {
|
|
||||||
// Log that we lost the default network and there is no replacement.
|
|
||||||
logDefaultNetworkEvent(null, nai);
|
|
||||||
}
|
|
||||||
if (nai.created) {
|
if (nai.created) {
|
||||||
// Tell netd to clean up the configuration for this network
|
// Tell netd to clean up the configuration for this network
|
||||||
// (routing rules, DNS, etc).
|
// (routing rules, DNS, etc).
|
||||||
@@ -4584,7 +4585,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
teardownUnneededNetwork(oldNetwork);
|
teardownUnneededNetwork(oldNetwork);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void makeDefault(NetworkAgentInfo newNetwork, NetworkAgentInfo prevNetwork) {
|
private void makeDefault(NetworkAgentInfo newNetwork) {
|
||||||
if (DBG) log("Switching to new default network: " + newNetwork);
|
if (DBG) log("Switching to new default network: " + newNetwork);
|
||||||
setupDataActivityTracking(newNetwork);
|
setupDataActivityTracking(newNetwork);
|
||||||
try {
|
try {
|
||||||
@@ -4596,7 +4597,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
handleApplyDefaultProxy(newNetwork.linkProperties.getHttpProxy());
|
handleApplyDefaultProxy(newNetwork.linkProperties.getHttpProxy());
|
||||||
updateTcpBufferSizes(newNetwork);
|
updateTcpBufferSizes(newNetwork);
|
||||||
setDefaultDnsSystemProperties(newNetwork.linkProperties.getDnsServers());
|
setDefaultDnsSystemProperties(newNetwork.linkProperties.getDnsServers());
|
||||||
logDefaultNetworkEvent(newNetwork, prevNetwork);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Handles a network appearing or improving its score.
|
// Handles a network appearing or improving its score.
|
||||||
@@ -4747,7 +4747,9 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
if (isNewDefault) {
|
if (isNewDefault) {
|
||||||
// Notify system services that this network is up.
|
// Notify system services that this network is up.
|
||||||
makeDefault(newNetwork, oldDefaultNetwork);
|
makeDefault(newNetwork);
|
||||||
|
// Log 0 -> X and Y -> X default network transitions, where X is the new default.
|
||||||
|
logDefaultNetworkEvent(newNetwork, oldDefaultNetwork);
|
||||||
synchronized (ConnectivityService.this) {
|
synchronized (ConnectivityService.this) {
|
||||||
// have a new default network, release the transition wakelock in
|
// have a new default network, release the transition wakelock in
|
||||||
// a second if it's held. The second pause is to allow apps
|
// a second if it's held. The second pause is to allow apps
|
||||||
|
|||||||
Reference in New Issue
Block a user