From 98905d9ab714a50cd904781ef3d84cf4fbef697d Mon Sep 17 00:00:00 2001 From: Taras Antoshchuk Date: Sun, 19 Dec 2021 12:04:26 +0000 Subject: [PATCH] Revert "Revert "Suppress NewApi warnings for @SystemApi -> public APIs"" This reverts commit d654277abfa0abd1268acc6db1753536509e41c8. Reason for revert: Re-landing changes not related to postsubmit failure Change-Id: I72fd6b908deeb293f1f3a342f006515029972089 --- .../module/util/netlink/RtNetlinkRouteMessage.java | 2 ++ .../net/module/util/netlink/StructNdOptPref64.java | 2 ++ .../src/com/android/net/module/util/IpRangeTest.java | 12 ++++++++++++ .../net/module/util/LinkPropertiesUtilsTest.java | 2 ++ .../src/com/android/net/module/util/StructTest.java | 2 ++ .../module/util/netlink/StructNdOptPref64Test.java | 2 ++ 6 files changed, 22 insertions(+) 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 c5efcb2651..1705f1c803 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 android.system.OsConstants.AF_INET6; 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 @@ public class RtNetlinkRouteMessage extends NetlinkMessage { * @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 f6b2e0e504..8226346649 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 @@ public class StructNdOptPref64 extends NdOption { 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 f44b17d751..20bbd4a143 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.assertNotEquals; 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 @@ public class IpRangeTest { } } + @SuppressLint("NewApi") @Test public void testConstructor() { IpRange r = new IpRange(new IpPrefix(IPV4_ADDR, 32)); @@ -119,6 +121,7 @@ public class IpRangeTest { 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 @@ public class IpRangeTest { assertEquals(r1, r2); } + @SuppressLint("NewApi") @Test public void testContainsRangeSubset() { final IpRange r1 = new IpRange(new IpPrefix(IPV6_ADDR, 64)); @@ -139,6 +143,7 @@ public class IpRangeTest { assertNotEquals(r1, r2); } + @SuppressLint("NewApi") @Test public void testContainsRangeTruncatesLowerOrderBits() { final IpRange r1 = new IpRange(new IpPrefix(IPV6_ADDR, 100)); @@ -149,6 +154,7 @@ public class IpRangeTest { assertEquals(r1, r2); } + @SuppressLint("NewApi") @Test public void testContainsRangeSubsetSameStartAddr() { final IpRange r1 = new IpRange(new IpPrefix(IPV6_ADDR, 35)); @@ -159,6 +165,7 @@ public class IpRangeTest { assertNotEquals(r1, r2); } + @SuppressLint("NewApi") @Test public void testContainsRangeOverlapping() { final IpRange r1 = new IpRange(new IpPrefix(address("2001:db9::"), 32)); @@ -169,6 +176,7 @@ public class IpRangeTest { assertNotEquals(r1, r2); } + @SuppressLint("NewApi") @Test public void testOverlapsRangeEqualRanges() { final IpRange r1 = new IpRange(new IpPrefix(IPV6_ADDR, 35)); @@ -179,6 +187,7 @@ public class IpRangeTest { assertEquals(r1, r2); } + @SuppressLint("NewApi") @Test public void testOverlapsRangeSubset() { final IpRange r1 = new IpRange(new IpPrefix(IPV6_ADDR, 35)); @@ -189,6 +198,7 @@ public class IpRangeTest { assertNotEquals(r1, r2); } + @SuppressLint("NewApi") @Test public void testOverlapsRangeDisjoint() { final IpRange r1 = new IpRange(new IpPrefix(IPV6_ADDR, 32)); @@ -199,6 +209,7 @@ public class IpRangeTest { assertNotEquals(r1, r2); } + @SuppressLint("NewApi") @Test public void testOverlapsRangePartialOverlapLow() { final IpRange r1 = new IpRange(new IpPrefix(address("2001:db9::"), 32)); @@ -209,6 +220,7 @@ public class IpRangeTest { 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 3d2d6ebaac..09f0490283 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.assertEquals; 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 @@ import java.util.function.Function; @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 eabc14b4bf..4e46210649 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.assertFalse; 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 @@ public class StructTest { } } + @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 57248eada6..beed838356 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 com.android.testutils.MiscAsserts.assertThrows; 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 @@ public class StructNdOptPref64Test { return prefixBytes; } + @SuppressLint("NewApi") private static IpPrefix prefix(String addrString, int prefixLength) throws Exception { return new IpPrefix(InetAddress.getByName(addrString), prefixLength); }