diff options
| author | Remi NGUYEN VAN <reminv@google.com> | 2021-11-01 12:01:59 +0900 |
|---|---|---|
| committer | Remi NGUYEN VAN <reminv@google.com> | 2021-11-01 13:23:27 +0900 |
| commit | 5d99aa78f7d20bd34cf73e737b13a25e2c40a945 (patch) | |
| tree | 047ecbec94a6686d73427d577b36c438e2a117f0 /tests/unit/java/android/net/KeepalivePacketDataUtilTest.java | |
| parent | 65571769cd74cb5bcb3b6a4a88cf718cde1158b3 (diff) | |
Move fromStableParcelable to KeepaliveController
TcpKeepaliveController is the only user of
KeepalivePacketDataUtil.fromStableParcelable. Because of
fromStableParcelable, networkstack-client needs to depend on
net-utils-framework-commonm, which pulls a lot of unnecessary classes.
This is particularly problematic considering that networkstack-client
may need to be redistributed as a prebuilt.
Move the method to TcpKeepaliveController, simplifying dependencies.
This also shows that fromStableParcelable could be removed altogether
(or moved to tests) if TcpKeepaliveController built a
TcpKeepalivePacketData class directly.
Test: atest ConnectivityCoverageTests
Change-Id: I554318f6bcd07c73d153598a0231e9fcaf912e90
Diffstat (limited to 'tests/unit/java/android/net/KeepalivePacketDataUtilTest.java')
| -rw-r--r-- | tests/unit/java/android/net/KeepalivePacketDataUtilTest.java | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/tests/unit/java/android/net/KeepalivePacketDataUtilTest.java b/tests/unit/java/android/net/KeepalivePacketDataUtilTest.java index 8498b6f65b..6afa4e928f 100644 --- a/tests/unit/java/android/net/KeepalivePacketDataUtilTest.java +++ b/tests/unit/java/android/net/KeepalivePacketDataUtilTest.java @@ -27,6 +27,7 @@ import android.net.util.KeepalivePacketDataUtil; import android.os.Build; import android.util.Log; +import com.android.server.connectivity.TcpKeepaliveController; import com.android.testutils.DevSdkIgnoreRule; import com.android.testutils.DevSdkIgnoreRunner; @@ -81,7 +82,7 @@ public final class KeepalivePacketDataUtilTest { testInfo.tos = tos; testInfo.ttl = ttl; try { - resultData = KeepalivePacketDataUtil.fromStableParcelable(testInfo); + resultData = TcpKeepaliveController.fromStableParcelable(testInfo); } catch (InvalidPacketException e) { fail("InvalidPacketException: " + e); } @@ -155,7 +156,7 @@ public final class KeepalivePacketDataUtilTest { testInfo.ttl = ttl; TcpKeepalivePacketData testData = null; TcpKeepalivePacketDataParcelable resultData = null; - testData = KeepalivePacketDataUtil.fromStableParcelable(testInfo); + testData = TcpKeepaliveController.fromStableParcelable(testInfo); resultData = KeepalivePacketDataUtil.toStableParcelable(testData); assertArrayEquals(resultData.srcAddress, IPV4_KEEPALIVE_SRC_ADDR); assertArrayEquals(resultData.dstAddress, IPV4_KEEPALIVE_DST_ADDR); @@ -198,11 +199,11 @@ public final class KeepalivePacketDataUtilTest { testParcel.ttl = ttl; final KeepalivePacketData testData = - KeepalivePacketDataUtil.fromStableParcelable(testParcel); + TcpKeepaliveController.fromStableParcelable(testParcel); final TcpKeepalivePacketDataParcelable parsedParcelable = KeepalivePacketDataUtil.parseTcpKeepalivePacketData(testData); final TcpKeepalivePacketData roundTripData = - KeepalivePacketDataUtil.fromStableParcelable(parsedParcelable); + TcpKeepaliveController.fromStableParcelable(parsedParcelable); // Generated packet is the same, but rcvWnd / wndScale will differ if scale is non-zero assertTrue(testData.getPacket().length > 0); @@ -210,11 +211,11 @@ public final class KeepalivePacketDataUtilTest { testParcel.rcvWndScale = 0; final KeepalivePacketData noScaleTestData = - KeepalivePacketDataUtil.fromStableParcelable(testParcel); + TcpKeepaliveController.fromStableParcelable(testParcel); final TcpKeepalivePacketDataParcelable noScaleParsedParcelable = KeepalivePacketDataUtil.parseTcpKeepalivePacketData(noScaleTestData); final TcpKeepalivePacketData noScaleRoundTripData = - KeepalivePacketDataUtil.fromStableParcelable(noScaleParsedParcelable); + TcpKeepaliveController.fromStableParcelable(noScaleParsedParcelable); assertEquals(noScaleTestData, noScaleRoundTripData); assertTrue(noScaleTestData.getPacket().length > 0); assertArrayEquals(noScaleTestData.getPacket(), noScaleRoundTripData.getPacket()); |
