[VCN15] expose addUnwantedCapability and related APIs

Test: m -j doc-comment-check-docs
Bug: 175662146
Merged-In: I3f2e6a99e015f09cc4405f6804eac4ae33e3dcc7
Change-Id: I3f2e6a99e015f09cc4405f6804eac4ae33e3dcc7
  (cherry-picked from ag/13929102)
This commit is contained in:
junyulai
2021-03-16 10:24:43 +08:00
parent e05e71e820
commit 24efbfdfbe
4 changed files with 82 additions and 16 deletions

View File

@@ -532,11 +532,22 @@ public class NetworkCapabilitiesTest {
assertFalse(nc1.equalsNetCapabilities(nc2));
nc2.addUnwantedCapability(NET_CAPABILITY_INTERNET);
assertTrue(nc1.equalsNetCapabilities(nc2));
if (isAtLeastS()) {
// Remove a required capability doesn't affect unwanted capabilities.
// This is a behaviour change from S.
nc1.removeCapability(NET_CAPABILITY_INTERNET);
assertTrue(nc1.equalsNetCapabilities(nc2));
nc1.removeCapability(NET_CAPABILITY_INTERNET);
assertFalse(nc1.equalsNetCapabilities(nc2));
nc2.removeCapability(NET_CAPABILITY_INTERNET);
assertTrue(nc1.equalsNetCapabilities(nc2));
nc1.removeUnwantedCapability(NET_CAPABILITY_INTERNET);
assertFalse(nc1.equalsNetCapabilities(nc2));
nc2.removeUnwantedCapability(NET_CAPABILITY_INTERNET);
assertTrue(nc1.equalsNetCapabilities(nc2));
} else {
nc1.removeCapability(NET_CAPABILITY_INTERNET);
assertFalse(nc1.equalsNetCapabilities(nc2));
nc2.removeCapability(NET_CAPABILITY_INTERNET);
assertTrue(nc1.equalsNetCapabilities(nc2));
}
}
@Test
@@ -597,11 +608,20 @@ public class NetworkCapabilitiesTest {
// This will effectively move NOT_ROAMING capability from required to unwanted for nc1.
nc1.addUnwantedCapability(NET_CAPABILITY_NOT_ROAMING);
nc2.combineCapabilities(nc1);
// We will get this capability in both requested and unwanted lists thus this request
// will never be satisfied.
assertTrue(nc2.hasCapability(NET_CAPABILITY_NOT_ROAMING));
assertTrue(nc2.hasUnwantedCapability(NET_CAPABILITY_NOT_ROAMING));
if (isAtLeastS()) {
// From S, it is not allowed to have the same capability in both wanted and
// unwanted list.
assertThrows(IllegalArgumentException.class, () -> nc2.combineCapabilities(nc1));
} else {
nc2.combineCapabilities(nc1);
// We will get this capability in both requested and unwanted lists thus this request
// will never be satisfied.
assertTrue(nc2.hasCapability(NET_CAPABILITY_NOT_ROAMING));
assertTrue(nc2.hasUnwantedCapability(NET_CAPABILITY_NOT_ROAMING));
}
// Remove unwanted capability to continue other tests.
nc1.removeUnwantedCapability(NET_CAPABILITY_NOT_ROAMING);
nc1.setSSID(TEST_SSID);
nc2.combineCapabilities(nc1);