Merge "Fix transport override" into main am: c20c1224bc
Original change: https://android-review.googlesource.com/c/platform/packages/modules/Connectivity/+/3561446 Change-Id: Iffdc456ce5d8e93611cef7154b48860721147514 Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
This commit is contained in:
commit
29b3dfebd0
2 changed files with 21 additions and 2 deletions
|
|
@ -933,7 +933,11 @@ public class EthernetTracker {
|
|||
if (isAtLeastB && capabilitiesString.equals("*")) {
|
||||
// On Android B+, a "*" string defaults to the same set of default
|
||||
// capabilities assigned to unconfigured interfaces.
|
||||
return new NetworkCapabilities(DEFAULT_CAPABILITIES);
|
||||
// Note that the transport type is populated later with the result of
|
||||
// parseTransportType().
|
||||
return new NetworkCapabilities.Builder(DEFAULT_CAPABILITIES)
|
||||
.removeTransportType(NetworkCapabilities.TRANSPORT_ETHERNET)
|
||||
.build();
|
||||
}
|
||||
|
||||
for (String strNetworkCapability : capabilitiesString.split(",")) {
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ package com.android.server.ethernet;
|
|||
|
||||
import static android.net.TestNetworkManager.TEST_TAP_PREFIX;
|
||||
|
||||
import static com.android.server.ethernet.EthernetTracker.DEFAULT_CAPABILITIES;
|
||||
import static com.google.common.truth.Truth.assertThat;
|
||||
|
||||
import static org.junit.Assert.assertFalse;
|
||||
|
|
@ -185,7 +186,7 @@ public class EthernetTrackerTest {
|
|||
|
||||
// On Android B+, "*" defaults to using DEFAULT_CAPABILITIES.
|
||||
p = new EthernetConfigParser("eth0;*;;;;;;", true /*isAtLeastB*/);
|
||||
assertThat(p.mCaps).isEqualTo(EthernetTracker.DEFAULT_CAPABILITIES);
|
||||
assertThat(p.mCaps).isEqualTo(DEFAULT_CAPABILITIES);
|
||||
|
||||
// But not so before B.
|
||||
p = new EthernetConfigParser("eth0;*", false /*isAtLeastB*/);
|
||||
|
|
@ -205,10 +206,24 @@ public class EthernetTrackerTest {
|
|||
// TRANSPORT_VPN (4) is not allowed.
|
||||
p = new EthernetConfigParser("eth0;;;4", false /*isAtLeastB*/);
|
||||
assertThat(p.mCaps.hasSingleTransport(NetworkCapabilities.TRANSPORT_ETHERNET)).isTrue();
|
||||
p = new EthernetConfigParser("eth0;*;;4", true /*isAtLeastB*/);
|
||||
assertThat(p.mCaps.hasSingleTransport(NetworkCapabilities.TRANSPORT_ETHERNET)).isTrue();
|
||||
|
||||
// invalid capability and transport type
|
||||
p = new EthernetConfigParser("eth0;-1,a,1000,,;;-1", false /*isAtLeastB*/);
|
||||
assertThat(p.mCaps).isEqualTo(baseNc);
|
||||
|
||||
p = new EthernetConfigParser("eth0;*;;0", false /*isAtLeastB*/);
|
||||
assertThat(p.mCaps.hasSingleTransport(NetworkCapabilities.TRANSPORT_CELLULAR)).isTrue();
|
||||
p = new EthernetConfigParser("eth0;*;;0", true /*isAtLeastB*/);
|
||||
assertThat(p.mCaps.hasSingleTransport(NetworkCapabilities.TRANSPORT_CELLULAR)).isTrue();
|
||||
|
||||
NetworkCapabilities nc = new NetworkCapabilities.Builder(DEFAULT_CAPABILITIES)
|
||||
.removeTransportType(NetworkCapabilities.TRANSPORT_ETHERNET)
|
||||
.addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR)
|
||||
.build();
|
||||
p = new EthernetConfigParser("eth0;*;;0", true /*isAtLeastB*/);
|
||||
assertThat(p.mCaps).isEqualTo(nc);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
Loading…
Reference in a new issue