Add Ethernet, TestNetworkSpecifier API
Rename StringNetworkSpecifier to EthernetNetworkSpecifier (its only production user), and make it module-lib API. The original StringNetworkSpecifier file is actually kept to satisfy some invalid dependencies; it will be removed separately. This allows specifying an Ethernet interface with a non-deprecated API: until this change the only way to do so would be to use NetworkRequest#setSpecifier(String), which is deprecated. Similarly, add the TestNetworkSpecifier API for TestNetworkManager, to replace previous usage of StringNetworkSpecifier. TestNetworkManager is module API, so TestNetworkSpecifier should be module API too. This allows tests to request the test interface specifically, without using the deprecated NetworkRequest#setSpecifier(String). Bug: 179329291 Test: m Merged-In: Iee569f5c8bbdc4bc979610e1191308281f3d4620 Change-Id: Iee569f5c8bbdc4bc979610e1191308281f3d4620
This commit is contained in:
committed by
junyulai
parent
82ff67f3cf
commit
57c9cc2614
@@ -211,7 +211,7 @@ public class NetworkCapabilitiesTest {
|
||||
nc1 = new NetworkCapabilities().addTransportType(TRANSPORT_WIFI);
|
||||
nc2 = new NetworkCapabilities()
|
||||
.addTransportType(TRANSPORT_WIFI)
|
||||
.setNetworkSpecifier(new StringNetworkSpecifier("specs"));
|
||||
.setNetworkSpecifier(new EthernetNetworkSpecifier("eth42"));
|
||||
assertNotEquals("", nc1.describeImmutableDifferences(nc2));
|
||||
assertEquals("", nc1.describeImmutableDifferences(nc1));
|
||||
}
|
||||
@@ -671,7 +671,7 @@ public class NetworkCapabilitiesTest {
|
||||
NetworkCapabilities nc1 = new NetworkCapabilities();
|
||||
nc1.addTransportType(TRANSPORT_CELLULAR).addTransportType(TRANSPORT_WIFI);
|
||||
try {
|
||||
nc1.setNetworkSpecifier(new StringNetworkSpecifier("specs"));
|
||||
nc1.setNetworkSpecifier(new EthernetNetworkSpecifier("eth0"));
|
||||
fail("Cannot set NetworkSpecifier on a NetworkCapability with multiple transports!");
|
||||
} catch (IllegalStateException expected) {
|
||||
// empty
|
||||
@@ -680,7 +680,7 @@ public class NetworkCapabilitiesTest {
|
||||
// Sequence 2: Transport + NetworkSpecifier + Transport
|
||||
NetworkCapabilities nc2 = new NetworkCapabilities();
|
||||
nc2.addTransportType(TRANSPORT_CELLULAR).setNetworkSpecifier(
|
||||
new StringNetworkSpecifier("specs"));
|
||||
new EthernetNetworkSpecifier("testtap3"));
|
||||
try {
|
||||
nc2.addTransportType(TRANSPORT_WIFI);
|
||||
fail("Cannot set a second TransportType of a network which has a NetworkSpecifier!");
|
||||
|
||||
@@ -102,7 +102,7 @@ class NetworkProviderTest {
|
||||
mCm.registerNetworkProvider(provider)
|
||||
assertNotEquals(provider.getProviderId(), NetworkProvider.ID_NONE)
|
||||
|
||||
val specifier = StringNetworkSpecifier(UUID.randomUUID().toString())
|
||||
val specifier = EthernetNetworkSpecifier(UUID.randomUUID().toString())
|
||||
val nr: NetworkRequest = NetworkRequest.Builder()
|
||||
.addTransportType(TRANSPORT_TEST)
|
||||
.setNetworkSpecifier(specifier)
|
||||
@@ -183,7 +183,7 @@ class NetworkProviderTest {
|
||||
|
||||
mCm.registerNetworkProvider(provider)
|
||||
|
||||
val specifier = StringNetworkSpecifier(UUID.randomUUID().toString())
|
||||
val specifier = EthernetNetworkSpecifier(UUID.randomUUID().toString())
|
||||
val nr: NetworkRequest = NetworkRequest.Builder()
|
||||
.addTransportType(TRANSPORT_TEST)
|
||||
.setNetworkSpecifier(specifier)
|
||||
|
||||
Reference in New Issue
Block a user