Merge changes from topic "services.net-wifi" into rvc-dev

* changes:
  services.net: Add a static library needed by wifi module
  services.net: Use the new ModuleNetworkStackClient
This commit is contained in:
Roshan Pius
2020-03-13 22:39:09 +00:00
committed by Android (Google) Code Review
2 changed files with 9 additions and 24 deletions

View File

@@ -22,7 +22,6 @@ import static android.net.InvalidPacketException.ERROR_INVALID_PORT;
import android.annotation.NonNull; import android.annotation.NonNull;
import android.annotation.SystemApi; import android.annotation.SystemApi;
import android.net.util.IpUtils; import android.net.util.IpUtils;
import android.os.Parcel;
import android.util.Log; import android.util.Log;
import java.net.InetAddress; import java.net.InetAddress;
@@ -30,7 +29,6 @@ import java.net.InetAddress;
/** /**
* Represents the actual packets that are sent by the * Represents the actual packets that are sent by the
* {@link android.net.SocketKeepalive} API. * {@link android.net.SocketKeepalive} API.
*
* @hide * @hide
*/ */
@SystemApi @SystemApi
@@ -54,6 +52,9 @@ public class KeepalivePacketData {
/** Packet data. A raw byte string of packet data, not including the link-layer header. */ /** Packet data. A raw byte string of packet data, not including the link-layer header. */
private final byte[] mPacket; 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 // This should only be constructed via static factory methods, such as
// nattKeepalivePacket. // nattKeepalivePacket.
/** /**
@@ -87,21 +88,4 @@ public class KeepalivePacketData {
return mPacket.clone(); 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();
}
} }

View File

@@ -35,6 +35,7 @@ import android.net.ipmemorystore.IOnStatusListener;
import android.net.ipmemorystore.NetworkAttributes; import android.net.ipmemorystore.NetworkAttributes;
import android.net.ipmemorystore.NetworkAttributesParcelable; import android.net.ipmemorystore.NetworkAttributesParcelable;
import android.net.ipmemorystore.Status; import android.net.ipmemorystore.Status;
import android.net.networkstack.ModuleNetworkStackClient;
import android.os.RemoteException; import android.os.RemoteException;
import androidx.test.filters.SmallTest; import androidx.test.filters.SmallTest;
@@ -67,7 +68,7 @@ public class IpMemoryStoreTest {
@Mock @Mock
Context mMockContext; Context mMockContext;
@Mock @Mock
NetworkStackClient mNetworkStackClient; ModuleNetworkStackClient mModuleNetworkStackClient;
@Mock @Mock
IIpMemoryStore mMockService; IIpMemoryStore mMockService;
@Mock @Mock
@@ -90,14 +91,14 @@ public class IpMemoryStoreTest {
((IIpMemoryStoreCallbacks) invocation.getArgument(0)) ((IIpMemoryStoreCallbacks) invocation.getArgument(0))
.onIpMemoryStoreFetched(mMockService); .onIpMemoryStoreFetched(mMockService);
return null; return null;
}).when(mNetworkStackClient).fetchIpMemoryStore(any()); }).when(mModuleNetworkStackClient).fetchIpMemoryStore(any());
} else { } else {
doNothing().when(mNetworkStackClient).fetchIpMemoryStore(mCbCaptor.capture()); doNothing().when(mModuleNetworkStackClient).fetchIpMemoryStore(mCbCaptor.capture());
} }
mStore = new IpMemoryStore(mMockContext) { mStore = new IpMemoryStore(mMockContext) {
@Override @Override
protected NetworkStackClient getNetworkStackClient() { protected ModuleNetworkStackClient getModuleNetworkStackClient(Context ctx) {
return mNetworkStackClient; return mModuleNetworkStackClient;
} }
}; };
} }