Merge "Make Ethernet interfaces more testable." am: e30d9267ef
Change-Id: I456acb05d548b3d0281e500cfd91d888441d7f94
This commit is contained in:
@@ -1442,6 +1442,7 @@ package android.net {
|
||||
|
||||
public class EthernetManager {
|
||||
method @NonNull @RequiresPermission(anyOf={android.Manifest.permission.NETWORK_STACK, android.net.NetworkStack.PERMISSION_MAINLINE_NETWORK_STACK}) public android.net.EthernetManager.TetheredInterfaceRequest requestTetheredInterface(@NonNull java.util.concurrent.Executor, @NonNull android.net.EthernetManager.TetheredInterfaceCallback);
|
||||
method public void setIncludeTestInterfaces(boolean);
|
||||
}
|
||||
|
||||
public static interface EthernetManager.TetheredInterfaceCallback {
|
||||
|
||||
@@ -199,6 +199,21 @@ public class EthernetManager {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Whether to treat interfaces created by {@link TestNetworkManager#createTapInterface}
|
||||
* as Ethernet interfaces. The effects of this method apply to any test interfaces that are
|
||||
* already present on the system.
|
||||
* @hide
|
||||
*/
|
||||
@TestApi
|
||||
public void setIncludeTestInterfaces(boolean include) {
|
||||
try {
|
||||
mService.setIncludeTestInterfaces(include);
|
||||
} catch (RemoteException e) {
|
||||
throw e.rethrowFromSystemServer();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* A request for a tethered interface.
|
||||
*/
|
||||
|
||||
@@ -33,6 +33,7 @@ interface IEthernetManager
|
||||
boolean isAvailable(String iface);
|
||||
void addListener(in IEthernetServiceListener listener);
|
||||
void removeListener(in IEthernetServiceListener listener);
|
||||
void setIncludeTestInterfaces(boolean include);
|
||||
void requestTetheredInterface(in ITetheredInterfaceCallback callback);
|
||||
void releaseTetheredInterface(in ITetheredInterfaceCallback callback);
|
||||
}
|
||||
|
||||
@@ -30,6 +30,18 @@ import com.android.internal.util.Preconditions;
|
||||
*/
|
||||
@TestApi
|
||||
public class TestNetworkManager {
|
||||
/**
|
||||
* Prefix for tun interfaces created by this class.
|
||||
* @hide
|
||||
*/
|
||||
public static final String TEST_TUN_PREFIX = "testtun";
|
||||
|
||||
/**
|
||||
* Prefix for tap interfaces created by this class.
|
||||
* @hide
|
||||
*/
|
||||
public static final String TEST_TAP_PREFIX = "testtap";
|
||||
|
||||
@NonNull private static final String TAG = TestNetworkManager.class.getSimpleName();
|
||||
|
||||
@NonNull private final ITestNetworkManager mService;
|
||||
|
||||
@@ -16,6 +16,9 @@
|
||||
|
||||
package com.android.server;
|
||||
|
||||
import static android.net.TestNetworkManager.TEST_TAP_PREFIX;
|
||||
import static android.net.TestNetworkManager.TEST_TUN_PREFIX;
|
||||
|
||||
import android.annotation.NonNull;
|
||||
import android.annotation.Nullable;
|
||||
import android.content.Context;
|
||||
@@ -61,8 +64,6 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
class TestNetworkService extends ITestNetworkManager.Stub {
|
||||
@NonNull private static final String TAG = TestNetworkService.class.getSimpleName();
|
||||
@NonNull private static final String TEST_NETWORK_TYPE = "TEST_NETWORK";
|
||||
@NonNull private static final String TEST_TUN_PREFIX = "testtun";
|
||||
@NonNull private static final String TEST_TAP_PREFIX = "testtap";
|
||||
@NonNull private static final AtomicInteger sTestTunIndex = new AtomicInteger();
|
||||
|
||||
@NonNull private final Context mContext;
|
||||
|
||||
Reference in New Issue
Block a user