Merge changes from topic "revert-1551943-vpn-impl-FKOLCXTDDT"
* changes:
Revert "Add VpnServiceBuilderShim for VpnService.Builder"
Revert "Suppress NewApi warnings for @SystemApi -> public APIs"
diff --git a/Android.bp b/Android.bp
index 9b3d80c..6d84691 100644
--- a/Android.bp
+++ b/Android.bp
@@ -191,7 +191,6 @@
visibility: [
"//packages/modules/Connectivity/Tethering",
"//packages/modules/Connectivity/tests/cts/net",
- "//packages/modules/Connectivity/tests/cts/hostside/app",
],
}
@@ -212,7 +211,6 @@
visibility: [
"//packages/modules/Connectivity/Tethering",
"//packages/modules/Connectivity/tests/cts/net",
- "//packages/modules/Connectivity/tests/cts/hostside/app",
],
}
diff --git a/apishim/29/com/android/networkstack/apishim/api29/VpnServiceBuilderShimImpl.java b/apishim/29/com/android/networkstack/apishim/api29/VpnServiceBuilderShimImpl.java
deleted file mode 100644
index 0f221bf..0000000
--- a/apishim/29/com/android/networkstack/apishim/api29/VpnServiceBuilderShimImpl.java
+++ /dev/null
@@ -1,48 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.networkstack.apishim.api29;
-
-import android.net.IpPrefix;
-import android.net.VpnService;
-
-import com.android.networkstack.apishim.common.UnsupportedApiLevelException;
-import com.android.networkstack.apishim.common.VpnServiceBuilderShim;
-
-/**
- * Implementation of {@link com.android.networkstack.apishim.common.VpnServiceBuilderShim}.
- */
-public class VpnServiceBuilderShimImpl implements VpnServiceBuilderShim {
-
- /**
- * Get a new instance of {@link VpnServiceBuilderShim}.
- */
- public static VpnServiceBuilderShim newInstance() {
- return new VpnServiceBuilderShimImpl();
- }
-
- @Override
- public VpnService.Builder excludeRoute(VpnService.Builder builder, IpPrefix prefix)
- throws UnsupportedApiLevelException {
- throw new UnsupportedApiLevelException("Only supported after API level 31.");
- }
-
- @Override
- public VpnService.Builder addRoute(VpnService.Builder builder, IpPrefix prefix)
- throws UnsupportedApiLevelException {
- throw new UnsupportedApiLevelException("Only supported after API level 31.");
- }
-}
diff --git a/apishim/31/com/android/networkstack/apishim/api31/VpnServiceBuilderShimImpl.java b/apishim/31/com/android/networkstack/apishim/api31/VpnServiceBuilderShimImpl.java
deleted file mode 100644
index 8b82935..0000000
--- a/apishim/31/com/android/networkstack/apishim/api31/VpnServiceBuilderShimImpl.java
+++ /dev/null
@@ -1,24 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.networkstack.apishim.api31;
-
-/**
- * Implementation of {@link com.android.networkstack.apishim.common.VpnServiceBuilderShim}.
- */
-public class VpnServiceBuilderShimImpl extends
- com.android.networkstack.apishim.api29.VpnServiceBuilderShimImpl {
-}
diff --git a/apishim/32/com/android/networkstack/apishim/VpnServiceBuilderShimImpl.java b/apishim/32/com/android/networkstack/apishim/VpnServiceBuilderShimImpl.java
deleted file mode 100644
index e869909..0000000
--- a/apishim/32/com/android/networkstack/apishim/VpnServiceBuilderShimImpl.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.networkstack.apishim;
-
-import android.net.IpPrefix;
-import android.net.VpnService;
-import android.os.Build;
-
-import androidx.annotation.RequiresApi;
-
-import com.android.modules.utils.build.SdkLevel;
-import com.android.networkstack.apishim.common.UnsupportedApiLevelException;
-import com.android.networkstack.apishim.common.VpnServiceBuilderShim;
-
-/**
- * Implementation of {@link com.android.networkstack.apishim.common.VpnServiceBuilderShim}.
- */
-@RequiresApi(32) // Change to Build.VERSION_CODES.T when it is available, and adding T methods
-public class VpnServiceBuilderShimImpl extends
- com.android.networkstack.apishim.api31.VpnServiceBuilderShimImpl {
-
- /**
- * Get a new instance of {@link VpnServiceBuilderShim}.
- */
- @RequiresApi(Build.VERSION_CODES.Q)
- public static VpnServiceBuilderShim newInstance() {
- if (SdkLevel.isAtLeastT()) {
- return new VpnServiceBuilderShimImpl();
- } else {
- return new com.android.networkstack.apishim.api31.VpnServiceBuilderShimImpl();
- }
- }
-
- @Override
- public VpnService.Builder excludeRoute(VpnService.Builder builder, IpPrefix prefix)
- throws UnsupportedApiLevelException {
- return builder.excludeRoute(prefix);
- }
-
- @Override
- public VpnService.Builder addRoute(VpnService.Builder builder, IpPrefix prefix)
- throws UnsupportedApiLevelException {
- return builder.addRoute(prefix);
- }
-}
diff --git a/apishim/common/com/android/networkstack/apishim/common/VpnServiceBuilderShim.java b/apishim/common/com/android/networkstack/apishim/common/VpnServiceBuilderShim.java
deleted file mode 100644
index fbfcf6c..0000000
--- a/apishim/common/com/android/networkstack/apishim/common/VpnServiceBuilderShim.java
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2021 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-package com.android.networkstack.apishim.common;
-
-import android.net.IpPrefix;
-import android.net.VpnService;
-
-/** Shim for {@link VpnService.Builder}. */
-public interface VpnServiceBuilderShim {
- /**
- * @see VpnService.Builder#excludeRoute(IpPrefix)
- */
- VpnService.Builder excludeRoute(VpnService.Builder builder, IpPrefix prefix)
- throws UnsupportedApiLevelException;
-
- /**
- * @see VpnService.Builder#addRoute(IpPrefix)
- */
- VpnService.Builder addRoute(VpnService.Builder builder, IpPrefix prefix)
- throws UnsupportedApiLevelException;
-}
diff --git a/src/android/net/dhcp/DhcpServingParams.java b/src/android/net/dhcp/DhcpServingParams.java
index 9d395f7..0fd649d 100644
--- a/src/android/net/dhcp/DhcpServingParams.java
+++ b/src/android/net/dhcp/DhcpServingParams.java
@@ -24,7 +24,6 @@
import static java.lang.Integer.toUnsignedLong;
-import android.annotation.SuppressLint;
import android.net.IpPrefix;
import android.net.LinkAddress;
import android.util.ArraySet;
@@ -412,7 +411,6 @@
/**
* Utility method to create an IpPrefix with the address and prefix length of a LinkAddress.
*/
- @SuppressLint("NewApi")
@NonNull
static IpPrefix makeIpPrefix(@NonNull LinkAddress addr) {
return new IpPrefix(addr.getAddress(), addr.getPrefixLength());
diff --git a/tests/unit/src/android/net/dhcp/DhcpLeaseRepositoryTest.java b/tests/unit/src/android/net/dhcp/DhcpLeaseRepositoryTest.java
index b9b1652..7b0af69 100644
--- a/tests/unit/src/android/net/dhcp/DhcpLeaseRepositoryTest.java
+++ b/tests/unit/src/android/net/dhcp/DhcpLeaseRepositoryTest.java
@@ -45,7 +45,6 @@
import android.annotation.NonNull;
import android.annotation.Nullable;
-import android.annotation.SuppressLint;
import android.net.IpPrefix;
import android.net.MacAddress;
import android.net.dhcp.DhcpServer.Clock;
@@ -85,7 +84,6 @@
private static final Inet4Address TEST_INETADDR_2 = parseAddr4("192.168.42.249");
private static final String TEST_HOSTNAME_1 = "hostname1";
private static final String TEST_HOSTNAME_2 = "hostname2";
- @SuppressLint("NewApi")
private static final IpPrefix TEST_IP_PREFIX = new IpPrefix(TEST_SERVER_ADDR, 22);
private static final long TEST_TIME = 100L;
private static final int TEST_LEASE_TIME_MS = 3_600_000;
@@ -151,7 +149,6 @@
}
}
- @SuppressLint("NewApi")
@Test
public void testAddressExhaustion() throws Exception {
// Use a /28 to quickly run out of addresses
@@ -172,7 +169,6 @@
verifyNoMoreInteractions(mCallbacks);
}
- @SuppressLint("NewApi")
@Test
public void testUpdateParams_LeaseCleanup() throws Exception {
// Inside /28:
@@ -233,7 +229,6 @@
}
}
- @SuppressLint("NewApi")
@Test
public void testUpdateParams_UsesNewPrefix() throws Exception {
final IpPrefix newPrefix = new IpPrefix(parseAddr4("192.168.123.0"), 24);
@@ -543,7 +538,6 @@
assertNotEquals(lease.getNetAddr(), newLease.getNetAddr());
}
- @SuppressLint("NewApi")
@Test
public void testMarkLeaseDeclined_UsedIfOutOfAddresses() throws Exception {
// Use a /28 to quickly run out of addresses
diff --git a/tests/unit/src/android/net/ip/IpClientTest.java b/tests/unit/src/android/net/ip/IpClientTest.java
index 37f12ca..173a9e1 100644
--- a/tests/unit/src/android/net/ip/IpClientTest.java
+++ b/tests/unit/src/android/net/ip/IpClientTest.java
@@ -40,7 +40,6 @@
import static java.util.Collections.emptySet;
-import android.annotation.SuppressLint;
import android.app.AlarmManager;
import android.content.ContentResolver;
import android.content.Context;
@@ -297,7 +296,6 @@
return ipc;
}
- @SuppressLint("NewApi")
private void addIPv4Provisioning(LinkProperties lp) {
final LinkAddress la = new LinkAddress(TEST_IPV4_LINKADDRESS);
final RouteInfo defaultRoute = new RouteInfo(new IpPrefix(Inet4Address.ANY, 0),
@@ -627,7 +625,6 @@
TEST_IFNAME));
}
- @SuppressLint("NewApi")
static RouteInfo defaultIPV6Route(String gateway) {
return new RouteInfo(new IpPrefix(Inet6Address.ANY, 0),
InetAddresses.parseNumericAddress(gateway), TEST_IFNAME);
diff --git a/tests/unit/src/android/net/ip/IpReachabilityMonitorTest.kt b/tests/unit/src/android/net/ip/IpReachabilityMonitorTest.kt
index 0109022..246f000 100644
--- a/tests/unit/src/android/net/ip/IpReachabilityMonitorTest.kt
+++ b/tests/unit/src/android/net/ip/IpReachabilityMonitorTest.kt
@@ -15,7 +15,6 @@
*/
package android.net.ip
-import android.annotation.SuppressLint
import android.content.Context
import android.net.ip.IpNeighborMonitor.NeighborEventConsumer
import android.net.INetd
@@ -107,8 +106,6 @@
private val TEST_IPV6_DNS2 = parseNumericAddress("2001:db8::456") as Inet6Address
private val TEST_IFACE = InterfaceParams("fake0", 21, null)
-
-@SuppressLint("NewApi")
private val TEST_LINK_PROPERTIES = LinkProperties().apply {
interfaceName = TEST_IFACE.name
addLinkAddress(TEST_IPV4_LINKADDR)
@@ -126,7 +123,6 @@
addDnsServer(TEST_IPV6_DNS)
}
-@SuppressLint("NewApi")
private val TEST_IPV4_ONLY_LINK_PROPERTIES = LinkProperties().apply {
interfaceName = TEST_IFACE.name
addLinkAddress(TEST_IPV4_LINKADDR)
@@ -140,7 +136,6 @@
addDnsServer(TEST_IPV4_GATEWAY_DNS)
}
-@SuppressLint("NewApi")
private val TEST_IPV6_LINKLOCAL_SCOPED_LINK_PROPERTIES = LinkProperties().apply {
interfaceName = TEST_IFACE.name
addLinkAddress(TEST_IPV6_LINKADDR)
@@ -156,7 +151,6 @@
addDnsServer(TEST_IPV6_DNS)
}
-@SuppressLint("NewApi")
private val TEST_DUAL_LINK_PROPERTIES = LinkProperties().apply {
interfaceName = TEST_IFACE.name
addLinkAddress(TEST_IPV4_LINKADDR)
diff --git a/tests/unit/src/android/net/shared/InitialConfigurationTest.java b/tests/unit/src/android/net/shared/InitialConfigurationTest.java
index 0ec0053..4d5a7df 100644
--- a/tests/unit/src/android/net/shared/InitialConfigurationTest.java
+++ b/tests/unit/src/android/net/shared/InitialConfigurationTest.java
@@ -23,7 +23,6 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
-import android.annotation.SuppressLint;
import android.net.IpPrefix;
import android.net.LinkAddress;
@@ -45,7 +44,6 @@
public class InitialConfigurationTest {
private InitialConfiguration mConfig;
- @SuppressLint("NewApi")
@Before
public void setUp() {
mConfig = new InitialConfiguration();
@@ -69,7 +67,6 @@
assertEquals(mConfig, unparceled);
}
- @SuppressLint("NewApi")
@Test
public void testEquals() {
assertEquals(mConfig, InitialConfiguration.copy(mConfig));