Merge "Revert the fallback naming into default network"
This commit is contained in:
@@ -740,11 +740,11 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void maybeLogBroadcast(NetworkAgentInfo nai, DetailedState state, int type,
|
private void maybeLogBroadcast(NetworkAgentInfo nai, DetailedState state, int type,
|
||||||
boolean isFallbackNetwork) {
|
boolean isDefaultNetwork) {
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
log("Sending " + state
|
log("Sending " + state
|
||||||
+ " broadcast for type " + type + " " + nai.toShortString()
|
+ " broadcast for type " + type + " " + nai.toShortString()
|
||||||
+ " isFallbackNetwork=" + isFallbackNetwork);
|
+ " isDefaultNetwork=" + isDefaultNetwork);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -763,10 +763,10 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
list.add(nai);
|
list.add(nai);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Send a broadcast if this is the first network of its type or if it's the fallback.
|
// Send a broadcast if this is the first network of its type or if it's the default.
|
||||||
final boolean isFallbackNetwork = mService.isFallbackNetwork(nai);
|
final boolean isDefaultNetwork = mService.isDefaultNetwork(nai);
|
||||||
if ((list.size() == 1) || isFallbackNetwork) {
|
if ((list.size() == 1) || isDefaultNetwork) {
|
||||||
maybeLogBroadcast(nai, DetailedState.CONNECTED, type, isFallbackNetwork);
|
maybeLogBroadcast(nai, DetailedState.CONNECTED, type, isDefaultNetwork);
|
||||||
mService.sendLegacyNetworkBroadcast(nai, DetailedState.CONNECTED, type);
|
mService.sendLegacyNetworkBroadcast(nai, DetailedState.CONNECTED, type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -795,7 +795,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
", sending connected broadcast");
|
", sending connected broadcast");
|
||||||
final NetworkAgentInfo replacement = list.get(0);
|
final NetworkAgentInfo replacement = list.get(0);
|
||||||
maybeLogBroadcast(replacement, DetailedState.CONNECTED, type,
|
maybeLogBroadcast(replacement, DetailedState.CONNECTED, type,
|
||||||
mService.isFallbackNetwork(replacement));
|
mService.isDefaultNetwork(replacement));
|
||||||
mService.sendLegacyNetworkBroadcast(replacement, DetailedState.CONNECTED, type);
|
mService.sendLegacyNetworkBroadcast(replacement, DetailedState.CONNECTED, type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -811,14 +811,14 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
// send out another legacy broadcast - currently only used for suspend/unsuspend
|
// send out another legacy broadcast - currently only used for suspend/unsuspend
|
||||||
// toggle
|
// toggle
|
||||||
public void update(NetworkAgentInfo nai) {
|
public void update(NetworkAgentInfo nai) {
|
||||||
final boolean isFallback = mService.isFallbackNetwork(nai);
|
final boolean isDefault = mService.isDefaultNetwork(nai);
|
||||||
final DetailedState state = nai.networkInfo.getDetailedState();
|
final DetailedState state = nai.networkInfo.getDetailedState();
|
||||||
for (int type = 0; type < mTypeLists.length; type++) {
|
for (int type = 0; type < mTypeLists.length; type++) {
|
||||||
final ArrayList<NetworkAgentInfo> list = mTypeLists[type];
|
final ArrayList<NetworkAgentInfo> list = mTypeLists[type];
|
||||||
final boolean contains = (list != null && list.contains(nai));
|
final boolean contains = (list != null && list.contains(nai));
|
||||||
final boolean isFirst = contains && (nai == list.get(0));
|
final boolean isFirst = contains && (nai == list.get(0));
|
||||||
if (isFirst || contains && isFallback) {
|
if (isFirst || contains && isDefault) {
|
||||||
maybeLogBroadcast(nai, state, type, isFallback);
|
maybeLogBroadcast(nai, state, type, isDefault);
|
||||||
mService.sendLegacyNetworkBroadcast(nai, state, type);
|
mService.sendLegacyNetworkBroadcast(nai, state, type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1032,12 +1032,12 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
|
|
||||||
mMetricsLog = logger;
|
mMetricsLog = logger;
|
||||||
mNetworkRanker = new NetworkRanker();
|
mNetworkRanker = new NetworkRanker();
|
||||||
final NetworkRequest fallbackRequest = createDefaultInternetRequestForTransport(
|
final NetworkRequest defaultInternetRequest = createDefaultInternetRequestForTransport(
|
||||||
-1, NetworkRequest.Type.REQUEST);
|
-1, NetworkRequest.Type.REQUEST);
|
||||||
mFallbackRequest = new NetworkRequestInfo(null, fallbackRequest, new Binder());
|
mDefaultRequest = new NetworkRequestInfo(null, defaultInternetRequest, new Binder());
|
||||||
mNetworkRequests.put(fallbackRequest, mFallbackRequest);
|
mNetworkRequests.put(defaultInternetRequest, mDefaultRequest);
|
||||||
mDefaultNetworkRequests.add(mFallbackRequest);
|
mDefaultNetworkRequests.add(mDefaultRequest);
|
||||||
mNetworkRequestInfoLogs.log("REGISTER " + mFallbackRequest);
|
mNetworkRequestInfoLogs.log("REGISTER " + mDefaultRequest);
|
||||||
|
|
||||||
mDefaultMobileDataRequest = createDefaultInternetRequestForTransport(
|
mDefaultMobileDataRequest = createDefaultInternetRequestForTransport(
|
||||||
NetworkCapabilities.TRANSPORT_CELLULAR, NetworkRequest.Type.BACKGROUND_REQUEST);
|
NetworkCapabilities.TRANSPORT_CELLULAR, NetworkRequest.Type.BACKGROUND_REQUEST);
|
||||||
@@ -1376,7 +1376,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
private NetworkState getUnfilteredActiveNetworkState(int uid) {
|
private NetworkState getUnfilteredActiveNetworkState(int uid) {
|
||||||
NetworkAgentInfo nai = getFallbackNetwork();
|
NetworkAgentInfo nai = getDefaultNetwork();
|
||||||
|
|
||||||
final Network[] networks = getVpnUnderlyingNetworks(uid);
|
final Network[] networks = getVpnUnderlyingNetworks(uid);
|
||||||
if (networks != null) {
|
if (networks != null) {
|
||||||
@@ -1509,7 +1509,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
NetworkAgentInfo nai = getFallbackNetwork();
|
NetworkAgentInfo nai = getDefaultNetwork();
|
||||||
if (nai == null || isNetworkWithCapabilitiesBlocked(nai.networkCapabilities, uid,
|
if (nai == null || isNetworkWithCapabilitiesBlocked(nai.networkCapabilities, uid,
|
||||||
ignoreBlocked)) {
|
ignoreBlocked)) {
|
||||||
return null;
|
return null;
|
||||||
@@ -1648,7 +1648,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
|
|
||||||
HashMap<Network, NetworkCapabilities> result = new HashMap<>();
|
HashMap<Network, NetworkCapabilities> result = new HashMap<>();
|
||||||
|
|
||||||
final NetworkAgentInfo nai = getFallbackNetwork();
|
final NetworkAgentInfo nai = getDefaultNetwork();
|
||||||
NetworkCapabilities nc = getNetworkCapabilitiesInternal(nai);
|
NetworkCapabilities nc = getNetworkCapabilitiesInternal(nai);
|
||||||
if (nc != null) {
|
if (nc != null) {
|
||||||
result.put(
|
result.put(
|
||||||
@@ -2035,7 +2035,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
// TODO: Move the Dns Event to NetworkMonitor. NetdEventListenerService only allow one
|
// TODO: Move the Dns Event to NetworkMonitor. NetdEventListenerService only allow one
|
||||||
// callback from each caller type. Need to re-factor NetdEventListenerService to allow
|
// callback from each caller type. Need to re-factor NetdEventListenerService to allow
|
||||||
// multiple NetworkMonitor registrants.
|
// multiple NetworkMonitor registrants.
|
||||||
if (nai != null && nai.satisfies(mFallbackRequest.mRequests.get(0))) {
|
if (nai != null && nai.satisfies(mDefaultRequest.mRequests.get(0))) {
|
||||||
nai.networkMonitor().notifyDnsResponse(returnCode);
|
nai.networkMonitor().notifyDnsResponse(returnCode);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2592,12 +2592,12 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
pw.println();
|
pw.println();
|
||||||
pw.println();
|
pw.println();
|
||||||
|
|
||||||
final NetworkAgentInfo fallbackNai = getFallbackNetwork();
|
final NetworkAgentInfo defaultNai = getDefaultNetwork();
|
||||||
pw.print("Active default network: ");
|
pw.print("Active default network: ");
|
||||||
if (fallbackNai == null) {
|
if (defaultNai == null) {
|
||||||
pw.println("none");
|
pw.println("none");
|
||||||
} else {
|
} else {
|
||||||
pw.println(fallbackNai.network.getNetId());
|
pw.println(defaultNai.network.getNetId());
|
||||||
}
|
}
|
||||||
pw.println();
|
pw.println();
|
||||||
|
|
||||||
@@ -2980,7 +2980,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
|
|
||||||
final boolean valid = ((testResult & NETWORK_VALIDATION_RESULT_VALID) != 0);
|
final boolean valid = ((testResult & NETWORK_VALIDATION_RESULT_VALID) != 0);
|
||||||
final boolean wasValidated = nai.lastValidated;
|
final boolean wasValidated = nai.lastValidated;
|
||||||
final boolean wasFallback = isFallbackNetwork(nai);
|
final boolean wasDefault = isDefaultNetwork(nai);
|
||||||
|
|
||||||
if (DBG) {
|
if (DBG) {
|
||||||
final String logMsg = !TextUtils.isEmpty(redirectUrl)
|
final String logMsg = !TextUtils.isEmpty(redirectUrl)
|
||||||
@@ -2989,7 +2989,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
log(nai.toShortString() + " validation " + (valid ? "passed" : "failed") + logMsg);
|
log(nai.toShortString() + " validation " + (valid ? "passed" : "failed") + logMsg);
|
||||||
}
|
}
|
||||||
if (valid != nai.lastValidated) {
|
if (valid != nai.lastValidated) {
|
||||||
if (wasFallback) {
|
if (wasDefault) {
|
||||||
mMetricsLog.logDefaultNetworkValidity(valid);
|
mMetricsLog.logDefaultNetworkValidity(valid);
|
||||||
}
|
}
|
||||||
final int oldScore = nai.getCurrentScore();
|
final int oldScore = nai.getCurrentScore();
|
||||||
@@ -3365,13 +3365,13 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
loge("Error connecting NetworkAgent");
|
loge("Error connecting NetworkAgent");
|
||||||
mNetworkAgentInfos.remove(nai);
|
mNetworkAgentInfos.remove(nai);
|
||||||
if (nai != null) {
|
if (nai != null) {
|
||||||
final boolean wasFallback = isFallbackNetwork(nai);
|
final boolean wasDefault = isDefaultNetwork(nai);
|
||||||
synchronized (mNetworkForNetId) {
|
synchronized (mNetworkForNetId) {
|
||||||
mNetworkForNetId.remove(nai.network.getNetId());
|
mNetworkForNetId.remove(nai.network.getNetId());
|
||||||
}
|
}
|
||||||
mNetIdManager.releaseNetId(nai.network.getNetId());
|
mNetIdManager.releaseNetId(nai.network.getNetId());
|
||||||
// Just in case.
|
// Just in case.
|
||||||
mLegacyTypeTracker.remove(nai, wasFallback);
|
mLegacyTypeTracker.remove(nai, wasDefault);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -3410,8 +3410,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
nai.networkInfo.setDetailedState(NetworkInfo.DetailedState.DISCONNECTED,
|
nai.networkInfo.setDetailedState(NetworkInfo.DetailedState.DISCONNECTED,
|
||||||
null, null);
|
null, null);
|
||||||
}
|
}
|
||||||
final boolean wasFallback = isFallbackNetwork(nai);
|
final boolean wasDefault = isDefaultNetwork(nai);
|
||||||
if (wasFallback) {
|
if (wasDefault) {
|
||||||
mDefaultInetConditionPublished = 0;
|
mDefaultInetConditionPublished = 0;
|
||||||
// Log default network disconnection before required book-keeping.
|
// Log default network disconnection before required book-keeping.
|
||||||
// Let rematchAllNetworksAndRequests() below record a new default network event
|
// Let rematchAllNetworksAndRequests() below record a new default network event
|
||||||
@@ -3454,9 +3454,9 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
nri.setSatisfier(null, null);
|
nri.setSatisfier(null, null);
|
||||||
sendUpdatedScoreToFactories(request, null);
|
sendUpdatedScoreToFactories(request, null);
|
||||||
|
|
||||||
if (mFallbackRequest == nri) {
|
if (mDefaultRequest == nri) {
|
||||||
// TODO : make battery stats aware that since 2013 multiple interfaces may be
|
// TODO : make battery stats aware that since 2013 multiple interfaces may be
|
||||||
// active at the same time. For now keep calling this with the fallback
|
// active at the same time. For now keep calling this with the default
|
||||||
// network, because while incorrect this is the closest to the old (also
|
// network, because while incorrect this is the closest to the old (also
|
||||||
// incorrect) behavior.
|
// incorrect) behavior.
|
||||||
mNetworkActivityTracker.updateDataActivityTracking(
|
mNetworkActivityTracker.updateDataActivityTracking(
|
||||||
@@ -3468,9 +3468,9 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
nai.clearLingerState();
|
nai.clearLingerState();
|
||||||
// TODO: mLegacyTypeTracker.remove seems redundant given there's a full rematch right after.
|
// TODO: mLegacyTypeTracker.remove seems redundant given there's a full rematch right after.
|
||||||
// Currently, deleting it breaks tests that check for the fallback network disconnecting.
|
// Currently, deleting it breaks tests that check for the default network disconnecting.
|
||||||
// Find out why, fix the rematch code, and delete this.
|
// Find out why, fix the rematch code, and delete this.
|
||||||
mLegacyTypeTracker.remove(nai, wasFallback);
|
mLegacyTypeTracker.remove(nai, wasDefault);
|
||||||
rematchAllNetworksAndRequests();
|
rematchAllNetworksAndRequests();
|
||||||
mLingerMonitor.noteDisconnect(nai);
|
mLingerMonitor.noteDisconnect(nai);
|
||||||
if (nai.created) {
|
if (nai.created) {
|
||||||
@@ -3478,10 +3478,9 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
// (routing rules, DNS, etc).
|
// (routing rules, DNS, etc).
|
||||||
// This may be slow as it requires a lot of netd shelling out to ip and
|
// This may be slow as it requires a lot of netd shelling out to ip and
|
||||||
// ip[6]tables to flush routes and remove the incoming packet mark rule, so do it
|
// ip[6]tables to flush routes and remove the incoming packet mark rule, so do it
|
||||||
// after we've rematched networks with requests which should make a potential
|
// after we've rematched networks with requests (which might change the default
|
||||||
// fallback network the default or requested a new network from the
|
// network or service a new request from an app), so network traffic isn't interrupted
|
||||||
// NetworkProviders, so network traffic isn't interrupted for an unnecessarily
|
// for an unnecessarily long time.
|
||||||
// long time.
|
|
||||||
destroyNativeNetwork(nai);
|
destroyNativeNetwork(nai);
|
||||||
mDnsManager.removeNetwork(nai.network);
|
mDnsManager.removeNetwork(nai.network);
|
||||||
}
|
}
|
||||||
@@ -4270,7 +4269,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public NetworkRequest getDefaultRequest() {
|
public NetworkRequest getDefaultRequest() {
|
||||||
return mFallbackRequest.mRequests.get(0);
|
return mDefaultRequest.mRequests.get(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
private class InternalHandler extends Handler {
|
private class InternalHandler extends Handler {
|
||||||
@@ -4516,7 +4515,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
// revalidate the network and generate a ConnectivityDiagnostics ConnectivityReport event.
|
// revalidate the network and generate a ConnectivityDiagnostics ConnectivityReport event.
|
||||||
final NetworkAgentInfo nai;
|
final NetworkAgentInfo nai;
|
||||||
if (network == null) {
|
if (network == null) {
|
||||||
nai = getFallbackNetwork();
|
nai = getDefaultNetwork();
|
||||||
} else {
|
} else {
|
||||||
nai = getNetworkAgentInfoForNetwork(network);
|
nai = getNetworkAgentInfoForNetwork(network);
|
||||||
}
|
}
|
||||||
@@ -4535,7 +4534,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
Network network, int uid, boolean hasConnectivity) {
|
Network network, int uid, boolean hasConnectivity) {
|
||||||
final NetworkAgentInfo nai;
|
final NetworkAgentInfo nai;
|
||||||
if (network == null) {
|
if (network == null) {
|
||||||
nai = getFallbackNetwork();
|
nai = getDefaultNetwork();
|
||||||
} else {
|
} else {
|
||||||
nai = getNetworkAgentInfoForNetwork(network);
|
nai = getNetworkAgentInfoForNetwork(network);
|
||||||
}
|
}
|
||||||
@@ -4901,7 +4900,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
// see VpnService.setUnderlyingNetworks()'s javadoc about how to interpret
|
// see VpnService.setUnderlyingNetworks()'s javadoc about how to interpret
|
||||||
// the underlyingNetworks list.
|
// the underlyingNetworks list.
|
||||||
if (underlyingNetworks == null) {
|
if (underlyingNetworks == null) {
|
||||||
final NetworkAgentInfo defaultNai = getFallbackNetwork();
|
final NetworkAgentInfo defaultNai = getDefaultNetwork();
|
||||||
if (defaultNai != null) {
|
if (defaultNai != null) {
|
||||||
underlyingNetworks = new Network[] { defaultNai.network };
|
underlyingNetworks = new Network[] { defaultNai.network };
|
||||||
}
|
}
|
||||||
@@ -4953,7 +4952,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
private Network[] underlyingNetworksOrDefault(Network[] underlyingNetworks) {
|
private Network[] underlyingNetworksOrDefault(Network[] underlyingNetworks) {
|
||||||
final Network defaultNetwork = getNetwork(getFallbackNetwork());
|
final Network defaultNetwork = getNetwork(getDefaultNetwork());
|
||||||
if (underlyingNetworks == null && defaultNetwork != null) {
|
if (underlyingNetworks == null && defaultNetwork != null) {
|
||||||
// null underlying networks means to track the default.
|
// null underlying networks means to track the default.
|
||||||
underlyingNetworks = new Network[] { defaultNetwork };
|
underlyingNetworks = new Network[] { defaultNetwork };
|
||||||
@@ -6060,7 +6059,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
// The always-on request for an Internet-capable network that apps without a specific default
|
// The always-on request for an Internet-capable network that apps without a specific default
|
||||||
// fall back to.
|
// fall back to.
|
||||||
@NonNull
|
@NonNull
|
||||||
private final NetworkRequestInfo mFallbackRequest;
|
private final NetworkRequestInfo mDefaultRequest;
|
||||||
// Collection of NetworkRequestInfo's used for default networks.
|
// Collection of NetworkRequestInfo's used for default networks.
|
||||||
@NonNull
|
@NonNull
|
||||||
private final ArraySet<NetworkRequestInfo> mDefaultNetworkRequests = new ArraySet<>();
|
private final ArraySet<NetworkRequestInfo> mDefaultNetworkRequests = new ArraySet<>();
|
||||||
@@ -6077,9 +6076,9 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
private final NetworkRequest mDefaultVehicleRequest;
|
private final NetworkRequest mDefaultVehicleRequest;
|
||||||
|
|
||||||
// TODO: b/178729499 update this in favor of a method taking in a UID.
|
// TODO: b/178729499 update this in favor of a method taking in a UID.
|
||||||
// The NetworkAgentInfo currently satisfying the fallback request, if any.
|
// The NetworkAgentInfo currently satisfying the default request, if any.
|
||||||
private NetworkAgentInfo getFallbackNetwork() {
|
private NetworkAgentInfo getDefaultNetwork() {
|
||||||
return mFallbackRequest.mSatisfier;
|
return mDefaultRequest.mSatisfier;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
@@ -6096,8 +6095,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected boolean isFallbackNetwork(NetworkAgentInfo nai) {
|
protected boolean isDefaultNetwork(NetworkAgentInfo nai) {
|
||||||
return nai == getFallbackNetwork();
|
return nai == getDefaultNetwork();
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO : remove this method. It's a stopgap measure to help sheperding a number of dependent
|
// TODO : remove this method. It's a stopgap measure to help sheperding a number of dependent
|
||||||
@@ -6166,8 +6165,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
|
|
||||||
LinkProperties lp = new LinkProperties(linkProperties);
|
LinkProperties lp = new LinkProperties(linkProperties);
|
||||||
|
|
||||||
// TODO: Instead of passing mFallbackRequest, provide an API to determine whether a Network
|
// TODO: Instead of passing mDefaultRequest, provide an API to determine whether a Network
|
||||||
// satisfies mFallbackRequest.
|
// satisfies mDefaultRequest.
|
||||||
final NetworkCapabilities nc = new NetworkCapabilities(networkCapabilities);
|
final NetworkCapabilities nc = new NetworkCapabilities(networkCapabilities);
|
||||||
final NetworkAgentInfo nai = new NetworkAgentInfo(na,
|
final NetworkAgentInfo nai = new NetworkAgentInfo(na,
|
||||||
new Network(mNetIdManager.reserveNetId()), new NetworkInfo(networkInfo), lp, nc,
|
new Network(mNetIdManager.reserveNetId()), new NetworkInfo(networkInfo), lp, nc,
|
||||||
@@ -6244,7 +6243,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
// for (LinkProperties lp : newLp.getStackedLinks()) {
|
// for (LinkProperties lp : newLp.getStackedLinks()) {
|
||||||
// updateMtu(lp, null);
|
// updateMtu(lp, null);
|
||||||
// }
|
// }
|
||||||
if (isFallbackNetwork(networkAgent)) {
|
if (isDefaultNetwork(networkAgent)) {
|
||||||
updateTcpBufferSizes(newLp.getTcpBufferSizes());
|
updateTcpBufferSizes(newLp.getTcpBufferSizes());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6256,7 +6255,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
// updateDnses will fetch the private DNS configuration from DnsManager.
|
// updateDnses will fetch the private DNS configuration from DnsManager.
|
||||||
mDnsManager.updatePrivateDnsStatus(netId, newLp);
|
mDnsManager.updatePrivateDnsStatus(netId, newLp);
|
||||||
|
|
||||||
if (isFallbackNetwork(networkAgent)) {
|
if (isDefaultNetwork(networkAgent)) {
|
||||||
handleApplyDefaultProxy(newLp.getHttpProxy());
|
handleApplyDefaultProxy(newLp.getHttpProxy());
|
||||||
} else {
|
} else {
|
||||||
updateProxy(newLp, oldLp);
|
updateProxy(newLp, oldLp);
|
||||||
@@ -7236,7 +7235,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
// TODO http://b/176191930 update netd calls in follow-up CL for multinetwork changes.
|
// TODO http://b/176191930 update netd calls in follow-up CL for multinetwork changes.
|
||||||
if (mFallbackRequest != nri) {
|
if (mDefaultRequest != nri) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7634,34 +7633,34 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
private void updateLegacyTypeTrackerAndVpnLockdownForRematch(
|
private void updateLegacyTypeTrackerAndVpnLockdownForRematch(
|
||||||
@NonNull final NetworkReassignment changes,
|
@NonNull final NetworkReassignment changes,
|
||||||
@NonNull final Collection<NetworkAgentInfo> nais) {
|
@NonNull final Collection<NetworkAgentInfo> nais) {
|
||||||
final NetworkReassignment.RequestReassignment fallbackReassignment =
|
final NetworkReassignment.RequestReassignment reassignmentOfDefault =
|
||||||
changes.getReassignment(mFallbackRequest);
|
changes.getReassignment(mDefaultRequest);
|
||||||
final NetworkAgentInfo oldFallbackNetwork =
|
final NetworkAgentInfo oldDefaultNetwork =
|
||||||
null != fallbackReassignment ? fallbackReassignment.mOldNetwork : null;
|
null != reassignmentOfDefault ? reassignmentOfDefault.mOldNetwork : null;
|
||||||
final NetworkAgentInfo newFallbackNetwork =
|
final NetworkAgentInfo newDefaultNetwork =
|
||||||
null != fallbackReassignment ? fallbackReassignment.mNewNetwork : null;
|
null != reassignmentOfDefault ? reassignmentOfDefault.mNewNetwork : null;
|
||||||
|
|
||||||
if (oldFallbackNetwork != newFallbackNetwork) {
|
if (oldDefaultNetwork != newDefaultNetwork) {
|
||||||
// Maintain the illusion : since the legacy API only understands one network at a time,
|
// Maintain the illusion : since the legacy API only understands one network at a time,
|
||||||
// if the default network changed, apps should see a disconnected broadcast for the
|
// if the default network changed, apps should see a disconnected broadcast for the
|
||||||
// old default network before they see a connected broadcast for the new one.
|
// old default network before they see a connected broadcast for the new one.
|
||||||
if (oldFallbackNetwork != null) {
|
if (oldDefaultNetwork != null) {
|
||||||
mLegacyTypeTracker.remove(oldFallbackNetwork.networkInfo.getType(),
|
mLegacyTypeTracker.remove(oldDefaultNetwork.networkInfo.getType(),
|
||||||
oldFallbackNetwork, true);
|
oldDefaultNetwork, true);
|
||||||
}
|
}
|
||||||
if (newFallbackNetwork != null) {
|
if (newDefaultNetwork != null) {
|
||||||
// The new default network can be newly null if and only if the old default
|
// The new default network can be newly null if and only if the old default
|
||||||
// network doesn't satisfy the default request any more because it lost a
|
// network doesn't satisfy the default request any more because it lost a
|
||||||
// capability.
|
// capability.
|
||||||
mDefaultInetConditionPublished = newFallbackNetwork.lastValidated ? 100 : 0;
|
mDefaultInetConditionPublished = newDefaultNetwork.lastValidated ? 100 : 0;
|
||||||
mLegacyTypeTracker.add(
|
mLegacyTypeTracker.add(
|
||||||
newFallbackNetwork.networkInfo.getType(), newFallbackNetwork);
|
newDefaultNetwork.networkInfo.getType(), newDefaultNetwork);
|
||||||
// If the legacy VPN is connected, notifyLockdownVpn may end up sending a broadcast
|
// If the legacy VPN is connected, notifyLockdownVpn may end up sending a broadcast
|
||||||
// to reflect the NetworkInfo of this new network. This broadcast has to be sent
|
// to reflect the NetworkInfo of this new network. This broadcast has to be sent
|
||||||
// after the disconnect broadcasts above, but before the broadcasts sent by the
|
// after the disconnect broadcasts above, but before the broadcasts sent by the
|
||||||
// legacy type tracker below.
|
// legacy type tracker below.
|
||||||
// TODO : refactor this, it's too complex
|
// TODO : refactor this, it's too complex
|
||||||
notifyLockdownVpn(newFallbackNetwork);
|
notifyLockdownVpn(newDefaultNetwork);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -7696,7 +7695,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
}
|
}
|
||||||
|
|
||||||
// A VPN generally won't get added to the legacy tracker in the "for (nri)" loop above,
|
// A VPN generally won't get added to the legacy tracker in the "for (nri)" loop above,
|
||||||
// because usually there are no NetworkRequests it satisfies (e.g., mFallbackRequest
|
// because usually there are no NetworkRequests it satisfies (e.g., mDefaultRequest
|
||||||
// wants the NOT_VPN capability, so it will never be satisfied by a VPN). So, add the
|
// wants the NOT_VPN capability, so it will never be satisfied by a VPN). So, add the
|
||||||
// newNetwork to the tracker explicitly (it's a no-op if it has already been added).
|
// newNetwork to the tracker explicitly (it's a no-op if it has already been added).
|
||||||
if (nai.isVPN()) {
|
if (nai.isVPN()) {
|
||||||
@@ -7707,9 +7706,9 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
private void updateInetCondition(NetworkAgentInfo nai) {
|
private void updateInetCondition(NetworkAgentInfo nai) {
|
||||||
// Don't bother updating until we've graduated to validated at least once.
|
// Don't bother updating until we've graduated to validated at least once.
|
||||||
if (!nai.everValidated) return;
|
if (!nai.everValidated) return;
|
||||||
// For now only update icons for the fallback connection.
|
// For now only update icons for the default connection.
|
||||||
// TODO: Update WiFi and cellular icons separately. b/17237507
|
// TODO: Update WiFi and cellular icons separately. b/17237507
|
||||||
if (!isFallbackNetwork(nai)) return;
|
if (!isDefaultNetwork(nai)) return;
|
||||||
|
|
||||||
int newInetCondition = nai.lastValidated ? 100 : 0;
|
int newInetCondition = nai.lastValidated ? 100 : 0;
|
||||||
// Don't repeat publish.
|
// Don't repeat publish.
|
||||||
@@ -7977,8 +7976,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
intent.putExtra(ConnectivityManager.EXTRA_EXTRA_INFO, info.getExtraInfo());
|
intent.putExtra(ConnectivityManager.EXTRA_EXTRA_INFO, info.getExtraInfo());
|
||||||
}
|
}
|
||||||
NetworkAgentInfo newDefaultAgent = null;
|
NetworkAgentInfo newDefaultAgent = null;
|
||||||
if (nai.isSatisfyingRequest(mFallbackRequest.mRequests.get(0).requestId)) {
|
if (nai.isSatisfyingRequest(mDefaultRequest.mRequests.get(0).requestId)) {
|
||||||
newDefaultAgent = getFallbackNetwork();
|
newDefaultAgent = getDefaultNetwork();
|
||||||
if (newDefaultAgent != null) {
|
if (newDefaultAgent != null) {
|
||||||
intent.putExtra(ConnectivityManager.EXTRA_OTHER_NETWORK_INFO,
|
intent.putExtra(ConnectivityManager.EXTRA_OTHER_NETWORK_INFO,
|
||||||
newDefaultAgent.networkInfo);
|
newDefaultAgent.networkInfo);
|
||||||
@@ -8026,9 +8025,9 @@ public class ConnectivityService extends IConnectivityManager.Stub
|
|||||||
private Network[] getDefaultNetworks() {
|
private Network[] getDefaultNetworks() {
|
||||||
ensureRunningOnConnectivityServiceThread();
|
ensureRunningOnConnectivityServiceThread();
|
||||||
final ArrayList<Network> defaultNetworks = new ArrayList<>();
|
final ArrayList<Network> defaultNetworks = new ArrayList<>();
|
||||||
final NetworkAgentInfo fallbackNetwork = getFallbackNetwork();
|
final NetworkAgentInfo defaultNetwork = getDefaultNetwork();
|
||||||
for (NetworkAgentInfo nai : mNetworkAgentInfos) {
|
for (NetworkAgentInfo nai : mNetworkAgentInfos) {
|
||||||
if (nai.everConnected && (nai == fallbackNetwork || nai.isVPN())) {
|
if (nai.everConnected && (nai == defaultNetwork || nai.isVPN())) {
|
||||||
defaultNetworks.add(nai.network);
|
defaultNetworks.add(nai.network);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ class LegacyTypeTrackerTest {
|
|||||||
private val supportedTypes = arrayOf(TYPE_MOBILE, TYPE_WIFI, TYPE_ETHERNET, TYPE_MOBILE_SUPL)
|
private val supportedTypes = arrayOf(TYPE_MOBILE, TYPE_WIFI, TYPE_ETHERNET, TYPE_MOBILE_SUPL)
|
||||||
|
|
||||||
private val mMockService = mock(ConnectivityService::class.java).apply {
|
private val mMockService = mock(ConnectivityService::class.java).apply {
|
||||||
doReturn(false).`when`(this).isFallbackNetwork(any())
|
doReturn(false).`when`(this).isDefaultNetwork(any())
|
||||||
}
|
}
|
||||||
private val mTracker = LegacyTypeTracker(mMockService).apply {
|
private val mTracker = LegacyTypeTracker(mMockService).apply {
|
||||||
supportedTypes.forEach {
|
supportedTypes.forEach {
|
||||||
@@ -126,11 +126,11 @@ class LegacyTypeTrackerTest {
|
|||||||
fun testBroadcastOnDisconnect() {
|
fun testBroadcastOnDisconnect() {
|
||||||
val mobileNai1 = mock(NetworkAgentInfo::class.java)
|
val mobileNai1 = mock(NetworkAgentInfo::class.java)
|
||||||
val mobileNai2 = mock(NetworkAgentInfo::class.java)
|
val mobileNai2 = mock(NetworkAgentInfo::class.java)
|
||||||
doReturn(false).`when`(mMockService).isFallbackNetwork(mobileNai1)
|
doReturn(false).`when`(mMockService).isDefaultNetwork(mobileNai1)
|
||||||
mTracker.add(TYPE_MOBILE, mobileNai1)
|
mTracker.add(TYPE_MOBILE, mobileNai1)
|
||||||
verify(mMockService).sendLegacyNetworkBroadcast(mobileNai1, CONNECTED, TYPE_MOBILE)
|
verify(mMockService).sendLegacyNetworkBroadcast(mobileNai1, CONNECTED, TYPE_MOBILE)
|
||||||
reset(mMockService)
|
reset(mMockService)
|
||||||
doReturn(false).`when`(mMockService).isFallbackNetwork(mobileNai2)
|
doReturn(false).`when`(mMockService).isDefaultNetwork(mobileNai2)
|
||||||
mTracker.add(TYPE_MOBILE, mobileNai2)
|
mTracker.add(TYPE_MOBILE, mobileNai2)
|
||||||
verify(mMockService, never()).sendLegacyNetworkBroadcast(any(), any(), anyInt())
|
verify(mMockService, never()).sendLegacyNetworkBroadcast(any(), any(), anyInt())
|
||||||
mTracker.remove(TYPE_MOBILE, mobileNai1, false /* wasDefault */)
|
mTracker.remove(TYPE_MOBILE, mobileNai1, false /* wasDefault */)
|
||||||
|
|||||||
Reference in New Issue
Block a user