Suppress NewApi warnings for @SystemApi -> public APIs
Android Lint doesn't handle API change from @SystemApi to public API
correctly (see b/193460475). We have to manually suppress those
warnings for now.
This CL suppresses warnings related to:
- IpPrefix(InetAddress, int)
- RouteInfo#getType
Bug: 186082280
Test: presubmit
Change-Id: Ib24b2d3fb21b86bd9e3555316a5a5bcb94434c00
diff --git a/staticlibs/device/com/android/net/module/util/netlink/RtNetlinkRouteMessage.java b/staticlibs/device/com/android/net/module/util/netlink/RtNetlinkRouteMessage.java
index c5efcb2..1705f1c 100644
--- a/staticlibs/device/com/android/net/module/util/netlink/RtNetlinkRouteMessage.java
+++ b/staticlibs/device/com/android/net/module/util/netlink/RtNetlinkRouteMessage.java
@@ -22,6 +22,7 @@
import static com.android.net.module.util.NetworkStackConstants.IPV4_ADDR_ANY;
import static com.android.net.module.util.NetworkStackConstants.IPV6_ADDR_ANY;
+import android.annotation.SuppressLint;
import android.net.IpPrefix;
import android.system.OsConstants;
@@ -107,6 +108,7 @@
* @param header netlink message header.
* @param byteBuffer the ByteBuffer instance that wraps the raw netlink message bytes.
*/
+ @SuppressLint("NewApi")
@Nullable
public static RtNetlinkRouteMessage parse(@NonNull final StructNlMsgHdr header,
@NonNull final ByteBuffer byteBuffer) {
diff --git a/staticlibs/device/com/android/net/module/util/netlink/StructNdOptPref64.java b/staticlibs/device/com/android/net/module/util/netlink/StructNdOptPref64.java
index f6b2e0e..8226346 100644
--- a/staticlibs/device/com/android/net/module/util/netlink/StructNdOptPref64.java
+++ b/staticlibs/device/com/android/net/module/util/netlink/StructNdOptPref64.java
@@ -16,6 +16,7 @@
package com.android.net.module.util.netlink;
+import android.annotation.SuppressLint;
import android.net.IpPrefix;
import android.util.Log;
@@ -107,6 +108,7 @@
this.lifetime = lifetime & 0xfff8;
}
+ @SuppressLint("NewApi")
private StructNdOptPref64(@NonNull ByteBuffer buf) {
super(buf.get(), Byte.toUnsignedInt(buf.get()));
if (type != TYPE) throw new IllegalArgumentException("Invalid type " + type);
diff --git a/staticlibs/tests/unit/src/com/android/net/module/util/IpRangeTest.java b/staticlibs/tests/unit/src/com/android/net/module/util/IpRangeTest.java
index f44b17d..20bbd4a 100644
--- a/staticlibs/tests/unit/src/com/android/net/module/util/IpRangeTest.java
+++ b/staticlibs/tests/unit/src/com/android/net/module/util/IpRangeTest.java
@@ -22,6 +22,7 @@
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
+import android.annotation.SuppressLint;
import android.net.InetAddresses;
import android.net.IpPrefix;
@@ -92,6 +93,7 @@
}
}
+ @SuppressLint("NewApi")
@Test
public void testConstructor() {
IpRange r = new IpRange(new IpPrefix(IPV4_ADDR, 32));
@@ -119,6 +121,7 @@
assertEquals(IPV6_RANGE_END, r.getEndAddr());
}
+ @SuppressLint("NewApi")
@Test
public void testContainsRangeEqualRanges() {
final IpRange r1 = new IpRange(new IpPrefix(IPV6_ADDR, 35));
@@ -129,6 +132,7 @@
assertEquals(r1, r2);
}
+ @SuppressLint("NewApi")
@Test
public void testContainsRangeSubset() {
final IpRange r1 = new IpRange(new IpPrefix(IPV6_ADDR, 64));
@@ -139,6 +143,7 @@
assertNotEquals(r1, r2);
}
+ @SuppressLint("NewApi")
@Test
public void testContainsRangeTruncatesLowerOrderBits() {
final IpRange r1 = new IpRange(new IpPrefix(IPV6_ADDR, 100));
@@ -149,6 +154,7 @@
assertEquals(r1, r2);
}
+ @SuppressLint("NewApi")
@Test
public void testContainsRangeSubsetSameStartAddr() {
final IpRange r1 = new IpRange(new IpPrefix(IPV6_ADDR, 35));
@@ -159,6 +165,7 @@
assertNotEquals(r1, r2);
}
+ @SuppressLint("NewApi")
@Test
public void testContainsRangeOverlapping() {
final IpRange r1 = new IpRange(new IpPrefix(address("2001:db9::"), 32));
@@ -169,6 +176,7 @@
assertNotEquals(r1, r2);
}
+ @SuppressLint("NewApi")
@Test
public void testOverlapsRangeEqualRanges() {
final IpRange r1 = new IpRange(new IpPrefix(IPV6_ADDR, 35));
@@ -179,6 +187,7 @@
assertEquals(r1, r2);
}
+ @SuppressLint("NewApi")
@Test
public void testOverlapsRangeSubset() {
final IpRange r1 = new IpRange(new IpPrefix(IPV6_ADDR, 35));
@@ -189,6 +198,7 @@
assertNotEquals(r1, r2);
}
+ @SuppressLint("NewApi")
@Test
public void testOverlapsRangeDisjoint() {
final IpRange r1 = new IpRange(new IpPrefix(IPV6_ADDR, 32));
@@ -199,6 +209,7 @@
assertNotEquals(r1, r2);
}
+ @SuppressLint("NewApi")
@Test
public void testOverlapsRangePartialOverlapLow() {
final IpRange r1 = new IpRange(new IpPrefix(address("2001:db9::"), 32));
@@ -209,6 +220,7 @@
assertNotEquals(r1, r2);
}
+ @SuppressLint("NewApi")
@Test
public void testOverlapsRangePartialOverlapHigh() {
final IpRange r1 = new IpRange(new IpPrefix(address("2001:db7::"), 32));
diff --git a/staticlibs/tests/unit/src/com/android/net/module/util/LinkPropertiesUtilsTest.java b/staticlibs/tests/unit/src/com/android/net/module/util/LinkPropertiesUtilsTest.java
index 3d2d6eb..09f0490 100644
--- a/staticlibs/tests/unit/src/com/android/net/module/util/LinkPropertiesUtilsTest.java
+++ b/staticlibs/tests/unit/src/com/android/net/module/util/LinkPropertiesUtilsTest.java
@@ -22,6 +22,7 @@
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
+import android.annotation.SuppressLint;
import android.net.InetAddresses;
import android.net.IpPrefix;
import android.net.LinkAddress;
@@ -46,6 +47,7 @@
@RunWith(AndroidJUnit4.class)
public final class LinkPropertiesUtilsTest {
+ @SuppressLint("NewApi")
private static final IpPrefix PREFIX = new IpPrefix(toInetAddress("75.208.6.0"), 24);
private static final InetAddress V4_ADDR = toInetAddress("75.208.6.1");
private static final InetAddress V6_ADDR = toInetAddress(
diff --git a/staticlibs/tests/unit/src/com/android/net/module/util/StructTest.java b/staticlibs/tests/unit/src/com/android/net/module/util/StructTest.java
index eabc14b..4e46210 100644
--- a/staticlibs/tests/unit/src/com/android/net/module/util/StructTest.java
+++ b/staticlibs/tests/unit/src/com/android/net/module/util/StructTest.java
@@ -24,6 +24,7 @@
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
+import android.annotation.SuppressLint;
import android.net.InetAddresses;
import android.net.IpPrefix;
import android.net.MacAddress;
@@ -453,6 +454,7 @@
}
}
+ @SuppressLint("NewApi")
private void verifyPrefixByteArrayParsing(final PrefixMessage msg) throws Exception {
// The original PREF64 option message has just 12 bytes for prefix byte array
// (Highest 96 bits of the Prefix), copyOf pads the 128-bits IPv6 address with
diff --git a/staticlibs/tests/unit/src/com/android/net/module/util/netlink/StructNdOptPref64Test.java b/staticlibs/tests/unit/src/com/android/net/module/util/netlink/StructNdOptPref64Test.java
index 57248ea..beed838 100644
--- a/staticlibs/tests/unit/src/com/android/net/module/util/netlink/StructNdOptPref64Test.java
+++ b/staticlibs/tests/unit/src/com/android/net/module/util/netlink/StructNdOptPref64Test.java
@@ -24,6 +24,7 @@
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
+import android.annotation.SuppressLint;
import android.net.IpPrefix;
import androidx.test.filters.SmallTest;
@@ -51,6 +52,7 @@
return prefixBytes;
}
+ @SuppressLint("NewApi")
private static IpPrefix prefix(String addrString, int prefixLength) throws Exception {
return new IpPrefix(InetAddress.getByName(addrString), prefixLength);
}