VCN: Require capability matching on test networks for CTS
This commit updates NetworkPriorityClassifier to also require capabilty matching on test networks. This allows CTS to select underlying test networks based on their capabilities. Previously capability matching was only done cell networks. To do that this commit adds an abstract method to VcnUnderlyingNetworkTemplate to retrieve capability requirements so that the capability match can be done before the matching logic diverge to different transports. Bug: 263415068 Test: atest VcnManagerTest (new tests) Change-Id: Id6ee75e70dc31851d7d6980ee1bf5eceb843b294
This commit is contained in:
@@ -354,6 +354,7 @@ public final class VcnCellUnderlyingNetworkTemplate extends VcnUnderlyingNetwork
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@Override
|
||||
public Map<Integer, Integer> getCapabilitiesMatchCriteria() {
|
||||
return Collections.unmodifiableMap(new HashMap<>(mCapabilitiesMatchCriteria));
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import com.android.internal.util.Preconditions;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
@@ -307,4 +308,7 @@ public abstract class VcnUnderlyingNetworkTemplate {
|
||||
public int getMinExitDownstreamBandwidthKbps() {
|
||||
return mMinExitDownstreamBandwidthKbps;
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
public abstract Map<Integer, Integer> getCapabilitiesMatchCriteria();
|
||||
}
|
||||
|
||||
@@ -15,6 +15,9 @@
|
||||
*/
|
||||
package android.net.vcn;
|
||||
|
||||
import static android.net.NetworkCapabilities.NET_CAPABILITY_INTERNET;
|
||||
import static android.net.vcn.VcnUnderlyingNetworkTemplate.MATCH_ANY;
|
||||
|
||||
import static com.android.internal.annotations.VisibleForTesting.Visibility;
|
||||
import static com.android.server.vcn.util.PersistableBundleUtils.STRING_DESERIALIZER;
|
||||
import static com.android.server.vcn.util.PersistableBundleUtils.STRING_SERIALIZER;
|
||||
@@ -23,6 +26,7 @@ import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.net.NetworkCapabilities;
|
||||
import android.net.vcn.VcnUnderlyingNetworkTemplate.MatchCriteria;
|
||||
import android.os.PersistableBundle;
|
||||
import android.util.ArraySet;
|
||||
|
||||
@@ -32,6 +36,7 @@ import com.android.server.vcn.util.PersistableBundleUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -162,6 +167,12 @@ public final class VcnWifiUnderlyingNetworkTemplate extends VcnUnderlyingNetwork
|
||||
return Collections.unmodifiableSet(mSsids);
|
||||
}
|
||||
|
||||
/** @hide */
|
||||
@Override
|
||||
public Map<Integer, Integer> getCapabilitiesMatchCriteria() {
|
||||
return Collections.singletonMap(NET_CAPABILITY_INTERNET, MATCH_REQUIRED);
|
||||
}
|
||||
|
||||
/** This class is used to incrementally build VcnWifiUnderlyingNetworkTemplate objects. */
|
||||
public static final class Builder {
|
||||
private int mMeteredMatchCriteria = MATCH_ANY;
|
||||
|
||||
@@ -171,6 +171,18 @@ class NetworkPriorityClassifier {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (Map.Entry<Integer, Integer> entry :
|
||||
networkPriority.getCapabilitiesMatchCriteria().entrySet()) {
|
||||
final int cap = entry.getKey();
|
||||
final int matchCriteria = entry.getValue();
|
||||
|
||||
if (matchCriteria == MATCH_REQUIRED && !caps.hasCapability(cap)) {
|
||||
return false;
|
||||
} else if (matchCriteria == MATCH_FORBIDDEN && caps.hasCapability(cap)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (vcnContext.isInTestMode() && caps.hasTransport(TRANSPORT_TEST)) {
|
||||
return true;
|
||||
}
|
||||
@@ -319,18 +331,6 @@ class NetworkPriorityClassifier {
|
||||
return false;
|
||||
}
|
||||
|
||||
for (Map.Entry<Integer, Integer> entry :
|
||||
networkPriority.getCapabilitiesMatchCriteria().entrySet()) {
|
||||
final int cap = entry.getKey();
|
||||
final int matchCriteria = entry.getValue();
|
||||
|
||||
if (matchCriteria == MATCH_REQUIRED && !caps.hasCapability(cap)) {
|
||||
return false;
|
||||
} else if (matchCriteria == MATCH_FORBIDDEN && caps.hasCapability(cap)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user