services.net: Use the new ModuleNetworkStackClient am: 86a84576b5 am: 65d336cead
Change-Id: Ifa4d539bbcb499083a2f052bc4938c685efa14ca
This commit is contained in:
@@ -18,6 +18,7 @@ package android.net;
|
|||||||
|
|
||||||
import android.annotation.NonNull;
|
import android.annotation.NonNull;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.net.networkstack.ModuleNetworkStackClient;
|
||||||
import android.util.Log;
|
import android.util.Log;
|
||||||
|
|
||||||
import com.android.internal.annotations.VisibleForTesting;
|
import com.android.internal.annotations.VisibleForTesting;
|
||||||
@@ -41,7 +42,7 @@ public class IpMemoryStore extends IpMemoryStoreClient {
|
|||||||
super(context);
|
super(context);
|
||||||
mService = new CompletableFuture<>();
|
mService = new CompletableFuture<>();
|
||||||
mTailNode = new AtomicReference<CompletableFuture<IIpMemoryStore>>(mService);
|
mTailNode = new AtomicReference<CompletableFuture<IIpMemoryStore>>(mService);
|
||||||
getNetworkStackClient().fetchIpMemoryStore(
|
getModuleNetworkStackClient(context).fetchIpMemoryStore(
|
||||||
new IIpMemoryStoreCallbacks.Stub() {
|
new IIpMemoryStoreCallbacks.Stub() {
|
||||||
@Override
|
@Override
|
||||||
public void onIpMemoryStoreFetched(@NonNull final IIpMemoryStore memoryStore) {
|
public void onIpMemoryStoreFetched(@NonNull final IIpMemoryStore memoryStore) {
|
||||||
@@ -85,8 +86,8 @@ public class IpMemoryStore extends IpMemoryStoreClient {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@VisibleForTesting
|
@VisibleForTesting
|
||||||
protected NetworkStackClient getNetworkStackClient() {
|
protected ModuleNetworkStackClient getModuleNetworkStackClient(Context context) {
|
||||||
return NetworkStackClient.getInstance();
|
return ModuleNetworkStackClient.getInstance(context);
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Gets an instance of the memory store */
|
/** Gets an instance of the memory store */
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ import android.content.Context;
|
|||||||
import android.net.DhcpResultsParcelable;
|
import android.net.DhcpResultsParcelable;
|
||||||
import android.net.Layer2PacketParcelable;
|
import android.net.Layer2PacketParcelable;
|
||||||
import android.net.LinkProperties;
|
import android.net.LinkProperties;
|
||||||
import android.net.NetworkStackClient;
|
import android.net.networkstack.ModuleNetworkStackClient;
|
||||||
import android.os.ConditionVariable;
|
import android.os.ConditionVariable;
|
||||||
|
|
||||||
import java.io.FileDescriptor;
|
import java.io.FileDescriptor;
|
||||||
@@ -75,11 +75,11 @@ public class IpClientUtil {
|
|||||||
*
|
*
|
||||||
* <p>This is a convenience method to allow clients to use {@link IpClientCallbacks} instead of
|
* <p>This is a convenience method to allow clients to use {@link IpClientCallbacks} instead of
|
||||||
* {@link IIpClientCallbacks}.
|
* {@link IIpClientCallbacks}.
|
||||||
* @see {@link NetworkStackClient#makeIpClient(String, IIpClientCallbacks)}
|
* @see {@link ModuleNetworkStackClient#makeIpClient(String, IIpClientCallbacks)}
|
||||||
*/
|
*/
|
||||||
public static void makeIpClient(Context context, String ifName, IpClientCallbacks callback) {
|
public static void makeIpClient(Context context, String ifName, IpClientCallbacks callback) {
|
||||||
// TODO: migrate clients and remove context argument
|
ModuleNetworkStackClient.getInstance(context)
|
||||||
NetworkStackClient.getInstance().makeIpClient(ifName, new IpClientCallbacksProxy(callback));
|
.makeIpClient(ifName, new IpClientCallbacksProxy(callback));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -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;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user