From 58d144f6ed3e5aca99781fa4391bb85922cf70f2 Mon Sep 17 00:00:00 2001 From: Roshan Pius Date: Thu, 20 Feb 2020 21:47:01 -0800 Subject: [PATCH 1/2] services.net: Use the new ModuleNetworkStackClient Use the new ModuleNetworkStackClient to retrieve instances IpMemoryStore & IpClient. Bug: 145825329 Test: Compiles Change-Id: I065525fdbd64b9509ef0f47bb35954d267c65fd2 --- tests/net/java/android/net/IpMemoryStoreTest.java | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/net/java/android/net/IpMemoryStoreTest.java b/tests/net/java/android/net/IpMemoryStoreTest.java index b81ca36429..442ac5605e 100644 --- a/tests/net/java/android/net/IpMemoryStoreTest.java +++ b/tests/net/java/android/net/IpMemoryStoreTest.java @@ -35,6 +35,7 @@ import android.net.ipmemorystore.IOnStatusListener; import android.net.ipmemorystore.NetworkAttributes; import android.net.ipmemorystore.NetworkAttributesParcelable; import android.net.ipmemorystore.Status; +import android.net.networkstack.ModuleNetworkStackClient; import android.os.RemoteException; import androidx.test.filters.SmallTest; @@ -67,7 +68,7 @@ public class IpMemoryStoreTest { @Mock Context mMockContext; @Mock - NetworkStackClient mNetworkStackClient; + ModuleNetworkStackClient mModuleNetworkStackClient; @Mock IIpMemoryStore mMockService; @Mock @@ -90,14 +91,14 @@ public class IpMemoryStoreTest { ((IIpMemoryStoreCallbacks) invocation.getArgument(0)) .onIpMemoryStoreFetched(mMockService); return null; - }).when(mNetworkStackClient).fetchIpMemoryStore(any()); + }).when(mModuleNetworkStackClient).fetchIpMemoryStore(any()); } else { - doNothing().when(mNetworkStackClient).fetchIpMemoryStore(mCbCaptor.capture()); + doNothing().when(mModuleNetworkStackClient).fetchIpMemoryStore(mCbCaptor.capture()); } mStore = new IpMemoryStore(mMockContext) { @Override - protected NetworkStackClient getNetworkStackClient() { - return mNetworkStackClient; + protected ModuleNetworkStackClient getModuleNetworkStackClient(Context ctx) { + return mModuleNetworkStackClient; } }; } From 1378facba476eb8320f00fc0cbe36dfbf3fbbf6a Mon Sep 17 00:00:00 2001 From: Roshan Pius Date: Fri, 21 Feb 2020 07:37:30 -0800 Subject: [PATCH 2/2] services.net: Add a static library needed by wifi module Add a new static library that compiles against system_current which includes all the parts needed by the wifi mainline module. Also, a) Refactored TcpKeepalivePacketData to use public APIs. The parcel read/write methods in the base class are @hide and they're not used by the other child class (NatKeepalivePacketData). So, remove the @hide method from base class and use it direcly in the child class. b) Add jar-jar rules for all the statically linked dependencies in wifi service jar rules. Exempt-From-Owner-Approval: Minor change on top of owner's approval. Bug: 145825329 Test: Device boots up & connects to wifi networks. Change-Id: Ifde69b579cfe5b813766f676acb10e436e64a44c --- .../java/android/net/KeepalivePacketData.java | 22 +++---------------- 1 file changed, 3 insertions(+), 19 deletions(-) diff --git a/core/java/android/net/KeepalivePacketData.java b/core/java/android/net/KeepalivePacketData.java index 2b8b7e69de..6c0ba2f63a 100644 --- a/core/java/android/net/KeepalivePacketData.java +++ b/core/java/android/net/KeepalivePacketData.java @@ -22,7 +22,6 @@ import static android.net.InvalidPacketException.ERROR_INVALID_PORT; import android.annotation.NonNull; import android.annotation.SystemApi; import android.net.util.IpUtils; -import android.os.Parcel; import android.util.Log; import java.net.InetAddress; @@ -30,7 +29,6 @@ import java.net.InetAddress; /** * Represents the actual packets that are sent by the * {@link android.net.SocketKeepalive} API. - * * @hide */ @SystemApi @@ -54,6 +52,9 @@ public class KeepalivePacketData { /** Packet data. A raw byte string of packet data, not including the link-layer header. */ private final byte[] mPacket; + // Note: If you add new fields, please modify the parcelling code in the child classes. + + // This should only be constructed via static factory methods, such as // nattKeepalivePacket. /** @@ -87,21 +88,4 @@ public class KeepalivePacketData { return mPacket.clone(); } - /** @hide */ - public void writeToParcel(Parcel out, int flags) { - out.writeString(srcAddress.getHostAddress()); - out.writeString(dstAddress.getHostAddress()); - out.writeInt(srcPort); - out.writeInt(dstPort); - out.writeByteArray(mPacket); - } - - /** @hide */ - protected KeepalivePacketData(Parcel in) { - srcAddress = NetworkUtils.numericToInetAddress(in.readString()); - dstAddress = NetworkUtils.numericToInetAddress(in.readString()); - srcPort = in.readInt(); - dstPort = in.readInt(); - mPacket = in.createByteArray(); - } }